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

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

119 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
#include "Core/HW/GCPad.h"
#include "Core/HW/GCPadEmu.h"
2019-03-31 02:49:57 +00:00
#include "DolphinQt/TAS/TASCheckBox.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/InputConfig.h"
2018-02-06 11:10:28 +00:00
GCTASInputWindow::GCTASInputWindow(QWidget* parent, int controller_id)
: TASInputWindow(parent), m_controller_id(controller_id)
2018-01-27 13:35:02 +00:00
{
setWindowTitle(tr("GameCube TAS Input %1").arg(controller_id + 1));
2018-05-05 00:29:16 +00:00
m_main_stick_box = CreateStickInputs(tr("Main Stick"), GCPad::MAIN_STICK_GROUP, &m_overrider, 1,
1, 255, 255, Qt::Key_F, Qt::Key_G);
m_c_stick_box = CreateStickInputs(tr("C Stick"), GCPad::C_STICK_GROUP, &m_overrider, 1, 1, 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"), GCPad::TRIGGERS_GROUP, GCPad::L_ANALOG, &m_overrider,
0, 0, 0, 255, Qt::Key_N, m_triggers_box);
auto* r_trigger_layout =
CreateSliderValuePairLayout(tr("Right"), GCPad::TRIGGERS_GROUP, GCPad::R_ANALOG, &m_overrider,
0, 0, 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"), GCPad::BUTTONS_GROUP, GCPad::A_BUTTON, &m_overrider);
m_b_button =
CreateButton(QStringLiteral("&B"), GCPad::BUTTONS_GROUP, GCPad::B_BUTTON, &m_overrider);
m_x_button =
CreateButton(QStringLiteral("&X"), GCPad::BUTTONS_GROUP, GCPad::X_BUTTON, &m_overrider);
m_y_button =
CreateButton(QStringLiteral("&Y"), GCPad::BUTTONS_GROUP, GCPad::Y_BUTTON, &m_overrider);
m_z_button =
CreateButton(QStringLiteral("&Z"), GCPad::BUTTONS_GROUP, GCPad::Z_BUTTON, &m_overrider);
m_start_button = CreateButton(QStringLiteral("&START"), GCPad::BUTTONS_GROUP, GCPad::START_BUTTON,
&m_overrider);
m_l_button =
CreateButton(QStringLiteral("&L"), GCPad::TRIGGERS_GROUP, GCPad::L_DIGITAL, &m_overrider);
m_r_button =
CreateButton(QStringLiteral("&R"), GCPad::TRIGGERS_GROUP, GCPad::R_DIGITAL, &m_overrider);
m_left_button =
CreateButton(QStringLiteral("L&eft"), GCPad::DPAD_GROUP, DIRECTION_LEFT, &m_overrider);
m_up_button = CreateButton(QStringLiteral("&Up"), GCPad::DPAD_GROUP, DIRECTION_UP, &m_overrider);
m_down_button =
CreateButton(QStringLiteral("&Down"), GCPad::DPAD_GROUP, DIRECTION_DOWN, &m_overrider);
m_right_button =
CreateButton(QStringLiteral("R&ight"), GCPad::DPAD_GROUP, DIRECTION_RIGHT, &m_overrider);
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::hideEvent(QHideEvent* event)
{
Pad::GetConfig()->GetController(m_controller_id)->ClearInputOverrideFunction();
}
void GCTASInputWindow::showEvent(QShowEvent* event)
2018-01-27 13:35:02 +00:00
{
Pad::GetConfig()
->GetController(m_controller_id)
->SetInputOverrideFunction(m_overrider.GetInputOverrideFunction());
2018-01-27 13:35:02 +00:00
}