From e7a8e2fca172cadbe10ae875b42ac456c05c84ec Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 25 Nov 2024 14:58:48 -0600 Subject: [PATCH] DolphinQt: Update mapping indicators at screen refresh rate. --- Source/Core/DolphinQt/Config/Mapping/MappingWidget.h | 2 -- Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.h b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.h index 0ec5227f34..ee05834736 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.h +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.h @@ -27,8 +27,6 @@ class NumericSettingBase; enum class SettingVisibility; } // namespace ControllerEmu -constexpr int INDICATOR_UPDATE_FREQ = 30; - class MappingWidget : public QWidget { Q_OBJECT diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp index a41920e2c1..d5af344c30 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp @@ -10,12 +10,12 @@ #include #include #include +#include #include #include #include #include -#include "Core/Core.h" #include "Core/HotkeyManager.h" #include "Common/CommonPaths.h" @@ -73,12 +73,15 @@ MappingWindow::MappingWindow(QWidget* parent, Type type, int port_num) SetMappingType(type); const auto timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, [this] { + connect(timer, &QTimer::timeout, this, [this, timer] { + const double refresh_rate = screen()->refreshRate(); + timer->setInterval(1000 / refresh_rate); + const auto lock = GetController()->GetStateLock(); emit Update(); }); - timer->start(1000 / INDICATOR_UPDATE_FREQ); + timer->start(100); const auto lock = GetController()->GetStateLock(); emit ConfigChanged();