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