mirror of https://github.com/snes9xgit/snes9x.git
Merge pull request #573 from greg-kennedy/master
Joystick events send a bogus XWarpPointer event to prevent screensaver
This commit is contained in:
commit
855ab4d947
|
@ -166,7 +166,8 @@ static void * S9xProcessSound (void *);
|
||||||
#endif
|
#endif
|
||||||
#ifdef JOYSTICK_SUPPORT
|
#ifdef JOYSTICK_SUPPORT
|
||||||
static void InitJoysticks (void);
|
static void InitJoysticks (void);
|
||||||
static void ReadJoysticks (void);
|
static bool8 ReadJoysticks (void);
|
||||||
|
void S9xLatchJSEvent();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -1205,8 +1206,10 @@ static void InitJoysticks (void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReadJoysticks (void)
|
static bool8 ReadJoysticks (void)
|
||||||
{
|
{
|
||||||
|
// track if ANY joystick event happened this frame
|
||||||
|
int js_latch = FALSE;
|
||||||
#ifdef JSIOCGVERSION
|
#ifdef JSIOCGVERSION
|
||||||
struct js_event js_ev;
|
struct js_event js_ev;
|
||||||
|
|
||||||
|
@ -1220,6 +1223,7 @@ static void ReadJoysticks (void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Joystick %d reconnected.\n",i);
|
fprintf(stderr,"Joystick %d reconnected.\n",i);
|
||||||
js_unplugged[i] = FALSE;
|
js_unplugged[i] = FALSE;
|
||||||
|
js_latch = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1233,12 +1237,14 @@ static void ReadJoysticks (void)
|
||||||
case JS_EVENT_AXIS:
|
case JS_EVENT_AXIS:
|
||||||
S9xReportAxis(0x8000c000 | (i << 24) | js_ev.number, js_ev.value);
|
S9xReportAxis(0x8000c000 | (i << 24) | js_ev.number, js_ev.value);
|
||||||
S9xReportAxis(0x80008000 | (i << 24) | (js_mod[i] << 16) | js_ev.number, js_ev.value);
|
S9xReportAxis(0x80008000 | (i << 24) | (js_mod[i] << 16) | js_ev.number, js_ev.value);
|
||||||
|
js_latch = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JS_EVENT_BUTTON:
|
case JS_EVENT_BUTTON:
|
||||||
case JS_EVENT_BUTTON | JS_EVENT_INIT:
|
case JS_EVENT_BUTTON | JS_EVENT_INIT:
|
||||||
S9xReportButton(0x80004000 | (i << 24) | js_ev.number, js_ev.value);
|
S9xReportButton(0x80004000 | (i << 24) | js_ev.number, js_ev.value);
|
||||||
S9xReportButton(0x80000000 | (i << 24) | (js_mod[i] << 16) | js_ev.number, js_ev.value);
|
S9xReportButton(0x80000000 | (i << 24) | (js_mod[i] << 16) | js_ev.number, js_ev.value);
|
||||||
|
js_latch = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1260,9 +1266,12 @@ static void ReadJoysticks (void)
|
||||||
S9xReportButton(0x80004000 | (i << 24) | j, 0);
|
S9xReportButton(0x80004000 | (i << 24) | j, 0);
|
||||||
S9xReportButton(0x80000000 | (i << 24) | (js_mod[i] << 16) | j, 0);
|
S9xReportButton(0x80000000 | (i << 24) | (js_mod[i] << 16) | j, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
js_latch = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return js_latch;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1766,7 +1775,11 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
#ifdef JOYSTICK_SUPPORT
|
#ifdef JOYSTICK_SUPPORT
|
||||||
if (unixSettings.JoystickEnabled && (JoypadSkip++ & 1) == 0)
|
if (unixSettings.JoystickEnabled && (JoypadSkip++ & 1) == 0)
|
||||||
ReadJoysticks();
|
{
|
||||||
|
if (ReadJoysticks() == TRUE) {
|
||||||
|
S9xLatchJSEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
S9xProcessEvents(FALSE);
|
S9xProcessEvents(FALSE);
|
||||||
|
|
16
unix/x11.cpp
16
unix/x11.cpp
|
@ -100,6 +100,7 @@ struct GUIData
|
||||||
bool8 mod1_pressed;
|
bool8 mod1_pressed;
|
||||||
bool8 no_repeat;
|
bool8 no_repeat;
|
||||||
bool8 fullscreen;
|
bool8 fullscreen;
|
||||||
|
bool8 js_event_latch;
|
||||||
int x_offset;
|
int x_offset;
|
||||||
int y_offset;
|
int y_offset;
|
||||||
#ifdef USE_XVIDEO
|
#ifdef USE_XVIDEO
|
||||||
|
@ -1449,7 +1450,7 @@ static void Repaint (bool8 isFrameBoundry)
|
||||||
if (GUI.use_shared_memory)
|
if (GUI.use_shared_memory)
|
||||||
{
|
{
|
||||||
XShmPutImage(GUI.display, GUI.window, GUI.gc, GUI.image->ximage, 0, 0, GUI.x_offset, GUI.y_offset, SNES_WIDTH * 2, SNES_HEIGHT_EXTENDED * 2, False);
|
XShmPutImage(GUI.display, GUI.window, GUI.gc, GUI.image->ximage, 0, 0, GUI.x_offset, GUI.y_offset, SNES_WIDTH * 2, SNES_HEIGHT_EXTENDED * 2, False);
|
||||||
XSync(GUI.display, False);
|
XSync(GUI.display, False); // Is this double-sync? See XQueryPointer below...
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -1508,8 +1509,21 @@ static bool8 CheckForPendingXEvents (Display *display)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void S9xLatchJSEvent ()
|
||||||
|
{
|
||||||
|
// record that a JS event happened and was reported to the engine
|
||||||
|
GUI.js_event_latch = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void S9xProcessEvents (bool8 block)
|
void S9xProcessEvents (bool8 block)
|
||||||
{
|
{
|
||||||
|
// Kick the screensaver if a joystick event occurred
|
||||||
|
if (GUI.js_event_latch == TRUE) {
|
||||||
|
XWarpPointer(GUI.display, None, None, 0, 0, 0, 0, 0, 0);
|
||||||
|
GUI.js_event_latch = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process all other X events
|
||||||
while (block || CheckForPendingXEvents(GUI.display))
|
while (block || CheckForPendingXEvents(GUI.display))
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
|
Loading…
Reference in New Issue