summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h
blob: 0432286e01aa2fdbf2fff1f7ac2a73d242ad8c32 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <QDialog>
#include <QString>
#include <memory>

#include "InputCommon/ControllerInterface/Device.h"

namespace ControllerEmu
{
class EmulatedController;
}

class InputConfig;
class QCheckBox;
class QComboBox;
class QDialogButtonBox;
class QEvent;
class QHBoxLayout;
class QGroupBox;
class QVBoxLayout;
class QPushButton;
class QTabWidget;
class QWidget;

class MappingWindow final : public QDialog
{
  Q_OBJECT
public:
  enum class Type
  {
    // GameCube
    MAPPING_GC_BONGOS,
    MAPPING_GC_DANCEMAT,
    MAPPING_GC_KEYBOARD,
    MAPPING_GCPAD,
    MAPPING_GC_STEERINGWHEEL,
    MAPPING_GC_MICROPHONE,
    // Wii
    MAPPING_WIIMOTE_EMU,
    // Hotkeys
    MAPPING_HOTKEYS
  };

  explicit MappingWindow(QWidget* parent, Type type, int port_num);

  int GetPort() const;
  std::shared_ptr<ciface::Core::Device> GetDevice() const;
  ControllerEmu::EmulatedController* GetController() const;
  bool IsIterativeInput() const;
  bool IsMappingAllDevices() const;

signals:
  void Update();
  void ClearFields();
  void Save();

private:
  void SetMappingType(Type type);
  void CreateDevicesLayout();
  void CreateProfilesLayout();
  void CreateResetLayout();
  void CreateMainLayout();
  void ConnectWidgets();

  void AddWidget(const QString& name, QWidget* widget);

  void RefreshDevices();

  void OnDeleteProfilePressed();
  void OnLoadProfilePressed();
  void OnSaveProfilePressed();
  void OnDefaultFieldsPressed();
  void OnDeviceChanged(int index);
  void OnGlobalDevicesChanged();

  ControllerEmu::EmulatedController* m_controller = nullptr;

  // Main
  QCheckBox* m_iterative_input;
  QVBoxLayout* m_main_layout;
  QHBoxLayout* m_config_layout;
  QDialogButtonBox* m_button_box;

  // Devices
  QGroupBox* m_devices_box;
  QHBoxLayout* m_devices_layout;
  QComboBox* m_devices_combo;
  QPushButton* m_devices_refresh;

  // Profiles
  QGroupBox* m_profiles_box;
  QHBoxLayout* m_profiles_layout;
  QComboBox* m_profiles_combo;
  QPushButton* m_profiles_load;
  QPushButton* m_profiles_save;
  QPushButton* m_profiles_delete;

  // Reset
  QGroupBox* m_reset_box;
  QHBoxLayout* m_reset_layout;
  QPushButton* m_reset_default;
  QPushButton* m_reset_clear;

  QTabWidget* m_tab_widget;

  Type m_mapping_type;
  const int m_port;
  InputConfig* m_config;
};