2023-12-22 11:57:49 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0+
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
#pragma once
|
2023-10-14 08:45:09 +00:00
|
|
|
#include "ui_ControllerSettingsWindow.h"
|
2023-05-13 04:30:41 +00:00
|
|
|
|
|
|
|
#include "pcsx2/Input/InputManager.h"
|
2022-12-04 15:00:06 +00:00
|
|
|
#include "pcsx2/USB/USB.h"
|
2023-05-13 04:30:41 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <QtCore/QList>
|
|
|
|
#include <QtCore/QPair>
|
|
|
|
#include <QtCore/QString>
|
|
|
|
#include <QtCore/QStringList>
|
2023-10-14 08:45:09 +00:00
|
|
|
#include <QtWidgets/QWidget>
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <array>
|
2022-06-08 12:15:10 +00:00
|
|
|
#include <string>
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
class ControllerGlobalSettingsWidget;
|
|
|
|
class ControllerBindingWidget;
|
|
|
|
class HotkeySettingsWidget;
|
2022-12-04 15:00:06 +00:00
|
|
|
class USBDeviceWidget;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
class SettingsInterface;
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
class ControllerSettingsWindow final : public QWidget
|
2021-12-13 12:12:54 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum class Category
|
|
|
|
{
|
|
|
|
GlobalSettings,
|
|
|
|
FirstControllerSettings,
|
|
|
|
HotkeySettings,
|
|
|
|
Count
|
|
|
|
};
|
|
|
|
|
|
|
|
enum : u32
|
|
|
|
{
|
2022-06-07 14:16:37 +00:00
|
|
|
MAX_PORTS = 8
|
2021-12-13 12:12:54 +00:00
|
|
|
};
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerSettingsWindow();
|
|
|
|
~ControllerSettingsWindow();
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
__fi HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; }
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2022-03-25 12:16:21 +00:00
|
|
|
__fi const QList<QPair<QString, QString>>& getDeviceList() const { return m_device_list; }
|
2021-12-13 12:12:54 +00:00
|
|
|
__fi const QStringList& getVibrationMotors() const { return m_vibration_motors; }
|
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
__fi bool isEditingGlobalSettings() const { return m_profile_name.isEmpty(); }
|
|
|
|
__fi bool isEditingProfile() const { return !m_profile_name.isEmpty(); }
|
|
|
|
__fi SettingsInterface* getProfileSettingsInterface() { return m_profile_interface.get(); }
|
|
|
|
|
|
|
|
void updateListDescription(u32 global_slot, ControllerBindingWidget* widget);
|
2022-12-04 15:00:06 +00:00
|
|
|
void updateListDescription(u32 port, USBDeviceWidget* widget);
|
2022-06-08 12:15:10 +00:00
|
|
|
|
|
|
|
// Helper functions for updating setting values globally or in the profile.
|
|
|
|
bool getBoolValue(const char* section, const char* key, bool default_value) const;
|
2022-08-05 13:52:16 +00:00
|
|
|
s32 getIntValue(const char* section, const char* key, s32 default_value) const;
|
2022-06-08 12:15:10 +00:00
|
|
|
std::string getStringValue(const char* section, const char* key, const char* default_value) const;
|
|
|
|
void setBoolValue(const char* section, const char* key, bool value);
|
2022-08-05 13:52:16 +00:00
|
|
|
void setIntValue(const char* section, const char* key, s32 value);
|
2022-06-08 12:15:10 +00:00
|
|
|
void setStringValue(const char* section, const char* key, const char* value);
|
|
|
|
void clearSettingValue(const char* section, const char* key);
|
2024-05-04 13:33:35 +00:00
|
|
|
void saveAndReloadGameSettings();
|
2022-06-08 12:15:10 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void inputProfileSwitched();
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
void setCategory(Category category);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void onCategoryCurrentRowChanged(int row);
|
2022-06-08 12:15:10 +00:00
|
|
|
void onCurrentProfileChanged(int index);
|
|
|
|
void onNewProfileClicked();
|
2024-05-15 13:43:29 +00:00
|
|
|
void onApplyProfileClicked();
|
2022-06-08 12:15:10 +00:00
|
|
|
void onDeleteProfileClicked();
|
2024-01-26 06:03:57 +00:00
|
|
|
void onMappingSettingsClicked();
|
2022-06-08 12:15:10 +00:00
|
|
|
void onRestoreDefaultsClicked();
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
void onInputDevicesEnumerated(const QList<QPair<QString, QString>>& devices);
|
|
|
|
void onInputDeviceConnected(const QString& identifier, const QString& device_name);
|
|
|
|
void onInputDeviceDisconnected(const QString& identifier);
|
|
|
|
void onVibrationMotorsEnumerated(const QList<InputBindingKey>& motors);
|
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
void createWidgets();
|
2022-06-07 14:16:37 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
private:
|
2022-06-08 12:15:10 +00:00
|
|
|
void refreshProfileList();
|
|
|
|
void switchProfile(const QString& name);
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
Ui::ControllerSettingsWindow m_ui;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
ControllerGlobalSettingsWidget* m_global_settings = nullptr;
|
|
|
|
std::array<ControllerBindingWidget*, MAX_PORTS> m_port_bindings{};
|
2022-12-04 15:00:06 +00:00
|
|
|
std::array<USBDeviceWidget*, USB::NUM_PORTS> m_usb_bindings{};
|
2021-12-13 12:12:54 +00:00
|
|
|
HotkeySettingsWidget* m_hotkey_settings = nullptr;
|
|
|
|
|
2022-03-25 12:16:21 +00:00
|
|
|
QList<QPair<QString, QString>> m_device_list;
|
2021-12-13 12:12:54 +00:00
|
|
|
QStringList m_vibration_motors;
|
2022-06-08 12:15:10 +00:00
|
|
|
|
|
|
|
QString m_profile_name;
|
|
|
|
std::unique_ptr<SettingsInterface> m_profile_interface;
|
2021-12-13 12:12:54 +00:00
|
|
|
};
|