ref: d8ecb804f3659a04ad4203b4b11fef30b274b9d5
parent: 27b9738390004186f66c2e955fe7ac8c8b296127
author: Simon Howard <fraggle@gmail.com>
date: Thu Jun 21 18:51:47 EDT 2007
Add a joystick dead zone for joysticks that don't have them. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 924
--- 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:
@@ -156,6 +161,11 @@
if (invert)
{
result = -result;
+ }
+
+ if (result < DEAD_ZONE && result > -DEAD_ZONE)
+ {
+ result = 0;
}
return result;