onepad: use union instead of stange cast

Nicer this way. Beside it removes the strict aliasing issue.
This commit is contained in:
Gregory Hainaut 2014-12-16 22:24:35 +01:00
parent 43e854fece
commit 4f957feacd
1 changed files with 13 additions and 9 deletions

View File

@ -23,7 +23,7 @@
* Theoretically, this header is for anything to do with keyboard input.
* Pragmatically, event handing's going in here too.
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "keyboard.h"
@ -197,7 +197,6 @@ void PollForX11KeyboardInput(int pad)
{
keyEvent evt;
XEvent E;
XButtonEvent* BE;
// Keyboard input send by PCSX2
while (!ev_fifo.empty()) {
@ -211,17 +210,22 @@ void PollForX11KeyboardInput(int pad)
while (XPending(GSdsp) > 0)
{
XNextEvent(GSdsp, &E);
evt.evt = E.type;
evt.key = (int)XLookupKeysym((XKeyEvent *) & E, 0);
// Change the format of the structure to be compatible with GSOpen2
// mode (event come from pcsx2 not X)
BE = (XButtonEvent*)&E;
switch (evt.evt) {
case MotionNotify: evt.key = (BE->x & 0xFFFF) | (BE->y << 16); break;
evt.evt = E.type;
switch (E.type) {
case MotionNotify:
evt.key = (E.xbutton.x & 0xFFFF) | (E.xbutton.y << 16);
break;
case ButtonRelease:
case ButtonPress: evt.key = BE->button; break;
default: break;
case ButtonPress:
evt.key = E.xbutton.button;
break;
default:
evt.key = (int)XLookupKeysym(&E.xkey, 0);
}
AnalyzeKeyEvent(pad, evt);
}
}