diff --git a/src/duckstation-qt/displaywidget.cpp b/src/duckstation-qt/displaywidget.cpp index 35cac05aa..035cf6fb6 100644 --- a/src/duckstation-qt/displaywidget.cpp +++ b/src/duckstation-qt/displaywidget.cpp @@ -345,7 +345,11 @@ bool DisplayWidget::event(QEvent* event) case QEvent::Wheel: { const QWheelEvent* wheel_event = static_cast(event); - emit windowMouseWheelEvent(wheel_event->angleDelta()); + const QPoint angle_delta = wheel_event->angleDelta(); + const float dx = static_cast(angle_delta.x()) / static_cast(QWheelEvent::DefaultDeltasPerStep); + const float dy = (static_cast(angle_delta.y()) / static_cast(QWheelEvent::DefaultDeltasPerStep)) * + static_cast(QApplication::wheelScrollLines()); + emit windowMouseWheelEvent(dx, dy); return true; } diff --git a/src/duckstation-qt/displaywidget.h b/src/duckstation-qt/displaywidget.h index ec725731f..6ae21dec9 100644 --- a/src/duckstation-qt/displaywidget.h +++ b/src/duckstation-qt/displaywidget.h @@ -44,7 +44,7 @@ Q_SIGNALS: void windowKeyEvent(int key_code, bool pressed); void windowTextEntered(const QString& text); void windowMouseButtonEvent(int button, bool pressed); - void windowMouseWheelEvent(const QPoint& angle_delta); + void windowMouseWheelEvent(float dx, float dy); protected: bool event(QEvent* event) override; diff --git a/src/duckstation-qt/inputbindingdialog.cpp b/src/duckstation-qt/inputbindingdialog.cpp index 15e5bcf97..ffd8a394c 100644 --- a/src/duckstation-qt/inputbindingdialog.cpp +++ b/src/duckstation-qt/inputbindingdialog.cpp @@ -97,7 +97,8 @@ bool InputBindingDialog::eventFilter(QObject* watched, QEvent* event) else if (event_type == QEvent::Wheel) { const QPoint delta_angle(static_cast(event)->angleDelta()); - const float dx = std::clamp(static_cast(delta_angle.x()) / QtUtils::MOUSE_WHEEL_DELTA, -1.0f, 1.0f); + const float dx = std::clamp( + static_cast(delta_angle.x()) / static_cast(QWheelEvent::DefaultDeltasPerStep), -1.0f, 1.0f); if (dx != 0.0f) { InputBindingKey key(InputManager::MakePointerAxisKey(0, InputPointerAxis::WheelX)); @@ -105,7 +106,8 @@ bool InputBindingDialog::eventFilter(QObject* watched, QEvent* event) m_new_bindings.push_back(key); } - const float dy = std::clamp(static_cast(delta_angle.y()) / QtUtils::MOUSE_WHEEL_DELTA, -1.0f, 1.0f); + const float dy = std::clamp( + static_cast(delta_angle.y()) / static_cast(QWheelEvent::DefaultDeltasPerStep), -1.0f, 1.0f); if (dy != 0.0f) { InputBindingKey key(InputManager::MakePointerAxisKey(0, InputPointerAxis::WheelY)); diff --git a/src/duckstation-qt/inputbindingwidgets.cpp b/src/duckstation-qt/inputbindingwidgets.cpp index 03325bc43..155b3aec2 100644 --- a/src/duckstation-qt/inputbindingwidgets.cpp +++ b/src/duckstation-qt/inputbindingwidgets.cpp @@ -124,7 +124,8 @@ bool InputBindingWidget::eventFilter(QObject* watched, QEvent* event) else if (event_type == QEvent::Wheel) { const QPoint delta_angle(static_cast(event)->angleDelta()); - const float dx = std::clamp(static_cast(delta_angle.x()) / QtUtils::MOUSE_WHEEL_DELTA, -1.0f, 1.0f); + const float dx = std::clamp( + static_cast(delta_angle.x()) / static_cast(QWheelEvent::DefaultDeltasPerStep), -1.0f, 1.0f); if (dx != 0.0f) { InputBindingKey key(InputManager::MakePointerAxisKey(0, InputPointerAxis::WheelX)); @@ -132,7 +133,8 @@ bool InputBindingWidget::eventFilter(QObject* watched, QEvent* event) m_new_bindings.push_back(key); } - const float dy = std::clamp(static_cast(delta_angle.y()) / QtUtils::MOUSE_WHEEL_DELTA, -1.0f, 1.0f); + const float dy = std::clamp( + static_cast(delta_angle.y()) / static_cast(QWheelEvent::DefaultDeltasPerStep), -1.0f, 1.0f); if (dy != 0.0f) { InputBindingKey key(InputManager::MakePointerAxisKey(0, InputPointerAxis::WheelY)); diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 45ab796a8..6094986d3 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -903,15 +903,13 @@ void EmuThread::onDisplayWindowMouseButtonEvent(int button, bool pressed) GenericInputBinding::Unknown); } -void EmuThread::onDisplayWindowMouseWheelEvent(const QPoint& delta_angle) +void EmuThread::onDisplayWindowMouseWheelEvent(float dx, float dy) { DebugAssert(isCurrentThread()); - const float dx = std::clamp(static_cast(delta_angle.x()) / QtUtils::MOUSE_WHEEL_DELTA, -1.0f, 1.0f); if (dx != 0.0f) InputManager::UpdatePointerRelativeDelta(0, InputPointerAxis::WheelX, dx); - const float dy = std::clamp(static_cast(delta_angle.y()) / QtUtils::MOUSE_WHEEL_DELTA, -1.0f, 1.0f); if (dy != 0.0f) InputManager::UpdatePointerRelativeDelta(0, InputPointerAxis::WheelY, dy); } diff --git a/src/duckstation-qt/qthost.h b/src/duckstation-qt/qthost.h index 9726788d5..ba68210c3 100644 --- a/src/duckstation-qt/qthost.h +++ b/src/duckstation-qt/qthost.h @@ -223,7 +223,7 @@ public Q_SLOTS: private Q_SLOTS: void stopInThread(); void onDisplayWindowMouseButtonEvent(int button, bool pressed); - void onDisplayWindowMouseWheelEvent(const QPoint& delta_angle); + void onDisplayWindowMouseWheelEvent(float dx, float dy); void onDisplayWindowResized(int width, int height, float scale); void onDisplayWindowKeyEvent(int key, bool pressed); void onDisplayWindowTextEntered(const QString& text); diff --git a/src/duckstation-qt/qtutils.h b/src/duckstation-qt/qtutils.h index 83b2563cf..942040fca 100644 --- a/src/duckstation-qt/qtutils.h +++ b/src/duckstation-qt/qtutils.h @@ -45,9 +45,6 @@ enum class EntryType : u8; namespace QtUtils { -/// Wheel delta is 120 as in winapi. -static constexpr float MOUSE_WHEEL_DELTA = 120.0f; - /// Creates a horizontal line widget. QFrame* CreateHorizontalLine(QWidget* parent); diff --git a/src/util/imgui_fullscreen.cpp b/src/util/imgui_fullscreen.cpp index c37b6f80e..5690fd12d 100644 --- a/src/util/imgui_fullscreen.cpp +++ b/src/util/imgui_fullscreen.cpp @@ -808,6 +808,7 @@ void ImGuiFullscreen::PushResetLayout() ImGui::PushStyleVar(ImGuiStyleVar_GrabMinSize, LayoutScale(10.0f)); ImGui::PushStyleVar(ImGuiStyleVar_TabRounding, LayoutScale(4.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ScrollSmooth, UIStyle.SmoothScrolling ? SMOOTH_SCROLLING_SPEED : 1.0f); + ImGui::PushStyleVar(ImGuiStyleVar_ScrollStepSize, LayoutScale(LAYOUT_LARGE_FONT_SIZE, LAYOUT_MENU_BUTTON_HEIGHT)); ImGui::PushStyleColor(ImGuiCol_Text, UIStyle.SecondaryTextColor); ImGui::PushStyleColor(ImGuiCol_TextDisabled, UIStyle.DisabledColor); ImGui::PushStyleColor(ImGuiCol_Button, UIStyle.SecondaryColor); @@ -825,7 +826,7 @@ void ImGuiFullscreen::PushResetLayout() void ImGuiFullscreen::PopResetLayout() { ImGui::PopStyleColor(12); - ImGui::PopStyleVar(13); + ImGui::PopStyleVar(14); } void ImGuiFullscreen::QueueResetFocus(FocusResetType type)