diff options
author | 2023-02-24 19:31:12 +1100 | |
---|---|---|
committer | 2023-02-24 19:31:12 +1100 | |
commit | 65aeb63a2a1f4f65a6fa0dedabba1b852a189f96 (patch) | |
tree | 42a56bcf4d22b624dbb117946e376981e691a5f0 /src/osd/modules/input/input_xinput.cpp | |
parent | 3b5dbeea3bad50ad04c966de4afffb864a9856d0 (diff) |
Update accumulating relative inputs exactly once per frame.
This fixes "amplification" effects that would happen if the frame rate
rose above 100 Hz (whether by unthrottling or otherwise).
Synchronise with wall clock any time inputs are read. Not doing this
has weird effects on relative inputs with frame skipping and contributes
to unresponsiveness of menus.
Reduce visual latency for mouse movement on menus when paused or
skipping frames. The rest of the code changes to menus won't provide
benefits until draw can happen after event handling.
Diffstat (limited to 'src/osd/modules/input/input_xinput.cpp')
-rw-r--r-- | src/osd/modules/input/input_xinput.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/osd/modules/input/input_xinput.cpp b/src/osd/modules/input/input_xinput.cpp index 783dc720994..ec3f956b909 100644 --- a/src/osd/modules/input/input_xinput.cpp +++ b/src/osd/modules/input/input_xinput.cpp @@ -713,7 +713,7 @@ public: XINPUT_CAPABILITIES const &caps, xinput_api_helper const &helper); - virtual void poll() override; + virtual void poll(bool relative_reset) override; virtual void reset() override; virtual void configure(input_device &device) override; @@ -805,7 +805,7 @@ xinput_joystick_device::xinput_joystick_device( } -void xinput_joystick_device::poll() +void xinput_joystick_device::poll(bool relative_reset) { // poll the device first, and skip if nothing changed if (!read_state()) @@ -1255,7 +1255,7 @@ public: XINPUT_CAPABILITIES const &caps, xinput_api_helper const &helper); - virtual void poll() override; + virtual void poll(bool relative_reset) override; virtual void reset() override; virtual void configure(input_device &device) override; @@ -1335,7 +1335,7 @@ xinput_flight_stick_device::xinput_flight_stick_device( } -void xinput_flight_stick_device::poll() +void xinput_flight_stick_device::poll(bool relative_reset) { // poll the device first, and skip if nothing changed if (!read_state()) @@ -1717,7 +1717,7 @@ public: XINPUT_CAPABILITIES const &caps, xinput_api_helper const &helper); - virtual void poll() override; + virtual void poll(bool relative_reset) override; virtual void reset() override; virtual void configure(input_device &device) override; @@ -1796,7 +1796,7 @@ xinput_guitar_device::xinput_guitar_device( } -void xinput_guitar_device::poll() +void xinput_guitar_device::poll(bool relative_reset) { // poll the device first, and skip if nothing changed if (!read_state()) @@ -2002,7 +2002,7 @@ public: XINPUT_CAPABILITIES const &caps, xinput_api_helper const &helper); - virtual void poll() override; + virtual void poll(bool relative_reset) override; virtual void reset() override; virtual void configure(input_device &device) override; @@ -2078,7 +2078,7 @@ xinput_drumkit_device::xinput_drumkit_device( } -void xinput_drumkit_device::poll() +void xinput_drumkit_device::poll(bool relative_reset) { // poll the device first, and skip if nothing changed if (!read_state()) @@ -2258,7 +2258,7 @@ public: XINPUT_CAPABILITIES const &caps, xinput_api_helper const &helper); - virtual void poll() override; + virtual void poll(bool relative_reset) override; virtual void reset() override; virtual void configure(input_device &device) override; @@ -2337,7 +2337,7 @@ xinput_turntable_device::xinput_turntable_device( } -void xinput_turntable_device::poll() +void xinput_turntable_device::poll(bool relative_reset) { // poll the device first bool const was_reset = is_reset(); @@ -2355,17 +2355,23 @@ void xinput_turntable_device::poll() m_axes[AXIS_TURNTABLE] = s32(thumb_left_y()) * input_device::RELATIVE_PER_PIXEL * 2; m_axes[AXIS_CROSSFADE] = normalize_absolute_axis(thumb_right_y(), XINPUT_AXIS_MINVALUE, XINPUT_AXIS_MAXVALUE); - // convert effect dial value to relative displacement - s32 effect_delta = s32(u32(u16(thumb_right_x()))) - s32(u32(m_prev_effect)); - if (!was_reset) + // handle effect dial + if (was_reset) { + // just grab the current count after regaining focus + m_prev_effect = u16(thumb_right_x()); + } + else if (relative_reset) + { + // convert value to relative displacement + s32 effect_delta = s32(u32(u16(thumb_right_x()))) - s32(u32(m_prev_effect)); + m_prev_effect = u16(thumb_right_x()); if (0x8000 < effect_delta) effect_delta -= 0x1'0000; else if (-0x8000 > effect_delta) effect_delta += 0x1'0000; m_axes[AXIS_EFFECT] = effect_delta * input_device::RELATIVE_PER_PIXEL / 128; } - m_prev_effect = u16(thumb_right_x()); } else { @@ -2683,7 +2689,7 @@ public: XINPUT_CAPABILITIES const &caps, xinput_api_helper const &helper); - virtual void poll() override; + virtual void poll(bool relative_reset) override; virtual void reset() override; virtual void configure(input_device &device) override; @@ -2758,7 +2764,7 @@ xinput_keyboard_device::xinput_keyboard_device( } -void xinput_keyboard_device::poll() +void xinput_keyboard_device::poll(bool relative_reset) { // TODO: how many bits are really velocity? // TODO: how are touch strip and overdrive read? |