diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt
index 9216e9702b..bbf7890da1 100644
--- a/Source/Core/DolphinQt/CMakeLists.txt
+++ b/Source/Core/DolphinQt/CMakeLists.txt
@@ -277,6 +277,8 @@ add_executable(dolphin-emu
TAS/TASCheckBox.h
TAS/TASInputWindow.cpp
TAS/TASInputWindow.h
+ TAS/TASSlider.cpp
+ TAS/TASSlider.h
TAS/StickWidget.cpp
TAS/StickWidget.h
TAS/IRWidget.cpp
diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj
index 3d93fb43e4..99c6a00b7d 100644
--- a/Source/Core/DolphinQt/DolphinQt.vcxproj
+++ b/Source/Core/DolphinQt/DolphinQt.vcxproj
@@ -174,6 +174,7 @@
+
@@ -321,6 +322,7 @@
+
diff --git a/Source/Core/DolphinQt/TAS/GCTASInputWindow.cpp b/Source/Core/DolphinQt/TAS/GCTASInputWindow.cpp
index 1dee285351..5cd6fcf401 100644
--- a/Source/Core/DolphinQt/TAS/GCTASInputWindow.cpp
+++ b/Source/Core/DolphinQt/TAS/GCTASInputWindow.cpp
@@ -34,9 +34,9 @@ GCTASInputWindow::GCTASInputWindow(QWidget* parent, int num) : TASInputWindow(pa
m_triggers_box = new QGroupBox(tr("Triggers"));
auto* l_trigger_layout =
- CreateSliderValuePairLayout(tr("Left"), m_l_trigger_value, 255, Qt::Key_N, m_triggers_box);
- auto* r_trigger_layout =
- CreateSliderValuePairLayout(tr("Right"), m_r_trigger_value, 255, Qt::Key_M, m_triggers_box);
+ CreateSliderValuePairLayout(tr("Left"), m_l_trigger_value, 0, 255, Qt::Key_N, m_triggers_box);
+ auto* r_trigger_layout = CreateSliderValuePairLayout(tr("Right"), m_r_trigger_value, 0, 255,
+ Qt::Key_M, m_triggers_box);
auto* triggers_layout = new QVBoxLayout;
triggers_layout->addLayout(l_trigger_layout);
diff --git a/Source/Core/DolphinQt/TAS/TASInputWindow.cpp b/Source/Core/DolphinQt/TAS/TASInputWindow.cpp
index 2bb830db7f..626404e642 100644
--- a/Source/Core/DolphinQt/TAS/TASInputWindow.cpp
+++ b/Source/Core/DolphinQt/TAS/TASInputWindow.cpp
@@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include "DolphinQt/TAS/TASInputWindow.h"
+
#include
#include
@@ -20,7 +22,7 @@
#include "DolphinQt/Resources.h"
#include "DolphinQt/TAS/StickWidget.h"
#include "DolphinQt/TAS/TASCheckBox.h"
-#include "DolphinQt/TAS/TASInputWindow.h"
+#include "DolphinQt/TAS/TASSlider.h"
#include "InputCommon/GCPadStatus.h"
@@ -79,22 +81,27 @@ QGroupBox* TASInputWindow::CreateStickInputs(QString name, QSpinBox*& x_value, Q
.arg(name, x_shortcut_key_sequence.toString(QKeySequence::NativeText),
y_shortcut_key_sequence.toString(QKeySequence::NativeText)));
+ const int x_default = static_cast(std::round(max_x / 2.));
+ const int y_default = static_cast(std::round(max_y / 2.));
+
auto* x_layout = new QHBoxLayout;
- x_value = CreateSliderValuePair(x_layout, max_x, x_shortcut_key_sequence, Qt::Horizontal, box);
+ x_value = CreateSliderValuePair(x_layout, x_default, max_x, x_shortcut_key_sequence,
+ Qt::Horizontal, box);
auto* y_layout = new QVBoxLayout;
- y_value = CreateSliderValuePair(y_layout, max_y, y_shortcut_key_sequence, Qt::Vertical, box);
+ y_value =
+ CreateSliderValuePair(y_layout, y_default, max_y, y_shortcut_key_sequence, Qt::Vertical, box);
y_value->setMaximumWidth(60);
auto* visual = new StickWidget(this, max_x, max_y);
+ visual->SetX(x_default);
+ visual->SetY(y_default);
+
connect(x_value, qOverload(&QSpinBox::valueChanged), visual, &StickWidget::SetX);
connect(y_value, qOverload(&QSpinBox::valueChanged), visual, &StickWidget::SetY);
connect(visual, &StickWidget::ChangedX, x_value, &QSpinBox::setValue);
connect(visual, &StickWidget::ChangedY, y_value, &QSpinBox::setValue);
- x_value->setValue(static_cast(std::round(max_x / 2.)));
- y_value->setValue(static_cast(std::round(max_y / 2.)));
-
auto* visual_ar = new AspectRatioWidget(visual, max_x, max_y);
auto* visual_layout = new QHBoxLayout;
@@ -109,8 +116,8 @@ QGroupBox* TASInputWindow::CreateStickInputs(QString name, QSpinBox*& x_value, Q
return box;
}
-QBoxLayout* TASInputWindow::CreateSliderValuePairLayout(QString name, QSpinBox*& value, u16 max,
- Qt::Key shortcut_key,
+QBoxLayout* TASInputWindow::CreateSliderValuePairLayout(QString name, QSpinBox*& value,
+ int default_, u16 max, Qt::Key shortcut_key,
QWidget* shortcut_widget, bool invert)
{
const QKeySequence shortcut_key_sequence = QKeySequence(Qt::ALT + shortcut_key);
@@ -121,27 +128,29 @@ QBoxLayout* TASInputWindow::CreateSliderValuePairLayout(QString name, QSpinBox*&
QBoxLayout* layout = new QHBoxLayout;
layout->addWidget(label);
- value = CreateSliderValuePair(layout, max, shortcut_key_sequence, Qt::Horizontal, shortcut_widget,
- invert);
+ value = CreateSliderValuePair(layout, default_, max, shortcut_key_sequence, Qt::Horizontal,
+ shortcut_widget, invert);
return layout;
}
// The shortcut_widget argument needs to specify the container widget that will be hidden/shown.
// This is done to avoid ambigous shortcuts
-QSpinBox* TASInputWindow::CreateSliderValuePair(QBoxLayout* layout, u16 max,
+QSpinBox* TASInputWindow::CreateSliderValuePair(QBoxLayout* layout, int default_, u16 max,
QKeySequence shortcut_key_sequence,
Qt::Orientation orientation,
QWidget* shortcut_widget, bool invert)
{
auto* value = new QSpinBox();
value->setRange(0, 99999);
+ value->setValue(default_);
connect(value, qOverload(&QSpinBox::valueChanged), [value, max](int i) {
if (i > max)
value->setValue(max);
});
- auto* slider = new QSlider(orientation);
+ auto* slider = new TASSlider(default_, orientation);
slider->setRange(0, max);
+ slider->setValue(default_);
slider->setFocusPolicy(Qt::ClickFocus);
slider->setInvertedAppearance(invert);
diff --git a/Source/Core/DolphinQt/TAS/TASInputWindow.h b/Source/Core/DolphinQt/TAS/TASInputWindow.h
index c5eb125776..d76da87d81 100644
--- a/Source/Core/DolphinQt/TAS/TASInputWindow.h
+++ b/Source/Core/DolphinQt/TAS/TASInputWindow.h
@@ -30,12 +30,12 @@ protected:
TASCheckBox* CreateButton(const QString& name);
QGroupBox* CreateStickInputs(QString name, QSpinBox*& x_value, QSpinBox*& y_value, u16 max_x,
u16 max_y, Qt::Key x_shortcut_key, Qt::Key y_shortcut_key);
- QBoxLayout* CreateSliderValuePairLayout(QString name, QSpinBox*& value, u16 max,
+ QBoxLayout* CreateSliderValuePairLayout(QString name, QSpinBox*& value, int default_, u16 max,
Qt::Key shortcut_key, QWidget* shortcut_widget,
bool invert = false);
- QSpinBox* CreateSliderValuePair(QBoxLayout* layout, u16 max, QKeySequence shortcut_key_sequence,
- Qt::Orientation orientation, QWidget* shortcut_widget,
- bool invert = false);
+ QSpinBox* CreateSliderValuePair(QBoxLayout* layout, int default_, u16 max,
+ QKeySequence shortcut_key_sequence, Qt::Orientation orientation,
+ QWidget* shortcut_widget, bool invert = false);
template
void GetButton(TASCheckBox* button, UX& pad, UX mask);
void GetSpinBoxU8(QSpinBox* spin, u8& controller_value);
diff --git a/Source/Core/DolphinQt/TAS/TASSlider.cpp b/Source/Core/DolphinQt/TAS/TASSlider.cpp
new file mode 100644
index 0000000000..83975cb9f7
--- /dev/null
+++ b/Source/Core/DolphinQt/TAS/TASSlider.cpp
@@ -0,0 +1,24 @@
+// Copyright 2020 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#include "DolphinQt/TAS/TASSlider.h"
+
+#include
+
+TASSlider::TASSlider(int default_, QWidget* parent) : QSlider(parent), m_default(default_)
+{
+}
+
+TASSlider::TASSlider(int default_, Qt::Orientation orientation, QWidget* parent)
+ : QSlider(orientation, parent), m_default(default_)
+{
+}
+
+void TASSlider::mouseReleaseEvent(QMouseEvent* event)
+{
+ if (event->button() == Qt::RightButton)
+ setValue(m_default);
+ else
+ QSlider::mouseReleaseEvent(event);
+}
diff --git a/Source/Core/DolphinQt/TAS/TASSlider.h b/Source/Core/DolphinQt/TAS/TASSlider.h
new file mode 100644
index 0000000000..d38d2a948f
--- /dev/null
+++ b/Source/Core/DolphinQt/TAS/TASSlider.h
@@ -0,0 +1,22 @@
+// Copyright 2020 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include
+
+class QMouseEvent;
+
+class TASSlider : public QSlider
+{
+public:
+ explicit TASSlider(int default_, QWidget* parent = nullptr);
+ explicit TASSlider(int default_, Qt::Orientation orientation, QWidget* parent = nullptr);
+
+protected:
+ void mouseReleaseEvent(QMouseEvent* event) override;
+
+private:
+ int m_default;
+};
diff --git a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp
index b8b7495e92..8b27badaaf 100644
--- a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp
+++ b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp
@@ -48,24 +48,27 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
ir_x_shortcut_key_sequence.toString(QKeySequence::NativeText),
ir_y_shortcut_key_sequence.toString(QKeySequence::NativeText)));
+ const int ir_x_default = static_cast(std::round(ir_max_x / 2.));
+ const int ir_y_default = static_cast(std::round(ir_max_y / 2.));
+
auto* x_layout = new QHBoxLayout;
- m_ir_x_value = CreateSliderValuePair(x_layout, ir_max_x, ir_x_shortcut_key_sequence,
+ m_ir_x_value = CreateSliderValuePair(x_layout, ir_x_default, ir_max_x, ir_x_shortcut_key_sequence,
Qt::Horizontal, m_ir_box, true);
auto* y_layout = new QVBoxLayout;
- m_ir_y_value = CreateSliderValuePair(y_layout, ir_max_y, ir_y_shortcut_key_sequence, Qt::Vertical,
- m_ir_box, true);
+ m_ir_y_value = CreateSliderValuePair(y_layout, ir_y_default, ir_max_y, ir_y_shortcut_key_sequence,
+ Qt::Vertical, m_ir_box, true);
m_ir_y_value->setMaximumWidth(60);
auto* visual = new IRWidget(this);
+ visual->SetX(ir_x_default);
+ visual->SetY(ir_y_default);
+
connect(m_ir_x_value, qOverload(&QSpinBox::valueChanged), visual, &IRWidget::SetX);
connect(m_ir_y_value, qOverload(&QSpinBox::valueChanged), visual, &IRWidget::SetY);
connect(visual, &IRWidget::ChangedX, m_ir_x_value, &QSpinBox::setValue);
connect(visual, &IRWidget::ChangedY, m_ir_y_value, &QSpinBox::setValue);
- m_ir_x_value->setValue(static_cast(std::round(ir_max_x / 2.)));
- m_ir_y_value->setValue(static_cast(std::round(ir_max_y / 2.)));
-
auto* visual_ar = new AspectRatioWidget(visual, ir_max_x, ir_max_y);
auto* visual_layout = new QHBoxLayout;
@@ -103,21 +106,17 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
auto* remote_orientation_x_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
- CreateSliderValuePairLayout(tr("X"), m_remote_orientation_x_value, 1023, Qt::Key_Q,
+ CreateSliderValuePairLayout(tr("X"), m_remote_orientation_x_value, 512, 1023, Qt::Key_Q,
m_remote_orientation_box);
auto* remote_orientation_y_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
- CreateSliderValuePairLayout(tr("Y"), m_remote_orientation_y_value, 1023, Qt::Key_W,
+ CreateSliderValuePairLayout(tr("Y"), m_remote_orientation_y_value, 512, 1023, Qt::Key_W,
m_remote_orientation_box);
auto* remote_orientation_z_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
- CreateSliderValuePairLayout(tr("Z"), m_remote_orientation_z_value, 1023, Qt::Key_E,
+ CreateSliderValuePairLayout(tr("Z"), m_remote_orientation_z_value, 616, 1023, Qt::Key_E,
m_remote_orientation_box);
- m_remote_orientation_x_value->setValue(512);
- m_remote_orientation_y_value->setValue(512);
- m_remote_orientation_z_value->setValue(616);
-
auto* remote_orientation_layout = new QVBoxLayout;
remote_orientation_layout->addLayout(remote_orientation_x_layout);
remote_orientation_layout->addLayout(remote_orientation_y_layout);
@@ -128,21 +127,17 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
auto* nunchuk_orientation_x_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
- CreateSliderValuePairLayout(tr("X"), m_nunchuk_orientation_x_value, 1023, Qt::Key_I,
+ CreateSliderValuePairLayout(tr("X"), m_nunchuk_orientation_x_value, 512, 1023, Qt::Key_I,
m_nunchuk_orientation_box);
auto* nunchuk_orientation_y_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
- CreateSliderValuePairLayout(tr("Y"), m_nunchuk_orientation_y_value, 1023, Qt::Key_O,
+ CreateSliderValuePairLayout(tr("Y"), m_nunchuk_orientation_y_value, 512, 1023, Qt::Key_O,
m_nunchuk_orientation_box);
auto* nunchuk_orientation_z_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
- CreateSliderValuePairLayout(tr("Z"), m_nunchuk_orientation_z_value, 1023, Qt::Key_P,
+ CreateSliderValuePairLayout(tr("Z"), m_nunchuk_orientation_z_value, 512, 1023, Qt::Key_P,
m_nunchuk_orientation_box);
- m_nunchuk_orientation_x_value->setValue(512);
- m_nunchuk_orientation_y_value->setValue(512);
- m_nunchuk_orientation_z_value->setValue(512);
-
auto* nunchuk_orientation_layout = new QVBoxLayout;
nunchuk_orientation_layout->addLayout(nunchuk_orientation_x_layout);
nunchuk_orientation_layout->addLayout(nunchuk_orientation_y_layout);
@@ -150,9 +145,9 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
m_nunchuk_orientation_box->setLayout(nunchuk_orientation_layout);
m_triggers_box = new QGroupBox(tr("Triggers"));
- auto* l_trigger_layout =
- CreateSliderValuePairLayout(tr("Left"), m_left_trigger_value, 31, Qt::Key_N, m_triggers_box);
- auto* r_trigger_layout = CreateSliderValuePairLayout(tr("Right"), m_right_trigger_value, 31,
+ auto* l_trigger_layout = CreateSliderValuePairLayout(tr("Left"), m_left_trigger_value, 0, 31,
+ Qt::Key_N, m_triggers_box);
+ auto* r_trigger_layout = CreateSliderValuePairLayout(tr("Right"), m_right_trigger_value, 0, 31,
Qt::Key_M, m_triggers_box);
auto* triggers_layout = new QVBoxLayout;