A try to fix up input race between glinit and padsimple

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@705 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2008-09-26 11:37:09 +00:00
parent f69166d0c2
commit 7a402985ab
2 changed files with 131 additions and 108 deletions

View File

@ -401,37 +401,53 @@ void XInput_Read(int _numPAD, SPADStatus* _pPADStatus)
void X11_Read(int _numPAD, SPADStatus* _pPADStatus)
{
// Do all the stuff we need to do once per frame here
if (_numPAD != 0)
{
if (_numPAD != 0) {
return;
}
int i;
// This code is from Zerofrog's pcsx2 pad plugin
XEvent E;
//int keyPress=0, keyRelease=0;
KeySym key;
// keyboard input
while (XPending(GXdsp) > 0) {
int num_events;
for (num_events = XPending(GXdsp);num_events > 0;num_events--) {
XNextEvent(GXdsp, &E);
switch (E.type) {
case KeyPress:
//_KeyPress(pad, XLookupKeysym((XKeyEvent *)&E, 0)); break;
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(GXdsp, &E);
break;
}
int i;
for (i = 0; i < NUMCONTROLS; i++) {
if (key == pad[_numPAD].keyForControl[i]) {
KeyStatus[i] = true;
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(GXdsp, &E);
break;
}
//_KeyRelease(pad, XLookupKeysym((XKeyEvent *)&E, 0));
for (i = 0; i < NUMCONTROLS; i++) {
if (key == pad[_numPAD].keyForControl[i]) {
@ -439,8 +455,10 @@ void X11_Read(int _numPAD, SPADStatus* _pPADStatus)
break;
}
}
break;
case FocusIn:
XAutoRepeatOff(GXdsp);
break;
@ -448,6 +466,9 @@ void X11_Read(int _numPAD, SPADStatus* _pPADStatus)
case FocusOut:
XAutoRepeatOn(GXdsp);
break;
default:
break;
}
}

View File

@ -511,33 +511,36 @@ void OpenGL_Update()
static bool ShiftPressed = false;
static bool ControlPressed = false;
static int FKeyPressed = -1;
int num_events = XPending(GLWin.dpy);
while (XPending(GLWin.dpy) > 0 && num_events != 0) {
int num_events;
for (num_events = XPending(GLWin.dpy);num_events > 0;num_events--) {
XNextEvent(GLWin.dpy, &event);
switch(event.type)
{
switch(event.type) {
case KeyRelease:
key = XLookupKeysym((XKeyEvent*)&event, 0);
if(key >= XK_F1 && key <= XK_F9)
{
if(key >= XK_F1 && key <= XK_F9) {
g_VideoInitialize.pKeyPress(FKeyPressed, ShiftPressed, ControlPressed);
FKeyPressed = -1;
}
if(key == XK_Shift_L || key == XK_Shift_L)
} else {
if(key == XK_Shift_L || key == XK_Shift_R)
ShiftPressed = false;
if(key == XK_Control_L || key == XK_Control_L)
else if(key == XK_Control_L || key == XK_Control_R)
ControlPressed = false;
else
XPutBackEvent(GLWin.dpy, &event);
}
break;
case KeyPress:
key = XLookupKeysym((XKeyEvent*)&event, 0);
if(key >= XK_F1 && key <= XK_F9)
FKeyPressed = key - 0xff4e;
if(key == XK_Shift_L || key == XK_Shift_L)
else {
if(key == XK_Shift_L || key == XK_Shift_R)
ShiftPressed = true;
if(key == XK_Control_L || key == XK_Control_L)
else if(key == XK_Control_L || key == XK_Control_R)
ControlPressed = true;
else
XPutBackEvent(GLWin.dpy, &event);
}
break;
case ButtonPress:
case ButtonRelease:
@ -559,10 +562,9 @@ void OpenGL_Update()
//TODO: Should we put the event back if we don't handle it?
// I think we handle all the needed ones, the rest shouldn't matter
// But to be safe, let's but them back anyway
XPutBackEvent(GLWin.dpy, &event);
//XPutBackEvent(GLWin.dpy, &event);
break;
}
num_events--;
}
return;
#endif