dolphin/Source/Core/DolphinQt/TAS/GCTASInputWindow.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

124 lines
4.4 KiB
C++
Raw Normal View History

2018-01-27 13:35:02 +00:00
// Copyright 2018 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2018-01-27 13:35:02 +00:00
2018-07-06 22:40:15 +00:00
#include "DolphinQt/TAS/GCTASInputWindow.h"
2018-01-27 13:35:02 +00:00
#include <QCheckBox>
2019-03-26 00:18:11 +00:00
#include <QGridLayout>
2018-01-27 13:35:02 +00:00
#include <QGroupBox>
#include <QHBoxLayout>
2019-03-26 00:18:11 +00:00
#include <QSpacerItem>
2018-01-31 11:35:09 +00:00
#include <QSpinBox>
2018-01-27 13:35:02 +00:00
#include <QVBoxLayout>
2018-02-06 11:10:28 +00:00
#include "Common/CommonTypes.h"
2018-05-28 01:48:04 +00:00
2019-03-31 02:49:57 +00:00
#include "DolphinQt/TAS/TASCheckBox.h"
2018-02-06 11:10:28 +00:00
#include "InputCommon/GCPadStatus.h"
GCTASInputWindow::GCTASInputWindow(QWidget* parent, int num) : TASInputWindow(parent)
2018-01-27 13:35:02 +00:00
{
2018-01-31 11:35:09 +00:00
setWindowTitle(tr("GameCube TAS Input %1").arg(num + 1));
2018-05-05 00:29:16 +00:00
m_main_stick_box = CreateStickInputs(tr("Main Stick"), m_x_main_stick_value, m_y_main_stick_value,
255, 255, Qt::Key_F, Qt::Key_G);
m_c_stick_box = CreateStickInputs(tr("C Stick"), m_x_c_stick_value, m_y_c_stick_value, 255, 255,
Qt::Key_H, Qt::Key_J);
2018-01-27 13:35:02 +00:00
auto* top_layout = new QHBoxLayout;
top_layout->addWidget(m_main_stick_box);
top_layout->addWidget(m_c_stick_box);
2018-01-27 13:35:02 +00:00
m_triggers_box = new QGroupBox(tr("Triggers"));
2018-01-27 13:35:02 +00:00
auto* l_trigger_layout =
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);
2018-01-27 13:35:02 +00:00
2018-01-31 11:35:09 +00:00
auto* triggers_layout = new QVBoxLayout;
triggers_layout->addLayout(l_trigger_layout);
triggers_layout->addLayout(r_trigger_layout);
m_triggers_box->setLayout(triggers_layout);
2018-01-27 13:35:02 +00:00
m_a_button = CreateButton(QStringLiteral("&A"));
m_b_button = CreateButton(QStringLiteral("&B"));
m_x_button = CreateButton(QStringLiteral("&X"));
m_y_button = CreateButton(QStringLiteral("&Y"));
m_z_button = CreateButton(QStringLiteral("&Z"));
m_l_button = CreateButton(QStringLiteral("&L"));
m_r_button = CreateButton(QStringLiteral("&R"));
m_start_button = CreateButton(QStringLiteral("&START"));
m_left_button = CreateButton(QStringLiteral("L&eft"));
m_up_button = CreateButton(QStringLiteral("&Up"));
m_down_button = CreateButton(QStringLiteral("&Down"));
m_right_button = CreateButton(QStringLiteral("R&ight"));
2018-01-27 13:35:02 +00:00
2019-03-26 00:18:11 +00:00
auto* buttons_layout = new QGridLayout;
buttons_layout->addWidget(m_a_button, 0, 0);
buttons_layout->addWidget(m_b_button, 0, 1);
buttons_layout->addWidget(m_x_button, 0, 2);
buttons_layout->addWidget(m_y_button, 0, 3);
buttons_layout->addWidget(m_z_button, 0, 4);
buttons_layout->addWidget(m_l_button, 0, 5);
buttons_layout->addWidget(m_r_button, 0, 6);
buttons_layout->addWidget(m_start_button, 1, 0);
buttons_layout->addWidget(m_left_button, 1, 1);
buttons_layout->addWidget(m_up_button, 1, 2);
buttons_layout->addWidget(m_down_button, 1, 3);
buttons_layout->addWidget(m_right_button, 1, 4);
buttons_layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding), 0, 7);
2018-01-27 13:35:02 +00:00
m_buttons_box = new QGroupBox(tr("Buttons"));
m_buttons_box->setLayout(buttons_layout);
2018-01-27 13:35:02 +00:00
auto* layout = new QVBoxLayout;
layout->addLayout(top_layout);
layout->addWidget(m_triggers_box);
layout->addWidget(m_buttons_box);
layout->addWidget(m_settings_box);
2018-01-27 13:35:02 +00:00
setLayout(layout);
}
void GCTASInputWindow::GetValues(GCPadStatus* pad)
{
if (!isVisible())
return;
GetButton<u16>(m_a_button, pad->button, PAD_BUTTON_A);
GetButton<u16>(m_b_button, pad->button, PAD_BUTTON_B);
GetButton<u16>(m_x_button, pad->button, PAD_BUTTON_X);
GetButton<u16>(m_y_button, pad->button, PAD_BUTTON_Y);
GetButton<u16>(m_z_button, pad->button, PAD_TRIGGER_Z);
GetButton<u16>(m_l_button, pad->button, PAD_TRIGGER_L);
GetButton<u16>(m_r_button, pad->button, PAD_TRIGGER_R);
GetButton<u16>(m_left_button, pad->button, PAD_BUTTON_LEFT);
GetButton<u16>(m_up_button, pad->button, PAD_BUTTON_UP);
GetButton<u16>(m_down_button, pad->button, PAD_BUTTON_DOWN);
GetButton<u16>(m_right_button, pad->button, PAD_BUTTON_RIGHT);
GetButton<u16>(m_start_button, pad->button, PAD_BUTTON_START);
2018-01-27 13:35:02 +00:00
if (m_a_button->isChecked())
pad->analogA = 0xFF;
else
pad->analogA = 0x00;
if (m_b_button->isChecked())
pad->analogB = 0xFF;
else
pad->analogB = 0x00;
GetSpinBoxU8(m_l_trigger_value, pad->triggerLeft);
GetSpinBoxU8(m_r_trigger_value, pad->triggerRight);
GetSpinBoxU8(m_x_main_stick_value, pad->stickX);
GetSpinBoxU8(m_y_main_stick_value, pad->stickY);
2018-01-27 13:35:02 +00:00
GetSpinBoxU8(m_x_c_stick_value, pad->substickX);
GetSpinBoxU8(m_y_c_stick_value, pad->substickY);
2018-01-27 13:35:02 +00:00
}