From 173af3a992933231634232b8cf97ea10618b1e3b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 27 Jan 2013 14:30:13 +0900 Subject: [PATCH] Tweak the deadzone code to work better with pre-amp. Everthing was fine with pre-amp == 1, but if it was anything else, the offset would become invalid. --- libs/video/targets/joy.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libs/video/targets/joy.c b/libs/video/targets/joy.c index bdfabc474..81b8809dd 100644 --- a/libs/video/targets/joy.c +++ b/libs/video/targets/joy.c @@ -140,13 +140,11 @@ JOY_Move (void) for (i = 0; i < JOY_MAX_AXES; i++) { ja = &joy_axes[i]; - if (abs (ja->offset) + abs (ja->current) < - abs (ja->offset) + abs (ja->deadzone)) - ja->current = -ja->offset; - - value = - amp * ja->amp * (ja->offset + - ja->current * pre * ja->pre_amp) / 100.0f; + value = ja->current * pre * ja->pre_amp; + if (fabs (value) < ja->deadzone) + value = -ja->offset; + value += ja->offset; + value *= amp * ja->amp / 100.0f; switch (ja->dest) { case js_none: // ignore axis