summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorSonicadvance1 <sonicadvance1@gmail.com>2009-08-02 08:53:54 +0000
committerSonicadvance1 <sonicadvance1@gmail.com>2009-08-02 08:53:54 +0000
commit8fd481fdfac45b76afc7294eaacf3ac372af190f (patch)
tree83a47077e9494a72ab95548d761fda9e1494b1ab /Source
parentdf5451c7db2cb47cfb48fd1aba3e734df67a2ab0 (diff)
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
Diffstat (limited to 'Source')
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp2
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h6
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp114
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/EmuMain.h1
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp2
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp2
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/main.cpp8
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/main.h8
8 files changed, 134 insertions, 9 deletions
diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp
index 3b487ee223..4a96ccb5da 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp
@@ -66,7 +66,7 @@ KeyboardWiimote g_Wiimote_kbd;
KeyboardNunchuck g_NunchuckExt;
KeyboardClassicController g_ClassicContExt;
KeyboardGH3GLP g_GH3Ext;
-
+bool KeyStatus[64];
} // namespace
#endif //_EMU_DECLARATIONS_
diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h
index 6e63d7c2b9..40c7a43377 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h
+++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h
@@ -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_
diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp
index 77a5809ec3..4a3c542b8a 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp
@@ -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 \ No newline at end of file
+} // end of namespace
diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h
index 07b425cf3e..c3f4c3bec8 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h
+++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h
@@ -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();
diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp
index 22efbe8cfb..49189c6f11 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/EmuPad.cpp
@@ -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)
diff --git a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp
index 02cde4660a..5002ecfa41 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp
@@ -334,7 +334,7 @@ int IsKey(int Key)
}
#else
- return false;
+ return KeyStatus[Key];
#endif
}
diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp
index 61f51631ee..f5d3667b40 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp
@@ -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;
@@ -1045,4 +1051,4 @@ void DoInitialize()
#if HAVE_WIIUSE
if (g_Config.bConnectRealWiimote) WiiMoteReal::Initialize();
#endif
-} \ No newline at end of file
+}
diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.h b/Source/Plugins/Plugin_Wiimote/Src/main.h
index 76bd5d5607..a5bb15b4ba 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/main.h
+++ b/Source/Plugins/Plugin_Wiimote/Src/main.h
@@ -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();