Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11732 from malleoz/malleo/limit_stick_emits
DolphinQt: StickWidget and IRWidget check for changed x/y before signaling change
  • Loading branch information
AdmiralCurtiss committed Apr 6, 2023
2 parents 0a88c23 + cd79207 commit d32e47c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
20 changes: 17 additions & 3 deletions Source/Core/DolphinQt/TAS/IRWidget.cpp
Expand Up @@ -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.);
Expand All @@ -94,7 +97,18 @@ void IRWidget::handleMouseEvent(QMouseEvent* event)
m_y = std::max(0, std::min(static_cast<int>(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();
}
20 changes: 17 additions & 3 deletions Source/Core/DolphinQt/TAS/StickWidget.cpp
Expand Up @@ -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.);
Expand All @@ -97,7 +100,18 @@ void StickWidget::handleMouseEvent(QMouseEvent* event)
m_y = std::max(0, std::min(static_cast<int>(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();
}

0 comments on commit d32e47c

Please sign in to comment.