2024-07-30 11:42:36 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-07-25 15:10:02 +00:00
|
|
|
#include "pcsx2/SIO/Pad/PadTypes.h"
|
2022-08-05 13:52:16 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <QtWidgets/QWidget>
|
|
|
|
|
2023-07-19 13:53:42 +00:00
|
|
|
#include <span>
|
2022-12-04 15:00:06 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
#include "ui_ControllerBindingWidget.h"
|
|
|
|
#include "ui_ControllerBindingWidget_DualShock2.h"
|
2023-06-11 06:06:40 +00:00
|
|
|
#include "ui_ControllerBindingWidget_Guitar.h"
|
2024-07-25 21:26:29 +00:00
|
|
|
#include "ui_ControllerBindingWidget_Jogcon.h"
|
|
|
|
#include "ui_ControllerBindingWidget_Negcon.h"
|
2024-01-01 23:17:33 +00:00
|
|
|
#include "ui_ControllerBindingWidget_Popn.h"
|
2022-08-05 13:52:16 +00:00
|
|
|
#include "ui_ControllerMacroWidget.h"
|
|
|
|
#include "ui_ControllerMacroEditWidget.h"
|
2022-12-04 15:00:06 +00:00
|
|
|
#include "ui_USBDeviceWidget.h"
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
class InputBindingWidget;
|
2023-10-14 08:45:09 +00:00
|
|
|
class ControllerSettingsWindow;
|
2022-08-05 13:52:16 +00:00
|
|
|
class ControllerCustomSettingsWidget;
|
|
|
|
class ControllerMacroWidget;
|
|
|
|
class ControllerMacroEditWidget;
|
2021-12-13 12:12:54 +00:00
|
|
|
class ControllerBindingWidget_Base;
|
|
|
|
|
2022-12-04 15:00:06 +00:00
|
|
|
class USBBindingWidget;
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
class ControllerBindingWidget final : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerBindingWidget(QWidget* parent, ControllerSettingsWindow* dialog, u32 port);
|
2021-12-13 12:12:54 +00:00
|
|
|
~ControllerBindingWidget();
|
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
QIcon getIcon() const;
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
__fi ControllerSettingsWindow* getDialog() const { return m_dialog; }
|
2021-12-13 12:12:54 +00:00
|
|
|
__fi const std::string& getConfigSection() const { return m_config_section; }
|
2023-07-29 03:42:45 +00:00
|
|
|
__fi Pad::ControllerType getControllerType() const { return m_controller_type; }
|
2021-12-13 12:12:54 +00:00
|
|
|
__fi u32 getPortNumber() const { return m_port_number; }
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void onTypeChanged();
|
2022-08-05 13:52:16 +00:00
|
|
|
void onAutomaticBindingClicked();
|
|
|
|
void onClearBindingsClicked();
|
|
|
|
void onBindingsClicked();
|
|
|
|
void onSettingsClicked();
|
|
|
|
void onMacrosClicked();
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void populateControllerTypes();
|
2022-08-05 13:52:16 +00:00
|
|
|
void updateHeaderToolButtons();
|
2022-03-25 12:16:21 +00:00
|
|
|
void doDeviceAutomaticBinding(const QString& device);
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
Ui::ControllerBindingWidget m_ui;
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerSettingsWindow* m_dialog;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
std::string m_config_section;
|
2023-07-29 03:42:45 +00:00
|
|
|
Pad::ControllerType m_controller_type;
|
2021-12-13 12:12:54 +00:00
|
|
|
u32 m_port_number;
|
|
|
|
|
2022-08-05 13:52:16 +00:00
|
|
|
ControllerBindingWidget_Base* m_bindings_widget = nullptr;
|
|
|
|
ControllerCustomSettingsWidget* m_settings_widget = nullptr;
|
|
|
|
ControllerMacroWidget* m_macros_widget = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class ControllerMacroWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ControllerMacroWidget(ControllerBindingWidget* parent);
|
|
|
|
~ControllerMacroWidget();
|
|
|
|
|
|
|
|
void updateListItem(u32 index);
|
|
|
|
|
|
|
|
private:
|
2023-07-25 15:10:02 +00:00
|
|
|
static constexpr u32 NUM_MACROS = Pad::NUM_MACRO_BUTTONS_PER_CONTROLLER;
|
2022-08-05 13:52:16 +00:00
|
|
|
|
|
|
|
void createWidgets(ControllerBindingWidget* parent);
|
|
|
|
|
|
|
|
Ui::ControllerMacroWidget m_ui;
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerSettingsWindow* m_dialog;
|
2022-08-05 13:52:16 +00:00
|
|
|
std::array<ControllerMacroEditWidget*, NUM_MACROS> m_macros;
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class ControllerMacroEditWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ControllerMacroEditWidget(ControllerMacroWidget* parent, ControllerBindingWidget* bwidget, u32 index);
|
|
|
|
~ControllerMacroEditWidget();
|
|
|
|
|
|
|
|
QString getSummary() const;
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
2023-03-03 10:53:39 +00:00
|
|
|
void onPressureChanged();
|
2023-07-25 15:10:02 +00:00
|
|
|
void onDeadzoneChanged();
|
2022-08-05 13:52:16 +00:00
|
|
|
void onSetFrequencyClicked();
|
|
|
|
void updateBinds();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void modFrequency(s32 delta);
|
|
|
|
void updateFrequency();
|
|
|
|
void updateFrequencyText();
|
|
|
|
|
|
|
|
Ui::ControllerMacroEditWidget m_ui;
|
|
|
|
|
|
|
|
ControllerMacroWidget* m_parent;
|
|
|
|
ControllerBindingWidget* m_bwidget;
|
|
|
|
u32 m_index;
|
|
|
|
|
2022-11-27 08:27:17 +00:00
|
|
|
std::vector<const InputBindingInfo*> m_binds;
|
2022-08-05 13:52:16 +00:00
|
|
|
u32 m_frequency = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class ControllerCustomSettingsWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-07-19 13:53:42 +00:00
|
|
|
ControllerCustomSettingsWidget(std::span<const SettingInfo> settings, std::string config_section, std::string config_prefix,
|
2023-10-14 08:45:09 +00:00
|
|
|
const char* translation_ctx, ControllerSettingsWindow* dialog, QWidget* parent_widget);
|
2022-08-05 13:52:16 +00:00
|
|
|
~ControllerCustomSettingsWidget();
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void restoreDefaults();
|
|
|
|
|
|
|
|
private:
|
2022-12-04 15:00:06 +00:00
|
|
|
void createSettingWidgets(const char* translation_ctx, QWidget* widget_parent, QGridLayout* layout);
|
|
|
|
|
2023-07-19 13:53:42 +00:00
|
|
|
std::span<const SettingInfo> m_settings;
|
2022-12-04 15:00:06 +00:00
|
|
|
std::string m_config_section;
|
|
|
|
std::string m_config_prefix;
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerSettingsWindow* m_dialog;
|
2021-12-13 12:12:54 +00:00
|
|
|
};
|
|
|
|
|
2022-08-05 13:52:16 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
class ControllerBindingWidget_Base : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ControllerBindingWidget_Base(ControllerBindingWidget* parent);
|
|
|
|
virtual ~ControllerBindingWidget_Base();
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
__fi ControllerSettingsWindow* getDialog() const { return static_cast<ControllerBindingWidget*>(parent())->getDialog(); }
|
2021-12-13 12:12:54 +00:00
|
|
|
__fi const std::string& getConfigSection() const { return static_cast<ControllerBindingWidget*>(parent())->getConfigSection(); }
|
2023-07-29 03:42:45 +00:00
|
|
|
__fi Pad::ControllerType getControllerType() const { return static_cast<ControllerBindingWidget*>(parent())->getControllerType(); }
|
2021-12-13 12:12:54 +00:00
|
|
|
__fi u32 getPortNumber() const { return static_cast<ControllerBindingWidget*>(parent())->getPortNumber(); }
|
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
virtual QIcon getIcon() const;
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
protected:
|
|
|
|
void initBindingWidgets();
|
|
|
|
};
|
|
|
|
|
|
|
|
class ControllerBindingWidget_DualShock2 final : public ControllerBindingWidget_Base
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ControllerBindingWidget_DualShock2(ControllerBindingWidget* parent);
|
|
|
|
~ControllerBindingWidget_DualShock2();
|
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
QIcon getIcon() const override;
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
static ControllerBindingWidget_Base* createInstance(ControllerBindingWidget* parent);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::ControllerBindingWidget_DualShock2 m_ui;
|
|
|
|
};
|
2022-12-04 15:00:06 +00:00
|
|
|
|
2023-06-11 06:06:40 +00:00
|
|
|
class ControllerBindingWidget_Guitar final : public ControllerBindingWidget_Base
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ControllerBindingWidget_Guitar(ControllerBindingWidget* parent);
|
|
|
|
~ControllerBindingWidget_Guitar();
|
|
|
|
|
|
|
|
QIcon getIcon() const override;
|
|
|
|
|
|
|
|
static ControllerBindingWidget_Base* createInstance(ControllerBindingWidget* parent);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::ControllerBindingWidget_Guitar m_ui;
|
|
|
|
};
|
|
|
|
|
2024-07-25 21:26:29 +00:00
|
|
|
class ControllerBindingWidget_Jogcon final : public ControllerBindingWidget_Base
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ControllerBindingWidget_Jogcon(ControllerBindingWidget* parent);
|
|
|
|
~ControllerBindingWidget_Jogcon();
|
|
|
|
|
|
|
|
QIcon getIcon() const override;
|
|
|
|
|
|
|
|
static ControllerBindingWidget_Base* createInstance(ControllerBindingWidget* parent);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::ControllerBindingWidget_Jogcon m_ui;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ControllerBindingWidget_Negcon final : public ControllerBindingWidget_Base
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ControllerBindingWidget_Negcon(ControllerBindingWidget* parent);
|
|
|
|
~ControllerBindingWidget_Negcon();
|
|
|
|
|
|
|
|
QIcon getIcon() const override;
|
|
|
|
|
|
|
|
static ControllerBindingWidget_Base* createInstance(ControllerBindingWidget* parent);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::ControllerBindingWidget_Negcon m_ui;
|
|
|
|
};
|
|
|
|
|
2024-01-01 23:17:33 +00:00
|
|
|
class ControllerBindingWidget_Popn final : public ControllerBindingWidget_Base
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ControllerBindingWidget_Popn(ControllerBindingWidget* parent);
|
|
|
|
~ControllerBindingWidget_Popn();
|
|
|
|
|
|
|
|
QIcon getIcon() const override;
|
|
|
|
|
|
|
|
static ControllerBindingWidget_Base* createInstance(ControllerBindingWidget* parent);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::ControllerBindingWidget_Popn m_ui;
|
|
|
|
};
|
|
|
|
|
2022-12-04 15:00:06 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class USBDeviceWidget final : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-10-14 08:45:09 +00:00
|
|
|
USBDeviceWidget(QWidget* parent, ControllerSettingsWindow* dialog, u32 port);
|
2022-12-04 15:00:06 +00:00
|
|
|
~USBDeviceWidget();
|
|
|
|
|
|
|
|
QIcon getIcon() const;
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
__fi ControllerSettingsWindow* getDialog() const { return m_dialog; }
|
2022-12-04 15:00:06 +00:00
|
|
|
__fi const std::string& getConfigSection() const { return m_config_section; }
|
|
|
|
__fi const std::string& getDeviceType() const { return m_device_type; }
|
|
|
|
__fi u32 getPortNumber() const { return m_port_number; }
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void onTypeChanged();
|
|
|
|
void onSubTypeChanged(int new_index);
|
|
|
|
void onAutomaticBindingClicked();
|
|
|
|
void onClearBindingsClicked();
|
|
|
|
void onBindingsClicked();
|
|
|
|
void onSettingsClicked();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void populateDeviceTypes();
|
|
|
|
void populatePages();
|
|
|
|
void updateHeaderToolButtons();
|
|
|
|
void doDeviceAutomaticBinding(const QString& device);
|
|
|
|
|
|
|
|
Ui::USBDeviceWidget m_ui;
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerSettingsWindow* m_dialog;
|
2022-12-04 15:00:06 +00:00
|
|
|
|
|
|
|
std::string m_config_section;
|
|
|
|
std::string m_device_type;
|
|
|
|
u32 m_device_subtype;
|
|
|
|
u32 m_port_number;
|
|
|
|
|
|
|
|
USBBindingWidget* m_bindings_widget = nullptr;
|
|
|
|
ControllerCustomSettingsWidget* m_settings_widget = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
class USBBindingWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
USBBindingWidget(USBDeviceWidget* parent);
|
|
|
|
~USBBindingWidget() override;
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
__fi ControllerSettingsWindow* getDialog() const { return static_cast<USBDeviceWidget*>(parent())->getDialog(); }
|
2022-12-04 15:00:06 +00:00
|
|
|
__fi const std::string& getConfigSection() const { return static_cast<USBDeviceWidget*>(parent())->getConfigSection(); }
|
|
|
|
__fi const std::string& getDeviceType() const { return static_cast<USBDeviceWidget*>(parent())->getDeviceType(); }
|
|
|
|
__fi u32 getPortNumber() const { return static_cast<USBDeviceWidget*>(parent())->getPortNumber(); }
|
|
|
|
|
|
|
|
QIcon getIcon() const;
|
|
|
|
|
2023-07-19 13:53:42 +00:00
|
|
|
static USBBindingWidget* createInstance(const std::string& type, u32 subtype, std::span<const InputBindingInfo> bindings, USBDeviceWidget* parent);
|
2022-12-04 15:00:06 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
std::string getBindingKey(const char* binding_name) const;
|
|
|
|
|
2023-07-19 13:53:42 +00:00
|
|
|
void createWidgets(std::span<const InputBindingInfo> bindings);
|
|
|
|
void bindWidgets(std::span<const InputBindingInfo> bindings);
|
2022-12-04 15:00:06 +00:00
|
|
|
};
|