InputManager: Fix pointer-bound bind movement

i.e. psmouse

Regression from c4e0e7fadea0bf4f9da7bdea4335f619a6f14385
This commit is contained in:
Stenzek 2025-01-02 02:09:43 +10:00
parent cd873eb6c1
commit 08cd649187
No known key found for this signature in database

View File

@ -1223,27 +1223,29 @@ void InputManager::GenerateRelativeMouseEvents()
for (u32 axis = 0; axis < static_cast<u32>(static_cast<u8>(InputPointerAxis::Count)); axis++) for (u32 axis = 0; axis < static_cast<u32>(static_cast<u8>(InputPointerAxis::Count)); axis++)
{ {
PointerAxisState& state = s_pointer_state[device][axis]; PointerAxisState& state = s_pointer_state[device][axis];
const float delta = static_cast<float>(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<float>(deltai) / 65536.0f;
const float unclamped_value = delta * s_pointer_axis_scale[axis]; const float unclamped_value = delta * s_pointer_axis_scale[axis];
const float value = std::clamp(unclamped_value, -1.0f, 1.0f); 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<InputPointerAxis>(axis))); const InputBindingKey key(MakePointerAxisKey(device, static_cast<InputPointerAxis>(axis)));
if (device == 0 && axis >= static_cast<u32>(InputPointerAxis::WheelX) && if (device == 0 && axis >= static_cast<u32>(InputPointerAxis::WheelX) && delta != 0.0f &&
ImGuiManager::ProcessPointerAxisEvent(key, unclamped_value)) ImGuiManager::ProcessPointerAxisEvent(key, delta))
{ {
continue; continue;
} }
if (!system_running) // only generate axis-bound events when it hasn't changed
continue; 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<u32, PointerMoveCallback>& pmc : s_pointer_move_callbacks) for (const std::pair<u32, PointerMoveCallback>& pmc : s_pointer_move_callbacks)
{ {