GBATASInputWindow.cpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 2022 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "DolphinQt/TAS/GBATASInputWindow.h"
  4. #include <QCheckBox>
  5. #include <QGridLayout>
  6. #include <QGroupBox>
  7. #include <QHBoxLayout>
  8. #include <QSpacerItem>
  9. #include <QSpinBox>
  10. #include <QVBoxLayout>
  11. #include "Common/CommonTypes.h"
  12. #include "Core/HW/GBAPad.h"
  13. #include "Core/HW/GBAPadEmu.h"
  14. #include "DolphinQt/TAS/TASCheckBox.h"
  15. #include "InputCommon/ControllerEmu/ControllerEmu.h"
  16. #include "InputCommon/InputConfig.h"
  17. GBATASInputWindow::GBATASInputWindow(QWidget* parent, int controller_id)
  18. : TASInputWindow(parent), m_controller_id(controller_id)
  19. {
  20. setWindowTitle(tr("GBA TAS Input %1").arg(controller_id + 1));
  21. m_b_button =
  22. CreateButton(QStringLiteral("&B"), GBAPad::BUTTONS_GROUP, GBAPad::B_BUTTON, &m_overrider);
  23. m_a_button =
  24. CreateButton(QStringLiteral("&A"), GBAPad::BUTTONS_GROUP, GBAPad::A_BUTTON, &m_overrider);
  25. m_l_button =
  26. CreateButton(QStringLiteral("&L"), GBAPad::BUTTONS_GROUP, GBAPad::L_BUTTON, &m_overrider);
  27. m_r_button =
  28. CreateButton(QStringLiteral("&R"), GBAPad::BUTTONS_GROUP, GBAPad::R_BUTTON, &m_overrider);
  29. m_select_button = CreateButton(QStringLiteral("SELE&CT"), GBAPad::BUTTONS_GROUP,
  30. GBAPad::SELECT_BUTTON, &m_overrider);
  31. m_start_button = CreateButton(QStringLiteral("&START"), GBAPad::BUTTONS_GROUP,
  32. GBAPad::START_BUTTON, &m_overrider);
  33. m_left_button =
  34. CreateButton(QStringLiteral("L&eft"), GBAPad::DPAD_GROUP, DIRECTION_LEFT, &m_overrider);
  35. m_up_button = CreateButton(QStringLiteral("&Up"), GBAPad::DPAD_GROUP, DIRECTION_UP, &m_overrider);
  36. m_down_button =
  37. CreateButton(QStringLiteral("&Down"), GBAPad::DPAD_GROUP, DIRECTION_DOWN, &m_overrider);
  38. m_right_button =
  39. CreateButton(QStringLiteral("R&ight"), GBAPad::DPAD_GROUP, DIRECTION_RIGHT, &m_overrider);
  40. auto* buttons_layout = new QGridLayout;
  41. buttons_layout->addWidget(m_left_button, 0, 0);
  42. buttons_layout->addWidget(m_up_button, 0, 1);
  43. buttons_layout->addWidget(m_down_button, 0, 2);
  44. buttons_layout->addWidget(m_right_button, 0, 3);
  45. buttons_layout->addWidget(m_l_button, 1, 0);
  46. buttons_layout->addWidget(m_r_button, 1, 1);
  47. buttons_layout->addWidget(m_b_button, 1, 2);
  48. buttons_layout->addWidget(m_a_button, 1, 3);
  49. buttons_layout->addWidget(m_select_button, 2, 0, 1, 2);
  50. buttons_layout->addWidget(m_start_button, 2, 2, 1, 2);
  51. buttons_layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding), 0, 4);
  52. QGroupBox* buttons_box = new QGroupBox(tr("Buttons"));
  53. buttons_box->setLayout(buttons_layout);
  54. auto* layout = new QVBoxLayout;
  55. layout->addWidget(buttons_box);
  56. layout->addWidget(m_settings_box);
  57. setLayout(layout);
  58. }
  59. void GBATASInputWindow::hideEvent(QHideEvent* event)
  60. {
  61. Pad::GetGBAConfig()->GetController(m_controller_id)->ClearInputOverrideFunction();
  62. }
  63. void GBATASInputWindow::showEvent(QShowEvent* event)
  64. {
  65. Pad::GetGBAConfig()
  66. ->GetController(m_controller_id)
  67. ->SetInputOverrideFunction(m_overrider.GetInputOverrideFunction());
  68. }