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:
Soren Jorvang 2010-06-05 19:03:37 +00:00
parent 7d0f03cb61
commit 5c335a8c85
23 changed files with 364 additions and 156 deletions

View File

@ -22,9 +22,11 @@ namespace Common {
PluginWiimote::PluginWiimote(const char *_Filename)
: CPlugin(_Filename), validWiimote(false)
{
Wiimote_ControlChannel = reinterpret_cast<TWiimote_Output>
Wiimote_ControlChannel = reinterpret_cast<TWiimote_ControlChannel>
(LoadSymbol("Wiimote_ControlChannel"));
Wiimote_InterruptChannel = reinterpret_cast<TWiimote_Input>
Wiimote_Input = reinterpret_cast<TWiimote_Input>
(LoadSymbol("Wiimote_Input"));
Wiimote_InterruptChannel = reinterpret_cast<TWiimote_InterruptChannel>
(LoadSymbol("Wiimote_InterruptChannel"));
Wiimote_Update = reinterpret_cast<TWiimote_Update>
(LoadSymbol("Wiimote_Update"));
@ -32,6 +34,7 @@ PluginWiimote::PluginWiimote(const char *_Filename)
(LoadSymbol("Wiimote_GetAttachedControllers"));
if ((Wiimote_ControlChannel != 0) &&
(Wiimote_Input != 0) &&
(Wiimote_InterruptChannel != 0) &&
(Wiimote_Update != 0) &&
(Wiimote_GetAttachedControllers != 0))

View File

@ -25,8 +25,9 @@ namespace Common {
typedef unsigned int (__cdecl* TPAD_GetAttachedPads)();
typedef void (__cdecl* TWiimote_Update)(int _number);
typedef void (__cdecl* TWiimote_Output)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef void (__cdecl* TWiimote_Input)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef void (__cdecl* TWiimote_Input)(u16 _Key, u8 _UpDown);
typedef void (__cdecl* TWiimote_ControlChannel)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef void (__cdecl* TWiimote_InterruptChannel)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef unsigned int (__cdecl* TWiimote_GetAttachedControllers)();
class PluginWiimote : public CPlugin {
@ -35,8 +36,9 @@ public:
virtual ~PluginWiimote();
virtual bool IsValid() {return validWiimote;};
TWiimote_Output Wiimote_ControlChannel;
TWiimote_Input Wiimote_InterruptChannel;
TWiimote_ControlChannel Wiimote_ControlChannel;
TWiimote_Input Wiimote_Input;
TWiimote_InterruptChannel Wiimote_InterruptChannel;
TWiimote_Update Wiimote_Update;
TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers;

View File

@ -79,7 +79,7 @@ const char *Callback_ISOName(void);
void Callback_DSPInterrupt();
void Callback_PADLog(const TCHAR* _szMessage);
void Callback_WiimoteLog(const TCHAR* _szMessage, int _v);
void Callback_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size);
void Callback_WiimoteInterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
bool Callback_RendererHasFocus(void);
// For keyboard shortcuts.
@ -404,7 +404,7 @@ THREAD_RETURN EmuThread(void *pArg)
#endif
WiimoteInitialize.ISOId = Ascii2Hex(_CoreParameter.m_strUniqueID);
WiimoteInitialize.pLog = Callback_WiimoteLog;
WiimoteInitialize.pWiimoteInput = Callback_WiimoteInput;
WiimoteInitialize.pWiimoteInterruptChannel = Callback_WiimoteInterruptChannel;
WiimoteInitialize.pRendererHasFocus = Callback_RendererHasFocus;
// Wait for Wiiuse to find the number of connected Wiimotes
Plugins.GetWiimote(0)->Initialize((void *)&WiimoteInitialize);

View File

@ -906,12 +906,12 @@ namespace Core
{
/* This is called continuously from the Wiimote plugin as soon as it has received
a reporting mode. _Size is the byte size of the report. */
void Callback_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size)
void Callback_WiimoteInterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
{
const u8* pData = (const u8*)_pData;
INFO_LOG(WIIMOTE, "====================");
INFO_LOG(WIIMOTE, "Callback_WiimoteInput: (Wiimote: #%i)", _number);
INFO_LOG(WIIMOTE, "Callback_WiimoteInterruptChannel: (Wiimote: #%i)", _number);
DEBUG_LOG(WIIMOTE, " Data: %s", ArrayToString(pData, _Size, 0, 50).c_str());
DEBUG_LOG(WIIMOTE, " Channel: %u", _channelID);

View File

@ -881,8 +881,9 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
#endif
// Send the keyboard status to the Input plugin
// Send the keyboard status to the Input plugins
CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down
CPluginManager::GetInstance().GetWiimote(0)->Wiimote_Input(event.GetKeyCode(), 1); // 1 = Down
}
else
event.Skip();
@ -892,8 +893,10 @@ void CFrame::OnKeyUp(wxKeyEvent& event)
{
event.Skip();
if(Core::GetState() != Core::CORE_UNINITIALIZED)
if(Core::GetState() != Core::CORE_UNINITIALIZED) {
CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 0); // 0 = Up
CPluginManager::GetInstance().GetWiimote(0)->Wiimote_Input(event.GetKeyCode(), 0); // 0 = Up
}
}
// --------

View File

@ -15,112 +15,137 @@
// 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)
const wxString 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);
}
case WXK_BACK: return wxT("Back");
case WXK_TAB: return wxT("Tab");
case WXK_RETURN: return wxT("Return");
case WXK_ESCAPE: return wxT("Escape");
case WXK_SPACE: return wxT("Space");
case WXK_DELETE: return wxT("Delete");
case WXK_START: return wxT("Start");
case WXK_LBUTTON: return wxT("L Button");
case WXK_RBUTTON: return wxT("R Button");
case WXK_CANCEL: return wxT("Cancel");
case WXK_MBUTTON: return wxT("M Button");
case WXK_CLEAR: return wxT("Clear");
case WXK_SHIFT: return wxT("Shift");
case WXK_ALT: return wxT("Alt");
case WXK_CONTROL: return wxT("Control");
case WXK_MENU: return wxT("Menu");
case WXK_PAUSE: return wxT("Pause");
case WXK_CAPITAL: return wxT("Caps Lock");
case WXK_END: return wxT("End");
case WXK_HOME: return wxT("Home");
case WXK_LEFT: return wxT("Left");
case WXK_UP: return wxT("Up");
case WXK_RIGHT: return wxT("Right");
case WXK_DOWN: return wxT("Down");
case WXK_SELECT: return wxT("Select");
case WXK_PRINT: return wxT("Print");
case WXK_EXECUTE: return wxT("Execute");
case WXK_SNAPSHOT: return wxT("Snapshot");
case WXK_INSERT: return wxT("Insert");
case WXK_HELP: return wxT("Help");
case WXK_NUMPAD0: return wxT("NP 0");
case WXK_NUMPAD1: return wxT("NP 1");
case WXK_NUMPAD2: return wxT("NP 2");
case WXK_NUMPAD3: return wxT("NP 3");
case WXK_NUMPAD4: return wxT("NP 4");
case WXK_NUMPAD5: return wxT("NP 5");
case WXK_NUMPAD6: return wxT("NP 6");
case WXK_NUMPAD7: return wxT("NP 7");
case WXK_NUMPAD8: return wxT("NP 8");
case WXK_NUMPAD9: return wxT("NP 9");
case WXK_MULTIPLY: return wxT("Multiply");
case WXK_ADD: return wxT("Add");
case WXK_SEPARATOR: return wxT("Separator");
case WXK_SUBTRACT: return wxT("Subtract");
case WXK_DECIMAL: return wxT("Decimal");
case WXK_DIVIDE: return wxT("Divide");
case WXK_F1: return wxT("F1");
case WXK_F2: return wxT("F2");
case WXK_F3: return wxT("F3");
case WXK_F4: return wxT("F4");
case WXK_F5: return wxT("F5");
case WXK_F6: return wxT("F6");
case WXK_F7: return wxT("F7");
case WXK_F8: return wxT("F8");
case WXK_F9: return wxT("F9");
case WXK_F10: return wxT("F10");
case WXK_F11: return wxT("F11");
case WXK_F12: return wxT("F12");
case WXK_F13: return wxT("F13");
case WXK_F14: return wxT("F14");
case WXK_F15: return wxT("F15");
case WXK_F16: return wxT("F16");
case WXK_F17: return wxT("F17");
case WXK_F18: return wxT("F19");
case WXK_F19: return wxT("F20");
case WXK_F20: return wxT("F21");
case WXK_F21: return wxT("F22");
case WXK_F22: return wxT("F23");
case WXK_F23: return wxT("F24");
case WXK_F24: return wxT("F25");
case WXK_NUMLOCK: return wxT("Num Lock");
case WXK_SCROLL: return wxT("Scroll Lock");
case WXK_PAGEUP: return wxT("Page Up");
case WXK_PAGEDOWN: return wxT("Page Down");
case WXK_NUMPAD_SPACE: return wxT("NP Space");
case WXK_NUMPAD_TAB: return wxT("NP Tab");
case WXK_NUMPAD_ENTER: return wxT("NP Enter");
case WXK_NUMPAD_F1: return wxT("NP F1");
case WXK_NUMPAD_F2: return wxT("NP F2");
case WXK_NUMPAD_F3: return wxT("NP F3");
case WXK_NUMPAD_F4: return wxT("NP F4");
case WXK_NUMPAD_HOME: return wxT("NP Home");
case WXK_NUMPAD_LEFT: return wxT("NP Left");
case WXK_NUMPAD_UP: return wxT("NP Up");
case WXK_NUMPAD_RIGHT: return wxT("NP Right");
case WXK_NUMPAD_DOWN: return wxT("NP Down");
case WXK_NUMPAD_PAGEUP: return wxT("NP Page Up");
case WXK_NUMPAD_PAGEDOWN: return wxT("NP Page Down");
case WXK_NUMPAD_END: return wxT("NP End");
case WXK_NUMPAD_BEGIN: return wxT("NP Begin");
case WXK_NUMPAD_INSERT: return wxT("NP Insert");
case WXK_NUMPAD_DELETE: return wxT("NP Delete");
case WXK_NUMPAD_EQUAL: return wxT("NP Equal");
case WXK_NUMPAD_MULTIPLY: return wxT("NP Multiply");
case WXK_NUMPAD_ADD: return wxT("NP Add");
case WXK_NUMPAD_SEPARATOR: return wxT("NP Separator");
case WXK_NUMPAD_SUBTRACT: return wxT("NP Subtract");
case WXK_NUMPAD_DECIMAL: return wxT("NP Decimal");
case WXK_NUMPAD_DIVIDE: return wxT("NP Divide");
case WXK_WINDOWS_LEFT: return wxT("Windows Left");
case WXK_WINDOWS_RIGHT: return wxT("Windows Right");
case WXK_WINDOWS_MENU: return wxT("Windows Menu");
case WXK_COMMAND: return wxT("Command");
}
const wxChar *WXKeymodToString(int modifier)
if (keycode > WXK_SPACE && keycode < WXK_DELETE) {
return wxString((wxChar)keycode, 1);
}
return wxT("");
}
const wxString 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;
case wxMOD_ALT: return wxT("Alt");
case wxMOD_CMD: return wxT("Ctrl");
case wxMOD_ALTGR: return wxT("Ctrl+Alt");
case wxMOD_SHIFT: return wxT("Shift");
default: return wxT("");
}
}

View File

@ -22,7 +22,7 @@
namespace InputCommon
{
const wxChar *WXKeyToString(int keycode);
const wxChar *WXKeymodToString(int modifier);
const wxString WXKeyToString(int keycode);
const wxString WXKeymodToString(int modifier);
}
#endif

View File

@ -17,7 +17,7 @@ typedef void (*TLogv)(const char* _pMessage, int _v);
// This is called when the Wiimote sends input reports to the Core.
// Payload: an L2CAP packet.
typedef void (*TWiimoteInput)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef void (*TWiimoteInterruptChannel)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef bool (*TRendererHasFocus)(void);
// This data is passed from the core on initialization.
@ -29,7 +29,7 @@ typedef struct
#endif
u32 ISOId;
TLogv pLog;
TWiimoteInput pWiimoteInput;
TWiimoteInterruptChannel pWiimoteInterruptChannel;
TRendererHasFocus pRendererHasFocus;
} SWiimoteInitialize;
@ -47,7 +47,15 @@ typedef struct
EXPORT void CALL Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
// __________________________________________________________________________________________________
// Function: Wiimote_Input
// Function: Send keyboard input to the plugin
// Purpose:
// input: The key and if it's pressed or released
// output: None
//
EXPORT void CALL Wiimote_Input(u16 _Key, u8 _UpDown);
// __________________________________________________________________________________________________
// Function: Wiimote_InterruptChannel
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
// on the HID INTERRUPT channel.
// input: Da pakket.

View File

@ -34,6 +34,7 @@
#include "Config.h"
#include "GCPad.h"
#include "FileUtil.h"
#include "WXInputBase.h"
static const char* gcControlNames[] =
{
@ -122,34 +123,32 @@ static const int gcDefaultControls[] =
0x00, // L semi-press
0x00, // R semi-press
};
#elif defined(__APPLE__)
// Reference for Cocoa key codes:
// http://boredzo.org/blog/archives/2007-05-22/virtual-key-codes
#else defined(USE_WX) && USE_WX
{
7, // A (x)
6, // B (z)
8, // X (c)
1, // Y (s)
2, // Z (d)
36, // Start (return)
17, // D-pad up (t)
5, // D-pad down (g)
3, // D-pad left (f)
4, // D-pad right (h)
126, // Main stick up (up)
125, // Main stick down (down)
123, // Main stick left (left)
124, // Main stick right (right)
56, // Main stick semi (left shift)
34, // C-stick up (i)
40, // C-stick down (k)
38, // C-stick left (j)
37, // C-stick right (l)
59, // C-stick semi (left control)
12, // L (q)
13, // R (w)
-1, // L semi-press (none)
-1, // R semi-press (none)
'X', // A
'Z', // B
'C', // X
'S', // Y
'D', // Z
WXK_RETURN, // Start
'T', // D-pad up
'G', // D-pad down
'F', // D-pad left
'H', // D-pad right
WXK_UP, // Main stick up
WXK_DOWN, // Main stick down
WXK_LEFT, // Main stick left
WXK_RIGHT, // Main stick right
WXK_SHIFT, // Main stick semi
'I', // C-stick up
'K', // C-stick down
'J', // C-stick left
'L', // C-stick right
WXK_CONTROL, // C-stick semi
'Q', // L
'W', // R
0, // L semi-press
0, // R semi-press
};
#endif

View File

@ -28,6 +28,7 @@
#include "math.h" // System
#include "WXInputBase.h"
#include "ConfigBox.h"
#include "Config.h"
#include "GCPad.h"
@ -239,6 +240,10 @@ void GCPadConfigDialog::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();
@ -394,6 +399,13 @@ void GCPadConfigDialog::UpdateGUI()
InputCommon::XKeyToString(GCMapping[m_Page].Button[x + EGC_A], keyStr);
m_Button_GC[x][m_Page]->SetLabel(wxString::FromAscii(keyStr));
}
#elif defined(USE_WX) && USE_WX
for (int x = 0; x <= IDB_SHDR_SEMI_R - IDB_BTN_A; x++)
{
m_Button_GC[x][m_Page]-> \
SetLabel(InputCommon::WXKeyToString(
GCMapping[m_Page].Button[x + EGC_A]));
}
#endif
DoChangeDeadZone();

View File

@ -243,10 +243,19 @@ void EmuStateChange(PLUGIN_EMUSTATE 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 PAD_Input(u16 _Key, u8 _UpDown)
{
#if defined(__APPLE__) && defined(USE_WX) && USE_WX
if (_Key < 256)
{
wxkeystate[_Key] = _UpDown;
}
#endif
}
// Set PAD status
@ -624,6 +633,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
@ -647,5 +661,8 @@ bool IsKey(int Key)
// ----------------
bool IsFocus()
{
#if defined(__APPLE__) && defined(USE_WX) && USE_WX
return true; /* XXX */
#endif
return g_PADInitialize->pRendererHasFocus();
}

View File

@ -42,9 +42,6 @@
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
//no need for Cocoa yet, but I guess ayuanx isn't done yet.
//#elif defined(__APPLE__)
// #include <Cocoa/Cocoa.h>
#endif
#include "pluginspecs_pad.h"

View File

@ -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

View File

@ -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();

View File

@ -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);

View File

@ -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!");
}

View File

@ -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);

View File

@ -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

View File

@ -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();
}

View File

@ -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);

View File

@ -195,7 +195,7 @@ void Wiimote::SendAck(const u16 _channelID, u8 _reportID)
ack->reportID = _reportID;
ack->errorID = 0;
g_WiimoteInitialize.pWiimoteInput( m_index, _channelID, data, sizeof(data));
g_WiimoteInitialize.pWiimoteInterruptChannel( m_index, _channelID, data, sizeof(data));
}
// old comment
@ -234,7 +234,7 @@ void Wiimote::RequestStatus(const u16 _channelID, wm_request_status* rs)
*(wm_status_report*)(data + 2) = m_status;
// send report
g_WiimoteInitialize.pWiimoteInput(m_index, _channelID, data, sizeof(data));
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, _channelID, data, sizeof(data));
}
/* Write data to Wiimote and Extensions registers. */
@ -487,7 +487,7 @@ void Wiimote::SendReadDataReply(const u16 _channelID, ReadRequest& _request)
}
// Send a piece
g_WiimoteInitialize.pWiimoteInput(m_index, _channelID, data, sizeof(data));
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, _channelID, data, sizeof(data));
}
void Wiimote::DoState(PointerWrap& p)

View File

@ -589,7 +589,7 @@ void Wiimote::Update()
}
}
// send data report
g_WiimoteInitialize.pWiimoteInput( m_index, m_reporting_channel, data, rpt.size );
g_WiimoteInitialize.pWiimoteInterruptChannel( m_index, m_reporting_channel, data, rpt.size );
}
void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size)
@ -628,7 +628,7 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size
HidOutputReport(_channelID, (wm_report*)hidp->data);
u8 handshake = HID_HANDSHAKE_SUCCESS;
g_WiimoteInitialize.pWiimoteInput(m_index, _channelID, &handshake, 1);
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, _channelID, &handshake, 1);
PanicAlert("HID_TYPE_DATA - OUTPUT: Ambiguous Control Channel Report!");
}

View File

@ -144,7 +144,18 @@ void Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32
}
// __________________________________________________________________________________________________
// Function: Wiimote_Input
// Function: Send keyboard input to the plugin
// Purpose:
// input: The key and if it's pressed or released
// output: None
//
void Wiimote_Input(u16 _Key, u8 _UpDown)
{
return;
}
// __________________________________________________________________________________________________
// Function: Wiimote_InterruptChannel
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
// on the HID INTERRUPT channel.
// input: Da pakket.