diff --git a/Source/Core/InputCommon/Src/SConscript b/Source/Core/InputCommon/Src/SConscript index c5059b3222..13ee418d0d 100644 --- a/Source/Core/InputCommon/Src/SConscript +++ b/Source/Core/InputCommon/Src/SConscript @@ -9,6 +9,11 @@ files = [ 'SDL.cpp', ] +if env['HAVE_X11']: + files += [ + "X11InputBase.cpp", + ] + env_inputcommon = env.Clone() env_inputcommon.Append(CXXFLAGS = [ '-fPIC' ]) env_inputcommon.StaticLibrary(env['local_libs'] + "inputcommon", files) diff --git a/Source/Plugins/Plugin_PadSimple/Src/XInputBase.cpp b/Source/Core/InputCommon/Src/X11InputBase.cpp similarity index 99% rename from Source/Plugins/Plugin_PadSimple/Src/XInputBase.cpp rename to Source/Core/InputCommon/Src/X11InputBase.cpp index bca40e64db..9cd3edb3b1 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/XInputBase.cpp +++ b/Source/Core/InputCommon/Src/X11InputBase.cpp @@ -1,6 +1,7 @@ -#include "XInputBase.h" - +#include "X11InputBase.h" +namespace InputCommon +{ // Taken from wxw source code KeySym wxCharCodeWXToX(int id) { @@ -127,3 +128,4 @@ void XKeyToString(unsigned int keycode, char *keyStr) { sprintf(keyStr, "%c", toupper(keycode)); } } +} \ No newline at end of file diff --git a/Source/Plugins/Plugin_PadSimple/Src/XInputBase.h b/Source/Core/InputCommon/Src/X11InputBase.h similarity index 88% rename from Source/Plugins/Plugin_PadSimple/Src/XInputBase.h rename to Source/Core/InputCommon/Src/X11InputBase.h index 4c3a1c5afa..9176a28dd5 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/XInputBase.h +++ b/Source/Core/InputCommon/Src/X11InputBase.h @@ -5,8 +5,9 @@ #include #include #include - +namespace InputCommon +{ KeySym wxCharCodeWXToX(int id); void XKeyToString(unsigned int keycode, char *keyStr); - +} #endif diff --git a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp index 825e5a5d5e..56de37908d 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp @@ -106,7 +106,7 @@ inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer, #ifdef _WIN32 DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr); #elif defined(HAVE_X11) && HAVE_X11 - XKeyToString(pad[controller].keyForControl[ctl], keyStr); + InputCommon::XKeyToString(pad[controller].keyForControl[ctl], keyStr); #endif // Add the button to its sizer @@ -355,9 +355,9 @@ void PADConfigDialogSimple::OnKeyDown(wxKeyEvent& event) } } #elif defined(HAVE_X11) && HAVE_X11 - pad[page].keyForControl[ClickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode()); + pad[page].keyForControl[ClickedButton->GetId()] = InputCommon::wxCharCodeWXToX(event.GetKeyCode()); - XKeyToString(pad[page].keyForControl[ClickedButton->GetId()], keyStr); + InputCommon::XKeyToString(pad[page].keyForControl[ClickedButton->GetId()], keyStr); ClickedButton->SetLabel(wxString::FromAscii(keyStr)); #endif ClickedButton->Disconnect(); diff --git a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h index 639f9cfb87..1962145359 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h @@ -30,7 +30,7 @@ #include #if defined(HAVE_X11) && HAVE_X11 -#include "../XInputBase.h" +#include "X11InputBase.h" #endif class PADConfigDialogSimple : public wxDialog diff --git a/Source/Plugins/Plugin_PadSimple/Src/SConscript b/Source/Plugins/Plugin_PadSimple/Src/SConscript index 626f33398a..b389364769 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/SConscript +++ b/Source/Plugins/Plugin_PadSimple/Src/SConscript @@ -28,15 +28,10 @@ if padenv['HAVE_WX']: "GUI/ConfigDlg.cpp", ] -if env['HAVE_X11']: - files += [ - "XInputBase.cpp", - ] - if padenv['HAVE_COCOA']: padenv.Append( CXXFLAGS = compileFlags, LIBS = [ 'common' ]) else: - padenv.Append(LIBS = [ 'common' ]) + padenv.Append(LIBS = [ 'common', 'inputcommon' ]) padenv.SharedLibrary(env['plugin_dir']+name, files) diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp index 4b02418fd5..beef72cd78 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp @@ -26,18 +26,6 @@ #include "EmuDefinitions.h" // for PadMapping #include "main.h" -// TODO: Figure out what to do for non-Win32 -#ifndef _WIN32 -#define VK_LEFT 0 -#define VK_RIGHT 0 -#define VK_UP 0 -#define VK_DOWN 0 -#define VK_NUMPAD4 0 -#define VK_NUMPAD6 0 -#define VK_NUMPAD8 0 -#define VK_NUMPAD5 0 -#endif - Config g_Config; Config::Config() diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.h b/Source/Plugins/Plugin_Wiimote/Src/Config.h index 5e03cd8f8e..c5eea84253 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.h +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.h @@ -199,12 +199,15 @@ static int wmDefaultControls[] = VK_LEFT, // Regular directional keys VK_RIGHT, VK_UP, - VK_DOWN, + VK_DOWN, +#else + 0,0,0,0, #endif 83, // WmShake (S) 51, // WmPitchL (3) 52, // WmPitchR (4) }; + static int nCDefaultControls[] = { 90, // NcZ Z @@ -214,6 +217,8 @@ static int nCDefaultControls[] = VK_NUMPAD6, // NcR VK_NUMPAD8, // NcU VK_NUMPAD5, // NcD +#else + 0,0,0,0, #endif 68, // NcShake D }; @@ -236,6 +241,8 @@ static int ccDefaultControls[] = VK_NUMPAD8, // CcDu VK_NUMPAD6, // CcDr VK_NUMPAD5, // CcDd +#else + 0,0,0,0, #endif 0x4a, // CcLl J 0x49, // CcLu I diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp index ec961237af..3b3ae3c1a9 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp @@ -199,6 +199,17 @@ void WiimotePadConfigDialog::UpdateGUIButtonMapping(int controller) m_Button_GH3[x][controller]->SetLabel(wxString::FromAscii( InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].GH3c.keyForControls[x]).c_str())); } +#else + if(g_Config.iExtensionConnected == EXT_GUITARHERO3_CONTROLLER) + { + //TODO: fix this and add for all key settings + for (int x = 0; x < GH3_CONTROLS; x++) + { + char keyStr[10] = {0}; + //InputCommon::XKeyToString(WiiMoteEmu::PadMapping[controller].GH3c.keyForControls[x], keyStr); + m_Button_GH3[x][controller]->SetLabel(wxString::FromAscii(keyStr)); + } + } #endif //INFO_LOG(CONSOLE, "m_bWmA[%i] = %i = %s\n", controller, WiiMoteEmu::PadMapping[controller].Wm.keyForControls[0], InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].Wm.keyForControls[0]).c_str()); diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp index 834bbc49cc..1058a15cb5 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp @@ -142,7 +142,7 @@ void WiimotePadConfigDialog::OnKeyDown(wxKeyEvent& event) g_Pressed = event.GetKeyCode(); // Handle the keyboard key mapping - std::string StrKey; + char keyStr[64] = {0}; if(ClickedButton != NULL) { // Allow the escape key to set a blank key @@ -164,15 +164,17 @@ void WiimotePadConfigDialog::OnKeyDown(wxKeyEvent& event) // Use the left and right specific keys instead of the common ones if (i == VK_SHIFT || i == VK_CONTROL || i == VK_MENU) continue; // Update the button label - char KeyStr[64] = {0}; strcpy(KeyStr, InputCommon::VKToString(i).c_str()); - SetButtonText(ClickedButton->GetId(), KeyStr); + strcpy(keyStr, InputCommon::VKToString(i).c_str()); + SetButtonText(ClickedButton->GetId(), keyStr); // Save the setting SaveKeyboardMapping(Page, ClickedButton->GetId(), i); } } #elif defined(HAVE_X11) && HAVE_X11 - //pad[page].keyForControl[ClickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode()); - //ClickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode())); + g_Pressed = InputCommon::wxCharCodeWXToX(g_Pressed); + InputCommon::XKeyToString(g_Pressed, keyStr); + SetButtonText(ClickedButton->GetId(), keyStr); + SaveKeyboardMapping(Page, ClickedButton->GetId(), g_Pressed); #endif } ClickedButton = NULL; diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h index 5d2c9cff0f..73e60fbf80 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h @@ -31,6 +31,14 @@ #include #include +#if defined(HAVE_X11) && HAVE_X11 + #include + #include + #include + #include + #include "X11InputBase.h" +#endif + #define GH3_CONTROLS 14 class WiimotePadConfigDialog : public wxDialog diff --git a/Source/Plugins/Plugin_Wiimote/Src/SConscript b/Source/Plugins/Plugin_Wiimote/Src/SConscript index 0c599fcb56..99a4ad5c88 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/SConscript +++ b/Source/Plugins/Plugin_Wiimote/Src/SConscript @@ -26,6 +26,10 @@ if wmenv['HAVE_WX']: "ConfigRecording.cpp", "FillReport.cpp", ] +if wmenv['HAVE_X11']: + files += [ + "XInputBase.cpp", + ] libs = [ 'common', 'inputcommon' ]