Commit lpfaint99\'s Emulated Wiimote Fix for Linux. Works, haven't tested any extension emulation, but should work

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3927 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2009-08-02 08:53:54 +00:00
parent df5451c7db
commit 8fd481fdfa
8 changed files with 134 additions and 9 deletions

View File

@ -66,7 +66,7 @@ KeyboardWiimote g_Wiimote_kbd;
KeyboardNunchuck g_NunchuckExt;
KeyboardClassicController g_ClassicContExt;
KeyboardGH3GLP g_GH3Ext;
bool KeyStatus[64];
} // namespace
#endif //_EMU_DECLARATIONS_

View File

@ -219,7 +219,7 @@ struct KeyboardWiimote
// Raw X and Y coordinate and processed X and Y coordinates
SIR IR;
};
extern KeyboardWiimote g_Wiimote_kbd;
extern KeyboardWiimote g_Wiimote_kbd;
struct KeyboardNunchuck
{
enum EKeyboardNunchuck
@ -274,11 +274,13 @@ struct KeyboardGH3GLP
Whammy,
Al, Ar, Au, Ad,
StrumUp, StrumDown,
SHAKE
SHAKE,
LAST_CONSTANT
};
};
extern KeyboardGH3GLP g_GH3Ext;
extern bool KeyStatus[64];
} // namespace
#endif //_EMU_DEFINITIONS_

View File

@ -37,7 +37,6 @@ extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu
{
/* Bit shift conversions */
u32 convert24bit(const u8* src) {
return (src[0] << 16) | (src[1] << 8) | src[2];
@ -698,6 +697,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
of times per second. */
void Update()
{
readKeyboard();
//LOG(WII_IPC_WIIMOTE, "Wiimote_Update");
//INFO_LOG(WII_IPC_WIIMOTE, "Emu Update: %i\n", g_ReportingMode);
@ -727,5 +727,115 @@ void Update()
CheckAckDelay();
}
void readKeyboard()
{
#if defined(HAVE_X11) && HAVE_X11
XEvent E;
KeySym key;
// keyboard input
int num_events;
for (num_events = XPending(WMdisplay); num_events > 0; num_events--)
{
XNextEvent(WMdisplay, &E);
switch (E.type)
{
case KeyPress:
{
key = XLookupKeysym((XKeyEvent*)&E, 0);
if((key >= XK_F1 && key <= XK_F9) ||
key == XK_Shift_L || key == XK_Shift_R ||
key == XK_Control_L || key == XK_Control_R) {
XPutBackEvent(WMdisplay, &E);
break;
}
int i;
for (i = g_Wiimote_kbd.A; i < g_Wiimote_kbd.LAST_CONSTANT; i++)
{
if (key == PadMapping[0].Wm.keyForControls[i - g_Wiimote_kbd.A])
KeyStatus[i] = true;
}
switch (g_Config.iExtensionConnected)
{
case EXT_NUNCHUCK:
for (i = g_NunchuckExt.Z; i < g_NunchuckExt.LAST_CONSTANT; i++)
{
if (key == PadMapping[0].Nc.keyForControls[i - g_NunchuckExt.Z])
KeyStatus[i] = true;
}
break;
case EXT_CLASSIC_CONTROLLER:
for (i = g_ClassicContExt.A; i < g_ClassicContExt.LAST_CONSTANT; i++)
{
if (key == PadMapping[0].Cc.keyForControls[i - g_ClassicContExt.A])
KeyStatus[i] = true;
}
break;
case EXT_GUITARHERO3_CONTROLLER:
for (i = g_GH3Ext.Green; i < g_GH3Ext.LAST_CONSTANT; i++)
{
if (key == PadMapping[0].GH3c.keyForControls[i - g_GH3Ext.Green])
KeyStatus[i] = true;
}
break;
default:
break;
}
break;
}
case KeyRelease:
{
key = XLookupKeysym((XKeyEvent*)&E, 0);
if((key >= XK_F1 && key <= XK_F9) ||
key == XK_Shift_L || key == XK_Shift_R ||
key == XK_Control_L || key == XK_Control_R) {
XPutBackEvent(WMdisplay, &E);
break;
}
int i;
for (i = g_Wiimote_kbd.A; i < g_Wiimote_kbd.LAST_CONSTANT; i++)
{
if (key == PadMapping[0].Wm.keyForControls[i - g_Wiimote_kbd.A])
KeyStatus[i] = false;
}
switch (g_Config.iExtensionConnected)
{
case EXT_NUNCHUCK:
for (i = g_NunchuckExt.Z; i < g_NunchuckExt.LAST_CONSTANT; i++)
{
if (key == PadMapping[0].Nc.keyForControls[i - g_NunchuckExt.Z])
KeyStatus[i] = false;
}
break;
case EXT_CLASSIC_CONTROLLER:
for (i = g_ClassicContExt.A; i < g_ClassicContExt.LAST_CONSTANT; i++)
{
if (key == PadMapping[0].Cc.keyForControls[i - g_ClassicContExt.A])
KeyStatus[i] = false;
}
break;
case EXT_GUITARHERO3_CONTROLLER:
for (i = g_GH3Ext.Green; i < g_GH3Ext.LAST_CONSTANT; i++)
{
if (key == PadMapping[0].GH3c.keyForControls[i - g_GH3Ext.Green])
KeyStatus[i] = false;
}
break;
default:
break;
}
break;
}
default:
break;
}
}
#endif
}
} // end of namespace

View File

@ -41,6 +41,7 @@ void Shutdown(void);
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size);
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) ;
void Update();
void readKeyboard();
// Recordings
void LoadRecordedMovements();

View File

@ -43,7 +43,7 @@ namespace WiiMoteEmu
// Fill joyinfo with the current connected devices
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
{
bool Success = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads);
bool WasGotten = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads);
// Warn the user if no gamepads are detected
if (_NumGoodPads == 0 && g_EmulatorRunning)

View File

@ -334,7 +334,7 @@ int IsKey(int Key)
}
#else
return false;
return KeyStatus[Key];
#endif
}

View File

@ -57,6 +57,9 @@ and Wiimote functions worked.
#include "wiimote_real.h"
#endif
#if defined(HAVE_X11) && HAVE_X11
Display* WMdisplay;
#endif
SWiimoteInitialize g_WiimoteInitialize;
PLUGIN_GLOBALS* globals = NULL;
@ -220,6 +223,9 @@ void Initialize(void *init)
if(m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI();
}
#endif
#if defined(HAVE_X11) && HAVE_X11
WMdisplay = (Display*)_WiimoteInitialize.hWnd;
#endif
// Save the ISO Id, again if we had a window open
g_ISOId = g_WiimoteInitialize.ISOId;

View File

@ -22,7 +22,13 @@
#include <vector>
#include "CommonTypes.h"
#if defined(HAVE_X11) && HAVE_X11
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
extern Display* WMdisplay;
#endif
// Definitions and declarations
void DoInitialize();
double GetDoubleTime();