mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Fixed WXKeyToString which had several problems, mostly just to get
hotkey configuration working with wx 2.9, but it turned out to be too tempting to use it to hack up OS X keyboard support using wx key events in the "old" input plugins. It was with some reluctance that I used PAD_Input (and copied it for Wiimote as well) as that is clearly a deprecated interface, but this way the hack is contained within the old plugins for when the switchover to ControllerInterface happens. The idea is to provide stable keyboard support on OS X for both GCPad and Wiimote while we debug HID keyboard and real 'mote code. It works pretty well, although the wx approach does impose a few limitations like no arrow keys and left/right side modifier keys are considered equivalent. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5622 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -26,6 +26,7 @@
|
||||
#include "EmuDefinitions.h" // for PadMapping
|
||||
#include "main.h"
|
||||
#include "FileUtil.h"
|
||||
#include "WXInputBase.h"
|
||||
|
||||
// Configuration file control names
|
||||
// Do not change the order unless you change the related arrays
|
||||
@ -139,6 +140,23 @@ static int wmDefaultControls[] =
|
||||
XK_comma,
|
||||
XK_period,
|
||||
XK_slash,
|
||||
#elif defined(USE_WX) && USE_WX
|
||||
'Z',
|
||||
'X',
|
||||
'C',
|
||||
'V',
|
||||
'P',
|
||||
'O',
|
||||
WXK_BACK,
|
||||
WXK_LEFT,
|
||||
WXK_RIGHT,
|
||||
WXK_UP,
|
||||
WXK_DOWN,
|
||||
'N',
|
||||
'M',
|
||||
WXK_SEPARATOR,
|
||||
WXK_DECIMAL,
|
||||
WXK_DIVIDE,
|
||||
#else
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
#endif
|
||||
@ -168,6 +186,18 @@ static int wmDefaultControls[] =
|
||||
XK_KP_1,
|
||||
XK_KP_3,
|
||||
XK_KP_2,
|
||||
#elif defined(USE_WX) && USE_WX
|
||||
WXK_NUMPAD0,
|
||||
WXK_NUMPAD_DECIMAL,
|
||||
WXK_NUMPAD4,
|
||||
WXK_NUMPAD6,
|
||||
WXK_NUMPAD8,
|
||||
WXK_NUMPAD5,
|
||||
WXK_NUMPAD7,
|
||||
WXK_NUMPAD9,
|
||||
WXK_NUMPAD1,
|
||||
WXK_NUMPAD3,
|
||||
WXK_NUMPAD2,
|
||||
#else
|
||||
0,0,0,0,0,0,0,0,0,0,0,
|
||||
#endif
|
||||
@ -184,6 +214,11 @@ static int wmDefaultControls[] =
|
||||
XK_bracketright,
|
||||
XK_semicolon,
|
||||
XK_quoteright,
|
||||
#elif defined(USE_WX) && USE_WX
|
||||
'O',
|
||||
'P',
|
||||
'K',
|
||||
'L',
|
||||
#else
|
||||
0,0,0,0,
|
||||
#endif
|
||||
@ -207,6 +242,11 @@ static int wmDefaultControls[] =
|
||||
XK_KP_6,
|
||||
XK_KP_8,
|
||||
XK_KP_5,
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
WXK_NUMPAD4,
|
||||
WXK_NUMPAD6,
|
||||
WXK_NUMPAD8,
|
||||
WXK_NUMPAD5,
|
||||
#else
|
||||
0,0,0,0,
|
||||
#endif
|
||||
@ -240,6 +280,11 @@ static int wmDefaultControls[] =
|
||||
XK_KP_6,
|
||||
XK_KP_8,
|
||||
XK_KP_5,
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
WXK_NUMPAD4,
|
||||
WXK_NUMPAD6,
|
||||
WXK_NUMPAD8,
|
||||
WXK_NUMPAD5,
|
||||
#else
|
||||
0,0,0,0,
|
||||
#endif
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "wiimote_real.h" // for MAX_WIIMOTES
|
||||
#include "wiimote_hid.h"
|
||||
#include "main.h"
|
||||
#include "WXInputBase.h"
|
||||
#include "ConfigPadDlg.h"
|
||||
#include "ConfigBasicDlg.h"
|
||||
#include "Config.h"
|
||||
@ -241,6 +242,10 @@ void WiimotePadConfigDialog::OnKeyDown(wxKeyEvent& event)
|
||||
SetButtonText(ClickedButton->GetId(),
|
||||
wxString::FromAscii(keyStr));
|
||||
SaveButtonMapping(ClickedButton->GetId(), XKey);
|
||||
#elif defined(USE_WX) && USE_WX
|
||||
SetButtonText(ClickedButton->GetId(),
|
||||
InputCommon::WXKeyToString(g_Pressed));
|
||||
SaveButtonMapping(ClickedButton->GetId(), g_Pressed);
|
||||
#endif
|
||||
}
|
||||
EndGetButtons();
|
||||
@ -1133,6 +1138,61 @@ void WiimotePadConfigDialog::UpdateGUI()
|
||||
m_Button_GH3[x][m_Page]->SetLabel(wxString::FromAscii(keyStr));
|
||||
}
|
||||
}
|
||||
#elif defined(USE_WX) && USE_WX
|
||||
for (int x = 0; x <= IDB_WM_SHAKE - IDB_WM_A; x++)
|
||||
{
|
||||
m_Button_Wiimote[x][m_Page]-> \
|
||||
SetLabel(InputCommon::WXKeyToString(
|
||||
WiiMoteEmu::WiiMapping[m_Page]. \
|
||||
Button[x + WiiMoteEmu::EWM_A]));
|
||||
}
|
||||
if (WiiMoteEmu::WiiMapping[m_Page].iExtensionConnected ==
|
||||
WiiMoteEmu::EXT_NUNCHUK)
|
||||
{
|
||||
m_NunchuckComboStick[m_Page]-> \
|
||||
SetSelection(WiiMoteEmu::WiiMapping[m_Page].Stick.NC);
|
||||
|
||||
for (int x = 0; x <= IDB_NC_SHAKE - IDB_NC_Z; x++)
|
||||
{
|
||||
m_Button_NunChuck[x][m_Page]-> \
|
||||
SetLabel(InputCommon::WXKeyToString(
|
||||
WiiMoteEmu::WiiMapping[m_Page]. \
|
||||
Button[x + WiiMoteEmu::ENC_Z]));
|
||||
}
|
||||
}
|
||||
else if (WiiMoteEmu::WiiMapping[m_Page].iExtensionConnected ==
|
||||
WiiMoteEmu::EXT_CLASSIC_CONTROLLER)
|
||||
{
|
||||
m_CcComboLeftStick[m_Page]-> \
|
||||
SetSelection(WiiMoteEmu::WiiMapping[m_Page].Stick.CCL);
|
||||
m_CcComboRightStick[m_Page]-> \
|
||||
SetSelection(WiiMoteEmu::WiiMapping[m_Page].Stick.CCR);
|
||||
m_CcComboTriggers[m_Page]-> \
|
||||
SetSelection(WiiMoteEmu::WiiMapping[m_Page].Stick.CCT);
|
||||
|
||||
for (int x = 0; x <= IDB_CC_RD - IDB_CC_A; x++)
|
||||
{
|
||||
m_Button_Classic[x][m_Page]-> \
|
||||
SetLabel(InputCommon::WXKeyToString(
|
||||
WiiMoteEmu::WiiMapping[m_Page]. \
|
||||
Button[x + WiiMoteEmu::ECC_A]));
|
||||
}
|
||||
}
|
||||
|
||||
else if(WiiMoteEmu::WiiMapping[m_Page].iExtensionConnected ==
|
||||
WiiMoteEmu::EXT_GUITARHERO)
|
||||
{
|
||||
m_GH3ComboAnalog[m_Page]-> \
|
||||
SetSelection(WiiMoteEmu::WiiMapping[m_Page].Stick.GH);
|
||||
|
||||
for (int x = 0; x <= IDB_GH3_STRUM_DOWN - IDB_GH3_GREEN; x++)
|
||||
{
|
||||
m_Button_GH3[x][m_Page]-> \
|
||||
SetLabel(InputCommon::WXKeyToString(
|
||||
WiiMoteEmu::WiiMapping[m_Page]. \
|
||||
Button[x + WiiMoteEmu::EGH_Green]));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
DoChangeDeadZone();
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
The Data Report's path from here is
|
||||
WII_IPC_HLE_WiiMote.cpp:
|
||||
Callback_WiimoteInput()
|
||||
Callback_WiimoteInterruptChannel()
|
||||
CWII_IPC_HLE_WiiMote::SendL2capData()
|
||||
WII_IPC_HLE_Device_usb.cpp:
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLPacket()
|
||||
@ -116,7 +116,7 @@ void SendReportCore(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(g_ID, _channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
@ -141,7 +141,7 @@ void SendReportCoreAccel(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(g_ID, _channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
@ -170,7 +170,7 @@ void SendReportCoreAccelIr12(u16 _channelID) {
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(g_ID, _channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
@ -215,7 +215,7 @@ void SendReportCoreAccelExt16(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(g_ID, _channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
@ -290,7 +290,7 @@ void SendReportCoreAccelIr10Ext(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Channel: %04x", _channelID);
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(g_ID, _channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
|
@ -677,7 +677,7 @@ void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
HidOutputReport(_channelID, (wm_report*)hidp->data);
|
||||
|
||||
u8 handshake = HID_HANDSHAKE_SUCCESS;
|
||||
g_WiimoteInitialize.pWiimoteInput(g_ID, _channelID, &handshake, 1);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, &handshake, 1);
|
||||
|
||||
PanicAlert("HID_TYPE_DATA - OUTPUT: Ambiguous Control Channel Report!");
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ void WmSendAck(u16 _channelID, u8 _reportID)
|
||||
DEBUG_LOG(WIIMOTE, "WMSendAck");
|
||||
DEBUG_LOG(WIIMOTE, " Report ID: %02x", _reportID);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(g_ID, _channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
@ -363,7 +363,7 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _AddressHI,
|
||||
#endif
|
||||
|
||||
// Send a piece
|
||||
g_WiimoteInitialize.pWiimoteInput(g_ID, _channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Update the size that is left
|
||||
_Size -= copySize;
|
||||
@ -541,7 +541,7 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
|
||||
DEBUG_LOG(WIIMOTE, " LEDs: %x", pStatus->leds);
|
||||
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(g_ID, _channelID, DataFrame, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
|
@ -34,6 +34,9 @@
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
// Hack to use wx key events
|
||||
extern volatile bool wxkeystate[256];
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
@ -319,6 +322,11 @@ bool IsKey(int Key)
|
||||
Ret = (keys[keyCode/8] & (1 << (keyCode%8))); // Keyboard (Linux)
|
||||
}
|
||||
else if (MapKey < 0x1100)
|
||||
#elif defined (USE_WX) && USE_WX
|
||||
if (MapKey < 256) {
|
||||
Ret = wxkeystate[MapKey];
|
||||
}
|
||||
else if (MapKey < 0x1100)
|
||||
#else
|
||||
if (MapKey < 0x1100)
|
||||
#endif
|
||||
|
@ -294,6 +294,21 @@ void EmuStateChange(PLUGIN_EMUSTATE newState)
|
||||
g_EmulatorState = newState;
|
||||
}
|
||||
|
||||
// Hack to use wx key events
|
||||
volatile bool wxkeystate[256];
|
||||
|
||||
// Set buttons status from keyboard input. Currently this is done from
|
||||
// wxWidgets in the main application.
|
||||
// --------------
|
||||
void Wiimote_Input(u16 _Key, u8 _UpDown)
|
||||
{
|
||||
#if defined(__APPLE__) && defined(USE_WX) && USE_WX
|
||||
if (_Key < 256)
|
||||
{
|
||||
wxkeystate[_Key] = _UpDown;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This function produce Wiimote Input (reports from the Wiimote) in response
|
||||
to Output from the Wii. It's called from WII_IPC_HLE_WiiMote.cpp.
|
||||
@ -415,6 +430,9 @@ unsigned int Wiimote_GetAttachedControllers()
|
||||
|
||||
bool IsFocus()
|
||||
{
|
||||
#if defined(__APPLE__) && defined(USE_WX) && USE_WX
|
||||
return true; /* XXX */
|
||||
#endif
|
||||
return g_WiimoteInitialize.pRendererHasFocus();
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ void SendEvent(SEvent& _rEvent)
|
||||
Offset += sizeof(_rEvent.m_PayLoad);
|
||||
|
||||
// Send it
|
||||
g_WiimoteInitialize.pWiimoteInput(m_WiimoteNumber, m_channelID, Buffer, Offset);
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(m_WiimoteNumber, m_channelID, Buffer, Offset);
|
||||
|
||||
// Debugging
|
||||
// ReadDebugging(false, Buffer, Offset);
|
||||
|
Reference in New Issue
Block a user