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_dinput.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_dinput.cpp')
-rw-r--r-- | src/osd/modules/input/input_dinput.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/osd/modules/input/input_dinput.cpp b/src/osd/modules/input/input_dinput.cpp index ce19ed88dfe..1ec3c85a886 100644 --- a/src/osd/modules/input/input_dinput.cpp +++ b/src/osd/modules/input/input_dinput.cpp @@ -163,7 +163,7 @@ public: DIDEVCAPS const &caps, LPCDIDATAFORMAT format); - virtual void poll() override; + virtual void poll(bool relative_reset) override; virtual void reset() override; virtual void configure(input_device &device) override; @@ -184,7 +184,7 @@ dinput_keyboard_device::dinput_keyboard_device( { } -void dinput_keyboard_device::poll() +void dinput_keyboard_device::poll(bool relative_reset) { // poll the DirectInput immediate state std::lock_guard<std::mutex> scope_lock(m_device_lock); @@ -233,7 +233,7 @@ public: DIDEVCAPS const &caps, LPCDIDATAFORMAT format); - void poll() override; + void poll(bool relative_reset) override; void reset() override; virtual void configure(input_device &device) override; @@ -256,10 +256,10 @@ dinput_mouse_device::dinput_mouse_device( m_caps.dwButtons = std::min(m_caps.dwButtons, DWORD((m_format == &c_dfDIMouse) ? 4 : 8)); } -void dinput_mouse_device::poll() +void dinput_mouse_device::poll(bool relative_reset) { // poll - if (poll_dinput(&m_mouse) == DI_OK) + if (relative_reset && (poll_dinput(&m_mouse) == DI_OK)) { // scale the axis data m_mouse.lX *= input_device::RELATIVE_PER_PIXEL; @@ -566,7 +566,7 @@ void dinput_joystick_device::reset() std::fill(std::begin(m_joystick.state.rgdwPOV), std::end(m_joystick.state.rgdwPOV), 0xffff); } -void dinput_joystick_device::poll() +void dinput_joystick_device::poll(bool relative_reset) { // poll the device first if (dinput_device::poll_dinput(&m_joystick.state) == DI_OK) |