summaryrefslogtreecommitdiff
path: root/src/core/settings.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/settings.h')
-rw-r--r--src/core/settings.h57
1 files changed, 46 insertions, 11 deletions
diff --git a/src/core/settings.h b/src/core/settings.h
index 28616a574..edd2a00ca 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -65,6 +65,38 @@ private:
65 Type local{}; 65 Type local{};
66}; 66};
67 67
68/**
69 * The InputSetting class allows for getting a reference to either the global or local members.
70 * This is required as we cannot easily modify the values of user-defined types within containers
71 * using the SetValue() member function found in the Setting class. The primary purpose of this
72 * class is to store an array of 10 PlayerInput structs for both the global and local (per-game)
73 * setting and allows for easily accessing and modifying both settings.
74 */
75template <typename Type>
76class InputSetting final {
77public:
78 InputSetting() = default;
79 explicit InputSetting(Type val) : global{val} {}
80 ~InputSetting() = default;
81 void SetGlobal(bool to_global) {
82 use_global = to_global;
83 }
84 bool UsingGlobal() const {
85 return use_global;
86 }
87 Type& GetValue(bool need_global = false) {
88 if (use_global || need_global) {
89 return global;
90 }
91 return local;
92 }
93
94private:
95 bool use_global = true;
96 Type global{};
97 Type local{};
98};
99
68struct TouchFromButtonMap { 100struct TouchFromButtonMap {
69 std::string name; 101 std::string name;
70 std::vector<std::string> buttons; 102 std::vector<std::string> buttons;
@@ -133,9 +165,17 @@ struct Values {
133 Setting<s32> sound_index; 165 Setting<s32> sound_index;
134 166
135 // Controls 167 // Controls
136 std::array<PlayerInput, 10> players; 168 InputSetting<std::array<PlayerInput, 10>> players;
169
170 Setting<bool> use_docked_mode;
137 171
138 bool use_docked_mode; 172 Setting<bool> vibration_enabled;
173
174 Setting<bool> motion_enabled;
175 std::string motion_device;
176 std::string udp_input_address;
177 u16 udp_input_port;
178 u8 udp_pad_index;
139 179
140 bool mouse_enabled; 180 bool mouse_enabled;
141 std::string mouse_device; 181 std::string mouse_device;
@@ -149,20 +189,15 @@ struct Values {
149 ButtonsRaw debug_pad_buttons; 189 ButtonsRaw debug_pad_buttons;
150 AnalogsRaw debug_pad_analogs; 190 AnalogsRaw debug_pad_analogs;
151 191
152 bool vibration_enabled;
153
154 bool motion_enabled;
155 std::string motion_device;
156 std::string touch_device;
157 TouchscreenInput touchscreen; 192 TouchscreenInput touchscreen;
158 std::atomic_bool is_device_reload_pending{true}; 193
159 bool use_touch_from_button; 194 bool use_touch_from_button;
195 std::string touch_device;
160 int touch_from_button_map_index; 196 int touch_from_button_map_index;
161 std::string udp_input_address;
162 u16 udp_input_port;
163 u8 udp_pad_index;
164 std::vector<TouchFromButtonMap> touch_from_button_maps; 197 std::vector<TouchFromButtonMap> touch_from_button_maps;
165 198
199 std::atomic_bool is_device_reload_pending{true};
200
166 // Data Storage 201 // Data Storage
167 bool use_virtual_sd; 202 bool use_virtual_sd;
168 bool gamecard_inserted; 203 bool gamecard_inserted;