diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-03-09 16:08:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-09 16:08:30 +0100 |
| commit | 234c5dd90e31cbbe6782b4a6c6ae5f2f578e199b (patch) | |
| tree | cdc1505c7932d8de0f129b06437d686e27445685 /Source/Core/DolphinQt/TAS/TASCheckBox.cpp | |
| parent | a6b1b2f9a50b41d491115a8fb08f33a4a5dcf586 (diff) | |
| parent | 0300b44d23b149a0b93dd0aa2e77d20a02882ddf (diff) | |
Merge pull request #11622 from JosJuice/tas-input-nonblocking
DolphinQt: Rework TAS input threading
Diffstat (limited to 'Source/Core/DolphinQt/TAS/TASCheckBox.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/TAS/TASCheckBox.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/Core/DolphinQt/TAS/TASCheckBox.cpp b/Source/Core/DolphinQt/TAS/TASCheckBox.cpp index 29a7171f47..32d1b3b0b0 100644 --- a/Source/Core/DolphinQt/TAS/TASCheckBox.cpp +++ b/Source/Core/DolphinQt/TAS/TASCheckBox.cpp @@ -6,23 +6,34 @@ #include <QMouseEvent> #include "Core/Movie.h" +#include "DolphinQt/QtUtils/QueueOnObject.h" #include "DolphinQt/TAS/TASInputWindow.h" TASCheckBox::TASCheckBox(const QString& text, TASInputWindow* parent) : QCheckBox(text, parent), m_parent(parent) { setTristate(true); + + connect(this, &TASCheckBox::stateChanged, this, &TASCheckBox::OnUIValueChanged); } bool TASCheckBox::GetValue() const { - if (checkState() == Qt::PartiallyChecked) + Qt::CheckState check_state = static_cast<Qt::CheckState>(m_state.GetValue()); + + if (check_state == Qt::PartiallyChecked) { const u64 frames_elapsed = Movie::GetCurrentFrame() - m_frame_turbo_started; return static_cast<int>(frames_elapsed % m_turbo_total_frames) < m_turbo_press_frames; } - return isChecked(); + return check_state != Qt::Unchecked; +} + +void TASCheckBox::OnControllerValueChanged(bool new_value) +{ + if (m_state.OnControllerValueChanged(new_value ? Qt::Checked : Qt::Unchecked)) + QueueOnObject(this, &TASCheckBox::ApplyControllerValueChange); } void TASCheckBox::mousePressEvent(QMouseEvent* event) @@ -44,3 +55,14 @@ void TASCheckBox::mousePressEvent(QMouseEvent* event) m_turbo_total_frames = m_turbo_press_frames + m_parent->GetTurboReleaseFrames(); setCheckState(Qt::PartiallyChecked); } + +void TASCheckBox::OnUIValueChanged(int new_value) +{ + m_state.OnUIValueChanged(static_cast<u16>(new_value)); +} + +void TASCheckBox::ApplyControllerValueChange() +{ + const QSignalBlocker blocker(this); + setCheckState(static_cast<Qt::CheckState>(m_state.ApplyControllerValueChange())); +} |
