mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
DolphinQt: Add GBA TAS input window
When emulated GBAs were added to Dolphin, it was possible to control them
using the GC TAS input window. (Z was mapped to Select.) Unaware of this,
I broke the functionality in b296248
.
To make it possible to control emulated GBAs using TAS input again,
I'm adding a proper TAS input window for GBAs, with a real Select button
and no analog controls.
This commit is contained in:
86
Source/Core/DolphinQt/TAS/GBATASInputWindow.cpp
Normal file
86
Source/Core/DolphinQt/TAS/GBATASInputWindow.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
// Copyright 2022 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "DolphinQt/TAS/GBATASInputWindow.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QSpacerItem>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "Core/HW/GBAPad.h"
|
||||
#include "Core/HW/GBAPadEmu.h"
|
||||
|
||||
#include "DolphinQt/TAS/TASCheckBox.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
GBATASInputWindow::GBATASInputWindow(QWidget* parent, int controller_id)
|
||||
: TASInputWindow(parent), m_controller_id(controller_id)
|
||||
{
|
||||
setWindowTitle(tr("GBA TAS Input %1").arg(controller_id + 1));
|
||||
|
||||
m_b_button =
|
||||
CreateButton(QStringLiteral("&B"), GBAPad::BUTTONS_GROUP, GBAPad::B_BUTTON, &m_overrider);
|
||||
m_a_button =
|
||||
CreateButton(QStringLiteral("&A"), GBAPad::BUTTONS_GROUP, GBAPad::A_BUTTON, &m_overrider);
|
||||
m_l_button =
|
||||
CreateButton(QStringLiteral("&L"), GBAPad::BUTTONS_GROUP, GBAPad::L_BUTTON, &m_overrider);
|
||||
m_r_button =
|
||||
CreateButton(QStringLiteral("&R"), GBAPad::BUTTONS_GROUP, GBAPad::R_BUTTON, &m_overrider);
|
||||
m_select_button = CreateButton(QStringLiteral("SELE&CT"), GBAPad::BUTTONS_GROUP,
|
||||
GBAPad::SELECT_BUTTON, &m_overrider);
|
||||
m_start_button = m_start_button = CreateButton(QStringLiteral("&START"), GBAPad::BUTTONS_GROUP,
|
||||
GBAPad::START_BUTTON, &m_overrider);
|
||||
|
||||
m_left_button =
|
||||
CreateButton(QStringLiteral("L&eft"), GBAPad::DPAD_GROUP, DIRECTION_LEFT, &m_overrider);
|
||||
m_up_button = CreateButton(QStringLiteral("&Up"), GBAPad::DPAD_GROUP, DIRECTION_UP, &m_overrider);
|
||||
m_down_button =
|
||||
CreateButton(QStringLiteral("&Down"), GBAPad::DPAD_GROUP, DIRECTION_DOWN, &m_overrider);
|
||||
m_right_button =
|
||||
CreateButton(QStringLiteral("R&ight"), GBAPad::DPAD_GROUP, DIRECTION_RIGHT, &m_overrider);
|
||||
|
||||
auto* buttons_layout = new QGridLayout;
|
||||
|
||||
buttons_layout->addWidget(m_left_button, 0, 0);
|
||||
buttons_layout->addWidget(m_up_button, 0, 1);
|
||||
buttons_layout->addWidget(m_down_button, 0, 2);
|
||||
buttons_layout->addWidget(m_right_button, 0, 3);
|
||||
|
||||
buttons_layout->addWidget(m_l_button, 1, 0);
|
||||
buttons_layout->addWidget(m_r_button, 1, 1);
|
||||
buttons_layout->addWidget(m_b_button, 1, 2);
|
||||
buttons_layout->addWidget(m_a_button, 1, 3);
|
||||
|
||||
buttons_layout->addWidget(m_select_button, 2, 0, 1, 2);
|
||||
buttons_layout->addWidget(m_start_button, 2, 2, 1, 2);
|
||||
|
||||
buttons_layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding), 0, 4);
|
||||
|
||||
QGroupBox* buttons_box = new QGroupBox(tr("Buttons"));
|
||||
buttons_box->setLayout(buttons_layout);
|
||||
|
||||
auto* layout = new QVBoxLayout;
|
||||
layout->addWidget(buttons_box);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void GBATASInputWindow::hideEvent(QHideEvent* event)
|
||||
{
|
||||
Pad::GetGBAConfig()->GetController(m_controller_id)->ClearInputOverrideFunction();
|
||||
}
|
||||
|
||||
void GBATASInputWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
Pad::GetGBAConfig()
|
||||
->GetController(m_controller_id)
|
||||
->SetInputOverrideFunction(m_overrider.GetInputOverrideFunction());
|
||||
}
|
39
Source/Core/DolphinQt/TAS/GBATASInputWindow.h
Normal file
39
Source/Core/DolphinQt/TAS/GBATASInputWindow.h
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright 2022 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DolphinQt/TAS/TASInputWindow.h"
|
||||
|
||||
class QGroupBox;
|
||||
class QHideEvent;
|
||||
class QShowEvent;
|
||||
class QSpinBox;
|
||||
class TASCheckBox;
|
||||
|
||||
class GBATASInputWindow final : public TASInputWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GBATASInputWindow(QWidget* parent, int controller_id);
|
||||
|
||||
void hideEvent(QHideEvent* event) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
private:
|
||||
int m_controller_id;
|
||||
|
||||
InputOverrider m_overrider;
|
||||
|
||||
TASCheckBox* m_b_button;
|
||||
TASCheckBox* m_a_button;
|
||||
TASCheckBox* m_l_button;
|
||||
TASCheckBox* m_r_button;
|
||||
TASCheckBox* m_select_button;
|
||||
TASCheckBox* m_start_button;
|
||||
|
||||
TASCheckBox* m_left_button;
|
||||
TASCheckBox* m_up_button;
|
||||
TASCheckBox* m_down_button;
|
||||
TASCheckBox* m_right_button;
|
||||
};
|
Reference in New Issue
Block a user