2017-06-13 15:16:41 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-06-13 15:16:41 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-11-08 00:10:26 +00:00
|
|
|
#include <memory>
|
2021-05-20 22:33:38 +00:00
|
|
|
#include <mutex>
|
2020-11-08 00:10:26 +00:00
|
|
|
#include <string>
|
|
|
|
|
2021-02-04 04:11:38 +00:00
|
|
|
#include <QComboBox>
|
2017-06-13 15:16:41 +00:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QString>
|
2019-03-02 20:47:26 +00:00
|
|
|
#include <QSyntaxHighlighter>
|
2017-06-13 15:16:41 +00:00
|
|
|
|
|
|
|
#include "Common/Flag.h"
|
2020-09-15 11:34:41 +00:00
|
|
|
#include "InputCommon/ControllerInterface/CoreDevice.h"
|
2017-06-13 15:16:41 +00:00
|
|
|
|
|
|
|
class ControlReference;
|
2019-01-06 23:15:00 +00:00
|
|
|
class MappingWidget;
|
2017-06-13 15:16:41 +00:00
|
|
|
class QAbstractButton;
|
|
|
|
class QDialogButtonBox;
|
2019-03-02 20:47:26 +00:00
|
|
|
class QLineEdit;
|
2019-01-06 23:15:00 +00:00
|
|
|
class QTableWidget;
|
2017-06-13 15:16:41 +00:00
|
|
|
class QVBoxLayout;
|
|
|
|
class QWidget;
|
|
|
|
class QPlainTextEdit;
|
|
|
|
class QPushButton;
|
|
|
|
class QSlider;
|
|
|
|
class QSpinBox;
|
|
|
|
|
|
|
|
namespace ControllerEmu
|
|
|
|
{
|
|
|
|
class EmulatedController;
|
|
|
|
}
|
|
|
|
|
2020-11-22 02:33:36 +00:00
|
|
|
class InputStateLineEdit;
|
|
|
|
|
2019-03-02 20:47:26 +00:00
|
|
|
class ControlExpressionSyntaxHighlighter final : public QSyntaxHighlighter
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-11-08 00:10:26 +00:00
|
|
|
explicit ControlExpressionSyntaxHighlighter(QTextDocument* parent);
|
2019-03-02 20:47:26 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void highlightBlock(const QString& text) final override;
|
|
|
|
};
|
|
|
|
|
2021-02-04 04:11:38 +00:00
|
|
|
class QComboBoxWithMouseWheelDisabled : public QComboBox
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit QComboBoxWithMouseWheelDisabled(QWidget* parent = nullptr) : QComboBox(parent) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Consumes event while doing nothing
|
|
|
|
void wheelEvent(QWheelEvent* event) override;
|
|
|
|
};
|
|
|
|
|
2017-06-13 15:16:41 +00:00
|
|
|
class IOWindow final : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum class Type
|
|
|
|
{
|
|
|
|
Input,
|
|
|
|
Output
|
|
|
|
};
|
|
|
|
|
2019-01-06 23:15:00 +00:00
|
|
|
explicit IOWindow(MappingWidget* parent, ControllerEmu::EmulatedController* m_controller,
|
2017-06-13 15:16:41 +00:00
|
|
|
ControlReference* ref, Type type);
|
|
|
|
|
|
|
|
private:
|
2021-05-20 22:33:38 +00:00
|
|
|
std::shared_ptr<ciface::Core::Device> GetSelectedDevice() const;
|
|
|
|
|
2017-06-13 15:16:41 +00:00
|
|
|
void CreateMainLayout();
|
|
|
|
void ConnectWidgets();
|
2019-03-15 01:27:49 +00:00
|
|
|
void ConfigChanged();
|
2019-01-06 23:15:00 +00:00
|
|
|
void Update();
|
2017-06-13 15:16:41 +00:00
|
|
|
|
|
|
|
void OnDialogButtonPressed(QAbstractButton* button);
|
2021-05-20 22:33:38 +00:00
|
|
|
void OnDeviceChanged();
|
2017-06-13 15:16:41 +00:00
|
|
|
void OnDetectButtonPressed();
|
2019-02-28 00:10:18 +00:00
|
|
|
void OnTestButtonPressed();
|
2017-06-13 15:16:41 +00:00
|
|
|
void OnRangeChanged(int range);
|
|
|
|
|
2019-01-27 16:35:29 +00:00
|
|
|
void AppendSelectedOption();
|
2017-06-13 15:16:41 +00:00
|
|
|
void UpdateOptionList();
|
|
|
|
void UpdateDeviceList();
|
2021-05-20 22:33:38 +00:00
|
|
|
void ReleaseDevices();
|
2017-06-13 15:16:41 +00:00
|
|
|
|
2020-11-22 02:33:36 +00:00
|
|
|
enum class UpdateMode
|
|
|
|
{
|
|
|
|
Normal,
|
|
|
|
Force,
|
|
|
|
};
|
|
|
|
|
|
|
|
void UpdateExpression(std::string new_expression, UpdateMode mode = UpdateMode::Normal);
|
2020-11-08 00:10:26 +00:00
|
|
|
|
2017-06-13 15:16:41 +00:00
|
|
|
// Main Layout
|
|
|
|
QVBoxLayout* m_main_layout;
|
|
|
|
|
|
|
|
// Devices
|
|
|
|
QComboBox* m_devices_combo;
|
|
|
|
|
|
|
|
// Options
|
2019-01-06 23:15:00 +00:00
|
|
|
QTableWidget* m_option_list;
|
2017-06-13 15:16:41 +00:00
|
|
|
|
|
|
|
// Range
|
|
|
|
QSlider* m_range_slider;
|
|
|
|
QSpinBox* m_range_spinbox;
|
|
|
|
|
|
|
|
// Shared actions
|
|
|
|
QPushButton* m_select_button;
|
2019-01-27 16:35:29 +00:00
|
|
|
QComboBox* m_operators_combo;
|
2021-03-11 22:01:18 +00:00
|
|
|
QComboBox* m_variables_combo;
|
2017-06-13 15:16:41 +00:00
|
|
|
|
|
|
|
// Input actions
|
|
|
|
QPushButton* m_detect_button;
|
2019-01-27 16:35:29 +00:00
|
|
|
QComboBox* m_functions_combo;
|
2017-06-13 15:16:41 +00:00
|
|
|
|
|
|
|
// Output actions
|
|
|
|
QPushButton* m_test_button;
|
|
|
|
|
|
|
|
// Textarea
|
|
|
|
QPlainTextEdit* m_expression_text;
|
2020-11-22 02:33:36 +00:00
|
|
|
InputStateLineEdit* m_parse_text;
|
2017-06-13 15:16:41 +00:00
|
|
|
|
|
|
|
// Buttonbox
|
|
|
|
QDialogButtonBox* m_button_box;
|
|
|
|
QPushButton* m_clear_button;
|
|
|
|
|
|
|
|
ControlReference* m_reference;
|
2020-11-08 00:10:26 +00:00
|
|
|
std::string m_original_expression;
|
2017-06-13 15:16:41 +00:00
|
|
|
ControllerEmu::EmulatedController* m_controller;
|
|
|
|
|
|
|
|
ciface::Core::DeviceQualifier m_devq;
|
|
|
|
Type m_type;
|
2019-01-06 23:15:00 +00:00
|
|
|
std::shared_ptr<ciface::Core::Device> m_selected_device;
|
2021-05-20 22:33:38 +00:00
|
|
|
std::mutex m_selected_device_mutex;
|
2017-06-13 15:16:41 +00:00
|
|
|
};
|