From d8ecb804f3659a04ad4203b4b11fef30b274b9d5 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 21 Jun 2007 22:51:47 +0000 Subject: 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; } -- cgit v1.2.3