From cd79207853a5b8a8c564c99e1fe141214dac292f Mon Sep 17 00:00:00 2001 From: sowens99 Date: Thu, 6 Apr 2023 01:47:42 -0400 Subject: [PATCH] DolphinQt: StickWidget and IRWidget check for changed x/y before signaling change --- Source/Core/DolphinQt/TAS/IRWidget.cpp | 20 +++++++++++++++++--- Source/Core/DolphinQt/TAS/StickWidget.cpp | 20 +++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinQt/TAS/IRWidget.cpp b/Source/Core/DolphinQt/TAS/IRWidget.cpp index 7bab30186b..1efa6748c5 100644 --- a/Source/Core/DolphinQt/TAS/IRWidget.cpp +++ b/Source/Core/DolphinQt/TAS/IRWidget.cpp @@ -79,6 +79,9 @@ void IRWidget::mouseMoveEvent(QMouseEvent* event) void IRWidget::handleMouseEvent(QMouseEvent* event) { + u16 prev_x = m_x; + u16 prev_y = m_y; + if (event->button() == Qt::RightButton) { m_x = std::round(ir_max_x / 2.); @@ -94,7 +97,18 @@ void IRWidget::handleMouseEvent(QMouseEvent* event) m_y = std::max(0, std::min(static_cast(ir_max_y), new_y)); } - emit ChangedX(m_x); - emit ChangedY(m_y); - update(); + bool changed = false; + if (prev_x != m_x) + { + emit ChangedX(m_x); + changed = true; + } + if (prev_y != m_y) + { + emit ChangedY(m_y); + changed = true; + } + + if (changed) + update(); } diff --git a/Source/Core/DolphinQt/TAS/StickWidget.cpp b/Source/Core/DolphinQt/TAS/StickWidget.cpp index 7a8842477a..fd43496930 100644 --- a/Source/Core/DolphinQt/TAS/StickWidget.cpp +++ b/Source/Core/DolphinQt/TAS/StickWidget.cpp @@ -82,6 +82,9 @@ void StickWidget::mouseMoveEvent(QMouseEvent* event) void StickWidget::handleMouseEvent(QMouseEvent* event) { + u16 prev_x = m_x; + u16 prev_y = m_y; + if (event->button() == Qt::RightButton) { m_x = std::round(m_max_x / 2.); @@ -97,7 +100,18 @@ void StickWidget::handleMouseEvent(QMouseEvent* event) m_y = std::max(0, std::min(static_cast(m_max_y), new_y)); } - emit ChangedX(m_x); - emit ChangedY(m_y); - update(); + bool changed = false; + if (prev_x != m_x) + { + emit ChangedX(m_x); + changed = true; + } + if (prev_y != m_y) + { + emit ChangedY(m_y); + changed = true; + } + + if (changed) + update(); }