diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2010-06-03 04:55:39 +0000 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2010-06-03 04:55:39 +0000 |
| commit | e4085f0f049c0f681e3feaa97f7f0842c017ae8e (patch) | |
| tree | b04dce91280d8a771c894fcf8495473fc9e0c45b /Source/Core/InputCommon | |
| parent | d0c65b610c91531ff80298834bc866cf6b016fcd (diff) | |
Merge GCPadNew into Dolphin. This takes place in three segments: Core, InputCommon, and InputUICommon. From now on it can be referred to just as "GCPad".
Switch to Billiard's IniFile implementation throughout Dolphin (it's faster!!).
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5579 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/InputCommon')
18 files changed, 878 insertions, 1165 deletions
diff --git a/Source/Core/InputCommon/InputCommon.vcproj b/Source/Core/InputCommon/InputCommon.vcproj index eaa33a78ca..cf176d76e7 100644 --- a/Source/Core/InputCommon/InputCommon.vcproj +++ b/Source/Core/InputCommon/InputCommon.vcproj @@ -45,7 +45,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src;../../PluginSpecs;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\wxWidgets\lib\vc_lib\msw;..\..\..\Externals\wxWidgets\include\msvc" + AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src" PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -110,7 +110,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src;../../PluginSpecs;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\wxWidgets\lib\vc_lib\msw;..\..\..\Externals\wxWidgets\include\msvc" + AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src" PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_SECURE_SCL=0;_LIB;__WXMSW__;wxUSE_BASE=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -175,7 +175,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src;../../PluginSpecs;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\wxWidgets\lib\vc_lib\msw;..\..\..\Externals\wxWidgets\include\msvc" + AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src" PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" StringPooling="true" RuntimeLibrary="0" @@ -244,7 +244,7 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" OmitFramePointers="false" - AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src;../../PluginSpecs;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\wxWidgets\lib\vc_lib\msw;..\..\..\Externals\wxWidgets\include\msvc" + AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src" PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" RuntimeLibrary="0" BufferSecurityCheck="false" @@ -306,7 +306,7 @@ /> <Tool Name="VCCLCompilerTool" - AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src;../../PluginSpecs;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\wxWidgets\lib\vc_lib\msw;..\..\..\Externals\wxWidgets\include\msvc" + AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src" PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0" RuntimeLibrary="0" BufferSecurityCheck="false" @@ -368,7 +368,7 @@ /> <Tool Name="VCCLCompilerTool" - AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src;../../PluginSpecs;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\wxWidgets\lib\vc_lib\msw;..\..\..\Externals\wxWidgets\include\msvc" + AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src" PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;__WXMSW__;wxUSE_BASE=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" RuntimeLibrary="0" BufferSecurityCheck="false" @@ -476,60 +476,48 @@ </File> </Filter> </Filter> - <File - RelativePath=".\Src\Configuration.cpp" - > - </File> - <File - RelativePath=".\Src\DirectInputBase.cpp" - > - </File> - <File - RelativePath=".\Src\DirectInputBase.h" - > - </File> - <File - RelativePath=".\Src\Event.hpp" - > - </File> - <File - RelativePath=".\Src\EventHandler.cpp" - > - </File> - <File - RelativePath=".\Src\EventHandler.h" - > - </File> - <File - RelativePath=".\Src\InputCommon.cpp" - > - </File> - <File - RelativePath=".\Src\InputCommon.h" - > - </File> - <File - RelativePath=".\Src\SDL_Util.cpp" - > - </File> - <File - RelativePath=".\Src\SDL_Util.h" + <Filter + Name="old" > - </File> + <File + RelativePath=".\Src\Configuration.cpp" + > + </File> + <File + RelativePath=".\Src\InputCommon.h" + > + </File> + <File + RelativePath=".\Src\SDL_Util.cpp" + > + </File> + <File + RelativePath=".\Src\SDL_Util.h" + > + </File> + <File + RelativePath=".\Src\XInput_Util.cpp" + > + </File> + <File + RelativePath=".\Src\XInput_Util.h" + > + </File> + </Filter> <File - RelativePath=".\Src\WXInputBase.cpp" + RelativePath=".\Src\Config.cpp" > </File> <File - RelativePath=".\Src\WXInputBase.h" + RelativePath=".\Src\Config.h" > </File> <File - RelativePath=".\Src\XInput_Util.cpp" + RelativePath=".\Src\ControllerEmu.cpp" > </File> <File - RelativePath=".\Src\XInput_Util.h" + RelativePath=".\Src\ControllerEmu.h" > </File> </Files> diff --git a/Source/Core/InputCommon/Src/Config.cpp b/Source/Core/InputCommon/Src/Config.cpp new file mode 100644 index 0000000000..134d2687e0 --- /dev/null +++ b/Source/Core/InputCommon/Src/Config.cpp @@ -0,0 +1,57 @@ +
+#include "Config.h"
+
+Plugin::Plugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name )
+ : ini_name(_ini_name)
+ , gui_name(_gui_name)
+ , profile_name(_profile_name)
+{
+ // GCPads
+ //for ( unsigned int i = 0; i<4; ++i )
+ //controllers.push_back( new GCPad( i ) );
+ // Wiimotes / disabled, cause it only the GUI half is done
+ //for ( unsigned int i = 0; i<4; ++i )
+ // controllers.push_back( new Wiimote( i ) );
+};
+
+Plugin::~Plugin()
+{
+ // delete pads
+ std::vector<ControllerEmu*>::const_iterator i = controllers.begin(),
+ e = controllers.end();
+ for ( ; i != e; ++i )
+ delete *i;
+}
+
+void Plugin::LoadConfig()
+{
+ IniFile inifile;
+
+ std::ifstream file;
+ file.open( (std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini" ).c_str() );
+ inifile.Load( file );
+ file.close();
+
+ std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
+ e = controllers.end();
+ for ( ; i!=e; ++i )
+ (*i)->LoadConfig( inifile[ (*i)->GetName() ] );
+}
+
+void Plugin::SaveConfig()
+{
+ IniFile inifile;
+
+ std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
+ e = controllers.end();
+ for ( ; i!=e; ++i )
+ (*i)->SaveConfig( inifile[ (*i)->GetName() ] );
+
+ // dont need to save empty values
+ //inifile.Clean();
+
+ std::ofstream file;
+ file.open( (std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini" ).c_str() );
+ inifile.Save( file );
+ file.close();
+}
diff --git a/Source/Core/InputCommon/Src/Config.h b/Source/Core/InputCommon/Src/Config.h new file mode 100644 index 0000000000..51379a33fc --- /dev/null +++ b/Source/Core/InputCommon/Src/Config.h @@ -0,0 +1,33 @@ +#pragma once
+
+#include "ControllerInterface/ControllerInterface.h"
+#include "Thread.h"
+#include "FileUtil.h"
+#include "IniFile.h"
+
+#include "ControllerEmu.h"
+
+#include <string>
+#include <vector>
+#include <map>
+#include <sstream>
+
+class Plugin
+{
+public:
+
+ Plugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name );
+ ~Plugin();
+
+ void LoadConfig();
+ void SaveConfig();
+
+ std::vector< ControllerEmu* > controllers;
+
+ Common::CriticalSection controls_crit, interface_crit; // lock controls first
+ ControllerInterface controller_interface;
+
+ const char * const ini_name;
+ const char * const gui_name;
+ const char * const profile_name;
+};
diff --git a/Source/Core/InputCommon/Src/Configuration.cpp b/Source/Core/InputCommon/Src/Configuration.cpp index c48e48d05f..7f4972ea11 100644 --- a/Source/Core/InputCommon/Src/Configuration.cpp +++ b/Source/Core/InputCommon/Src/Configuration.cpp @@ -18,13 +18,10 @@ #include <iostream> // System #include <vector> -#include <cmath> +#define _USE_MATH_DEFINES +#include <math.h> #include "Common.h" // Common -#if defined HAVE_WX && HAVE_WX - #include <wx/wx.h> -#endif - #ifdef _WIN32 #define NOMINMAX #include <Windows.h> diff --git a/Source/Core/InputCommon/Src/ControllerEmu.cpp b/Source/Core/InputCommon/Src/ControllerEmu.cpp new file mode 100644 index 0000000000..e94a9b70d8 --- /dev/null +++ b/Source/Core/InputCommon/Src/ControllerEmu.cpp @@ -0,0 +1,350 @@ +#include "ControllerEmu.h"
+
+#if defined(HAVE_X11) && HAVE_X11
+#include <X11/Xlib.h>
+#endif
+
+ControllerEmu::~ControllerEmu()
+{
+ // control groups
+ std::vector<ControlGroup*>::const_iterator
+ i = groups.begin(),
+ e = groups.end();
+ for ( ; i!=e; ++i )
+ delete *i;
+}
+
+ControllerEmu::ControlGroup::~ControlGroup()
+{
+ // controls
+ std::vector<Control*>::const_iterator
+ ci = controls.begin(),
+ ce = controls.end();
+ for ( ; ci!=ce; ++ci )
+ delete *ci;
+
+ // settings
+ std::vector<Setting*>::const_iterator
+ si = settings.begin(),
+ se = settings.end();
+ for ( ; si!=se; ++si )
+ delete *si;
+}
+
+ControllerEmu::Extension::~Extension()
+{
+ // attachments
+ std::vector<ControllerEmu*>::const_iterator
+ ai = attachments.begin(),
+ ae = attachments.end();
+ for ( ; ai!=ae; ++ai )
+ delete *ai;
+}
+ControllerEmu::ControlGroup::Control::~Control()
+{
+ delete control_ref;
+}
+
+void ControllerEmu::UpdateReferences( ControllerInterface& devi )
+{
+ std::vector<ControlGroup*>::const_iterator
+ i = groups.begin(),
+ e = groups.end();
+ for ( ; i!=e; ++i )
+ {
+ std::vector<ControlGroup::Control*>::const_iterator
+ ci = (*i)->controls.begin(),
+ ce = (*i)->controls.end();
+ for ( ; ci!=ce; ++ci )
+ devi.UpdateReference( (*ci)->control_ref );
+
+ // extension
+ if ( GROUP_TYPE_EXTENSION == (*i)->type )
+ {
+ std::vector<ControllerEmu*>::const_iterator
+ ai = ((Extension*)*i)->attachments.begin(),
+ ae = ((Extension*)*i)->attachments.end();
+ for ( ; ai!=ae; ++ai )
+ (*ai)->UpdateReferences( devi );
+ }
+ }
+}
+
+void ControllerEmu::UpdateDefaultDevice()
+{
+ std::vector<ControlGroup*>::const_iterator
+ i = groups.begin(),
+ e = groups.end();
+ for ( ; i!=e; ++i )
+ {
+ std::vector<ControlGroup::Control*>::const_iterator
+ ci = (*i)->controls.begin(),
+ ce = (*i)->controls.end();
+ for ( ; ci!=ce; ++ci )
+ (*ci)->control_ref->device_qualifier = default_device;
+
+ // extension
+ if ( GROUP_TYPE_EXTENSION == (*i)->type )
+ {
+ std::vector<ControllerEmu*>::const_iterator
+ ai = ((Extension*)*i)->attachments.begin(),
+ ae = ((Extension*)*i)->attachments.end();
+ for ( ; ai!=ae; ++ai )
+ {
+ (*ai)->default_device = default_device;
+ (*ai)->UpdateDefaultDevice();
+ }
+ }
+ }
+}
+
+void ControllerEmu::ControlGroup::LoadConfig( Section& sec, const std::string& defdev, const std::string& base )
+{
+ std::string group( base + name ); group += "/";
+
+ // settings
+ std::vector<ControlGroup::Setting*>::const_iterator
+ si = settings.begin(),
+ se = settings.end();
+ for ( ; si!=se; ++si )
+ { + sec.Get(group+(*si)->name, &(*si)->value, (*si)->default_value*100); + (*si)->value /= 100; + }
+
+ // controls
+ std::vector<ControlGroup::Control*>::const_iterator
+ ci = controls.begin(),
+ ce = controls.end();
+ for ( ; ci!=ce; ++ci )
+ {
+ // control and dev qualifier
+ (*ci)->control_ref->control_qualifier.name = sec[group + (*ci)->name];
+ std::string tmpdevstr; + sec.Get( group+(*ci)->name+"/Device", &tmpdevstr, defdev ); + (*ci)->control_ref->device_qualifier.FromString(tmpdevstr); + + // range + sec.Get( group+(*ci)->name+"/Range", &(*ci)->control_ref->range, 100.0f ); + (*ci)->control_ref->range /= 100; + + // input mode + if ( (*ci)->control_ref->is_input ) + sec.Get( group+(*ci)->name+"/Mode", + &((ControllerInterface::InputReference*)((*ci)->control_ref))->mode, 0 );
+ }
+
+ // extensions
+ if ( GROUP_TYPE_EXTENSION == type )
+ {
+ Extension* const ex = ((Extension*)this);
+
+ ex->switch_extension = 0;
+ unsigned int n = 0;
+ const std::string extname = sec[ base + name ];
+
+ std::vector<ControllerEmu*>::const_iterator
+ ai = ((Extension*)this)->attachments.begin(),
+ ae = ((Extension*)this)->attachments.end();
+ for ( ; ai!=ae; ++ai,++n )
+ {
+ (*ai)->default_device.FromString( defdev );
+ (*ai)->LoadConfig( sec, base + (*ai)->GetName() + "/" );
+
+ if ( (*ai)->GetName() == extname )
+ ex->switch_extension = n;
+ }
+ }
+}
+
+void ControllerEmu::LoadConfig( Section& sec, const std::string& base )
+{
+ std::string defdev = default_device.ToString();
+ if ( base.empty() )
+ {
+ defdev = sec[ base + "Device" ];
+ default_device.FromString( defdev );
+ }
+
+ std::vector<ControlGroup*>::const_iterator i = groups.begin(),
+ e = groups.end();
+ for ( ; i!=e; ++i )
+ (*i)->LoadConfig( sec, defdev, base );
+}
+
+void ControllerEmu::ControlGroup::SaveConfig( Section& sec, const std::string& defdev, const std::string& base )
+{
+ std::string group( base + name ); group += "/";
+
+ // settings
+ std::vector<ControlGroup::Setting*>::const_iterator
+ si = settings.begin(),
+ se = settings.end();
+ for ( ; si!=se; ++si )
+ sec.Set( group+(*si)->name, (*si)->value*100, (*si)->default_value*100 );
+
+ // controls
+ std::vector<ControlGroup::Control*>::const_iterator
+ ci = controls.begin(),
+ ce = controls.end();
+ for ( ; ci!=ce; ++ci )
+ {
+ // control and dev qualifier
+ sec.Set( group+(*ci)->name, (*ci)->control_ref->control_qualifier.name );
+ sec.Set( group+(*ci)->name+"/Device", (*ci)->control_ref->device_qualifier.ToString(), defdev );
+
+ // range
+ sec.Set( group+(*ci)->name+"/Range", (*ci)->control_ref->range*100, 100 );
+
+ // input mode
+ if ( (*ci)->control_ref->is_input )
+ sec.Set( group+(*ci)->name+"/Mode",
+ ((ControllerInterface::InputReference*)((*ci)->control_ref))->mode, (unsigned int)0 );
+ }
+
+ // extensions
+ if ( GROUP_TYPE_EXTENSION == type )
+ {
+ Extension* const ext = ((Extension*)this);
+ sec.Set( base + name, ext->attachments[ext->switch_extension]->GetName(), std::string("None") );
+
+ std::vector<ControllerEmu*>::const_iterator
+ ai = ((Extension*)this)->attachments.begin(),
+ ae = ((Extension*)this)->attachments.end();
+ for ( ; ai!=ae; ++ai )
+ (*ai)->SaveConfig( sec, base + (*ai)->GetName() + "/" );
+ }
+}
+
+void ControllerEmu::SaveConfig( Section& sec, const std::string& base )
+{
+ const std::string defdev = default_device.ToString();
+ if ( base.empty() )
+ sec.Set( std::string(" ") + base + "Device", defdev );
+
+ std::vector<ControlGroup*>::const_iterator i = groups.begin(),
+ e = groups.end();
+ for ( ; i!=e; ++i )
+ (*i)->SaveConfig( sec, defdev, base );
+}
+
+ControllerEmu::AnalogStick::AnalogStick( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_STICK )
+{
+ for ( unsigned int i = 0; i < 4; ++i )
+ controls.push_back( new Input( named_directions[i] ) );
+
+ controls.push_back( new Input( "Modifier" ) );
+
+ settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
+ settings.push_back( new Setting("Square Stick", 0 ) );
+
+}
+
+ControllerEmu::Buttons::Buttons( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_BUTTONS )
+{
+ settings.push_back( new Setting("Threshold", 0.5f ) );
+}
+
+ControllerEmu::MixedTriggers::MixedTriggers( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_MIXED_TRIGGERS )
+{
+ settings.push_back( new Setting("Threshold", 0.9f ) );
+}
+
+ControllerEmu::Triggers::Triggers( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_TRIGGERS )
+{
+ settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
+}
+
+ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_FORCE )
+{
+ controls.push_back( new Input( "Up" ) );
+ controls.push_back( new Input( "Down" ) );
+ controls.push_back( new Input( "Left" ) );
+ controls.push_back( new Input( "Right" ) );
+ controls.push_back( new Input( "Forward" ) );
+ controls.push_back( new Input( "Backward" ) );
+ controls.push_back( new Input( "Modifier" ) );
+
+ settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
+}
+
+ControllerEmu::Tilt::Tilt( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_TILT )
+{
+ //for ( unsigned int i = 0; i < 4; ++i )
+ //controls.push_back( new Input( named_directions[i] ) );
+ controls.push_back( new Input( "Forward" ) );
+ controls.push_back( new Input( "Backward" ) );
+ controls.push_back( new Input( "Left" ) );
+ controls.push_back( new Input( "Right" ) );
+
+ controls.push_back( new Input( "Modifier" ) );
+
+ settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
+ settings.push_back( new Setting("Circle Stick", 0 ) );
+}
+
+ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize )
+ : ControlGroup( _name, GROUP_TYPE_CURSOR )
+ //, z(0)
+ , wiimote_initialize(_wiimote_initialize)
+{
+ for ( unsigned int i = 0; i < 4; ++i )
+ controls.push_back( new Input( named_directions[i] ) );
+ controls.push_back( new Input( "Forward" ) );
+ controls.push_back( new Input( "Hide" ) );
+
+ settings.push_back( new Setting("Center", 0.5f ) );
+ settings.push_back( new Setting("Width", 0.5f ) );
+ settings.push_back( new Setting("Height", 0.5f ) );
+
+}
+
+void GetMousePos(float& x, float& y, const SWiimoteInitialize* const wiimote_initialize)
+{
+#if ( defined(_WIN32) || (defined(HAVE_X11) && HAVE_X11))
+ unsigned int win_width = 2, win_height = 2;
+#endif
+
+#ifdef _WIN32
+ // Get the cursor position for the entire screen
+ POINT point = { 1, 1 };
+ GetCursorPos(&point);
+ // Get the cursor position relative to the upper left corner of the rendering window
+ ScreenToClient(wiimote_initialize->hWnd, &point);
+
+ // Get the size of the rendering window. (In my case Rect.top and Rect.left was zero.)
+ RECT Rect;
+ GetClientRect(wiimote_initialize->hWnd, &Rect);
+ // Width and height is the size of the rendering window
+ win_width = Rect.right - Rect.left;
+ win_height = Rect.bottom - Rect.top;
+
+#elif defined(HAVE_X11) && HAVE_X11
+ int root_x, root_y;
+ struct
+ {
+ int x, y;
+ } point = { 1, 1 };
+
+ Display* const wm_display = (Display*)wiimote_initialize->hWnd;
+ Window glwin = *(Window *)wiimote_initialize->pXWindow;
+
+ XWindowAttributes win_attribs;
+ XGetWindowAttributes (wm_display, glwin, &win_attribs);
+ win_width = win_attribs.width;
+ win_height = win_attribs.height;
+ Window root_dummy, child_win;
+ unsigned int mask;
+ XQueryPointer(wm_display, glwin, &root_dummy, &child_win, &root_x, &root_y, &point.x, &point.y, &mask);
+#endif
+
+#if ( defined(_WIN32) || (defined(HAVE_X11) && HAVE_X11))
+ // Return the mouse position as a range from -1 to 1
+ x = (float)point.x / (float)win_width * 2 - 1;
+ y = (float)point.y / (float)win_height * 2 - 1;
+#else
+ x = 0;
+ y = 0;
+#endif
+
+}
diff --git a/Source/Core/InputCommon/Src/ControllerEmu.h b/Source/Core/InputCommon/Src/ControllerEmu.h new file mode 100644 index 0000000000..875cb0ffeb --- /dev/null +++ b/Source/Core/InputCommon/Src/ControllerEmu.h @@ -0,0 +1,392 @@ +#pragma once
+
+// windows crap
+#define NOMINMAX
+
+#include "../../../PluginSpecs/pluginspecs_wiimote.h"
+#include <math.h>
+
+#include "ControllerInterface/ControllerInterface.h"
+#include "IniFile.h"
+
+#include <vector>
+#include <string>
+#include <algorithm>
+
+#define sign(x) ((x)?(x)<0?-1:1:0)
+
+enum
+{
+ GROUP_TYPE_OTHER,
+ GROUP_TYPE_STICK,
+ GROUP_TYPE_MIXED_TRIGGERS,
+ GROUP_TYPE_BUTTONS,
+ GROUP_TYPE_FORCE,
+ GROUP_TYPE_EXTENSION,
+ GROUP_TYPE_TILT,
+ GROUP_TYPE_CURSOR,
+ GROUP_TYPE_TRIGGERS,
+};
+
+const char * const named_directions[] =
+{
+ "Up",
+ "Down",
+ "Left",
+ "Right"
+};
+
+void GetMousePos(float& x, float& y, const SWiimoteInitialize* const wiimote_initialize);
+
+class ControllerEmu
+{
+public:
+
+ class ControlGroup
+ {
+ public:
+
+ class Control
+ {
+ protected:
+ Control( ControllerInterface::ControlReference* const _ref, const char * const _name )
+ : control_ref(_ref), name(_name){}
+ public:
+
+ virtual ~Control();
+ ControllerInterface::ControlReference* const control_ref;
+ const char * const name;
+
+ };
+
+ class Input : public Control
+ {
+ public:
+
+ Input( const char * const _name )
+ : Control( new ControllerInterface::InputReference, _name ) {}
+
+ };
+
+ class Output : public Control
+ {
+ public:
+
+ Output( const char * const _name )
+ : Control( new ControllerInterface::OutputReference, _name ) {}
+
+ };
+
+ class Setting
+ {
+ public:
+
+ Setting(const char* const _name, const ControlState def_value
+ , const unsigned int _low = 1, const unsigned int _high = 100 )
+ : name(_name)
+ , value(def_value)
+ , default_value(def_value)
+ , low(_low)
+ , high(_high){}
+
+ const char* const name;
+ ControlState value;
+ const ControlState default_value;
+ const unsigned int low, high;
+ };
+
+ ControlGroup( const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER ) : name(_name), type(_type) {}
+ virtual ~ControlGroup();
+
+ void LoadConfig( Section& sec, const std::string& defdev = "", const std::string& base = "" );
+ void SaveConfig( Section& sec, const std::string& defdev = "", const std::string& base = "" );
+
+ const char* const name;
+ const unsigned int type;
+
+ std::vector< Control* > controls;
+ std::vector< Setting* > settings;
+
+ };
+
+ class AnalogStick : public ControlGroup
+ {
+ public:
+
+ template <typename C>
+ void GetState( C* const x, C* const y, const unsigned int base, const unsigned int range )
+ {
+ // this is all a mess
+
+ ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
+ ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
+
+ ControlState deadzone = settings[0]->value;
+ ControlState square = settings[1]->value;
+ ControlState m = controls[4]->control_ref->State();
+
+ // modifier code
+ if ( m )
+ {
+ yy = (abs(yy)>deadzone) * sign(yy) * (m + deadzone/2);
+ xx = (abs(xx)>deadzone) * sign(xx) * (m + deadzone/2);
+ }
+
+ // deadzone / square stick code
+ if ( deadzone || square )
+ {
+ // this section might be all wrong, but its working good enough, i think
+
+ ControlState ang = atan2( yy, xx );
+ ControlState ang_sin = sin(ang);
+ ControlState ang_cos = cos(ang);
+
+ // the amt a full square stick would have at current angle
+ ControlState square_full = std::min( ang_sin ? 1/abs(ang_sin) : 2, ang_cos ? 1/abs(ang_cos) : 2 );
+
+ // the amt a full stick would have that was ( user setting squareness) at current angle
+ // i think this is more like a pointed circle rather than a rounded square like it should be
+ ControlState stick_full = ( 1 + ( square_full - 1 ) * square );
+
+ ControlState dist = sqrt(xx*xx + yy*yy);
+
+ // dead zone code
+ dist = std::max( 0.0f, dist - deadzone * stick_full );
+ dist /= ( 1 - deadzone );
+
+ // square stick code
+ ControlState amt = dist / stick_full;
+ dist -= ((square_full - 1) * amt * square);
+
+ yy = std::max( -1.0f, std::min( 1.0f, ang_sin * dist ) );
+ xx = std::max( -1.0f, std::min( 1.0f, ang_cos * dist ) );
+ }
+
+ *y = C( yy * range + base );
+ *x = C( xx * range + base );
+ }
+
+ AnalogStick( const char* const _name );
+
+ };
+
+ class Buttons : public ControlGroup
+ {
+ public:
+ Buttons( const char* const _name );
+
+ template <typename C>
+ void GetState( C* const buttons, const C* bitmasks )
+ {
+ std::vector<Control*>::iterator i = controls.begin(),
+ e = controls.end();
+ for ( ; i!=e; ++i, ++bitmasks )
+ if ( (*i)->control_ref->State() > settings[0]->value ) // threshold
+ *buttons |= *bitmasks;
+ }
+
+ };
+
+ class MixedTriggers : public ControlGroup
+ {
+ public:
+
+ template <typename C, typename S>
+ void GetState( C* const digital, const C* bitmasks, S* analog, const unsigned int range )
+ {
+ const unsigned int trig_count = ((unsigned int) (controls.size() / 2));
+ for ( unsigned int i=0; i<trig_count; ++i,++bitmasks,++analog )
+ {
+ if ( controls[i]->control_ref->State() > settings[0]->value ) //threshold
+ {
+ *analog = range;
+ *digital |= *bitmasks;
+ }
+ else
+ *analog = S(controls[i+trig_count]->control_ref->State() * range);
+
+ }
+ }
+
+ MixedTriggers( const char* const _name );
+
+ };
+
+ class Triggers : public ControlGroup
+ {
+ public:
+
+ template <typename S>
+ void GetState( S* analog, const unsigned int range )
+ {
+ const unsigned int trig_count = ((unsigned int) (controls.size()));
+ const ControlState deadzone = settings[0]->value;
+ for ( unsigned int i=0; i<trig_count; ++i,++analog )
+ *analog = S( std::max(controls[i]->control_ref->State() - deadzone, 0.0f) / (1 - deadzone) * range );
+ }
+
+ Triggers( const char* const _name );
+
+ };
+
+ class Force : public ControlGroup
+ {
+ public:
+ Force( const char* const _name );
+
+ template <typename C, typename R>
+ void GetState( C* axis, const u8 base, const R range )
+ {
+ const float deadzone = settings[0]->value;
+ for ( unsigned int i=0; i<6; i+=2 )
+ {
+ const float state = controls[i+1]->control_ref->State() - controls[i]->control_ref->State();
+ if (abs(state) > deadzone)
+ *axis++ = (C)((state - (deadzone * sign(state))) / (1 - deadzone) * range + base);
+ //*axis++ = state * range + base;
+ else
+ *axis++ = (C)(base);
+ }
+ }
+ };
+
+ class Tilt : public ControlGroup
+ {
+ public:
+ Tilt( const char* const _name );
+
+ template <typename C, typename R>
+ void GetState( C* const x, C* const y, const unsigned int base, const R range )
+ {
+ // this is all a mess
+
+ ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
+ ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
+
+ ControlState deadzone = settings[0]->value;
+ ControlState circle = settings[1]->value;
+ ControlState m = controls[4]->control_ref->State();
+
+ // modifier code
+ if ( m )
+ {
+ yy = (abs(yy)>deadzone) * sign(yy) * (m + deadzone/2);
+ xx = (abs(xx)>deadzone) * sign(xx) * (m + deadzone/2);
+ }
+
+ // deadzone / circle stick code
+ if ( deadzone || circle )
+ {
+ // this section might be all wrong, but its working good enough, i think
+
+ ControlState ang = atan2( yy, xx );
+ ControlState ang_sin = sin(ang);
+ ControlState ang_cos = cos(ang);
+
+ // the amt a full square stick would have at current angle
+ ControlState square_full = std::min( ang_sin ? 1/abs(ang_sin) : 2, ang_cos ? 1/abs(ang_cos) : 2 );
+
+ // the amt a full stick would have that was ( user setting circular ) at current angle
+ // i think this is more like a pointed circle rather than a rounded square like it should be
+ ControlState stick_full = (square_full * (1 - circle)) + (circle);
+
+ ControlState dist = sqrt(xx*xx + yy*yy);
+
+ // dead zone code
+ dist = std::max( 0.0f, dist - deadzone * stick_full );
+ dist /= (1 - deadzone);
+
+ // circle stick code
+ ControlState amt = dist / stick_full;
+ dist += (square_full - 1) * amt * circle;
+
+ yy = std::max( -1.0f, std::min( 1.0f, ang_sin * dist ) );
+ xx = std::max( -1.0f, std::min( 1.0f, ang_cos * dist ) );
+ }
+
+ *y = C( yy * range + base );
+ *x = C( xx * range + base );
+ }
+ };
+
+ class Cursor : public ControlGroup
+ {
+ public:
+ Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize );
+
+ template <typename C>
+ void GetState( C* const x, C* const y, C* const forward, const bool adjusted = false )
+ {
+ const ControlState z = controls[4]->control_ref->State();
+
+ // hide
+ if (controls[5]->control_ref->State() > 0.5f)
+ {
+ *x = 10000; *y = 0; *forward = 0;
+ }
+ else
+ {
+ *forward = z;
+ float xx, yy;
+ GetMousePos(xx, yy, wiimote_initialize);
+
+ // use mouse cursor, or user defined mapping if they have something mapped
+ // this if seems horrible
+ if ( controls[0]->control_ref->control_qualifier.name.size() || controls[1]->control_ref->control_qualifier.name.size() )
+ yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
+ else
+ yy = -yy;
+
+ if ( controls[2]->control_ref->control_qualifier.name.size() || controls[3]->control_ref->control_qualifier.name.size() )
+ xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
+
+ // adjust cursor according to settings
+ if (adjusted)
+ {
+ xx *= ( settings[1]->value * 2 );
+ yy *= ( settings[2]->value * 2 );
+ yy += ( settings[0]->value - 0.5f );
+ }
+
+ *x = xx;
+ *y = yy;
+ }
+ }
+
+ private:
+ const SWiimoteInitialize* const wiimote_initialize;
+
+ };
+
+ class Extension : public ControlGroup
+ {
+ public:
+ Extension( const char* const _name )
+ : ControlGroup( _name, GROUP_TYPE_EXTENSION )
+ , switch_extension(0)
+ , active_extension(0) {}
+ ~Extension();
+
+ void GetState( u8* const data, const bool focus = true );
+
+ std::vector<ControllerEmu*> attachments;
+
+ int switch_extension;
+ int active_extension;
+ };
+
+ virtual ~ControllerEmu();
+
+ virtual std::string GetName() const = 0;
+
+ void LoadConfig( Section& sec, const std::string& base = "" );
+ void SaveConfig( Section& sec, const std::string& base = "" );
+ void UpdateDefaultDevice();
+
+ void UpdateReferences( ControllerInterface& devi );
+
+ std::vector< ControlGroup* > groups;
+
+ ControllerInterface::DeviceQualifier default_device;
+
+};
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputKeyboardMouse.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputKeyboardMouse.cpp index 071a233887..98e199c24f 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputKeyboardMouse.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputKeyboardMouse.cpp @@ -2,6 +2,7 @@ #ifdef CIFACE_USE_DIRECTINPUT_KBM +#include <Timer.h> #include "DirectInputKeyboardMouse.h" // TODO: maybe add a ClearInputState function to this device @@ -95,7 +96,7 @@ KeyboardMouse::KeyboardMouse( const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRE : m_kb_device(kb_device) , m_mo_device(mo_device) { - m_last_update = wxGetLocalTimeMillis(); + m_last_update = Common::Timer::GetLocalTimeSinceJan1970(); ZeroMemory( &m_state_in, sizeof(m_state_in) ); ZeroMemory( m_state_out, sizeof(m_state_out) ); @@ -133,7 +134,7 @@ bool KeyboardMouse::UpdateInput() DIMOUSESTATE2 tmp_mouse; // if mouse position hasn't been updated in a short while, skip a dev state - wxLongLong cur_time = wxGetLocalTimeMillis(); + u64 cur_time = Common::Timer::GetLocalTimeSinceJan1970(); if ( cur_time - m_last_update > DROP_INPUT_TIME ) { // set axes to zero @@ -178,7 +179,7 @@ bool KeyboardMouse::UpdateOutput() { bool want_on = false; if ( m_state_out[i] ) - want_on = m_state_out[i] > wxGetLocalTimeMillis() % 255 ; // light should flash when output is 0.5 + want_on = m_state_out[i] > Common::Timer::GetLocalTimeSinceJan1970() % 255 ; // light should flash when output is 0.5 // lights are set to their original state when output is zero if ( want_on ^ m_current_state_out[i] ) diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputKeyboardMouse.h b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputKeyboardMouse.h index 6af5fb10d0..e57e8d7e97 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputKeyboardMouse.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputKeyboardMouse.h @@ -9,8 +9,6 @@ #include <Windows.h> #include <dinput.h> -#include <wx/stopwatch.h> -#include <wx/utils.h> namespace ciface { @@ -113,7 +111,7 @@ private: const LPDIRECTINPUTDEVICE8 m_kb_device; const LPDIRECTINPUTDEVICE8 m_mo_device; - wxLongLong m_last_update; + u64 m_last_update; State m_state_in; unsigned char m_state_out[3]; // NUM CAPS SCROLL bool m_current_state_out[3]; // NUM CAPS SCROLL diff --git a/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.cpp b/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.cpp index a2b6c638c9..61a7b724f6 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/XInput/XInput.cpp @@ -4,6 +4,8 @@ #include "XInput.h" +#pragma comment(lib, "xinput.lib") + namespace ciface { namespace XInput diff --git a/Source/Core/InputCommon/Src/DirectInputBase.cpp b/Source/Core/InputCommon/Src/DirectInputBase.cpp deleted file mode 100644 index b9a7fee33d..0000000000 --- a/Source/Core/InputCommon/Src/DirectInputBase.cpp +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - - - -// Include -// ------------------- -#include "DirectInputBase.h" - - - -DInput::DInput() - : g_pDI(NULL), - g_pKeyboard(NULL) -{} - - -DInput::~DInput() -{ - Free(); -} - -void DInput::DIKToString(unsigned int keycode, char *keyStr) -{ - switch(keycode) { - case DIK_RETURN: - sprintf(keyStr, "Enter"); - break; - case DIK_LCONTROL: - sprintf(keyStr, "Left Ctrl"); - break; - case DIK_RCONTROL: - strcpy(keyStr, "Right Ctrl"); - break; - case DIK_LSHIFT: - sprintf(keyStr, "Left Shift"); - break; - case DIK_RSHIFT: - sprintf(keyStr, "Right Shift"); - break; - case DIK_LMENU: - sprintf(keyStr, "Left Alt"); - break; - case DIK_RMENU: - strcpy(keyStr, "Right Alt"); - break; - case DIK_UP: - sprintf(keyStr, "Up"); - break; - case DIK_DOWN: - sprintf(keyStr, "Down"); - break; - case DIK_LEFT: - sprintf(keyStr, "Left"); - break; - case DIK_RIGHT: - sprintf(keyStr, "Right"); - break; - case DIK_HOME: - strcpy(keyStr, "Home"); - break; - case DIK_END: - strcpy(keyStr, "End"); - break; - case DIK_INSERT: - strcpy(keyStr, "Ins"); - break; - case DIK_DELETE: - strcpy(keyStr, "Del"); - break; - case DIK_PGUP: - strcpy(keyStr, "PgUp"); - break; - case DIK_PGDN: - strcpy(keyStr, "PgDn"); - break; - case DIK_NUMLOCK: - strcpy(keyStr, "Num Lock"); - break; - case DIK_NUMPAD0: - strcpy(keyStr, "Num 0"); - break; - case DIK_NUMPAD1: - strcpy(keyStr, "Num 1"); - break; - case DIK_NUMPAD2: - strcpy(keyStr, "Num 2"); - break; - case DIK_NUMPAD3: - strcpy(keyStr, "Num 3"); - break; - case DIK_NUMPAD4: - strcpy(keyStr, "Num 4"); - break; - case DIK_NUMPAD5: - strcpy(keyStr, "Num 5"); - break; - case DIK_NUMPAD6: - strcpy(keyStr, "Num 6"); - break; - case DIK_NUMPAD7: - strcpy(keyStr, "Num 7"); - break; - case DIK_NUMPAD8: - strcpy(keyStr, "Num 8"); - break; - case DIK_NUMPAD9: - strcpy(keyStr, "Num 9"); - break; - case DIK_DIVIDE: - strcpy(keyStr, "Num /"); - break; - case DIK_NUMPADENTER: - strcpy(keyStr, "Num Enter"); - break; - case DIK_DECIMAL: - strcpy(keyStr, "Num Decimal"); - break; - case DIK_NUMPADCOMMA: - case DIK_ABNT_C2: - strcpy(keyStr, "Num Separator"); - break; - case DIK_NUMPADEQUALS: - strcpy(keyStr, "Num ="); - break; - default: - // TODO: Switch to unicode GetKeyNameText? - GetKeyNameTextA(keycode << 16, keyStr, 64); - break; - } -} - -HRESULT DInput::Init(HWND hWnd) -{ - HRESULT hr; - DWORD dwCoopFlags; - dwCoopFlags = DISCL_FOREGROUND | DISCL_NOWINKEY; - - // Create a DInput object - if (FAILED(hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, - IID_IDirectInput8, (VOID* *)&g_pDI, NULL))) - { - MessageBox(0, L"Direct Input Create Failed", 0, MB_ICONERROR); - return(hr); - } - - if (FAILED(hr = g_pDI->CreateDevice(GUID_SysKeyboard, &g_pKeyboard, NULL))) - { - MessageBox(0, L"Couldn't access keyboard", 0, MB_ICONERROR); - Free(); - return(hr); - } - - g_pKeyboard->SetDataFormat(&c_dfDIKeyboard); - g_pKeyboard->SetCooperativeLevel(hWnd, dwCoopFlags); - g_pKeyboard->Acquire(); - - return(S_OK); -} - -void DInput::Free() -{ - if (g_pKeyboard) - { - g_pKeyboard->Unacquire(); - g_pKeyboard->Release(); - g_pKeyboard = 0; - } - - if (g_pDI) - { - g_pDI->Release(); - g_pDI = 0; - } -} - -// Desc: Read the input device's state when in immediate mode and display it. -HRESULT DInput::Read() -{ - HRESULT hr; - - if (NULL == g_pKeyboard) - { - return(S_OK); - } - - // Get the input's device state, and put the state in dims - ZeroMemory(diks, sizeof(diks)); - hr = g_pKeyboard->GetDeviceState(sizeof(diks), diks); - - //for (int i=0; i<256; i++) - // if (diks[i]) MessageBox(0,"DSFJDKSF|",0,0); - if (FAILED(hr)) - { - // DirectInput may be telling us that the input stream has been - // interrupted. We aren't tracking any state between polls, so - // we don't have any special reset that needs to be done. - // We just re-acquire and try again. - - // If input is lost then acquire and keep trying - hr = g_pKeyboard->Acquire(); - - while (hr == DIERR_INPUTLOST) - { - hr = g_pKeyboard->Acquire(); - } - - // hr may be DIERR_OTHERAPPHASPRIO or other errors. This - // may occur when the app is minimized or in the process of - // switching, so just try again later - return(S_OK); - } - - return(S_OK); -} diff --git a/Source/Core/InputCommon/Src/DirectInputBase.h b/Source/Core/InputCommon/Src/DirectInputBase.h deleted file mode 100644 index 22f7fb5d2e..0000000000 --- a/Source/Core/InputCommon/Src/DirectInputBase.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#ifndef _DIRECTINPUTBASE_H -#define _DIRECTINPUTBASE_H - - -#include <windows.h> // System -#include <stdio.h> - -#define DIRECTINPUT_VERSION 0x0800 // DirectInput -#include <dinput.h> - - - -class DInput -{ - public: - - DInput(); - ~DInput(); - - static void DInput::DIKToString(unsigned int keycode, char *keyStr); - - HRESULT Init(HWND hWnd); - void Free(); - HRESULT Read(); - - - BYTE diks[256]; // DirectInput keyboard state buffer - - private: - - LPDIRECTINPUT8 g_pDI; // The DirectInput object - LPDIRECTINPUTDEVICE8 g_pKeyboard; // The keyboard device -}; - -#endif - diff --git a/Source/Core/InputCommon/Src/Event.hpp b/Source/Core/InputCommon/Src/Event.hpp deleted file mode 100755 index 7f84265c3d..0000000000 --- a/Source/Core/InputCommon/Src/Event.hpp +++ /dev/null @@ -1,264 +0,0 @@ -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. - -#ifndef SFML_EVENT_HPP -#define SFML_EVENT_HPP - - -namespace sf -{ - namespace Key - { - enum Code - { - A = 'a', - B = 'b', - C = 'c', - D = 'd', - E = 'e', - F = 'f', - G = 'g', - H = 'h', - I = 'i', - J = 'j', - K = 'k', - L = 'l', - M = 'm', - N = 'n', - O = 'o', - P = 'p', - Q = 'q', - R = 'r', - S = 's', - T = 't', - U = 'u', - V = 'v', - W = 'w', - X = 'x', - Y = 'y', - Z = 'z', - Num0 = '0', - Num1 = '1', - Num2 = '2', - Num3 = '3', - Num4 = '4', - Num5 = '5', - Num6 = '6', - Num7 = '7', - Num8 = '8', - Num9 = '9', - Escape = 256, - LControl, - LShift, - LAlt, - LSystem, - RControl, - RShift, - RAlt, - RSystem, - Menu, - LBracket, - RBracket, - SemiColon, - Comma, - Period, - Quote, - Slash, - BackSlash, - Tilde, - Equal, - Dash, - Space, - Return, - Back, - Tab, - PageUp, - PageDown, - End, - Home, - Insert, - Delete, - Add, - Subtract, - Multiply, - Divide, - Left, - Right, - Up, - Down, - Numpad0, - Numpad1, - Numpad2, - Numpad3, - Numpad4, - Numpad5, - Numpad6, - Numpad7, - Numpad8, - Numpad9, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - F13, - F14, - F15, - Pause, - - Count // For internal use - }; - } - - - namespace Mouse - { - enum Button - { - Left, - Right, - Middle, - XButton1, - XButton2, - - Count // For internal use - }; - } - - - namespace Joy - { - enum Axis - { - AxisX, - AxisY, - AxisZ, - AxisR, - AxisU, - AxisV, - AxisPOV, - - Count // For internal use - }; - } - - - class Event - { - public : - - struct KeyEvent - { - Key::Code Code; - bool Alt; - bool Control; - bool Shift; - }; - - struct TextEvent - { - // I'm not sure we need this... - unsigned short Unicode; - }; - - struct MouseMoveEvent - { - int X; - int Y; - }; - - struct MouseButtonEvent - { - Mouse::Button Button; - int X; - int Y; - }; - - struct MouseWheelEvent - { - int Delta; - }; - - struct JoyMoveEvent - { - unsigned int JoystickId; - Joy::Axis Axis; - float Position; - }; - - struct JoyButtonEvent - { - unsigned int JoystickId; - unsigned int Button; - }; - - struct SizeEvent - { - unsigned int Width; - unsigned int Height; - }; - - enum EventType - { - Closed, - Resized, - LostFocus, - GainedFocus, - TextEntered, - KeyPressed, - KeyReleased, - MouseWheelMoved, - MouseButtonPressed, - MouseButtonReleased, - MouseMoved, - MouseEntered, - MouseLeft, - JoyButtonPressed, - JoyButtonReleased, - JoyMoved - }; - - // Member data - EventType Type; - - union - { - KeyEvent Key; - TextEvent Text; - MouseMoveEvent MouseMove; - MouseButtonEvent MouseButton; - MouseWheelEvent MouseWheel; - JoyMoveEvent JoyMove; - JoyButtonEvent JoyButton; - SizeEvent Size; - }; - }; - -} // namespace sf - - -#endif // SFML_EVENT_HPP diff --git a/Source/Core/InputCommon/Src/EventHandler.cpp b/Source/Core/InputCommon/Src/EventHandler.cpp deleted file mode 100644 index 19dc819baf..0000000000 --- a/Source/Core/InputCommon/Src/EventHandler.cpp +++ /dev/null @@ -1,318 +0,0 @@ -#include "EventHandler.h" -#include <stdio.h> -#include <ctype.h> - -#if defined HAVE_WX && HAVE_WX -#include <wx/wx.h> -#endif - -EventHandler *EventHandler::m_Instance = 0; - -EventHandler::EventHandler() { - memset(keys, 0, sizeof(keys)); - memset(mouse, 0, sizeof(mouse)); - memset(joys, 0, sizeof(joys)); -} - -EventHandler::~EventHandler() { -} - -EventHandler *EventHandler::GetInstance() { - // fprintf(stderr, "handler instance %p\n", m_Instance); - return m_Instance; -} - -void EventHandler::Init() -{ - m_Instance = new EventHandler(); -} - -void EventHandler::Shutdown() { - if (m_Instance) - delete m_Instance; - // fprintf(stderr, "deleting instance %p\n", m_Instance); - m_Instance = 0; -} - -bool EventHandler::RegisterEventListener(listenFuncPtr func, Keys key) { - if (key.inputType == KeyboardInput) { - // fprintf(stderr, "Registering %d:%d %p %p \n", key.keyCode, key.mods, func, this); - if (key.keyCode == sf::Key::Count || key.mods >= NUMMODS || - key.keyCode >= NUMKEYS) - return false; - if (keys[key.keyCode][key.mods] && keys[key.keyCode][key.mods] != func) - return false -; - keys[key.keyCode][key.mods] = func; - } else if (key.inputType == MouseInput) { - if (mouse[key.mouseButton]) - return false; - mouse[key.mouseButton] = func; - } - - return true; -} - -bool EventHandler::RemoveEventListener(Keys key) { - if (key.inputType == KeyboardInput) { - if ((key.keyCode == sf::Key::Count || key.keyCode >= NUMKEYS - || key.mods >= NUMMODS) && ! keys[key.keyCode][key.mods]) - return false; - keys[key.keyCode][key.mods] = NULL; - } else if (key.inputType == MouseInput) { - if (! mouse[key.mouseButton]) - return false; - mouse[key.mouseButton] = NULL; - } - - return true; -} - -void EventHandler::Update() { - for (unsigned int i = 0; i < eventQueue.size();i++) { - sf::Event ev = eventQueue.front(); - eventQueue.pop(); - fprintf(stderr, "Updating event type %d code %d mod %d func %p %p\n", ev.Type, ev.Key.Code, ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control, keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control], this); - if(keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control]) - keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control](ev); - } -} - -bool EventHandler::addEvent(sf::Event *ev) { - eventQueue.push(*ev); - fprintf(stderr, "Got event type %d code %d %p\n", ev->Type, ev->Key.Code, this); - return true; -} - - -bool EventHandler::TestEvent (Keys k, sf::Event e) -{ - //Mouse event - if (k.inputType==MouseInput && k.eventType==e.Type && k.mouseButton==e.MouseButton.Button) - { - return (true); - } - //Keyboard event - if (k.inputType==KeyboardInput && k.eventType==e.Type && k.keyCode==e.Key.Code) - { - return (true); - } - return (false); -} - -#if defined HAVE_WX && HAVE_WX -// Taken from wxw source code -sf::Key::Code EventHandler::wxCharCodeToSF(int id) -{ - sf::Key::Code sfKey; - - switch (id) { -// case WXK_CANCEL: sfKey = sf::Key::Cancel; break; -// case WXK_BACK: sfKey = sf::Key::BackSpace; break; - case WXK_TAB: sfKey = sf::Key::Tab; break; -// case WXK_CLEAR: sfKey = sf::Key::Clear; break; - case WXK_RETURN: sfKey = sf::Key::Return; break; - case WXK_SHIFT: sfKey = sf::Key::LShift; break; - case WXK_CONTROL: sfKey = sf::Key::LControl; break; - case WXK_ALT: sfKey = sf::Key::LAlt; break; -// case WXK_CAPITAL: sfKey = sf::Key::Caps_Lock; break; - case WXK_MENU : sfKey = sf::Key::Menu; break; - case WXK_PAUSE: sfKey = sf::Key::Pause; break; - case WXK_ESCAPE: sfKey = sf::Key::Escape; break; - case WXK_SPACE: sfKey = sf::Key::Space; break; - case WXK_PAGEUP: sfKey = sf::Key::PageUp; break; - case WXK_PAGEDOWN: sfKey = sf::Key::PageDown; break; - case WXK_END: sfKey = sf::Key::End; break; - case WXK_HOME : sfKey = sf::Key::Home; break; - case WXK_LEFT : sfKey = sf::Key::Left; break; - case WXK_UP: sfKey = sf::Key::Up; break; - case WXK_RIGHT: sfKey = sf::Key::Right; break; - case WXK_DOWN : sfKey = sf::Key::Down; break; -// case WXK_SELECT: sfKey = sf::Key::Select; break; -// case WXK_PRINT: sfKey = sf::Key::Print; break; -// case WXK_EXECUTE: sfKey = sf::Key::Execute; break; - case WXK_INSERT: sfKey = sf::Key::Insert; break; - case WXK_DELETE: sfKey = sf::Key::Delete; break; -// case WXK_HELP : sfKey = sf::Key::Help; break; - case WXK_NUMPAD0: sfKey = sf::Key::Numpad0; break; - case WXK_NUMPAD_INSERT: sfKey = sf::Key::Insert; break; - case WXK_NUMPAD1: sfKey = sf::Key::Numpad1; break; - case WXK_NUMPAD_END: sfKey = sf::Key::End; break; - case WXK_NUMPAD2: sfKey = sf::Key::Numpad2; break; - case WXK_NUMPAD_DOWN: sfKey = sf::Key::Down; break; - case WXK_NUMPAD3: sfKey = sf::Key::Numpad3; break; - case WXK_NUMPAD_PAGEDOWN: sfKey = sf::Key::PageDown; break; - case WXK_NUMPAD4: sfKey = sf::Key::Numpad4; break; - case WXK_NUMPAD_LEFT: sfKey = sf::Key::Left; break; - case WXK_NUMPAD5: sfKey = sf::Key::Numpad5; break; - case WXK_NUMPAD6: sfKey = sf::Key::Numpad6; break; - case WXK_NUMPAD_RIGHT: sfKey = sf::Key::Right; break; - case WXK_NUMPAD7: sfKey = sf::Key::Numpad7; break; - case WXK_NUMPAD_HOME: sfKey = sf::Key::Home; break; - case WXK_NUMPAD8: sfKey = sf::Key::Numpad8; break; - case WXK_NUMPAD_UP: sfKey = sf::Key::Up; break; - case WXK_NUMPAD9: sfKey = sf::Key::Numpad9; break; - case WXK_NUMPAD_PAGEUP: sfKey = sf::Key::PageUp; break; -// case WXK_NUMPAD_DECIMAL: sfKey = sf::Key::Decimal; break; - case WXK_NUMPAD_DELETE: sfKey = sf::Key::Delete; break; - case WXK_NUMPAD_MULTIPLY: sfKey = sf::Key::Multiply; break; - case WXK_NUMPAD_ADD: sfKey = sf::Key::Add; break; - case WXK_NUMPAD_SUBTRACT: sfKey = sf::Key::Subtract; break; - case WXK_NUMPAD_DIVIDE: sfKey = sf::Key::Divide; break; - case WXK_NUMPAD_ENTER: sfKey = sf::Key::Return; break; -// case WXK_NUMPAD_SEPARATOR:sfKey = sf::Key::Separator; break; - case WXK_F1: sfKey = sf::Key::F1; break; - case WXK_F2: sfKey = sf::Key::F2; break; - case WXK_F3: sfKey = sf::Key::F3; break; - case WXK_F4: sfKey = sf::Key::F4; break; - case WXK_F5: sfKey = sf::Key::F5; break; - case WXK_F6: sfKey = sf::Key::F6; break; - case WXK_F7: sfKey = sf::Key::F7; break; - case WXK_F8: sfKey = sf::Key::F8; break; - case WXK_F9: sfKey = sf::Key::F9; break; - case WXK_F10: sfKey = sf::Key::F10; break; - case WXK_F11: sfKey = sf::Key::F11; break; - case WXK_F12: sfKey = sf::Key::F12; break; - case WXK_F13: sfKey = sf::Key::F13; break; - case WXK_F14: sfKey = sf::Key::F14; break; - case WXK_F15: sfKey = sf::Key::F15; break; -// case WXK_NUMLOCK: sfKey = sf::Key::Num_Lock; break; -// case WXK_SCROLL: sfKey = sf::Key::Scroll_Lock; break; - default: - - // To lower (will tolower work on windows?) - if (id >= 'A' && id <= 'Z') - id = id - 'A' + 'a'; - - if ((id >= 'a' && id <= 'z') || - (id >= '0' && id <= '9')) - sfKey = (sf::Key::Code)id; - else - sfKey = sf::Key::Count; // Invalid key - - } - - return sfKey; -} -#endif - -void EventHandler::SFKeyToString(sf::Key::Code keycode, char *keyStr) { - switch (keycode) { -/* case sf::Key::A = 'a': sprintf(keyStr, "UP"); break; - case sf::Key::B = 'b': sprintf(keyStr, "UP"); break; - case sf::Key::C = 'c': sprintf(keyStr, "UP"); break; - case sf::Key::D = 'd': sprintf(keyStr, "UP"); break; - case sf::Key::E = 'e': sprintf(keyStr, "UP"); break; - case sf::Key::F = 'f': sprintf(keyStr, "UP"); break; - case sf::Key::G = 'g': sprintf(keyStr, "UP"); break; - case sf::Key::H = 'h': sprintf(keyStr, "UP"); break; - case sf::Key::I = 'i': sprintf(keyStr, "UP"); break; - case sf::Key::J = 'j': sprintf(keyStr, "UP"); break; - case sf::Key::K = 'k': sprintf(keyStr, "UP"); break; - case sf::Key::L = 'l': sprintf(keyStr, "UP"); break; - case sf::Key::M = 'm': sprintf(keyStr, "UP"); break; - case sf::Key::N = 'n': sprintf(keyStr, "UP"); break; - case sf::Key::O = 'o': sprintf(keyStr, "UP"); break; - case sf::Key::P = 'p': sprintf(keyStr, "UP"); break; - case sf::Key::Q = 'q': sprintf(keyStr, "UP"); break; - case sf::Key::R = 'r': sprintf(keyStr, "UP"); break; - case sf::Key::S = 's': sprintf(keyStr, "UP"); break; - case sf::Key::T = 't': sprintf(keyStr, "UP"); break; - case sf::Key::U = 'u': sprintf(keyStr, "UP"); break; - case sf::Key::V = 'v': sprintf(keyStr, "UP"); break; - case sf::Key::W = 'w': sprintf(keyStr, "UP"); break; - case sf::Key::X = 'x': sprintf(keyStr, "UP"); break; - case sf::Key::Y = 'y': sprintf(keyStr, "UP"); break; - case sf::Key::Z = 'z': sprintf(keyStr, "UP"); break; - case sf::Key::Num0 = '0': sprintf(keyStr, "UP"); break; - case sf::Key::Num1 = '1': sprintf(keyStr, "UP"); break; - case sf::Key::Num2 = '2': sprintf(keyStr, "UP"); break; - case sf::Key::Num3 = '3': sprintf(keyStr, "UP"); break; - case sf::Key::Num4 = '4': sprintf(keyStr, "UP"); break; - case sf::Key::Num5 = '5': sprintf(keyStr, "UP"); break; - case sf::Key::Num6 = '6': sprintf(keyStr, "UP"); break; - case sf::Key::Num7 = '7': sprintf(keyStr, "UP"); break; - case sf::Key::Num8 = '8': sprintf(keyStr, "UP"); break; - case sf::Key::Num9 = '9': sprintf(keyStr, "UP"); break;*/ - case sf::Key::Escape: sprintf(keyStr, "Escape"); break; - case sf::Key::LControl: sprintf(keyStr, "LControl"); break; - case sf::Key::LShift: sprintf(keyStr, "LShift"); break; - case sf::Key::LAlt: sprintf(keyStr, "LAlt"); break; - case sf::Key::LSystem: sprintf(keyStr, "LSystem"); break; - case sf::Key::RControl: sprintf(keyStr, "RControl"); break; - case sf::Key::RShift: sprintf(keyStr, "RShift"); break; - case sf::Key::RAlt: sprintf(keyStr, "RAlt"); break; - case sf::Key::RSystem: sprintf(keyStr, "RSystem"); break; - case sf::Key::Menu: sprintf(keyStr, "Menu"); break; - case sf::Key::LBracket: sprintf(keyStr, "LBracket"); break; - case sf::Key::RBracket: sprintf(keyStr, "RBracket"); break; - case sf::Key::SemiColon: sprintf(keyStr, ";"); break; - case sf::Key::Comma: sprintf(keyStr, ","); break; - case sf::Key::Period: sprintf(keyStr, "."); break; - case sf::Key::Quote: sprintf(keyStr, "\'"); break; - case sf::Key::Slash: sprintf(keyStr, "/"); break; - case sf::Key::BackSlash: sprintf(keyStr, "\\"); break; - case sf::Key::Tilde: sprintf(keyStr, "~"); break; - case sf::Key::Equal: sprintf(keyStr, "="); break; - case sf::Key::Dash: sprintf(keyStr, "-"); break; - case sf::Key::Space: sprintf(keyStr, "Space"); break; - case sf::Key::Return: sprintf(keyStr, "Return"); break; - case sf::Key::Back: sprintf(keyStr, "Back"); break; - case sf::Key::Tab: sprintf(keyStr, "Tab"); break; - case sf::Key::PageUp: sprintf(keyStr, "Page Up"); break; - case sf::Key::PageDown: sprintf(keyStr, "Page Down"); break; - case sf::Key::End: sprintf(keyStr, "End"); break; - case sf::Key::Home: sprintf(keyStr, "Home"); break; - case sf::Key::Insert: sprintf(keyStr, "Insert"); break; - case sf::Key::Delete: sprintf(keyStr, "Delete"); break; - case sf::Key::Add: sprintf(keyStr, "+"); break; - case sf::Key::Subtract: sprintf(keyStr, "-"); break; - case sf::Key::Multiply: sprintf(keyStr, "*"); break; - case sf::Key::Divide: sprintf(keyStr, "/"); break; - case sf::Key::Left: sprintf(keyStr, "Left"); break; - case sf::Key::Right: sprintf(keyStr, "Right"); break; - case sf::Key::Up: sprintf(keyStr, "Up"); break; - case sf::Key::Down: sprintf(keyStr, "Down"); break; - case sf::Key::Numpad0: sprintf(keyStr, "NP 0"); break; - case sf::Key::Numpad1: sprintf(keyStr, "NP 1"); break; - case sf::Key::Numpad2: sprintf(keyStr, "NP 2"); break; - case sf::Key::Numpad3: sprintf(keyStr, "NP 3"); break; - case sf::Key::Numpad4: sprintf(keyStr, "NP 4"); break; - case sf::Key::Numpad5: sprintf(keyStr, "NP 5"); break; - case sf::Key::Numpad6: sprintf(keyStr, "NP 6"); break; - case sf::Key::Numpad7: sprintf(keyStr, "NP 7"); break; - case sf::Key::Numpad8: sprintf(keyStr, "NP 8"); break; - case sf::Key::Numpad9: sprintf(keyStr, "NP 9"); break; - case sf::Key::F1: sprintf(keyStr, "F1"); break; - case sf::Key::F2: sprintf(keyStr, "F2"); break; - case sf::Key::F3: sprintf(keyStr, "F3"); break; - case sf::Key::F4: sprintf(keyStr, "F4"); break; - case sf::Key::F5: sprintf(keyStr, "F5"); break; - case sf::Key::F6: sprintf(keyStr, "F6"); break; - case sf::Key::F7: sprintf(keyStr, "F7"); break; - case sf::Key::F8: sprintf(keyStr, "F8"); break; - case sf::Key::F9: sprintf(keyStr, "F9"); break; - case sf::Key::F10: sprintf(keyStr, "F10"); break; - case sf::Key::F11: sprintf(keyStr, "F11"); break; - case sf::Key::F12: sprintf(keyStr, "F12"); break; - case sf::Key::F13: sprintf(keyStr, "F13"); break; - case sf::Key::F14: sprintf(keyStr, "F14"); break; - case sf::Key::F15: sprintf(keyStr, "F15"); break; - case sf::Key::Pause: sprintf(keyStr, "Pause"); break; - default: - if (keycode > sf::Key::Escape) - sprintf(keyStr, "Invalid Key"); - else - sprintf(keyStr, "%c", toupper(keycode)); - break; - } -} - -class EventHandlerCleaner -{ -public: - ~EventHandlerCleaner() - { - //EventHandler::Destroy(); - } -} EventHandlerCleanerInst; diff --git a/Source/Core/InputCommon/Src/EventHandler.h b/Source/Core/InputCommon/Src/EventHandler.h deleted file mode 100644 index bde6bbf430..0000000000 --- a/Source/Core/InputCommon/Src/EventHandler.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef EVENTHANDER_H -#define EVENTHANDER_H 1 -#include "Common.h" -#include <queue> -#include "Event.hpp" - -#define NUMKEYS 300 -#define NUMMODS 8 - -typedef bool (*listenFuncPtr) (sf::Event); -enum InputType -{ - KeyboardInput, - MouseInput, - JoystickInput -}; - -enum Modifiers { - UseAlt = 1, - UseShift = 2, - UseCtrl = 4 -}; - -struct Keys { - InputType inputType; - sf::Event::EventType eventType; - sf::Key::Code keyCode; - int mods; - sf::Mouse::Button mouseButton; -}; - -class EventHandler { - -private: - listenFuncPtr keys[NUMKEYS][NUMMODS]; - listenFuncPtr mouse[sf::Mouse::Count+1]; - listenFuncPtr joys[sf::Joy::Count+1]; - std::queue<sf::Event> eventQueue; - static EventHandler *m_Instance; - -protected: - EventHandler(const EventHandler&); - EventHandler& operator= (const EventHandler&); - - EventHandler(); - ~EventHandler(); - -public: - - bool RegisterEventListener(listenFuncPtr func, Keys key); - bool RemoveEventListener(Keys key); - void Update(); - static EventHandler *GetInstance(); - static void Init(); - static void Shutdown(); - bool addEvent(sf::Event *e); - static bool TestEvent (Keys k, sf::Event e); -#if defined HAVE_WX && HAVE_WX - static sf::Key::Code wxCharCodeToSF(int id); -#endif - static void SFKeyToString(sf::Key::Code keycode, char *keyStr); -}; - -#endif diff --git a/Source/Core/InputCommon/Src/InputCommon.cpp b/Source/Core/InputCommon/Src/InputCommon.cpp deleted file mode 100644 index beed506f8e..0000000000 --- a/Source/Core/InputCommon/Src/InputCommon.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "EventHandler.h" - -//EventHandler *eventHandler = NULL; - -namespace InputCommon -{ - void Init() { - // init the event handler - //EventHandler::GetInstance(); - } - - void Shutdown() { - //if (eventHandler) - // delete eventHandler; - } -} diff --git a/Source/Core/InputCommon/Src/InputCommon.h b/Source/Core/InputCommon/Src/InputCommon.h index 5b930fb217..52b75e0f0f 100644 --- a/Source/Core/InputCommon/Src/InputCommon.h +++ b/Source/Core/InputCommon/Src/InputCommon.h @@ -1,7 +1,3 @@ -#include "EventHandler.h" - -//extern EventHandler *eventHandler; - namespace InputCommon { enum EButtonType @@ -24,6 +20,4 @@ enum EXInputTrigger XI_TRIGGER_R, }; - void Init(); - void Shutdown(); } diff --git a/Source/Core/InputCommon/Src/WXInputBase.cpp b/Source/Core/InputCommon/Src/WXInputBase.cpp deleted file mode 100644 index f89f813e97..0000000000 --- a/Source/Core/InputCommon/Src/WXInputBase.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#include <wx/stattext.h> -#include "WXInputBase.h" -//#include <string.h> -//#include <stdio.h> -//#include <ctype.h> - -namespace InputCommon -{ - -const wxChar *WXKeyToString(int keycode) -{ - switch (keycode) - { - case WXK_CANCEL: return wxT("Cancel"); break; - case WXK_BACK: return wxT("Back"); break; - case WXK_TAB: return wxT("Tab"); break; - case WXK_CLEAR: return wxT("Clear"); break; - case WXK_RETURN: return wxT("Return"); break; - case WXK_SHIFT: return wxT("Shift"); break; - case WXK_CONTROL: return wxT("Control"); break; - case WXK_ALT: return wxT("Alt"); break; - case WXK_CAPITAL: return wxT("CapsLock"); break; - case WXK_MENU : return wxT("Menu"); break; - case WXK_PAUSE: return wxT("Pause"); break; - case WXK_ESCAPE: return wxT("Escape"); break; - case WXK_SPACE: return wxT("Space"); break; - case WXK_PAGEUP: return wxT("PgUp"); break; - case WXK_PAGEDOWN: return wxT("PgDn"); break; - case WXK_END: return wxT("End"); break; - case WXK_HOME : return wxT("Home"); break; - case WXK_LEFT : return wxT("Left"); break; - case WXK_UP: return wxT("Up"); break; - case WXK_RIGHT: return wxT("Right"); break; - case WXK_DOWN : return wxT("Down"); break; - case WXK_SELECT: return wxT("Select"); break; - case WXK_PRINT: return wxT("Print"); break; - case WXK_EXECUTE: return wxT("Execute"); break; - case WXK_INSERT: return wxT("Insert"); break; - case WXK_DELETE: return wxT("Delete"); break; - case WXK_HELP : return wxT("Help"); break; - case WXK_NUMPAD0: return wxT("NP 0"); break; - case WXK_NUMPAD1: return wxT("NP 1"); break; - case WXK_NUMPAD2: return wxT("NP 2"); break; - case WXK_NUMPAD3: return wxT("NP 3"); break; - case WXK_NUMPAD4: return wxT("NP 4"); break; - case WXK_NUMPAD5: return wxT("NP 5"); break; - case WXK_NUMPAD6: return wxT("NP 6"); break; - case WXK_NUMPAD7: return wxT("NP 7"); break; - case WXK_NUMPAD8: return wxT("NP 8"); break; - case WXK_NUMPAD9: return wxT("NP 9"); break; - case WXK_NUMPAD_DECIMAL: return wxT("NP ."); break; - case WXK_NUMPAD_DELETE: return wxT("NP Delete"); break; - case WXK_NUMPAD_INSERT: return wxT("NP Insert"); break; - case WXK_NUMPAD_END: return wxT("NP End"); break; - case WXK_NUMPAD_DOWN: return wxT("NP Down"); break; - case WXK_NUMPAD_PAGEDOWN: return wxT("NP Pagedown"); break; - case WXK_NUMPAD_LEFT: return wxT("NP Left"); break; - case WXK_NUMPAD_RIGHT: return wxT("NP Right"); break; - case WXK_NUMPAD_HOME: return wxT("NP Home"); break; - case WXK_NUMPAD_UP: return wxT("NP Up"); break; - case WXK_NUMPAD_PAGEUP: return wxT("NP Pageup"); break; - case WXK_NUMPAD_MULTIPLY: return wxT("NP *"); break; - case WXK_NUMPAD_ADD: return wxT("NP +"); break; - case WXK_NUMPAD_SUBTRACT: return wxT("NP -"); break; - case WXK_NUMPAD_DIVIDE: return wxT("NP /"); break; - case WXK_NUMPAD_ENTER: return wxT("NP Enter"); break; - case WXK_NUMPAD_SEPARATOR: return wxT("NP Separator"); break; - case WXK_F1: return wxT("F1"); break; - case WXK_F2: return wxT("F2"); break; - case WXK_F3: return wxT("F3"); break; - case WXK_F4: return wxT("F4"); break; - case WXK_F5: return wxT("F5"); break; - case WXK_F6: return wxT("F6"); break; - case WXK_F7: return wxT("F7"); break; - case WXK_F8: return wxT("F8"); break; - case WXK_F9: return wxT("F9"); break; - case WXK_F10: return wxT("F10"); break; - case WXK_F11: return wxT("F11"); break; - case WXK_F12: return wxT("F12"); break; - case WXK_F13: return wxT("F13"); break; - case WXK_F14: return wxT("F14"); break; - case WXK_F15: return wxT("F15"); break; - case WXK_F16: return wxT("F16"); break; - case WXK_F17: return wxT("F17"); break; - case WXK_F18: return wxT("F19"); break; - case WXK_F19: return wxT("F20"); break; - case WXK_F20: return wxT("F21"); break; - case WXK_F21: return wxT("F22"); break; - case WXK_F22: return wxT("F23"); break; - case WXK_F23: return wxT("F24"); break; - case WXK_F24: return wxT("F25"); break; - case WXK_NUMLOCK: return wxT("Numlock"); break; - case WXK_SCROLL: return wxT("Scrolllock"); break; - default: return wxString::FromAscii(keycode); - } -} - -const wxChar *WXKeymodToString(int modifier) -{ - switch (modifier) - { - case wxMOD_ALT: return wxT("Alt"); break; - case wxMOD_CMD: return wxT("Ctrl"); break; - case wxMOD_ALTGR: return wxT("Ctrl+Alt"); break; - case wxMOD_SHIFT: return wxT("Shift"); break; - default: return wxT(""); break; - } -} - -} diff --git a/Source/Core/InputCommon/Src/WXInputBase.h b/Source/Core/InputCommon/Src/WXInputBase.h deleted file mode 100644 index 8c1e74aafc..0000000000 --- a/Source/Core/InputCommon/Src/WXInputBase.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#ifndef WXINPUTBASE_H -#define WXINPUTBASE_H - -#include <wx/wx.h> - -namespace InputCommon -{ -const wxChar *WXKeyToString(int keycode); -const wxChar *WXKeymodToString(int modifier); -} -#endif |
