From 1db9de390a331a7d55c35591c93d9e89184cce5f Mon Sep 17 00:00:00 2001 From: eds-collabora <88155680+eds-collabora@users.noreply.github.com> Date: Fri, 21 Jan 2022 07:38:30 +0000 Subject: [PATCH] Fixes for driving mode changes (#866) - Use a float divisor to reduce the high resolution counter to a gray code. This gives a more stable rate of change for the gray code when using a sensitivity other than 1. - Slightly remap the axis space, so that the positive and negative ranges are the same. The new range is [64,-1] [1, 64]. We don't need zero, because of the analog dead zone. - Reorder the Event enum as suggested for on PR860. --- src/emucore/Driving.cxx | 10 +++++----- src/emucore/Event.hxx | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/emucore/Driving.cxx b/src/emucore/Driving.cxx index 2dba825fb..32d94c7f3 100644 --- a/src/emucore/Driving.cxx +++ b/src/emucore/Driving.cxx @@ -124,15 +124,15 @@ void Driving::updateControllerAxes() int a_axis = myEvent.get(myAnalogEvent); if( abs(a_axis) > Controller::analogDeadZone()) { - /* a_axis is in -2^15 to +2^15-1; dividing by 2^9 gives us -2^6 to - +2^6-1, which gives us roughly the same range as digital - inputs. + /* a_axis is in -2^15 to +2^15-1; adding 1 when non-negative and + dividing by 2^9 gives us -2^6 to +2^6, which gives us the same + range as digital inputs. */ - myCounterHires += a_axis/512; + myCounterHires += (a_axis/512) + (a_axis >= 0); } // Only consider the lower-most bits (corresponding to pins 1 & 2) - myGrayIndex = Int32((myCounterHires / 256) * SENSITIVITY) & 0b11; + myGrayIndex = Int32((myCounterHires / 256.0) * SENSITIVITY) & 0b11; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index bbde53729..1b01cf729 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -183,7 +183,7 @@ class Event enum Group { Menu, Emulation, - Misc, AudioVideo, States, Console, Joystick, Paddles, Keyboard, Driving, + Misc, AudioVideo, States, Console, Joystick, Paddles, Driving, Keyboard, Devices, Debug, Combo, LastGroup