| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <map> |
| 7 |
#include <optional> |
| 8 |
#include <string_view> |
| 9 |
#include <utility> |
| 10 |
|
| 11 |
#include <QDialog> |
| 12 |
|
| 13 |
#include "Common/CommonTypes.h" |
| 14 |
|
| 15 |
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" |
| 16 |
#include "InputCommon/ControllerInterface/CoreDevice.h" |
| 17 |
|
| 18 |
class QCheckBox; |
| 19 |
class QDialog; |
| 20 |
class QEvent; |
| 21 |
class QGridLayout; |
| 22 |
class QGroupBox; |
| 23 |
class QLayout; |
| 24 |
class QSpinBox; |
| 25 |
class QString; |
| 26 |
class QWidget; |
| 27 |
class TASCheckBox; |
| 28 |
class TASSpinBox; |
| 29 |
|
| 30 |
class InputOverrider final |
| 31 |
{ |
| 32 |
public: |
| 33 |
using OverrideFunction = std::function<std::optional<ControlState>(ControlState)>; |
| 34 |
|
| 35 |
void AddFunction(std::string_view group_name, std::string_view control_name, |
| 36 |
OverrideFunction function); |
| 37 |
|
| 38 |
ControllerEmu::InputOverrideFunction GetInputOverrideFunction() const; |
| 39 |
|
| 40 |
private: |
| 41 |
std::map<std::pair<std::string_view, std::string_view>, OverrideFunction> m_functions; |
| 42 |
}; |
| 43 |
|
| 44 |
class TASInputWindow : public QDialog |
| 45 |
{ |
| 46 |
Q_OBJECT |
| 47 |
public: |
| 48 |
explicit TASInputWindow(QWidget* parent); |
| 49 |
|
| 50 |
int GetTurboPressFrames() const; |
| 51 |
int GetTurboReleaseFrames() const; |
| 52 |
|
| 53 |
protected: |
| 54 |
TASCheckBox* CreateButton(const QString& text, std::string_view group_name, |
| 55 |
std::string_view control_name, InputOverrider* overrider); |
| 56 |
QGroupBox* CreateStickInputs(const QString& text, std::string_view group_name, |
| 57 |
InputOverrider* overrider, int min_x, int min_y, int max_x, |
| 58 |
int max_y, Qt::Key x_shortcut_key, Qt::Key y_shortcut_key); |
| 59 |
QGridLayout* CreateSliderValuePairLayout(const QString& text, std::string_view group_name, |
| 60 |
std::string_view control_name, InputOverrider* overrider, |
| 61 |
int zero, int default_, int min, int max, |
| 62 |
Qt::Key shortcut_key, QWidget* shortcut_widget, |
| 63 |
std::optional<ControlState> scale = {}); |
| 64 |
TASSpinBox* CreateSliderValuePair(std::string_view group_name, std::string_view control_name, |
| 65 |
InputOverrider* overrider, QGridLayout* layout, int zero, |
| 66 |
int default_, int min, int max, |
| 67 |
const QKeySequence& shortcut_key_sequence, |
| 68 |
Qt::Orientation orientation, QWidget* shortcut_widget, |
| 69 |
std::optional<ControlState> scale = {}); |
| 70 |
TASSpinBox* CreateSliderValuePair(QGridLayout* layout, int default_, int max, |
| 71 |
const QKeySequence& shortcut_key_sequence, |
| 72 |
Qt::Orientation orientation, QWidget* shortcut_widget); |
| 73 |
|
| 74 |
void SetupScrollArea(QLayout* layout); |
| 75 |
|
| 76 |
void changeEvent(QEvent* event) override; |
| 77 |
|
| 78 |
QWidget* m_scroll_widget; |
| 79 |
QGroupBox* m_settings_box; |
| 80 |
QCheckBox* m_use_controller; |
| 81 |
QSpinBox* m_turbo_press_frames; |
| 82 |
QSpinBox* m_turbo_release_frames; |
| 83 |
|
| 84 |
private: |
| 85 |
std::optional<ControlState> GetButton(TASCheckBox* checkbox, ControlState controller_state); |
| 86 |
std::optional<ControlState> GetSpinBox(TASSpinBox* spin, int zero, int min, int max, |
| 87 |
ControlState controller_state); |
| 88 |
std::optional<ControlState> GetSpinBox(TASSpinBox* spin, int zero, ControlState controller_state, |
| 89 |
ControlState scale); |
| 90 |
}; |