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
|
// Copyright 2018 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <map>
#include <optional>
#include <string_view>
#include <utility>
#include <QDialog>
#include "Common/CommonTypes.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerInterface/CoreDevice.h"
class QCheckBox;
class QDialog;
class QEvent;
class QGridLayout;
class QGroupBox;
class QLayout;
class QSpinBox;
class QString;
class QWidget;
class TASCheckBox;
class TASSpinBox;
class InputOverrider final
{
public:
using OverrideFunction = std::function<std::optional<ControlState>(ControlState)>;
void AddFunction(std::string_view group_name, std::string_view control_name,
OverrideFunction function);
ControllerEmu::InputOverrideFunction GetInputOverrideFunction() const;
private:
std::map<std::pair<std::string_view, std::string_view>, OverrideFunction> m_functions;
};
class TASInputWindow : public QDialog
{
Q_OBJECT
public:
explicit TASInputWindow(QWidget* parent);
int GetTurboPressFrames() const;
int GetTurboReleaseFrames() const;
protected:
TASCheckBox* CreateButton(const QString& text, std::string_view group_name,
std::string_view control_name, InputOverrider* overrider);
QGroupBox* CreateStickInputs(const QString& text, std::string_view group_name,
InputOverrider* overrider, int min_x, int min_y, int max_x,
int max_y, Qt::Key x_shortcut_key, Qt::Key y_shortcut_key);
QGridLayout* CreateSliderValuePairLayout(const QString& text, std::string_view group_name,
std::string_view control_name, InputOverrider* overrider,
int zero, int default_, int min, int max,
Qt::Key shortcut_key, QWidget* shortcut_widget,
std::optional<ControlState> scale = {});
TASSpinBox* CreateSliderValuePair(std::string_view group_name, std::string_view control_name,
InputOverrider* overrider, QGridLayout* layout, int zero,
int default_, int min, int max,
const QKeySequence& shortcut_key_sequence,
Qt::Orientation orientation, QWidget* shortcut_widget,
std::optional<ControlState> scale = {});
TASSpinBox* CreateSliderValuePair(QGridLayout* layout, int default_, int max,
const QKeySequence& shortcut_key_sequence,
Qt::Orientation orientation, QWidget* shortcut_widget);
void SetupScrollArea(QLayout* layout);
void changeEvent(QEvent* event) override;
QWidget* m_scroll_widget;
QGroupBox* m_settings_box;
QCheckBox* m_use_controller;
QSpinBox* m_turbo_press_frames;
QSpinBox* m_turbo_release_frames;
private:
std::optional<ControlState> GetButton(TASCheckBox* checkbox, ControlState controller_state);
std::optional<ControlState> GetSpinBox(TASSpinBox* spin, int zero, int min, int max,
ControlState controller_state);
std::optional<ControlState> GetSpinBox(TASSpinBox* spin, int zero, ControlState controller_state,
ControlState scale);
};
|