mirror of https://github.com/PCSX2/pcsx2.git
onepad: use union instead of stange cast
Nicer this way. Beside it removes the strict aliasing issue.
This commit is contained in:
parent
43e854fece
commit
4f957feacd
|
@ -23,7 +23,7 @@
|
||||||
* Theoretically, this header is for anything to do with keyboard input.
|
* Theoretically, this header is for anything to do with keyboard input.
|
||||||
* Pragmatically, event handing's going in here too.
|
* Pragmatically, event handing's going in here too.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
@ -197,7 +197,6 @@ void PollForX11KeyboardInput(int pad)
|
||||||
{
|
{
|
||||||
keyEvent evt;
|
keyEvent evt;
|
||||||
XEvent E;
|
XEvent E;
|
||||||
XButtonEvent* BE;
|
|
||||||
|
|
||||||
// Keyboard input send by PCSX2
|
// Keyboard input send by PCSX2
|
||||||
while (!ev_fifo.empty()) {
|
while (!ev_fifo.empty()) {
|
||||||
|
@ -211,17 +210,22 @@ void PollForX11KeyboardInput(int pad)
|
||||||
while (XPending(GSdsp) > 0)
|
while (XPending(GSdsp) > 0)
|
||||||
{
|
{
|
||||||
XNextEvent(GSdsp, &E);
|
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
|
// Change the format of the structure to be compatible with GSOpen2
|
||||||
// mode (event come from pcsx2 not X)
|
// mode (event come from pcsx2 not X)
|
||||||
BE = (XButtonEvent*)&E;
|
evt.evt = E.type;
|
||||||
switch (evt.evt) {
|
switch (E.type) {
|
||||||
case MotionNotify: evt.key = (BE->x & 0xFFFF) | (BE->y << 16); break;
|
case MotionNotify:
|
||||||
|
evt.key = (E.xbutton.x & 0xFFFF) | (E.xbutton.y << 16);
|
||||||
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
case ButtonPress: evt.key = BE->button; break;
|
case ButtonPress:
|
||||||
default: break;
|
evt.key = E.xbutton.button;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
evt.key = (int)XLookupKeysym(&E.xkey, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyzeKeyEvent(pad, evt);
|
AnalyzeKeyEvent(pad, evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue