shithub: choc

Download patch

ref: c37d25a662aaef7d48e6c4a40315c89a632379d9
parent: 7bb82228db4c9f13f706cde47472619d7044ef85
parent: 3004b95a2baec9ee71da13c54db1066dc72252c5
author: Jonathan Dowland <jon+github@alcopop.org>
date: Tue Mar 28 13:21:57 EDT 2017

Merge pull request #900 from jmtd/joystick-hysteresis

move joystick hysteresis to i_video

--- a/src/doom/am_map.c
+++ b/src/doom/am_map.c
@@ -33,6 +33,7 @@
 #include "m_misc.h"
 #include "i_system.h"
 #include "i_timer.h"
+#include "i_video.h"
 
 // Needs access to LFB.
 #include "v_video.h"
@@ -599,7 +600,6 @@
 
     int rc;
     static int bigstate=0;
-    static int joywait = 0;
     static char buffer[20];
     int key;
 
@@ -606,7 +606,7 @@
     rc = false;
 
     if (ev->type == ev_joystick && joybautomap >= 0
-        && (ev->data1 & (1 << joybautomap)) != 0 && joywait < I_GetTime())
+        && (ev->data1 & (1 << joybautomap)) != 0)
     {
         joywait = I_GetTime() + 5;
 
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -1366,7 +1366,6 @@
     int             ch;
     int             key;
     int             i;
-    static  int     joywait = 0;
     static  int     mousewait = 0;
     static  int     mousey = 0;
     static  int     lasty = 0;
@@ -1413,7 +1412,7 @@
     ch = 0;
     key = -1;
 	
-    if (ev->type == ev_joystick && joywait < I_GetTime())
+    if (ev->type == ev_joystick)
     {
         // Simulate key presses from joystick events to interact with the menu.
 
@@ -1453,7 +1452,6 @@
             else if (saveStringEnter)
             {
                 key = KEY_ENTER;
-                // XXX: fire action bleeding into game
             }
             else
             {
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -191,6 +191,9 @@
 
 int usegamma = 0;
 
+// Joystick/gamepad hysteresis
+unsigned int joywait = 0;
+
 static boolean MouseShouldBeGrabbed()
 {
     // never grab the mouse when in screensaver mode
@@ -500,7 +503,10 @@
         I_ReadMouse();
     }
 
-    I_UpdateJoystick();
+    if (joywait < I_GetTime())
+    {
+        I_UpdateJoystick();
+    }
 }
 
 
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -97,4 +97,7 @@
 extern char *window_position;
 void I_GetWindowPosition(int *x, int *y, int w, int h);
 
+// Joystic/gamepad hysteresis
+extern unsigned int joywait;
+
 #endif