summaryrefslogtreecommitdiffstats
path: root/src/core/settings.h
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2020-09-28 16:00:15 +0200
committerMorph <39850852+Morph1984@users.noreply.github.com>2020-11-16 05:33:20 +0100
commit8f2959f6804e0d1048ecaa6f4046622e069fe7db (patch)
tree06451ddcfcc588d2803eaa908afa085bea7782de /src/core/settings.h
parentudp/client: Reduce testing period to 5 seconds (diff)
downloadyuzu-8f2959f6804e0d1048ecaa6f4046622e069fe7db.tar
yuzu-8f2959f6804e0d1048ecaa6f4046622e069fe7db.tar.gz
yuzu-8f2959f6804e0d1048ecaa6f4046622e069fe7db.tar.bz2
yuzu-8f2959f6804e0d1048ecaa6f4046622e069fe7db.tar.lz
yuzu-8f2959f6804e0d1048ecaa6f4046622e069fe7db.tar.xz
yuzu-8f2959f6804e0d1048ecaa6f4046622e069fe7db.tar.zst
yuzu-8f2959f6804e0d1048ecaa6f4046622e069fe7db.zip
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:
Type local{};
};
+/**
+ * The InputSetting class allows for getting a reference to either the global or local members.
+ * This is required as we cannot easily modify the values of user-defined types within containers
+ * using the SetValue() member function found in the Setting class. The primary purpose of this
+ * class is to store an array of 10 PlayerInput structs for both the global and local (per-game)
+ * setting and allows for easily accessing and modifying both settings.
+ */
+template <typename Type>
+class InputSetting final {
+public:
+ InputSetting() = default;
+ explicit InputSetting(Type val) : global{val} {}
+ ~InputSetting() = default;
+ void SetGlobal(bool to_global) {
+ use_global = to_global;
+ }
+ bool UsingGlobal() const {
+ return use_global;
+ }
+ Type& GetValue(bool need_global = false) {
+ if (use_global || need_global) {
+ return global;
+ }
+ return local;
+ }
+
+private:
+ bool use_global = true;
+ Type global{};
+ Type local{};
+};
+
struct TouchFromButtonMap {
std::string name;
std::vector<std::string> buttons;
@@ -133,9 +165,17 @@ struct Values {
Setting<s32> sound_index;
// Controls
- std::array<PlayerInput, 10> players;
+ InputSetting<std::array<PlayerInput, 10>> players;
+
+ Setting<bool> use_docked_mode;
- bool use_docked_mode;
+ Setting<bool> vibration_enabled;
+
+ Setting<bool> motion_enabled;
+ std::string motion_device;
+ std::string udp_input_address;
+ u16 udp_input_port;
+ u8 udp_pad_index;
bool mouse_enabled;
std::string mouse_device;
@@ -149,20 +189,15 @@ struct Values {
ButtonsRaw debug_pad_buttons;
AnalogsRaw debug_pad_analogs;
- bool vibration_enabled;
-
- bool motion_enabled;
- std::string motion_device;
- std::string touch_device;
TouchscreenInput touchscreen;
- std::atomic_bool is_device_reload_pending{true};
+
bool use_touch_from_button;
+ std::string touch_device;
int touch_from_button_map_index;
- std::string udp_input_address;
- u16 udp_input_port;
- u8 udp_pad_index;
std::vector<TouchFromButtonMap> touch_from_button_maps;
+ std::atomic_bool is_device_reload_pending{true};
+
// Data Storage
bool use_virtual_sd;
bool gamecard_inserted;