Path: blob/master/src/duckstation-qt/controllersettingswindow.h
7540 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:36ControllerSettingsWindow(INISettingsInterface* game_sif = nullptr, bool edit_profiles = false,37QWidget* parent = nullptr);38~ControllerSettingsWindow();3940static void editControllerSettingsForGame(QWidget* parent, INISettingsInterface* sif);4142ALWAYS_INLINE HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; }4344ALWAYS_INLINE bool isEditingGlobalSettings() const45{46return (!m_editing_input_profiles && !m_editing_settings_interface);47}48ALWAYS_INLINE bool isEditingGameSettings() const49{50return (!m_editing_input_profiles && m_editing_settings_interface);51}52ALWAYS_INLINE bool isEditingProfile() const { return m_editing_input_profiles; }53ALWAYS_INLINE INISettingsInterface* getEditingSettingsInterface() { return m_editing_settings_interface; }5455int getCategoryRow() const;56void setCategoryRow(int row);57void setCategory(u32 category);5859void updateListDescription(u32 global_slot, ControllerBindingWidget* widget);6061void switchProfile(const std::string_view name);6263// Helper functions for updating setting values globally or in the profile.64bool getBoolValue(const char* section, const char* key, bool default_value) const;65s32 getIntValue(const char* section, const char* key, s32 default_value) const;66std::string getStringValue(const char* section, const char* key, const char* default_value) const;67void setBoolValue(const char* section, const char* key, bool value);68void setIntValue(const char* section, const char* key, s32 value);69void setStringValue(const char* section, const char* key, const char* value);70void clearSettingValue(const char* section, const char* key);71void saveAndReloadGameSettings();7273static constexpr u32 CATEGORY_GLOBAL_SETTINGS = 0;74static constexpr u32 CATEGORY_FIRST_CONTROLLER_SETTINGS = 1;75static constexpr u32 CATEGORY_HOTKEY_SETTINGS = 2;7677protected:78void closeEvent(QCloseEvent* event) override;7980private:81int getHotkeyCategoryIndex() const;82void refreshProfileList();8384std::array<bool, 2> getEnabledMultitaps() const;8586void createWidgets();8788void onCategoryCurrentRowChanged(int row);89void onCurrentProfileChanged(int index);90void onNewProfileClicked();91void onApplyProfileClicked();92void onDeleteProfileClicked();93void onRestoreDefaultsClicked();94void onCopyGlobalSettingsClicked();9596Ui::ControllerSettingsWindow m_ui;9798INISettingsInterface* m_editing_settings_interface = nullptr;99100ControllerGlobalSettingsWidget* m_global_settings = nullptr;101std::array<ControllerBindingWidget*, NUM_CONTROLLER_AND_CARD_PORTS> m_port_bindings{};102HotkeySettingsWidget* m_hotkey_settings = nullptr;103104QString m_profile_name;105std::unique_ptr<INISettingsInterface> m_profile_settings_interface;106bool m_editing_input_profiles = false;107};108109110