diff --git a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp index 14733d3771..f44db49f5b 100644 --- a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp +++ b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp @@ -401,53 +401,74 @@ 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) - { - return; - } - int i; + if (_numPAD != 0) { + return; + } // 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); - - for (i = 0; i < NUMCONTROLS; i++) { - if (key == pad[_numPAD].keyForControl[i]) { - KeyStatus[i] = true; - break; - } - } - break; - - case KeyRelease: - key = XLookupKeysym((XKeyEvent*)&E, 0); - - //_KeyRelease(pad, XLookupKeysym((XKeyEvent *)&E, 0)); - for (i = 0; i < NUMCONTROLS; i++) { - if (key == pad[_numPAD].keyForControl[i]) { - KeyStatus[i] = false; - break; - } - } - break; - - case FocusIn: - XAutoRepeatOff(GXdsp); - break; - - case FocusOut: - XAutoRepeatOn(GXdsp); - break; + 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]) { + KeyStatus[i] = false; + break; + } + } + + break; + + + case FocusIn: + XAutoRepeatOff(GXdsp); + break; + + case FocusOut: + XAutoRepeatOn(GXdsp); + break; + + default: + break; } } @@ -479,7 +500,7 @@ void X11_Read(int _numPAD, SPADStatus* _pPADStatus) _pPADStatus->button |= PAD_BUTTON_B; _pPADStatus->analogB = 255; } - + if (KeyStatus[CTL_X]){_pPADStatus->button |= PAD_BUTTON_X;} if (KeyStatus[CTL_Y]){_pPADStatus->button |= PAD_BUTTON_Y;} if (KeyStatus[CTL_Z]){_pPADStatus->button |= PAD_TRIGGER_Z;} @@ -488,12 +509,12 @@ void X11_Read(int _numPAD, SPADStatus* _pPADStatus) _pPADStatus->button |= PAD_TRIGGER_L; _pPADStatus->triggerLeft = triggervalue; } - + if (KeyStatus[CTL_R]) { _pPADStatus->button |= PAD_TRIGGER_R; _pPADStatus->triggerRight = triggervalue; } - + if (KeyStatus[CTL_START]){_pPADStatus->button |= PAD_BUTTON_START;} } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp index 8fd5885ef1..ee747d3185 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp @@ -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;