2018-07-07 05:51:34 +00:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-07-07 05:51:34 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-03-21 21:42:33 +00:00
|
|
|
#include <map>
|
|
|
|
#include <optional>
|
|
|
|
#include <string_view>
|
|
|
|
#include <utility>
|
|
|
|
|
2018-07-07 05:51:34 +00:00
|
|
|
#include <QDialog>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2021-03-21 21:42:33 +00:00
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
|
|
|
#include "InputCommon/ControllerInterface/CoreDevice.h"
|
|
|
|
|
2018-07-07 05:51:34 +00:00
|
|
|
class QBoxLayout;
|
|
|
|
class QCheckBox;
|
|
|
|
class QDialog;
|
|
|
|
class QGroupBox;
|
|
|
|
class QSpinBox;
|
|
|
|
class QString;
|
2019-03-31 02:49:57 +00:00
|
|
|
class TASCheckBox;
|
2023-03-07 18:22:09 +00:00
|
|
|
class TASSpinBox;
|
2018-07-07 05:51:34 +00:00
|
|
|
|
2021-03-21 21:42:33 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2018-07-07 05:51:34 +00:00
|
|
|
class TASInputWindow : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit TASInputWindow(QWidget* parent);
|
|
|
|
|
2020-06-30 19:07:25 +00:00
|
|
|
int GetTurboPressFrames() const;
|
|
|
|
int GetTurboReleaseFrames() const;
|
|
|
|
|
2018-07-07 05:51:34 +00:00
|
|
|
protected:
|
2021-03-21 21:42:33 +00:00
|
|
|
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,
|
2023-03-07 18:30:21 +00:00
|
|
|
InputOverrider* overrider, u16 min_x, u16 min_y, u16 max_x,
|
|
|
|
u16 max_y, Qt::Key x_shortcut_key, Qt::Key y_shortcut_key);
|
2021-03-21 21:42:33 +00:00
|
|
|
QBoxLayout* CreateSliderValuePairLayout(const QString& text, std::string_view group_name,
|
|
|
|
std::string_view control_name, InputOverrider* overrider,
|
2023-03-07 18:30:21 +00:00
|
|
|
u16 zero, int default_, u16 min, u16 max,
|
|
|
|
Qt::Key shortcut_key, QWidget* shortcut_widget,
|
2021-03-21 21:42:33 +00:00
|
|
|
std::optional<ControlState> scale = {});
|
2023-03-07 18:22:09 +00:00
|
|
|
TASSpinBox* CreateSliderValuePair(std::string_view group_name, std::string_view control_name,
|
|
|
|
InputOverrider* overrider, QBoxLayout* layout, u16 zero,
|
|
|
|
int default_, u16 min, u16 max,
|
|
|
|
QKeySequence shortcut_key_sequence, Qt::Orientation orientation,
|
|
|
|
QWidget* shortcut_widget,
|
|
|
|
std::optional<ControlState> scale = {});
|
|
|
|
TASSpinBox* CreateSliderValuePair(QBoxLayout* layout, int default_, u16 max,
|
|
|
|
QKeySequence shortcut_key_sequence, Qt::Orientation orientation,
|
|
|
|
QWidget* shortcut_widget);
|
2020-06-30 19:07:25 +00:00
|
|
|
|
|
|
|
QGroupBox* m_settings_box;
|
2018-07-07 05:51:34 +00:00
|
|
|
QCheckBox* m_use_controller;
|
2020-06-30 19:07:25 +00:00
|
|
|
QSpinBox* m_turbo_press_frames;
|
|
|
|
QSpinBox* m_turbo_release_frames;
|
2018-07-07 05:51:34 +00:00
|
|
|
|
|
|
|
private:
|
2021-03-21 21:42:33 +00:00
|
|
|
std::optional<ControlState> GetButton(TASCheckBox* checkbox, ControlState controller_state);
|
2023-03-07 18:22:09 +00:00
|
|
|
std::optional<ControlState> GetSpinBox(TASSpinBox* spin, u16 zero, u16 min, u16 max,
|
2021-03-21 21:42:33 +00:00
|
|
|
ControlState controller_state);
|
2023-03-07 18:22:09 +00:00
|
|
|
std::optional<ControlState> GetSpinBox(TASSpinBox* spin, u16 zero, ControlState controller_state,
|
2021-03-21 21:42:33 +00:00
|
|
|
ControlState scale);
|
2018-07-07 05:51:34 +00:00
|
|
|
};
|