mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Qt2 TAS input: Generate key strings automatically
This saves us from having to hardcode strings, and it also gives us strings in whatever format is appropriate on the current OS (for instance, IIRC Windows uses Alt+F where other OSes use Alt-F).
This commit is contained in:
@ -17,12 +17,10 @@
|
|||||||
GCTASInputWindow::GCTASInputWindow(QWidget* parent, int num) : QDialog(parent)
|
GCTASInputWindow::GCTASInputWindow(QWidget* parent, int num) : QDialog(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("GameCube TAS Input %1").arg(num + 1));
|
setWindowTitle(tr("GameCube TAS Input %1").arg(num + 1));
|
||||||
auto* main_stick_box =
|
auto* main_stick_box = CreateStickInputs(this, tr("Main Stick"), m_x_main_stick_value,
|
||||||
CreateStickInputs(this, tr("Main Stick") + QStringLiteral(" (ALT+F/G)"), m_x_main_stick_value,
|
m_y_main_stick_value, 255, 255, Qt::Key_F, Qt::Key_G);
|
||||||
m_y_main_stick_value, 255, 255, Qt::Key_F, Qt::Key_G);
|
auto* c_stick_box = CreateStickInputs(this, tr("C Stick"), m_x_c_stick_value, m_y_c_stick_value,
|
||||||
auto* c_stick_box =
|
255, 255, Qt::Key_H, Qt::Key_J);
|
||||||
CreateStickInputs(this, tr("C Stick") + QStringLiteral(" (ALT+H/J)"), m_x_c_stick_value,
|
|
||||||
m_y_c_stick_value, 255, 255, Qt::Key_H, Qt::Key_J);
|
|
||||||
|
|
||||||
auto* top_layout = new QHBoxLayout;
|
auto* top_layout = new QHBoxLayout;
|
||||||
top_layout->addWidget(main_stick_box);
|
top_layout->addWidget(main_stick_box);
|
||||||
@ -30,12 +28,10 @@ GCTASInputWindow::GCTASInputWindow(QWidget* parent, int num) : QDialog(parent)
|
|||||||
|
|
||||||
auto* triggers_box = new QGroupBox(tr("Triggers"));
|
auto* triggers_box = new QGroupBox(tr("Triggers"));
|
||||||
|
|
||||||
auto* l_trigger_layout =
|
auto* l_trigger_layout = CreateSliderValuePairLayout(this, tr("Left"), m_l_trigger_value, 255,
|
||||||
CreateSliderValuePairLayout(this, tr("Left") + QStringLiteral(" (ALT+N)"), m_l_trigger_value,
|
Qt::Key_N, triggers_box);
|
||||||
255, Qt::Key_N, triggers_box);
|
auto* r_trigger_layout = CreateSliderValuePairLayout(this, tr("Right"), m_r_trigger_value, 255,
|
||||||
auto* r_trigger_layout =
|
Qt::Key_M, triggers_box);
|
||||||
CreateSliderValuePairLayout(this, tr("Right") + QStringLiteral(" (ALT+M)"), m_r_trigger_value,
|
|
||||||
255, Qt::Key_M, triggers_box);
|
|
||||||
|
|
||||||
auto* triggers_layout = new QVBoxLayout;
|
auto* triggers_layout = new QVBoxLayout;
|
||||||
triggers_layout->addLayout(l_trigger_layout);
|
triggers_layout->addLayout(l_trigger_layout);
|
||||||
|
@ -20,13 +20,21 @@
|
|||||||
QGroupBox* CreateStickInputs(QDialog* window, QString name, QSpinBox*& x_value, QSpinBox*& y_value,
|
QGroupBox* CreateStickInputs(QDialog* window, QString name, QSpinBox*& x_value, QSpinBox*& y_value,
|
||||||
u16 max_x, u16 max_y, Qt::Key x_shortcut_key, Qt::Key y_shortcut_key)
|
u16 max_x, u16 max_y, Qt::Key x_shortcut_key, Qt::Key y_shortcut_key)
|
||||||
{
|
{
|
||||||
auto* box = new QGroupBox(name);
|
const QKeySequence x_shortcut_key_sequence = QKeySequence(Qt::ALT + x_shortcut_key);
|
||||||
|
const QKeySequence y_shortcut_key_sequence = QKeySequence(Qt::ALT + y_shortcut_key);
|
||||||
|
|
||||||
|
auto* box =
|
||||||
|
new QGroupBox(QStringLiteral("%1 (%2/%3)")
|
||||||
|
.arg(name, x_shortcut_key_sequence.toString(QKeySequence::NativeText),
|
||||||
|
y_shortcut_key_sequence.toString(QKeySequence::NativeText)));
|
||||||
|
|
||||||
auto* x_layout = new QHBoxLayout;
|
auto* x_layout = new QHBoxLayout;
|
||||||
x_value = CreateSliderValuePair(window, x_layout, max_x, x_shortcut_key, Qt::Horizontal, box);
|
x_value =
|
||||||
|
CreateSliderValuePair(window, x_layout, max_x, x_shortcut_key_sequence, Qt::Horizontal, box);
|
||||||
|
|
||||||
auto* y_layout = new QVBoxLayout;
|
auto* y_layout = new QVBoxLayout;
|
||||||
y_value = CreateSliderValuePair(window, y_layout, max_y, y_shortcut_key, Qt::Vertical, box);
|
y_value =
|
||||||
|
CreateSliderValuePair(window, y_layout, max_y, y_shortcut_key_sequence, Qt::Vertical, box);
|
||||||
y_value->setMaximumWidth(60);
|
y_value->setMaximumWidth(60);
|
||||||
|
|
||||||
auto* visual = new StickWidget(window, max_x, max_y);
|
auto* visual = new StickWidget(window, max_x, max_y);
|
||||||
@ -57,21 +65,25 @@ QGroupBox* CreateStickInputs(QDialog* window, QString name, QSpinBox*& x_value,
|
|||||||
QBoxLayout* CreateSliderValuePairLayout(QDialog* window, QString name, QSpinBox*& value, u16 max,
|
QBoxLayout* CreateSliderValuePairLayout(QDialog* window, QString name, QSpinBox*& value, u16 max,
|
||||||
Qt::Key shortcut_key, QWidget* shortcut_widget, bool invert)
|
Qt::Key shortcut_key, QWidget* shortcut_widget, bool invert)
|
||||||
{
|
{
|
||||||
auto* label = new QLabel(name);
|
const QKeySequence shortcut_key_sequence = QKeySequence(Qt::ALT + shortcut_key);
|
||||||
|
|
||||||
|
auto* label = new QLabel(QStringLiteral("%1 (%2)").arg(
|
||||||
|
name, shortcut_key_sequence.toString(QKeySequence::NativeText)));
|
||||||
|
|
||||||
QBoxLayout* layout = new QHBoxLayout;
|
QBoxLayout* layout = new QHBoxLayout;
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
|
|
||||||
value = CreateSliderValuePair(window, layout, max, shortcut_key, Qt::Horizontal, shortcut_widget,
|
value = CreateSliderValuePair(window, layout, max, shortcut_key_sequence, Qt::Horizontal,
|
||||||
invert);
|
shortcut_widget, invert);
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The shortcut_widget argument needs to specify the container widget that will be hidden/shown.
|
// The shortcut_widget argument needs to specify the container widget that will be hidden/shown.
|
||||||
// This is done to avoid ambigous shortcuts
|
// This is done to avoid ambigous shortcuts
|
||||||
QSpinBox* CreateSliderValuePair(QDialog* window, QBoxLayout* layout, u16 max, Qt::Key shortcut_key,
|
QSpinBox* CreateSliderValuePair(QDialog* window, QBoxLayout* layout, u16 max,
|
||||||
Qt::Orientation orientation, QWidget* shortcut_widget, bool invert)
|
QKeySequence shortcut_key_sequence, Qt::Orientation orientation,
|
||||||
|
QWidget* shortcut_widget, bool invert)
|
||||||
{
|
{
|
||||||
auto* value = new QSpinBox();
|
auto* value = new QSpinBox();
|
||||||
value->setRange(0, 99999);
|
value->setRange(0, 99999);
|
||||||
@ -89,7 +101,7 @@ QSpinBox* CreateSliderValuePair(QDialog* window, QBoxLayout* layout, u16 max, Qt
|
|||||||
window->connect(value, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), slider,
|
window->connect(value, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), slider,
|
||||||
&QSlider::setValue);
|
&QSlider::setValue);
|
||||||
|
|
||||||
auto* shortcut = new QShortcut(QKeySequence(Qt::ALT + shortcut_key), shortcut_widget);
|
auto* shortcut = new QShortcut(shortcut_key_sequence, shortcut_widget);
|
||||||
window->connect(shortcut, &QShortcut::activated, [value] {
|
window->connect(shortcut, &QShortcut::activated, [value] {
|
||||||
value->setFocus();
|
value->setFocus();
|
||||||
value->selectAll();
|
value->selectAll();
|
||||||
|
@ -21,6 +21,6 @@ QGroupBox* CreateStickInputs(QDialog* window, QString name, QSpinBox*& x_value,
|
|||||||
QBoxLayout* CreateSliderValuePairLayout(QDialog* window, QString name, QSpinBox*& value, u16 max,
|
QBoxLayout* CreateSliderValuePairLayout(QDialog* window, QString name, QSpinBox*& value, u16 max,
|
||||||
Qt::Key shortcut_key, QWidget* shortcut_widget,
|
Qt::Key shortcut_key, QWidget* shortcut_widget,
|
||||||
bool invert = false);
|
bool invert = false);
|
||||||
QSpinBox* CreateSliderValuePair(QDialog* window, QBoxLayout* layout, u16 max, Qt::Key shortcut_key,
|
QSpinBox* CreateSliderValuePair(QDialog* window, QBoxLayout* layout, u16 max,
|
||||||
Qt::Orientation orientation, QWidget* shortcut_widget,
|
QKeySequence shortcut_key_sequence, Qt::Orientation orientation,
|
||||||
bool invert = false);
|
QWidget* shortcut_widget, bool invert = false);
|
||||||
|
@ -25,15 +25,21 @@
|
|||||||
|
|
||||||
WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : QDialog(parent), m_num(num)
|
WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : QDialog(parent), m_num(num)
|
||||||
{
|
{
|
||||||
m_ir_box = new QGroupBox(tr("IR") + QStringLiteral(" (ALT+F/G)"));
|
const QKeySequence ir_x_shortcut_key_sequence = QKeySequence(Qt::ALT + Qt::Key_F);
|
||||||
|
const QKeySequence ir_y_shortcut_key_sequence = QKeySequence(Qt::ALT + Qt::Key_G);
|
||||||
|
|
||||||
|
m_ir_box = new QGroupBox(QStringLiteral("%1 (%2/%3)")
|
||||||
|
.arg(tr("IR"),
|
||||||
|
ir_x_shortcut_key_sequence.toString(QKeySequence::NativeText),
|
||||||
|
ir_y_shortcut_key_sequence.toString(QKeySequence::NativeText)));
|
||||||
|
|
||||||
auto* x_layout = new QHBoxLayout;
|
auto* x_layout = new QHBoxLayout;
|
||||||
m_ir_x_value = CreateSliderValuePair(this, x_layout, ir_max_x, Qt::Key_F, Qt::Horizontal,
|
m_ir_x_value = CreateSliderValuePair(this, x_layout, ir_max_x, ir_x_shortcut_key_sequence,
|
||||||
m_ir_box, true);
|
Qt::Horizontal, m_ir_box, true);
|
||||||
|
|
||||||
auto* y_layout = new QVBoxLayout;
|
auto* y_layout = new QVBoxLayout;
|
||||||
m_ir_y_value = CreateSliderValuePair(this, y_layout, ir_max_y, Qt::Key_G, Qt::Vertical,
|
m_ir_y_value = CreateSliderValuePair(this, y_layout, ir_max_y, ir_y_shortcut_key_sequence,
|
||||||
m_ir_box, true);
|
Qt::Vertical, m_ir_box, true);
|
||||||
m_ir_y_value->setMaximumWidth(60);
|
m_ir_y_value->setMaximumWidth(60);
|
||||||
|
|
||||||
auto* visual = new IRWidget(this);
|
auto* visual = new IRWidget(this);
|
||||||
@ -58,17 +64,16 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : QDialog(parent)
|
|||||||
ir_layout->addLayout(visual_layout);
|
ir_layout->addLayout(visual_layout);
|
||||||
m_ir_box->setLayout(ir_layout);
|
m_ir_box->setLayout(ir_layout);
|
||||||
|
|
||||||
m_nunchuk_stick_box = CreateStickInputs(this, tr("Nunchuk Stick") + QStringLiteral(" (ALT+X/Y)"),
|
m_nunchuk_stick_box = CreateStickInputs(this, tr("Nunchuk Stick"), m_nunchuk_stick_x_value,
|
||||||
m_nunchuk_stick_x_value, m_nunchuk_stick_y_value, 255,
|
m_nunchuk_stick_y_value, 255, 255, Qt::Key_X, Qt::Key_Y);
|
||||||
255, Qt::Key_X, Qt::Key_Y);
|
|
||||||
|
|
||||||
m_classic_left_stick_box = CreateStickInputs(
|
m_classic_left_stick_box =
|
||||||
this, tr("Left Stick") + QStringLiteral(" (ALT+F/G)"), m_classic_left_stick_x_value,
|
CreateStickInputs(this, tr("Left Stick"), m_classic_left_stick_x_value,
|
||||||
m_classic_left_stick_y_value, 63, 63, Qt::Key_F, Qt::Key_G);
|
m_classic_left_stick_y_value, 63, 63, Qt::Key_F, Qt::Key_G);
|
||||||
|
|
||||||
m_classic_right_stick_box = CreateStickInputs(
|
m_classic_right_stick_box =
|
||||||
this, tr("Right Stick") + QStringLiteral(" (ALT+Q/W)"), m_classic_right_stick_x_value,
|
CreateStickInputs(this, tr("Right Stick"), m_classic_right_stick_x_value,
|
||||||
m_classic_right_stick_y_value, 31, 31, Qt::Key_Q, Qt::Key_W);
|
m_classic_right_stick_y_value, 31, 31, Qt::Key_Q, Qt::Key_W);
|
||||||
|
|
||||||
// Need to enforce the same minimum width because otherwise the different lengths in the labels
|
// Need to enforce the same minimum width because otherwise the different lengths in the labels
|
||||||
// used on the QGroupBox will cause the StickWidgets to have different sizes.
|
// used on the QGroupBox will cause the StickWidgets to have different sizes.
|
||||||
@ -85,18 +90,15 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : QDialog(parent)
|
|||||||
|
|
||||||
auto* remote_orientation_x_layout =
|
auto* remote_orientation_x_layout =
|
||||||
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
||||||
CreateSliderValuePairLayout(this, tr("X") + QStringLiteral(" (ALT+Q)"),
|
CreateSliderValuePairLayout(this, tr("X"), m_remote_orientation_x_value, 1023, Qt::Key_Q,
|
||||||
m_remote_orientation_x_value, 1023, Qt::Key_Q,
|
|
||||||
m_remote_orientation_box);
|
m_remote_orientation_box);
|
||||||
auto* remote_orientation_y_layout =
|
auto* remote_orientation_y_layout =
|
||||||
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
||||||
CreateSliderValuePairLayout(this, tr("Y") + QStringLiteral(" (ALT+W)"),
|
CreateSliderValuePairLayout(this, tr("Y"), m_remote_orientation_y_value, 1023, Qt::Key_W,
|
||||||
m_remote_orientation_y_value, 1023, Qt::Key_W,
|
|
||||||
m_remote_orientation_box);
|
m_remote_orientation_box);
|
||||||
auto* remote_orientation_z_layout =
|
auto* remote_orientation_z_layout =
|
||||||
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
||||||
CreateSliderValuePairLayout(this, tr("Z") + QStringLiteral(" (ALT+E)"),
|
CreateSliderValuePairLayout(this, tr("Z"), m_remote_orientation_z_value, 1023, Qt::Key_E,
|
||||||
m_remote_orientation_z_value, 1023, Qt::Key_E,
|
|
||||||
m_remote_orientation_box);
|
m_remote_orientation_box);
|
||||||
|
|
||||||
auto* remote_orientation_layout = new QVBoxLayout;
|
auto* remote_orientation_layout = new QVBoxLayout;
|
||||||
@ -109,18 +111,15 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : QDialog(parent)
|
|||||||
|
|
||||||
auto* nunchuk_orientation_x_layout =
|
auto* nunchuk_orientation_x_layout =
|
||||||
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
||||||
CreateSliderValuePairLayout(this, tr("X") + QStringLiteral(" (ALT+I)"),
|
CreateSliderValuePairLayout(this, tr("X"), m_nunchuk_orientation_x_value, 1023, Qt::Key_I,
|
||||||
m_nunchuk_orientation_x_value, 1023, Qt::Key_I,
|
|
||||||
m_nunchuk_orientation_box);
|
m_nunchuk_orientation_box);
|
||||||
auto* nunchuk_orientation_y_layout =
|
auto* nunchuk_orientation_y_layout =
|
||||||
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
||||||
CreateSliderValuePairLayout(this, tr("Y") + QStringLiteral(" (ALT+O)"),
|
CreateSliderValuePairLayout(this, tr("Y"), m_nunchuk_orientation_y_value, 1023, Qt::Key_O,
|
||||||
m_nunchuk_orientation_y_value, 1023, Qt::Key_O,
|
|
||||||
m_nunchuk_orientation_box);
|
m_nunchuk_orientation_box);
|
||||||
auto* nunchuk_orientation_z_layout =
|
auto* nunchuk_orientation_z_layout =
|
||||||
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
||||||
CreateSliderValuePairLayout(this, tr("Z") + QStringLiteral(" (ALT+P)"),
|
CreateSliderValuePairLayout(this, tr("Z"), m_nunchuk_orientation_z_value, 1023, Qt::Key_P,
|
||||||
m_nunchuk_orientation_z_value, 1023, Qt::Key_P,
|
|
||||||
m_nunchuk_orientation_box);
|
m_nunchuk_orientation_box);
|
||||||
|
|
||||||
auto* nunchuk_orientation_layout = new QVBoxLayout;
|
auto* nunchuk_orientation_layout = new QVBoxLayout;
|
||||||
@ -130,12 +129,10 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : QDialog(parent)
|
|||||||
m_nunchuk_orientation_box->setLayout(nunchuk_orientation_layout);
|
m_nunchuk_orientation_box->setLayout(nunchuk_orientation_layout);
|
||||||
|
|
||||||
m_triggers_box = new QGroupBox(tr("Triggers"));
|
m_triggers_box = new QGroupBox(tr("Triggers"));
|
||||||
auto* l_trigger_layout =
|
auto* l_trigger_layout = CreateSliderValuePairLayout(this, tr("Left"), m_left_trigger_value, 31,
|
||||||
CreateSliderValuePairLayout(this, tr("Left") + QStringLiteral(" (ALT+N)"),
|
Qt::Key_N, m_triggers_box);
|
||||||
m_left_trigger_value, 31, Qt::Key_N, m_triggers_box);
|
auto* r_trigger_layout = CreateSliderValuePairLayout(this, tr("Right"), m_right_trigger_value, 31,
|
||||||
auto* r_trigger_layout =
|
Qt::Key_M, m_triggers_box);
|
||||||
CreateSliderValuePairLayout(this, tr("Right") + QStringLiteral(" (ALT+M)"),
|
|
||||||
m_right_trigger_value, 31, Qt::Key_M, m_triggers_box);
|
|
||||||
|
|
||||||
auto* triggers_layout = new QVBoxLayout;
|
auto* triggers_layout = new QVBoxLayout;
|
||||||
triggers_layout->addLayout(l_trigger_layout);
|
triggers_layout->addLayout(l_trigger_layout);
|
||||||
|
Reference in New Issue
Block a user