summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common_funcs.h16
-rw-r--r--src/common/fs/fs_paths.h1
-rw-r--r--src/common/fs/path_util.cpp1
-rw-r--r--src/common/fs/path_util.h1
-rw-r--r--src/common/settings.cpp5
-rw-r--r--src/common/settings.h12
-rw-r--r--src/common/threadsafe_queue.h27
7 files changed, 52 insertions, 11 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 1e74d6930..4c1e29de6 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -61,6 +61,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
61 using T = std::underlying_type_t<type>; \ 61 using T = std::underlying_type_t<type>; \
62 return static_cast<type>(static_cast<T>(a) ^ static_cast<T>(b)); \ 62 return static_cast<type>(static_cast<T>(a) ^ static_cast<T>(b)); \
63 } \ 63 } \
64 [[nodiscard]] constexpr type operator<<(type a, type b) noexcept { \
65 using T = std::underlying_type_t<type>; \
66 return static_cast<type>(static_cast<T>(a) << static_cast<T>(b)); \
67 } \
68 [[nodiscard]] constexpr type operator>>(type a, type b) noexcept { \
69 using T = std::underlying_type_t<type>; \
70 return static_cast<type>(static_cast<T>(a) >> static_cast<T>(b)); \
71 } \
64 constexpr type& operator|=(type& a, type b) noexcept { \ 72 constexpr type& operator|=(type& a, type b) noexcept { \
65 a = a | b; \ 73 a = a | b; \
66 return a; \ 74 return a; \
@@ -73,6 +81,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
73 a = a ^ b; \ 81 a = a ^ b; \
74 return a; \ 82 return a; \
75 } \ 83 } \
84 constexpr type& operator<<=(type& a, type b) noexcept { \
85 a = a << b; \
86 return a; \
87 } \
88 constexpr type& operator>>=(type& a, type b) noexcept { \
89 a = a >> b; \
90 return a; \
91 } \
76 [[nodiscard]] constexpr type operator~(type key) noexcept { \ 92 [[nodiscard]] constexpr type operator~(type key) noexcept { \
77 using T = std::underlying_type_t<type>; \ 93 using T = std::underlying_type_t<type>; \
78 return static_cast<type>(~static_cast<T>(key)); \ 94 return static_cast<type>(~static_cast<T>(key)); \
diff --git a/src/common/fs/fs_paths.h b/src/common/fs/fs_paths.h
index b32614797..5d447f108 100644
--- a/src/common/fs/fs_paths.h
+++ b/src/common/fs/fs_paths.h
@@ -21,6 +21,7 @@
21#define SCREENSHOTS_DIR "screenshots" 21#define SCREENSHOTS_DIR "screenshots"
22#define SDMC_DIR "sdmc" 22#define SDMC_DIR "sdmc"
23#define SHADER_DIR "shader" 23#define SHADER_DIR "shader"
24#define TAS_DIR "tas"
24 25
25// yuzu-specific files 26// yuzu-specific files
26 27
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp
index 6cdd14f13..43b79bd6d 100644
--- a/src/common/fs/path_util.cpp
+++ b/src/common/fs/path_util.cpp
@@ -116,6 +116,7 @@ private:
116 GenerateYuzuPath(YuzuPath::ScreenshotsDir, yuzu_path / SCREENSHOTS_DIR); 116 GenerateYuzuPath(YuzuPath::ScreenshotsDir, yuzu_path / SCREENSHOTS_DIR);
117 GenerateYuzuPath(YuzuPath::SDMCDir, yuzu_path / SDMC_DIR); 117 GenerateYuzuPath(YuzuPath::SDMCDir, yuzu_path / SDMC_DIR);
118 GenerateYuzuPath(YuzuPath::ShaderDir, yuzu_path / SHADER_DIR); 118 GenerateYuzuPath(YuzuPath::ShaderDir, yuzu_path / SHADER_DIR);
119 GenerateYuzuPath(YuzuPath::TASDir, yuzu_path / TAS_DIR);
119 } 120 }
120 121
121 ~PathManagerImpl() = default; 122 ~PathManagerImpl() = default;
diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h
index f956ac9a2..0a9e3a145 100644
--- a/src/common/fs/path_util.h
+++ b/src/common/fs/path_util.h
@@ -23,6 +23,7 @@ enum class YuzuPath {
23 ScreenshotsDir, // Where yuzu screenshots are stored. 23 ScreenshotsDir, // Where yuzu screenshots are stored.
24 SDMCDir, // Where the emulated SDMC is stored. 24 SDMCDir, // Where the emulated SDMC is stored.
25 ShaderDir, // Where shaders are stored. 25 ShaderDir, // Where shaders are stored.
26 TASDir, // Where TAS scripts are stored.
26}; 27};
27 28
28/** 29/**
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 0d2df80a8..69f0bd8c0 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -61,7 +61,6 @@ void LogSettings() {
61 log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); 61 log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue());
62 log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue()); 62 log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue());
63 log_setting("Audio_OutputEngine", values.sink_id.GetValue()); 63 log_setting("Audio_OutputEngine", values.sink_id.GetValue());
64 log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue());
65 log_setting("Audio_OutputDevice", values.audio_device_id.GetValue()); 64 log_setting("Audio_OutputDevice", values.audio_device_id.GetValue());
66 log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd.GetValue()); 65 log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd.GetValue());
67 log_path("DataStorage_CacheDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir)); 66 log_path("DataStorage_CacheDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir));
@@ -72,6 +71,9 @@ void LogSettings() {
72 log_setting("Debugging_ProgramArgs", values.program_args.GetValue()); 71 log_setting("Debugging_ProgramArgs", values.program_args.GetValue());
73 log_setting("Services_BCATBackend", values.bcat_backend.GetValue()); 72 log_setting("Services_BCATBackend", values.bcat_backend.GetValue());
74 log_setting("Services_BCATBoxcatLocal", values.bcat_boxcat_local.GetValue()); 73 log_setting("Services_BCATBoxcatLocal", values.bcat_boxcat_local.GetValue());
74 log_setting("Input_EnableMotion", values.motion_enabled.GetValue());
75 log_setting("Input_EnableVibration", values.vibration_enabled.GetValue());
76 log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue());
75} 77}
76 78
77bool IsConfiguringGlobal() { 79bool IsConfiguringGlobal() {
@@ -112,7 +114,6 @@ void RestoreGlobalState(bool is_powered_on) {
112 } 114 }
113 115
114 // Audio 116 // Audio
115 values.enable_audio_stretching.SetGlobal(true);
116 values.volume.SetGlobal(true); 117 values.volume.SetGlobal(true);
117 118
118 // Core 119 // Core
diff --git a/src/common/settings.h b/src/common/settings.h
index b7195670b..c53d5acc3 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -16,7 +16,6 @@
16 16
17#include "common/common_types.h" 17#include "common/common_types.h"
18#include "common/settings_input.h" 18#include "common/settings_input.h"
19#include "input_common/udp/client.h"
20 19
21namespace Settings { 20namespace Settings {
22 21
@@ -415,7 +414,6 @@ struct Values {
415 BasicSetting<std::string> audio_device_id{"auto", "output_device"}; 414 BasicSetting<std::string> audio_device_id{"auto", "output_device"};
416 BasicSetting<std::string> sink_id{"auto", "output_engine"}; 415 BasicSetting<std::string> sink_id{"auto", "output_engine"};
417 BasicSetting<bool> audio_muted{false, "audio_muted"}; 416 BasicSetting<bool> audio_muted{false, "audio_muted"};
418 Setting<bool> enable_audio_stretching{true, "enable_audio_stretching"};
419 RangedSetting<u8> volume{100, 0, 100, "volume"}; 417 RangedSetting<u8> volume{100, 0, 100, "volume"};
420 418
421 // Core 419 // Core
@@ -504,14 +502,20 @@ struct Values {
504 502
505 Setting<bool> use_docked_mode{true, "use_docked_mode"}; 503 Setting<bool> use_docked_mode{true, "use_docked_mode"};
506 504
505 BasicSetting<bool> enable_raw_input{false, "enable_raw_input"};
506
507 Setting<bool> vibration_enabled{true, "vibration_enabled"}; 507 Setting<bool> vibration_enabled{true, "vibration_enabled"};
508 Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"}; 508 Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"};
509 509
510 Setting<bool> motion_enabled{true, "motion_enabled"}; 510 Setting<bool> motion_enabled{true, "motion_enabled"};
511 BasicSetting<std::string> motion_device{"engine:motion_emu,update_period:100,sensitivity:0.01", 511 BasicSetting<std::string> motion_device{"engine:motion_emu,update_period:100,sensitivity:0.01",
512 "motion_device"}; 512 "motion_device"};
513 BasicSetting<std::string> udp_input_servers{InputCommon::CemuhookUDP::DEFAULT_SRV, 513 BasicSetting<std::string> udp_input_servers{"127.0.0.1:26760", "udp_input_servers"};
514 "udp_input_servers"}; 514
515 BasicSetting<bool> pause_tas_on_load{true, "pause_tas_on_load"};
516 BasicSetting<bool> tas_enable{false, "tas_enable"};
517 BasicSetting<bool> tas_loop{false, "tas_loop"};
518 BasicSetting<bool> tas_swap_controllers{true, "tas_swap_controllers"};
515 519
516 BasicSetting<bool> mouse_panning{false, "mouse_panning"}; 520 BasicSetting<bool> mouse_panning{false, "mouse_panning"};
517 BasicRangedSetting<u8> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; 521 BasicRangedSetting<u8> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"};
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h
index 8430b9778..2c8c2b90e 100644
--- a/src/common/threadsafe_queue.h
+++ b/src/common/threadsafe_queue.h
@@ -14,7 +14,7 @@
14#include <utility> 14#include <utility>
15 15
16namespace Common { 16namespace Common {
17template <typename T> 17template <typename T, bool with_stop_token = false>
18class SPSCQueue { 18class SPSCQueue {
19public: 19public:
20 SPSCQueue() { 20 SPSCQueue() {
@@ -84,7 +84,7 @@ public:
84 void Wait() { 84 void Wait() {
85 if (Empty()) { 85 if (Empty()) {
86 std::unique_lock lock{cv_mutex}; 86 std::unique_lock lock{cv_mutex};
87 cv.wait(lock, [this]() { return !Empty(); }); 87 cv.wait(lock, [this] { return !Empty(); });
88 } 88 }
89 } 89 }
90 90
@@ -95,6 +95,19 @@ public:
95 return t; 95 return t;
96 } 96 }
97 97
98 T PopWait(std::stop_token stop_token) {
99 if (Empty()) {
100 std::unique_lock lock{cv_mutex};
101 cv.wait(lock, stop_token, [this] { return !Empty(); });
102 }
103 if (stop_token.stop_requested()) {
104 return T{};
105 }
106 T t;
107 Pop(t);
108 return t;
109 }
110
98 // not thread-safe 111 // not thread-safe
99 void Clear() { 112 void Clear() {
100 size.store(0); 113 size.store(0);
@@ -123,13 +136,13 @@ private:
123 ElementPtr* read_ptr; 136 ElementPtr* read_ptr;
124 std::atomic_size_t size{0}; 137 std::atomic_size_t size{0};
125 std::mutex cv_mutex; 138 std::mutex cv_mutex;
126 std::condition_variable cv; 139 std::conditional_t<with_stop_token, std::condition_variable_any, std::condition_variable> cv;
127}; 140};
128 141
129// a simple thread-safe, 142// a simple thread-safe,
130// single reader, multiple writer queue 143// single reader, multiple writer queue
131 144
132template <typename T> 145template <typename T, bool with_stop_token = false>
133class MPSCQueue { 146class MPSCQueue {
134public: 147public:
135 [[nodiscard]] std::size_t Size() const { 148 [[nodiscard]] std::size_t Size() const {
@@ -166,13 +179,17 @@ public:
166 return spsc_queue.PopWait(); 179 return spsc_queue.PopWait();
167 } 180 }
168 181
182 T PopWait(std::stop_token stop_token) {
183 return spsc_queue.PopWait(stop_token);
184 }
185
169 // not thread-safe 186 // not thread-safe
170 void Clear() { 187 void Clear() {
171 spsc_queue.Clear(); 188 spsc_queue.Clear();
172 } 189 }
173 190
174private: 191private:
175 SPSCQueue<T> spsc_queue; 192 SPSCQueue<T, with_stop_token> spsc_queue;
176 std::mutex write_lock; 193 std::mutex write_lock;
177}; 194};
178} // namespace Common 195} // namespace Common