| 1 | // Copyright 2017 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/Config/Mapping/GCKeyboardEmu.h" |
| 5 | |
| 6 | #include <QFormLayout> |
| 7 | #include <QGroupBox> |
| 8 | #include <QHBoxLayout> |
| 9 | #include <QLabel> |
| 10 | #include <QStyle> |
| 11 | #include <QVBoxLayout> |
| 12 | |
| 13 | #include "InputCommon/InputConfig.h" |
| 14 | |
| 15 | #include "Core/HW/GCKeyboard.h" |
| 16 | #include "Core/HW/GCKeyboardEmu.h" |
| 17 | |
| 18 | #include "DolphinQt/QtUtils/QtUtils.h" |
| 19 | |
| 20 | GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window) |
| 21 | { |
| 22 | CreateMainLayout(); |
| 23 | } |
| 24 | |
| 25 | void GCKeyboardEmu::CreateMainLayout() |
| 26 | { |
| 27 | auto* const vbox_layout = new QVBoxLayout{this}; |
| 28 | |
| 29 | auto* const warning_text = |
| 30 | new QLabel(tr("You are configuring a \"Keyboard Controller\". " |
| 31 | "This device is exclusively for \"Phantasy Star Online Episode I & II\". " |
| 32 | "If you are unsure, turn back now and configure a \"Standard Controller\".")); |
| 33 | warning_text->setWordWrap(true); |
| 34 | |
| 35 | vbox_layout->addWidget( |
| 36 | QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, warning_text)); |
| 37 | |
| 38 | auto* const layout = new QHBoxLayout; |
| 39 | |
| 40 | using KG = KeyboardGroup; |
| 41 | for (auto kbg : {KG::Kb0x, KG::Kb1x, KG::Kb2x, KG::Kb3x, KG::Kb4x, KG::Kb5x}) |
| 42 | layout->addWidget(CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), kbg))); |
| 43 | |
| 44 | vbox_layout->addLayout(layout); |
| 45 | } |
| 46 | |
| 47 | void GCKeyboardEmu::LoadSettings() |
| 48 | { |
| 49 | Keyboard::LoadConfig(); |
| 50 | } |
| 51 | |
| 52 | void GCKeyboardEmu::SaveSettings() |
| 53 | { |
| 54 | Keyboard::GetConfig()->SaveConfig(); |
| 55 | } |
| 56 | |
| 57 | InputConfig* GCKeyboardEmu::GetConfig() |
| 58 | { |
| 59 | return Keyboard::GetConfig(); |
| 60 | } |