summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/Mapping/GCKeyboardEmu.cpp
blob: 872f3f1aa5dd94e56120c4161cb9e4561cef43c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "DolphinQt/Config/Mapping/GCKeyboardEmu.h"

#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QStyle>
#include <QVBoxLayout>

#include "InputCommon/InputConfig.h"

#include "Core/HW/GCKeyboard.h"
#include "Core/HW/GCKeyboardEmu.h"

#include "DolphinQt/QtUtils/QtUtils.h"

GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window)
{
  CreateMainLayout();
}

void GCKeyboardEmu::CreateMainLayout()
{
  auto* const vbox_layout = new QVBoxLayout{this};

  auto* const warning_text =
      new QLabel(tr("You are configuring a \"Keyboard Controller\". "
                    "This device is exclusively for \"Phantasy Star Online Episode I & II\". "
                    "If you are unsure, turn back now and configure a \"Standard Controller\"."));
  warning_text->setWordWrap(true);

  vbox_layout->addWidget(
      QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, warning_text));

  auto* const layout = new QHBoxLayout;

  using KG = KeyboardGroup;
  for (auto kbg : {KG::Kb0x, KG::Kb1x, KG::Kb2x, KG::Kb3x, KG::Kb4x, KG::Kb5x})
    layout->addWidget(CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), kbg)));

  vbox_layout->addLayout(layout);
}

void GCKeyboardEmu::LoadSettings()
{
  Keyboard::LoadConfig();
}

void GCKeyboardEmu::SaveSettings()
{
  Keyboard::GetConfig()->SaveConfig();
}

InputConfig* GCKeyboardEmu::GetConfig()
{
  return Keyboard::GetConfig();
}