summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2007-06-21 22:51:47 +0000
committerSimon Howard2007-06-21 22:51:47 +0000
commitd8ecb804f3659a04ad4203b4b11fef30b274b9d5 (patch)
tree152139b85adb44aa3ae388388dcf46b1d00bac7d /src
parent27b9738390004186f66c2e955fe7ac8c8b296127 (diff)
downloadchocolate-doom-d8ecb804f3659a04ad4203b4b11fef30b274b9d5.tar.gz
chocolate-doom-d8ecb804f3659a04ad4203b4b11fef30b274b9d5.tar.bz2
chocolate-doom-d8ecb804f3659a04ad4203b4b11fef30b274b9d5.zip
Add a joystick dead zone for joysticks that don't have them.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 924
Diffstat (limited to 'src')
-rw-r--r--src/i_joystick.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/i_joystick.c b/src/i_joystick.c
index b6333334..06d3679b 100644
--- a/src/i_joystick.c
+++ b/src/i_joystick.c
@@ -37,6 +37,11 @@
#include "d_main.h"
#include "i_joystick.h"
+// When an axis is within the dead zone, it is set to zero.
+// This is 5% of the full range:
+
+#define DEAD_ZONE (32768 / 20)
+
static SDL_Joystick *joystick = NULL;
// Configuration variables:
@@ -158,6 +163,11 @@ static int GetAxisState(int axis, int invert)
result = -result;
}
+ if (result < DEAD_ZONE && result > -DEAD_ZONE)
+ {
+ result = 0;
+ }
+
return result;
}