2021-12-13 12:12:54 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
2023-10-14 08:45:09 +00:00
|
|
|
* Copyright (C) 2002-2023 PCSX2 Dev Team
|
2021-12-13 12:12:54 +00:00
|
|
|
*
|
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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);
|
|
|
|
|
|
|
|
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 onLoadProfileClicked();
|
|
|
|
void onDeleteProfileClicked();
|
|
|
|
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
|
|
|
};
|