mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
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:
@ -427,8 +427,8 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenGL_MakeCurrent()
|
||||
{
|
||||
bool OpenGL_MakeCurrent()
|
||||
{
|
||||
#if USE_SDL
|
||||
// Note: The reason for having the call to SDL_SetVideoMode in here instead
|
||||
// of in OpenGL_Create() is that "make current" is part of the video
|
||||
@ -440,7 +440,7 @@ bool OpenGL_MakeCurrent()
|
||||
|
||||
// Fetch video info.
|
||||
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
|
||||
if (!videoInfo) {
|
||||
if (!videoInfo) {
|
||||
// TODO: Display an error message.
|
||||
SDL_Quit();
|
||||
return false;
|
||||
@ -504,68 +504,70 @@ void OpenGL_Update()
|
||||
nBackbufferWidth = width;
|
||||
nBackbufferHeight = height;
|
||||
|
||||
#else // GLX
|
||||
// We just check all of our events here
|
||||
XEvent event;
|
||||
KeySym key;
|
||||
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) {
|
||||
XNextEvent(GLWin.dpy, &event);
|
||||
switch(event.type)
|
||||
{
|
||||
case KeyRelease:
|
||||
key = XLookupKeysym((XKeyEvent*)&event, 0);
|
||||
if(key >= XK_F1 && key <= XK_F9)
|
||||
{
|
||||
g_VideoInitialize.pKeyPress(FKeyPressed, ShiftPressed, ControlPressed);
|
||||
FKeyPressed = -1;
|
||||
}
|
||||
if(key == XK_Shift_L || key == XK_Shift_L)
|
||||
ShiftPressed = false;
|
||||
if(key == XK_Control_L || key == XK_Control_L)
|
||||
ControlPressed = false;
|
||||
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)
|
||||
ShiftPressed = true;
|
||||
if(key == XK_Control_L || key == XK_Control_L)
|
||||
ControlPressed = true;
|
||||
XPutBackEvent(GLWin.dpy, &event);
|
||||
break;
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
XPutBackEvent(GLWin.dpy, &event);
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
Window winDummy;
|
||||
unsigned int borderDummy;
|
||||
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
|
||||
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
|
||||
nBackbufferWidth = GLWin.width;
|
||||
nBackbufferHeight = GLWin.height;
|
||||
break;
|
||||
case ClientMessage: //TODO: We aren't reading this correctly, It could be anything, highest change is that it's a close event though
|
||||
Video_Shutdown(); // Calling from here since returning false does nothing
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
//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);
|
||||
break;
|
||||
}
|
||||
num_events--;
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
#else // GLX
|
||||
// We just check all of our events here
|
||||
XEvent event;
|
||||
KeySym key;
|
||||
static bool ShiftPressed = false;
|
||||
static bool ControlPressed = false;
|
||||
static int FKeyPressed = -1;
|
||||
int num_events;
|
||||
for (num_events = XPending(GLWin.dpy);num_events > 0;num_events--) {
|
||||
XNextEvent(GLWin.dpy, &event);
|
||||
switch(event.type) {
|
||||
case KeyRelease:
|
||||
key = XLookupKeysym((XKeyEvent*)&event, 0);
|
||||
if(key >= XK_F1 && key <= XK_F9) {
|
||||
g_VideoInitialize.pKeyPress(FKeyPressed, ShiftPressed, ControlPressed);
|
||||
FKeyPressed = -1;
|
||||
} else {
|
||||
if(key == XK_Shift_L || key == XK_Shift_R)
|
||||
ShiftPressed = false;
|
||||
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;
|
||||
else {
|
||||
if(key == XK_Shift_L || key == XK_Shift_R)
|
||||
ShiftPressed = true;
|
||||
else if(key == XK_Control_L || key == XK_Control_R)
|
||||
ControlPressed = true;
|
||||
else
|
||||
XPutBackEvent(GLWin.dpy, &event);
|
||||
}
|
||||
break;
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
XPutBackEvent(GLWin.dpy, &event);
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
Window winDummy;
|
||||
unsigned int borderDummy;
|
||||
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
|
||||
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
|
||||
nBackbufferWidth = GLWin.width;
|
||||
nBackbufferHeight = GLWin.height;
|
||||
break;
|
||||
case ClientMessage: //TODO: We aren't reading this correctly, It could be anything, highest change is that it's a close event though
|
||||
Video_Shutdown(); // Calling from here since returning false does nothing
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
//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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
|
||||
float FactorW = 640.0f / (float)nBackbufferWidth;
|
||||
float FactorH = 480.0f / (float)nBackbufferHeight;
|
||||
|
Reference in New Issue
Block a user