commit d8ecb804f3659a04ad4203b4b11fef30b274b9d5
Author: Simon Howard <fraggle@gmail.com>
AuthorDate: Thu Jun 21 22:51:47 2007 +0000
Commit: Simon Howard <fraggle@gmail.com>
CommitDate: Thu Jun 21 22:51:47 2007 +0000
Add a joystick dead zone for joysticks that don't have them.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 924
---
src/i_joystick.c | 10 ++++++++++
1 file changed, 10 insertions(+)
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;
}