summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/Mapping/GCKeyboardEmu.cpp
blob: 9078cd0172c22e2e111d7f076ac918a2ea9fc279 (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
61
62
63
64
65
66
// 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"

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

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

  const auto warning_layout = new QHBoxLayout;
  vbox_layout->addLayout(warning_layout);

  const auto warning_icon = new QLabel;
  const auto size = QFontMetrics(font()).height() * 3 / 2;
  warning_icon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size));
  warning_layout->addWidget(warning_icon);

  const auto 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);
  warning_layout->addWidget(warning_text, 1);

  const auto 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);

  setLayout(vbox_layout);
}

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

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

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