pcsx2/pcsx2-qt/Settings/ControllerSettingsWindow.h

107 lines
3.3 KiB
C
Raw Normal View History

// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+
2021-12-13 12:12:54 +00:00
#pragma once
#include "ui_ControllerSettingsWindow.h"
#include "pcsx2/Input/InputManager.h"
#include "pcsx2/USB/USB.h"
2021-12-13 12:12:54 +00:00
#include <QtCore/QList>
#include <QtCore/QPair>
#include <QtCore/QString>
#include <QtCore/QStringList>
#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;
class USBDeviceWidget;
2021-12-13 12:12:54 +00:00
2022-06-08 12:15:10 +00:00
class SettingsInterface;
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
};
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);
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;
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);
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);
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();
void onApplyProfileClicked();
2022-06-08 12:15:10 +00:00
void onDeleteProfileClicked();
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);
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{};
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
};