Path: blob/master/src/duckstation-qt/controllersettingswindow.h
4802 views
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <[email protected]>1// SPDX-License-Identifier: CC-BY-NC-ND-4.023#pragma once45#include "ui_controllersettingswindow.h"67#include "util/input_manager.h"89#include "core/types.h"1011#include <QtCore/QAbstractListModel>12#include <QtCore/QList>13#include <QtCore/QPair>14#include <QtCore/QString>15#include <QtCore/QStringList>16#include <QtWidgets/QDialog>1718#include <array>19#include <string>20#include <utility>21#include <vector>2223class Error;2425class ControllerGlobalSettingsWidget;26class ControllerBindingWidget;27class HotkeySettingsWidget;2829class INISettingsInterface;3031class ControllerSettingsWindow final : public QWidget32{33Q_OBJECT3435public:36enum class Category37{38GlobalSettings,39FirstControllerSettings,40HotkeySettings,41Count42};4344ControllerSettingsWindow(INISettingsInterface* game_sif = nullptr, bool edit_profiles = false,45QWidget* parent = nullptr);46~ControllerSettingsWindow();4748static void editControllerSettingsForGame(QWidget* parent, INISettingsInterface* sif);4950ALWAYS_INLINE HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; }5152ALWAYS_INLINE bool isEditingGlobalSettings() const53{54return (!m_editing_input_profiles && !m_editing_settings_interface);55}56ALWAYS_INLINE bool isEditingGameSettings() const57{58return (!m_editing_input_profiles && m_editing_settings_interface);59}60ALWAYS_INLINE bool isEditingProfile() const { return m_editing_input_profiles; }61ALWAYS_INLINE INISettingsInterface* getEditingSettingsInterface() { return m_editing_settings_interface; }6263Category getCurrentCategory() const;6465void updateListDescription(u32 global_slot, ControllerBindingWidget* widget);6667void switchProfile(const std::string_view name);6869void setCategory(Category category);7071// Helper functions for updating setting values globally or in the profile.72bool getBoolValue(const char* section, const char* key, bool default_value) const;73s32 getIntValue(const char* section, const char* key, s32 default_value) const;74std::string getStringValue(const char* section, const char* key, const char* default_value) const;75void setBoolValue(const char* section, const char* key, bool value);76void setIntValue(const char* section, const char* key, s32 value);77void setStringValue(const char* section, const char* key, const char* value);78void clearSettingValue(const char* section, const char* key);79void saveAndReloadGameSettings();8081Q_SIGNALS:82void windowClosed();83void inputProfileSwitched();8485protected:86void closeEvent(QCloseEvent* event) override;8788private:89int getHotkeyCategoryIndex() const;90void refreshProfileList();9192std::array<bool, 2> getEnabledMultitaps() const;9394void createWidgets();9596void onCategoryCurrentRowChanged(int row);97void onCurrentProfileChanged(int index);98void onNewProfileClicked();99void onApplyProfileClicked();100void onDeleteProfileClicked();101void onRestoreDefaultsClicked();102void onCopyGlobalSettingsClicked();103104Ui::ControllerSettingsWindow m_ui;105106INISettingsInterface* m_editing_settings_interface = nullptr;107108ControllerGlobalSettingsWidget* m_global_settings = nullptr;109std::array<ControllerBindingWidget*, NUM_CONTROLLER_AND_CARD_PORTS> m_port_bindings{};110HotkeySettingsWidget* m_hotkey_settings = nullptr;111112QString m_profile_name;113std::unique_ptr<INISettingsInterface> m_profile_settings_interface;114bool m_editing_input_profiles = false;115};116117118