Qt: Fix incorrect mouse button event being fired

Fixes left click bindings.
This commit is contained in:
Connor McLaughlin 2022-08-10 15:54:53 +10:00
parent f3ec05f1ba
commit ddbe28830e
2 changed files with 3 additions and 3 deletions

View file

@ -292,7 +292,7 @@ bool DisplayWidget::event(QEvent* event)
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
{ {
const u32 button_index = CountTrailingZeros(static_cast<u32>(static_cast<const QMouseEvent*>(event)->button())); const u32 button_index = CountTrailingZeros(static_cast<u32>(static_cast<const QMouseEvent*>(event)->button()));
emit windowMouseButtonEvent(static_cast<int>(button_index + 1u), event->type() != QEvent::MouseButtonRelease); emit windowMouseButtonEvent(static_cast<int>(button_index), event->type() != QEvent::MouseButtonRelease);
// don't toggle fullscreen when we're bound.. that wouldn't end well. // don't toggle fullscreen when we're bound.. that wouldn't end well.
if (event->type() == QEvent::MouseButtonDblClick && if (event->type() == QEvent::MouseButtonDblClick &&

View file

@ -745,11 +745,11 @@ void ImGuiManager::UpdateMousePosition(float x, float y)
bool ImGuiManager::ProcessPointerButtonEvent(InputBindingKey key, float value) bool ImGuiManager::ProcessPointerButtonEvent(InputBindingKey key, float value)
{ {
if (!ImGui::GetCurrentContext() || (key.data - 1u) >= std::size(ImGui::GetIO().MouseDown)) if (!ImGui::GetCurrentContext() || key.data >= std::size(ImGui::GetIO().MouseDown))
return false; return false;
// still update state anyway // still update state anyway
ImGui::GetIO().AddMouseButtonEvent(key.data - 1, value != 0.0f); ImGui::GetIO().AddMouseButtonEvent(key.data, value != 0.0f);
return s_imgui_wants_mouse.load(std::memory_order_acquire); return s_imgui_wants_mouse.load(std::memory_order_acquire);
} }