Path: blob/master/src/duckstation-qt/controllersettingswindow.h
4246 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/QList>12#include <QtCore/QPair>13#include <QtCore/QString>14#include <QtCore/QStringList>15#include <QtWidgets/QDialog>16#include <QtCore/QAbstractListModel>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);6869// Helper functions for updating setting values globally or in the profile.70bool getBoolValue(const char* section, const char* key, bool default_value) const;71s32 getIntValue(const char* section, const char* key, s32 default_value) const;72std::string getStringValue(const char* section, const char* key, const char* default_value) const;73void setBoolValue(const char* section, const char* key, bool value);74void setIntValue(const char* section, const char* key, s32 value);75void setStringValue(const char* section, const char* key, const char* value);76void clearSettingValue(const char* section, const char* key);77void saveAndReloadGameSettings();7879Q_SIGNALS:80void windowClosed();81void inputProfileSwitched();8283public Q_SLOTS:84void setCategory(Category category);8586private Q_SLOTS:87void onCategoryCurrentRowChanged(int row);88void onCurrentProfileChanged(int index);89void onNewProfileClicked();90void onApplyProfileClicked();91void onDeleteProfileClicked();92void onRestoreDefaultsClicked();93void onCopyGlobalSettingsClicked();9495void createWidgets();9697protected:98void closeEvent(QCloseEvent* event) override;99100private:101int getHotkeyCategoryIndex() const;102void refreshProfileList();103104std::array<bool, 2> getEnabledMultitaps() const;105106Ui::ControllerSettingsWindow m_ui;107108INISettingsInterface* m_editing_settings_interface = nullptr;109110ControllerGlobalSettingsWidget* m_global_settings = nullptr;111std::array<ControllerBindingWidget*, NUM_CONTROLLER_AND_CARD_PORTS> m_port_bindings{};112HotkeySettingsWidget* m_hotkey_settings = nullptr;113114QString m_profile_name;115std::unique_ptr<INISettingsInterface> m_profile_settings_interface;116bool m_editing_input_profiles = false;117};118119120