Move XInputBase from PadSimple to InputCommon,

Start work on X11 input for wiimote plugin mapping (copy XTra-KrazzY's fix for PadSimple)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3721 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2009-07-09 06:50:22 +00:00
parent 19ad53ea58
commit 722ee4cd06
12 changed files with 55 additions and 32 deletions

View File

@ -9,6 +9,11 @@ files = [
'SDL.cpp', 'SDL.cpp',
] ]
if env['HAVE_X11']:
files += [
"X11InputBase.cpp",
]
env_inputcommon = env.Clone() env_inputcommon = env.Clone()
env_inputcommon.Append(CXXFLAGS = [ '-fPIC' ]) env_inputcommon.Append(CXXFLAGS = [ '-fPIC' ])
env_inputcommon.StaticLibrary(env['local_libs'] + "inputcommon", files) env_inputcommon.StaticLibrary(env['local_libs'] + "inputcommon", files)

View File

@ -1,6 +1,7 @@
#include "XInputBase.h" #include "X11InputBase.h"
namespace InputCommon
{
// Taken from wxw source code // Taken from wxw source code
KeySym wxCharCodeWXToX(int id) KeySym wxCharCodeWXToX(int id)
{ {
@ -127,3 +128,4 @@ void XKeyToString(unsigned int keycode, char *keyStr) {
sprintf(keyStr, "%c", toupper(keycode)); sprintf(keyStr, "%c", toupper(keycode));
} }
} }
}

View File

@ -5,8 +5,9 @@
#include <X11/X.h> #include <X11/X.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <wx/wx.h> #include <wx/wx.h>
namespace InputCommon
{
KeySym wxCharCodeWXToX(int id); KeySym wxCharCodeWXToX(int id);
void XKeyToString(unsigned int keycode, char *keyStr); void XKeyToString(unsigned int keycode, char *keyStr);
}
#endif #endif

View File

@ -106,7 +106,7 @@ inline void AddControl(wxPanel *pan, wxButton **button, wxStaticBoxSizer *sizer,
#ifdef _WIN32 #ifdef _WIN32
DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr); DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr);
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
XKeyToString(pad[controller].keyForControl[ctl], keyStr); InputCommon::XKeyToString(pad[controller].keyForControl[ctl], keyStr);
#endif #endif
// Add the button to its sizer // Add the button to its sizer
@ -355,9 +355,9 @@ void PADConfigDialogSimple::OnKeyDown(wxKeyEvent& event)
} }
} }
#elif defined(HAVE_X11) && HAVE_X11 #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)); ClickedButton->SetLabel(wxString::FromAscii(keyStr));
#endif #endif
ClickedButton->Disconnect(); ClickedButton->Disconnect();

View File

@ -30,7 +30,7 @@
#include <wx/gbsizer.h> #include <wx/gbsizer.h>
#if defined(HAVE_X11) && HAVE_X11 #if defined(HAVE_X11) && HAVE_X11
#include "../XInputBase.h" #include "X11InputBase.h"
#endif #endif
class PADConfigDialogSimple : public wxDialog class PADConfigDialogSimple : public wxDialog

View File

@ -28,15 +28,10 @@ if padenv['HAVE_WX']:
"GUI/ConfigDlg.cpp", "GUI/ConfigDlg.cpp",
] ]
if env['HAVE_X11']:
files += [
"XInputBase.cpp",
]
if padenv['HAVE_COCOA']: if padenv['HAVE_COCOA']:
padenv.Append( CXXFLAGS = compileFlags, padenv.Append( CXXFLAGS = compileFlags,
LIBS = [ 'common' ]) LIBS = [ 'common' ])
else: else:
padenv.Append(LIBS = [ 'common' ]) padenv.Append(LIBS = [ 'common', 'inputcommon' ])
padenv.SharedLibrary(env['plugin_dir']+name, files) padenv.SharedLibrary(env['plugin_dir']+name, files)

View File

@ -26,18 +26,6 @@
#include "EmuDefinitions.h" // for PadMapping #include "EmuDefinitions.h" // for PadMapping
#include "main.h" #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 g_Config;
Config::Config() Config::Config()

View File

@ -199,12 +199,15 @@ static int wmDefaultControls[] =
VK_LEFT, // Regular directional keys VK_LEFT, // Regular directional keys
VK_RIGHT, VK_RIGHT,
VK_UP, VK_UP,
VK_DOWN, VK_DOWN,
#else
0,0,0,0,
#endif #endif
83, // WmShake (S) 83, // WmShake (S)
51, // WmPitchL (3) 51, // WmPitchL (3)
52, // WmPitchR (4) 52, // WmPitchR (4)
}; };
static int nCDefaultControls[] = static int nCDefaultControls[] =
{ {
90, // NcZ Z 90, // NcZ Z
@ -214,6 +217,8 @@ static int nCDefaultControls[] =
VK_NUMPAD6, // NcR VK_NUMPAD6, // NcR
VK_NUMPAD8, // NcU VK_NUMPAD8, // NcU
VK_NUMPAD5, // NcD VK_NUMPAD5, // NcD
#else
0,0,0,0,
#endif #endif
68, // NcShake D 68, // NcShake D
}; };
@ -236,6 +241,8 @@ static int ccDefaultControls[] =
VK_NUMPAD8, // CcDu VK_NUMPAD8, // CcDu
VK_NUMPAD6, // CcDr VK_NUMPAD6, // CcDr
VK_NUMPAD5, // CcDd VK_NUMPAD5, // CcDd
#else
0,0,0,0,
#endif #endif
0x4a, // CcLl J 0x4a, // CcLl J
0x49, // CcLu I 0x49, // CcLu I

View File

@ -199,6 +199,17 @@ void WiimotePadConfigDialog::UpdateGUIButtonMapping(int controller)
m_Button_GH3[x][controller]->SetLabel(wxString::FromAscii( m_Button_GH3[x][controller]->SetLabel(wxString::FromAscii(
InputCommon::VKToString(WiiMoteEmu::PadMapping[controller].GH3c.keyForControls[x]).c_str())); 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 #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()); //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());

View File

@ -142,7 +142,7 @@ void WiimotePadConfigDialog::OnKeyDown(wxKeyEvent& event)
g_Pressed = event.GetKeyCode(); g_Pressed = event.GetKeyCode();
// Handle the keyboard key mapping // Handle the keyboard key mapping
std::string StrKey; char keyStr[64] = {0};
if(ClickedButton != NULL) if(ClickedButton != NULL)
{ {
// Allow the escape key to set a blank key // 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 // Use the left and right specific keys instead of the common ones
if (i == VK_SHIFT || i == VK_CONTROL || i == VK_MENU) continue; if (i == VK_SHIFT || i == VK_CONTROL || i == VK_MENU) continue;
// Update the button label // Update the button label
char KeyStr[64] = {0}; strcpy(KeyStr, InputCommon::VKToString(i).c_str()); strcpy(keyStr, InputCommon::VKToString(i).c_str());
SetButtonText(ClickedButton->GetId(), KeyStr); SetButtonText(ClickedButton->GetId(), keyStr);
// Save the setting // Save the setting
SaveKeyboardMapping(Page, ClickedButton->GetId(), i); SaveKeyboardMapping(Page, ClickedButton->GetId(), i);
} }
} }
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
//pad[page].keyForControl[ClickedButton->GetId()] = wxCharCodeWXToX(event.GetKeyCode()); g_Pressed = InputCommon::wxCharCodeWXToX(g_Pressed);
//ClickedButton->SetLabel(wxString::Format(_T("%c"), event.GetKeyCode())); InputCommon::XKeyToString(g_Pressed, keyStr);
SetButtonText(ClickedButton->GetId(), keyStr);
SaveKeyboardMapping(Page, ClickedButton->GetId(), g_Pressed);
#endif #endif
} }
ClickedButton = NULL; ClickedButton = NULL;

View File

@ -31,6 +31,14 @@
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/gbsizer.h> #include <wx/gbsizer.h>
#if defined(HAVE_X11) && HAVE_X11
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
#include "X11InputBase.h"
#endif
#define GH3_CONTROLS 14 #define GH3_CONTROLS 14
class WiimotePadConfigDialog : public wxDialog class WiimotePadConfigDialog : public wxDialog

View File

@ -26,6 +26,10 @@ if wmenv['HAVE_WX']:
"ConfigRecording.cpp", "ConfigRecording.cpp",
"FillReport.cpp", "FillReport.cpp",
] ]
if wmenv['HAVE_X11']:
files += [
"XInputBase.cpp",
]
libs = [ 'common', 'inputcommon' ] libs = [ 'common', 'inputcommon' ]