From 08cd649187522c4fbaed6f41f5c0f7c69cb9c5b9 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 2 Jan 2025 02:09:43 +1000 Subject: [PATCH] InputManager: Fix pointer-bound bind movement i.e. psmouse Regression from c4e0e7fadea0bf4f9da7bdea4335f619a6f14385 --- src/util/input_manager.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/util/input_manager.cpp b/src/util/input_manager.cpp index 5a12eb978..0d8eeda16 100644 --- a/src/util/input_manager.cpp +++ b/src/util/input_manager.cpp @@ -1223,27 +1223,29 @@ void InputManager::GenerateRelativeMouseEvents() for (u32 axis = 0; axis < static_cast(static_cast(InputPointerAxis::Count)); axis++) { PointerAxisState& state = s_pointer_state[device][axis]; - const float delta = static_cast(state.delta.exchange(0, std::memory_order_acquire)) / 65536.0f; + const int deltai = state.delta.load(std::memory_order_acquire); + state.delta.fetch_sub(deltai, std::memory_order_release); + const float delta = static_cast(deltai) / 65536.0f; const float unclamped_value = delta * s_pointer_axis_scale[axis]; const float value = std::clamp(unclamped_value, -1.0f, 1.0f); - if (value == state.last_value) - continue; - - state.last_value = value; const InputBindingKey key(MakePointerAxisKey(device, static_cast(axis))); - if (device == 0 && axis >= static_cast(InputPointerAxis::WheelX) && - ImGuiManager::ProcessPointerAxisEvent(key, unclamped_value)) + if (device == 0 && axis >= static_cast(InputPointerAxis::WheelX) && delta != 0.0f && + ImGuiManager::ProcessPointerAxisEvent(key, delta)) { continue; } - if (!system_running) - continue; + // only generate axis-bound events when it hasn't changed + if (value != state.last_value) + { + state.last_value = value; + if (system_running) + InvokeEvents(key, value, GenericInputBinding::Unknown); + } - InvokeEvents(key, value, GenericInputBinding::Unknown); - - if (delta != 0.0f) + // and pointer events only when it hasn't moved + if (delta != 0.0f && system_running) { for (const std::pair& pmc : s_pointer_move_callbacks) {