summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt6
-rw-r--r--src/common/fs/path_util.cpp6
-rw-r--r--src/common/settings.cpp7
-rw-r--r--src/common/settings.h10
-rw-r--r--src/common/settings_common.cpp1
-rw-r--r--src/common/settings_common.h3
-rw-r--r--src/common/settings_enums.h2
-rw-r--r--src/common/swap.h5
8 files changed, 30 insertions, 10 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index bf97d9ba2..34877b461 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -151,6 +151,10 @@ add_library(common STATIC
151 zstd_compression.h 151 zstd_compression.h
152) 152)
153 153
154if (YUZU_ENABLE_PORTABLE)
155 add_compile_definitions(YUZU_ENABLE_PORTABLE)
156endif()
157
154if (WIN32) 158if (WIN32)
155 target_sources(common PRIVATE 159 target_sources(common PRIVATE
156 windows/timer_resolution.cpp 160 windows/timer_resolution.cpp
@@ -191,8 +195,6 @@ if (MSVC)
191 _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING 195 _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
192 ) 196 )
193 target_compile_options(common PRIVATE 197 target_compile_options(common PRIVATE
194 /W4
195
196 /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data 198 /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data
197 /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data 199 /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
198 /we4800 # Implicit conversion from 'type' to bool. Possible information loss 200 /we4800 # Implicit conversion from 'type' to bool. Possible information loss
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp
index d71cfacc6..dce219fcf 100644
--- a/src/common/fs/path_util.cpp
+++ b/src/common/fs/path_util.cpp
@@ -88,8 +88,9 @@ public:
88 fs::path yuzu_path_config; 88 fs::path yuzu_path_config;
89 89
90#ifdef _WIN32 90#ifdef _WIN32
91#ifdef YUZU_ENABLE_PORTABLE
91 yuzu_path = GetExeDirectory() / PORTABLE_DIR; 92 yuzu_path = GetExeDirectory() / PORTABLE_DIR;
92 93#endif
93 if (!IsDir(yuzu_path)) { 94 if (!IsDir(yuzu_path)) {
94 yuzu_path = GetAppDataRoamingDirectory() / YUZU_DIR; 95 yuzu_path = GetAppDataRoamingDirectory() / YUZU_DIR;
95 } 96 }
@@ -101,8 +102,9 @@ public:
101 yuzu_path_cache = yuzu_path / CACHE_DIR; 102 yuzu_path_cache = yuzu_path / CACHE_DIR;
102 yuzu_path_config = yuzu_path / CONFIG_DIR; 103 yuzu_path_config = yuzu_path / CONFIG_DIR;
103#else 104#else
105#ifdef YUZU_ENABLE_PORTABLE
104 yuzu_path = GetCurrentDir() / PORTABLE_DIR; 106 yuzu_path = GetCurrentDir() / PORTABLE_DIR;
105 107#endif
106 if (Exists(yuzu_path) && IsDir(yuzu_path)) { 108 if (Exists(yuzu_path) && IsDir(yuzu_path)) {
107 yuzu_path_cache = yuzu_path / CACHE_DIR; 109 yuzu_path_cache = yuzu_path / CACHE_DIR;
108 yuzu_path_config = yuzu_path / CONFIG_DIR; 110 yuzu_path_config = yuzu_path / CONFIG_DIR;
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 16a58a750..4ecaf550b 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -2,6 +2,7 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include <version> 4#include <version>
5#include "common/settings_enums.h"
5#if __cpp_lib_chrono >= 201907L 6#if __cpp_lib_chrono >= 201907L
6#include <chrono> 7#include <chrono>
7#include <exception> 8#include <exception>
@@ -145,6 +146,10 @@ bool IsFastmemEnabled() {
145 return true; 146 return true;
146} 147}
147 148
149bool IsDockedMode() {
150 return values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked;
151}
152
148float Volume() { 153float Volume() {
149 if (values.audio_muted) { 154 if (values.audio_muted) {
150 return 0.0f; 155 return 0.0f;
@@ -154,6 +159,8 @@ float Volume() {
154 159
155const char* TranslateCategory(Category category) { 160const char* TranslateCategory(Category category) {
156 switch (category) { 161 switch (category) {
162 case Category::Android:
163 return "Android";
157 case Category::Audio: 164 case Category::Audio:
158 return "Audio"; 165 return "Audio";
159 case Category::Core: 166 case Category::Core:
diff --git a/src/common/settings.h b/src/common/settings.h
index 4407c1e6d..b15213bd7 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -379,7 +379,13 @@ struct Values {
379 379
380 Setting<s32> current_user{linkage, 0, "current_user", Category::System}; 380 Setting<s32> current_user{linkage, 0, "current_user", Category::System};
381 381
382 SwitchableSetting<bool> use_docked_mode{linkage, true, "use_docked_mode", Category::System}; 382 SwitchableSetting<ConsoleMode> use_docked_mode{linkage,
383 ConsoleMode::Docked,
384 "use_docked_mode",
385 Category::System,
386 Specialization::Radio,
387 true,
388 true};
383 389
384 // Controls 390 // Controls
385 InputSetting<std::array<PlayerInput, 10>> players; 391 InputSetting<std::array<PlayerInput, 10>> players;
@@ -519,6 +525,8 @@ bool IsGPULevelHigh();
519 525
520bool IsFastmemEnabled(); 526bool IsFastmemEnabled();
521 527
528bool IsDockedMode();
529
522float Volume(); 530float Volume();
523 531
524std::string GetTimeZoneString(TimeZone time_zone); 532std::string GetTimeZoneString(TimeZone time_zone);
diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp
index 137b65d5f..5960b78aa 100644
--- a/src/common/settings_common.cpp
+++ b/src/common/settings_common.cpp
@@ -14,6 +14,7 @@ BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Categ
14 : label{name}, category{category_}, id{linkage.count}, save{save_}, 14 : label{name}, category{category_}, id{linkage.count}, save{save_},
15 runtime_modifiable{runtime_modifiable_}, specialization{specialization_}, 15 runtime_modifiable{runtime_modifiable_}, specialization{specialization_},
16 other_setting{other_setting_} { 16 other_setting{other_setting_} {
17 linkage.by_key.insert({name, this});
17 linkage.by_category[category].push_back(this); 18 linkage.by_category[category].push_back(this);
18 linkage.count++; 19 linkage.count++;
19} 20}
diff --git a/src/common/settings_common.h b/src/common/settings_common.h
index 2efb329b0..5b170dfd5 100644
--- a/src/common/settings_common.h
+++ b/src/common/settings_common.h
@@ -12,6 +12,7 @@
12namespace Settings { 12namespace Settings {
13 13
14enum class Category : u32 { 14enum class Category : u32 {
15 Android,
15 Audio, 16 Audio,
16 Core, 17 Core,
17 Cpu, 18 Cpu,
@@ -56,6 +57,7 @@ enum Specialization : u8 {
56 Scalar = 5, // Values are continuous 57 Scalar = 5, // Values are continuous
57 Countable = 6, // Can be stepped through 58 Countable = 6, // Can be stepped through
58 Paired = 7, // Another setting is associated with this setting 59 Paired = 7, // Another setting is associated with this setting
60 Radio = 8, // Setting should be presented in a radio group
59 61
60 Percentage = (1 << SpecializationAttributeOffset), // Should be represented as a percentage 62 Percentage = (1 << SpecializationAttributeOffset), // Should be represented as a percentage
61}; 63};
@@ -67,6 +69,7 @@ public:
67 explicit Linkage(u32 initial_count = 0); 69 explicit Linkage(u32 initial_count = 0);
68 ~Linkage(); 70 ~Linkage();
69 std::map<Category, std::vector<BasicSetting*>> by_category{}; 71 std::map<Category, std::vector<BasicSetting*>> by_category{};
72 std::map<std::string, Settings::BasicSetting*> by_key{};
70 std::vector<std::function<void()>> restore_functions{}; 73 std::vector<std::function<void()>> restore_functions{};
71 u32 count; 74 u32 count;
72}; 75};
diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h
index e7cb59ea5..815cafe15 100644
--- a/src/common/settings_enums.h
+++ b/src/common/settings_enums.h
@@ -146,6 +146,8 @@ ENUM(AntiAliasing, None, Fxaa, Smaa, MaxEnum);
146 146
147ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); 147ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch);
148 148
149ENUM(ConsoleMode, Handheld, Docked);
150
149template <typename Type> 151template <typename Type>
150inline std::string CanonicalizeEnum(Type id) { 152inline std::string CanonicalizeEnum(Type id) {
151 const auto group = EnumMetadata<Type>::Canonicalizations(); 153 const auto group = EnumMetadata<Type>::Canonicalizations();
diff --git a/src/common/swap.h b/src/common/swap.h
index 085baaf9a..fde343e45 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -460,11 +460,6 @@ S operator&(const S& i, const swap_struct_t<T, F> v) {
460 return i & v.swap(); 460 return i & v.swap();
461} 461}
462 462
463template <typename S, typename T, typename F>
464S operator&(const swap_struct_t<T, F> v, const S& i) {
465 return static_cast<S>(v.swap() & i);
466}
467
468// Comparison 463// Comparison
469template <typename S, typename T, typename F> 464template <typename S, typename T, typename F>
470bool operator<(const S& p, const swap_struct_t<T, F> v) { 465bool operator<(const S& p, const swap_struct_t<T, F> v) {