summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.ci/scripts/format/script.sh2
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/common/alignment.h21
-rw-r--r--src/common/div_ceil.h8
-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/intrusive_red_black_tree.h17
-rw-r--r--src/common/settings.cpp2
-rw-r--r--src/common/settings.h6
-rw-r--r--src/common/threadsafe_queue.h27
-rw-r--r--src/common/uuid.h7
-rw-r--r--src/common/vector_math.h4
-rw-r--r--src/core/core.cpp6
-rw-r--r--src/core/frontend/applets/profile_select.cpp3
-rw-r--r--src/core/hle/kernel/k_priority_queue.h27
-rw-r--r--src/core/hle/kernel/k_scheduler.h2
-rw-r--r--src/core/hle/kernel/k_scoped_lock.h15
-rw-r--r--src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h2
-rw-r--r--src/core/hle/service/acc/acc.cpp3
-rw-r--r--src/core/hle/service/acc/profile_manager.cpp9
-rw-r--r--src/core/hle/service/am/am.cpp4
-rw-r--r--src/core/hle/service/am/applets/applet_profile_select.cpp2
-rw-r--r--src/core/hle/service/audio/audctl.cpp8
-rw-r--r--src/core/hle/service/audio/audren_u.cpp3
-rw-r--r--src/core/hle/service/btdrv/btdrv.cpp4
-rw-r--r--src/core/hle/service/caps/caps_ss.cpp1
-rw-r--r--src/core/hle/service/es/es.cpp6
-rw-r--r--src/core/hle/service/hid/controllers/npad.h1
-rw-r--r--src/core/hle/service/hid/hid.cpp9
-rw-r--r--src/core/hle/service/npns/npns.cpp1
-rw-r--r--src/core/hle/service/sockets/bsd.cpp14
-rw-r--r--src/core/hle/service/sockets/bsd.h1
-rw-r--r--src/core/hle/service/usb/usb.cpp6
-rw-r--r--src/core/hle/service/vi/vi.cpp1
-rw-r--r--src/core/telemetry_session.cpp2
-rw-r--r--src/input_common/CMakeLists.txt4
-rw-r--r--src/input_common/main.cpp56
-rw-r--r--src/input_common/main.h39
-rw-r--r--src/input_common/tas/tas_input.cpp455
-rw-r--r--src/input_common/tas/tas_input.h237
-rw-r--r--src/input_common/tas/tas_poller.cpp101
-rw-r--r--src/input_common/tas/tas_poller.h43
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp8
-rw-r--r--src/shader_recompiler/object_pool.h6
-rw-r--r--src/video_core/gpu.cpp8
-rw-r--r--src/video_core/gpu.h3
-rw-r--r--src/video_core/gpu_thread.cpp57
-rw-r--r--src/video_core/gpu_thread.h13
-rw-r--r--src/video_core/renderer_vulkan/renderer_vulkan.cpp15
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp5
-rw-r--r--src/video_core/renderer_vulkan/vk_scheduler.cpp19
-rw-r--r--src/video_core/renderer_vulkan/vk_scheduler.h7
-rw-r--r--src/video_core/renderer_vulkan/vk_swapchain.cpp29
-rw-r--r--src/video_core/renderer_vulkan/vk_swapchain.h11
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp2
-rw-r--r--src/video_core/texture_cache/slot_vector.h4
-rw-r--r--src/video_core/vulkan_common/vulkan_device.cpp25
-rw-r--r--src/video_core/vulkan_common/vulkan_device.h6
-rw-r--r--src/yuzu/CMakeLists.txt3
-rw-r--r--src/yuzu/bootmanager.cpp2
-rw-r--r--src/yuzu/configuration/config.cpp28
-rw-r--r--src/yuzu/configuration/config.h2
-rw-r--r--src/yuzu/configuration/configure_audio.cpp9
-rw-r--r--src/yuzu/configuration/configure_audio.h2
-rw-r--r--src/yuzu/configuration/configure_audio.ui10
-rw-r--r--src/yuzu/configuration/configure_debug.ui181
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp30
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.cpp19
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.h3
-rw-r--r--src/yuzu/configuration/configure_tas.cpp84
-rw-r--r--src/yuzu/configuration/configure_tas.h38
-rw-r--r--src/yuzu/configuration/configure_tas.ui153
-rw-r--r--src/yuzu/configuration/configure_vibration.cpp2
-rw-r--r--src/yuzu/debugger/controller.cpp18
-rw-r--r--src/yuzu/debugger/controller.h22
-rw-r--r--src/yuzu/main.cpp67
-rw-r--r--src/yuzu/main.h3
-rw-r--r--src/yuzu/main.ui6
-rw-r--r--src/yuzu_cmd/config.cpp1
80 files changed, 1707 insertions, 360 deletions
diff --git a/.ci/scripts/format/script.sh b/.ci/scripts/format/script.sh
index 969ab637c..c2550c966 100644
--- a/.ci/scripts/format/script.sh
+++ b/.ci/scripts/format/script.sh
@@ -7,7 +7,7 @@ if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dis
7fi 7fi
8 8
9# Default clang-format points to default 3.5 version one 9# Default clang-format points to default 3.5 version one
10CLANG_FORMAT=clang-format-10 10CLANG_FORMAT=clang-format-12
11$CLANG_FORMAT --version 11$CLANG_FORMAT --version
12 12
13if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then 13if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5df2ff3fa..b7ea86d8a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -135,7 +135,7 @@ endif()
135# boost asio's concept usage doesn't play nicely with some compilers yet. 135# boost asio's concept usage doesn't play nicely with some compilers yet.
136add_definitions(-DBOOST_ASIO_DISABLE_CONCEPTS) 136add_definitions(-DBOOST_ASIO_DISABLE_CONCEPTS)
137if (MSVC) 137if (MSVC)
138 add_compile_options(/std:c++latest) 138 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>)
139 139
140 # cubeb and boost still make use of deprecated result_of. 140 # cubeb and boost still make use of deprecated result_of.
141 add_definitions(-D_HAS_DEPRECATED_RESULT_OF) 141 add_definitions(-D_HAS_DEPRECATED_RESULT_OF)
@@ -780,7 +780,7 @@ endif()
780# against all the src files. This should be used before making a pull request. 780# against all the src files. This should be used before making a pull request.
781# ======================================================================= 781# =======================================================================
782 782
783set(CLANG_FORMAT_POSTFIX "-10") 783set(CLANG_FORMAT_POSTFIX "-12")
784find_program(CLANG_FORMAT 784find_program(CLANG_FORMAT
785 NAMES clang-format${CLANG_FORMAT_POSTFIX} 785 NAMES clang-format${CLANG_FORMAT_POSTFIX}
786 clang-format 786 clang-format
diff --git a/src/common/alignment.h b/src/common/alignment.h
index 32d796ffa..1b56569d1 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -9,41 +9,48 @@
9namespace Common { 9namespace Common {
10 10
11template <typename T> 11template <typename T>
12requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUp(T value, size_t size) { 12requires std::is_unsigned_v<T>
13[[nodiscard]] constexpr T AlignUp(T value, size_t size) {
13 auto mod{static_cast<T>(value % size)}; 14 auto mod{static_cast<T>(value % size)};
14 value -= mod; 15 value -= mod;
15 return static_cast<T>(mod == T{0} ? value : value + size); 16 return static_cast<T>(mod == T{0} ? value : value + size);
16} 17}
17 18
18template <typename T> 19template <typename T>
19requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) { 20requires std::is_unsigned_v<T>
21[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) {
20 return static_cast<T>((value + ((1ULL << align_log2) - 1)) >> align_log2 << align_log2); 22 return static_cast<T>((value + ((1ULL << align_log2) - 1)) >> align_log2 << align_log2);
21} 23}
22 24
23template <typename T> 25template <typename T>
24requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignDown(T value, size_t size) { 26requires std::is_unsigned_v<T>
27[[nodiscard]] constexpr T AlignDown(T value, size_t size) {
25 return static_cast<T>(value - value % size); 28 return static_cast<T>(value - value % size);
26} 29}
27 30
28template <typename T> 31template <typename T>
29requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool Is4KBAligned(T value) { 32requires std::is_unsigned_v<T>
33[[nodiscard]] constexpr bool Is4KBAligned(T value) {
30 return (value & 0xFFF) == 0; 34 return (value & 0xFFF) == 0;
31} 35}
32 36
33template <typename T> 37template <typename T>
34requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool IsWordAligned(T value) { 38requires std::is_unsigned_v<T>
39[[nodiscard]] constexpr bool IsWordAligned(T value) {
35 return (value & 0b11) == 0; 40 return (value & 0b11) == 0;
36} 41}
37 42
38template <typename T> 43template <typename T>
39requires std::is_integral_v<T>[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) { 44requires std::is_integral_v<T>
45[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) {
40 using U = typename std::make_unsigned_t<T>; 46 using U = typename std::make_unsigned_t<T>;
41 const U mask = static_cast<U>(alignment - 1); 47 const U mask = static_cast<U>(alignment - 1);
42 return (value & mask) == 0; 48 return (value & mask) == 0;
43} 49}
44 50
45template <typename T, typename U> 51template <typename T, typename U>
46requires std::is_integral_v<T>[[nodiscard]] constexpr T DivideUp(T x, U y) { 52requires std::is_integral_v<T>
53[[nodiscard]] constexpr T DivideUp(T x, U y) {
47 return (x + (y - 1)) / y; 54 return (x + (y - 1)) / y;
48} 55}
49 56
diff --git a/src/common/div_ceil.h b/src/common/div_ceil.h
index 95e1489a9..e1db35464 100644
--- a/src/common/div_ceil.h
+++ b/src/common/div_ceil.h
@@ -11,15 +11,15 @@ namespace Common {
11 11
12/// Ceiled integer division. 12/// Ceiled integer division.
13template <typename N, typename D> 13template <typename N, typename D>
14requires std::is_integral_v<N>&& std::is_unsigned_v<D>[[nodiscard]] constexpr N DivCeil(N number, 14requires std::is_integral_v<N> && std::is_unsigned_v<D>
15 D divisor) { 15[[nodiscard]] constexpr N DivCeil(N number, D divisor) {
16 return static_cast<N>((static_cast<D>(number) + divisor - 1) / divisor); 16 return static_cast<N>((static_cast<D>(number) + divisor - 1) / divisor);
17} 17}
18 18
19/// Ceiled integer division with logarithmic divisor in base 2 19/// Ceiled integer division with logarithmic divisor in base 2
20template <typename N, typename D> 20template <typename N, typename D>
21requires std::is_integral_v<N>&& std::is_unsigned_v<D>[[nodiscard]] constexpr N DivCeilLog2( 21requires std::is_integral_v<N> && std::is_unsigned_v<D>
22 N value, D alignment_log2) { 22[[nodiscard]] constexpr N DivCeilLog2(N value, D alignment_log2) {
23 return static_cast<N>((static_cast<D>(value) + (D(1) << alignment_log2) - 1) >> alignment_log2); 23 return static_cast<N>((static_cast<D>(value) + (D(1) << alignment_log2) - 1) >> alignment_log2);
24} 24}
25 25
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/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h
index 1f696fe80..3173cc449 100644
--- a/src/common/intrusive_red_black_tree.h
+++ b/src/common/intrusive_red_black_tree.h
@@ -235,20 +235,19 @@ public:
235 235
236template <typename T> 236template <typename T>
237concept HasLightCompareType = requires { 237concept HasLightCompareType = requires {
238 { std::is_same<typename T::LightCompareType, void>::value } 238 { std::is_same<typename T::LightCompareType, void>::value } -> std::convertible_to<bool>;
239 ->std::convertible_to<bool>;
240}; 239};
241 240
242namespace impl { 241namespace impl {
243 242
244template <typename T, typename Default> 243 template <typename T, typename Default>
245consteval auto* GetLightCompareType() { 244 consteval auto* GetLightCompareType() {
246 if constexpr (HasLightCompareType<T>) { 245 if constexpr (HasLightCompareType<T>) {
247 return static_cast<typename T::LightCompareType*>(nullptr); 246 return static_cast<typename T::LightCompareType*>(nullptr);
248 } else { 247 } else {
249 return static_cast<Default*>(nullptr); 248 return static_cast<Default*>(nullptr);
249 }
250 } 250 }
251}
252 251
253} // namespace impl 252} // namespace impl
254 253
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index e1fa90c5a..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));
@@ -115,7 +114,6 @@ void RestoreGlobalState(bool is_powered_on) {
115 } 114 }
116 115
117 // Audio 116 // Audio
118 values.enable_audio_stretching.SetGlobal(true);
119 values.volume.SetGlobal(true); 117 values.volume.SetGlobal(true);
120 118
121 // Core 119 // Core
diff --git a/src/common/settings.h b/src/common/settings.h
index e674ccc5c..c53d5acc3 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -414,7 +414,6 @@ struct Values {
414 BasicSetting<std::string> audio_device_id{"auto", "output_device"}; 414 BasicSetting<std::string> audio_device_id{"auto", "output_device"};
415 BasicSetting<std::string> sink_id{"auto", "output_engine"}; 415 BasicSetting<std::string> sink_id{"auto", "output_engine"};
416 BasicSetting<bool> audio_muted{false, "audio_muted"}; 416 BasicSetting<bool> audio_muted{false, "audio_muted"};
417 Setting<bool> enable_audio_stretching{true, "enable_audio_stretching"};
418 RangedSetting<u8> volume{100, 0, 100, "volume"}; 417 RangedSetting<u8> volume{100, 0, 100, "volume"};
419 418
420 // Core 419 // Core
@@ -513,6 +512,11 @@ struct Values {
513 "motion_device"}; 512 "motion_device"};
514 BasicSetting<std::string> udp_input_servers{"127.0.0.1:26760", "udp_input_servers"}; 513 BasicSetting<std::string> udp_input_servers{"127.0.0.1:26760", "udp_input_servers"};
515 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"};
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"};
518 BasicSetting<bool> mouse_enabled{false, "mouse_enabled"}; 522 BasicSetting<bool> mouse_enabled{false, "mouse_enabled"};
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
diff --git a/src/common/uuid.h b/src/common/uuid.h
index 2353179d8..8ea01f8da 100644
--- a/src/common/uuid.h
+++ b/src/common/uuid.h
@@ -58,6 +58,13 @@ struct UUID {
58 uuid = INVALID_UUID; 58 uuid = INVALID_UUID;
59 } 59 }
60 60
61 [[nodiscard]] constexpr bool IsInvalid() const {
62 return uuid == INVALID_UUID;
63 }
64 [[nodiscard]] constexpr bool IsValid() const {
65 return !IsInvalid();
66 }
67
61 // TODO(ogniK): Properly generate a Nintendo ID 68 // TODO(ogniK): Properly generate a Nintendo ID
62 [[nodiscard]] constexpr u64 GetNintendoID() const { 69 [[nodiscard]] constexpr u64 GetNintendoID() const {
63 return uuid[0]; 70 return uuid[0];
diff --git a/src/common/vector_math.h b/src/common/vector_math.h
index 22dba3c2d..ba7c363c1 100644
--- a/src/common/vector_math.h
+++ b/src/common/vector_math.h
@@ -667,8 +667,8 @@ template <typename T>
667 667
668// linear interpolation via float: 0.0=begin, 1.0=end 668// linear interpolation via float: 0.0=begin, 1.0=end
669template <typename X> 669template <typename X>
670[[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{}) Lerp(const X& begin, const X& end, 670[[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{})
671 const float t) { 671 Lerp(const X& begin, const X& end, const float t) {
672 return begin * (1.f - t) + end * t; 672 return begin * (1.f - t) + end * t;
673} 673}
674 674
diff --git a/src/core/core.cpp b/src/core/core.cpp
index b13350f6e..50d5dab4b 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -305,10 +305,6 @@ struct System::Impl {
305 is_powered_on = false; 305 is_powered_on = false;
306 exit_lock = false; 306 exit_lock = false;
307 307
308 if (gpu_core) {
309 gpu_core->ShutDown();
310 }
311
312 services.reset(); 308 services.reset();
313 service_manager.reset(); 309 service_manager.reset();
314 cheat_engine.reset(); 310 cheat_engine.reset();
@@ -317,8 +313,8 @@ struct System::Impl {
317 time_manager.Shutdown(); 313 time_manager.Shutdown();
318 core_timing.Shutdown(); 314 core_timing.Shutdown();
319 app_loader.reset(); 315 app_loader.reset();
320 gpu_core.reset();
321 perf_stats.reset(); 316 perf_stats.reset();
317 gpu_core.reset();
322 kernel.Shutdown(); 318 kernel.Shutdown();
323 memory.Reset(); 319 memory.Reset();
324 applet_manager.ClearAll(); 320 applet_manager.ClearAll();
diff --git a/src/core/frontend/applets/profile_select.cpp b/src/core/frontend/applets/profile_select.cpp
index 4c58c310f..3e4f90be2 100644
--- a/src/core/frontend/applets/profile_select.cpp
+++ b/src/core/frontend/applets/profile_select.cpp
@@ -13,7 +13,8 @@ ProfileSelectApplet::~ProfileSelectApplet() = default;
13void DefaultProfileSelectApplet::SelectProfile( 13void DefaultProfileSelectApplet::SelectProfile(
14 std::function<void(std::optional<Common::UUID>)> callback) const { 14 std::function<void(std::optional<Common::UUID>)> callback) const {
15 Service::Account::ProfileManager manager; 15 Service::Account::ProfileManager manager;
16 callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::UUID{})); 16 callback(manager.GetUser(Settings::values.current_user.GetValue())
17 .value_or(Common::UUID{Common::INVALID_UUID}));
17 LOG_INFO(Service_ACC, "called, selecting current user instead of prompting..."); 18 LOG_INFO(Service_ACC, "called, selecting current user instead of prompting...");
18} 19}
19 20
diff --git a/src/core/hle/kernel/k_priority_queue.h b/src/core/hle/kernel/k_priority_queue.h
index 4aa669d95..f4d71ad7e 100644
--- a/src/core/hle/kernel/k_priority_queue.h
+++ b/src/core/hle/kernel/k_priority_queue.h
@@ -22,12 +22,10 @@ class KThread;
22 22
23template <typename T> 23template <typename T>
24concept KPriorityQueueAffinityMask = !std::is_reference_v<T> && requires(T & t) { 24concept KPriorityQueueAffinityMask = !std::is_reference_v<T> && requires(T & t) {
25 { t.GetAffinityMask() } 25 { t.GetAffinityMask() } -> Common::ConvertibleTo<u64>;
26 ->Common::ConvertibleTo<u64>;
27 {t.SetAffinityMask(0)}; 26 {t.SetAffinityMask(0)};
28 27
29 { t.GetAffinity(0) } 28 { t.GetAffinity(0) } -> std::same_as<bool>;
30 ->std::same_as<bool>;
31 {t.SetAffinity(0, false)}; 29 {t.SetAffinity(0, false)};
32 {t.SetAll()}; 30 {t.SetAll()};
33}; 31};
@@ -38,25 +36,20 @@ concept KPriorityQueueMember = !std::is_reference_v<T> && requires(T & t) {
38 {(typename T::QueueEntry()).Initialize()}; 36 {(typename T::QueueEntry()).Initialize()};
39 {(typename T::QueueEntry()).SetPrev(std::addressof(t))}; 37 {(typename T::QueueEntry()).SetPrev(std::addressof(t))};
40 {(typename T::QueueEntry()).SetNext(std::addressof(t))}; 38 {(typename T::QueueEntry()).SetNext(std::addressof(t))};
41 { (typename T::QueueEntry()).GetNext() } 39 { (typename T::QueueEntry()).GetNext() } -> std::same_as<T*>;
42 ->std::same_as<T*>; 40 { (typename T::QueueEntry()).GetPrev() } -> std::same_as<T*>;
43 { (typename T::QueueEntry()).GetPrev() } 41 { t.GetPriorityQueueEntry(0) } -> std::same_as<typename T::QueueEntry&>;
44 ->std::same_as<T*>;
45 { t.GetPriorityQueueEntry(0) }
46 ->std::same_as<typename T::QueueEntry&>;
47 42
48 {t.GetAffinityMask()}; 43 {t.GetAffinityMask()};
49 { std::remove_cvref_t<decltype(t.GetAffinityMask())>() } 44 { std::remove_cvref_t<decltype(t.GetAffinityMask())>() } -> KPriorityQueueAffinityMask;
50 ->KPriorityQueueAffinityMask;
51 45
52 { t.GetActiveCore() } 46 { t.GetActiveCore() } -> Common::ConvertibleTo<s32>;
53 ->Common::ConvertibleTo<s32>; 47 { t.GetPriority() } -> Common::ConvertibleTo<s32>;
54 { t.GetPriority() }
55 ->Common::ConvertibleTo<s32>;
56}; 48};
57 49
58template <typename Member, size_t NumCores_, int LowestPriority, int HighestPriority> 50template <typename Member, size_t NumCores_, int LowestPriority, int HighestPriority>
59requires KPriorityQueueMember<Member> class KPriorityQueue { 51requires KPriorityQueueMember<Member>
52class KPriorityQueue {
60public: 53public:
61 using AffinityMaskType = std::remove_cv_t< 54 using AffinityMaskType = std::remove_cv_t<
62 std::remove_reference_t<decltype(std::declval<Member>().GetAffinityMask())>>; 55 std::remove_reference_t<decltype(std::declval<Member>().GetAffinityMask())>>;
diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h
index 12cfae919..c8ccc1ae4 100644
--- a/src/core/hle/kernel/k_scheduler.h
+++ b/src/core/hle/kernel/k_scheduler.h
@@ -197,7 +197,7 @@ private:
197 197
198class [[nodiscard]] KScopedSchedulerLock : KScopedLock<GlobalSchedulerContext::LockType> { 198class [[nodiscard]] KScopedSchedulerLock : KScopedLock<GlobalSchedulerContext::LockType> {
199public: 199public:
200 explicit KScopedSchedulerLock(KernelCore & kernel); 200 explicit KScopedSchedulerLock(KernelCore& kernel);
201 ~KScopedSchedulerLock(); 201 ~KScopedSchedulerLock();
202}; 202};
203 203
diff --git a/src/core/hle/kernel/k_scoped_lock.h b/src/core/hle/kernel/k_scoped_lock.h
index 72c3b0252..4fb180fc6 100644
--- a/src/core/hle/kernel/k_scoped_lock.h
+++ b/src/core/hle/kernel/k_scoped_lock.h
@@ -13,19 +13,18 @@ namespace Kernel {
13 13
14template <typename T> 14template <typename T>
15concept KLockable = !std::is_reference_v<T> && requires(T & t) { 15concept KLockable = !std::is_reference_v<T> && requires(T & t) {
16 { t.Lock() } 16 { t.Lock() } -> std::same_as<void>;
17 ->std::same_as<void>; 17 { t.Unlock() } -> std::same_as<void>;
18 { t.Unlock() }
19 ->std::same_as<void>;
20}; 18};
21 19
22template <typename T> 20template <typename T>
23requires KLockable<T> class [[nodiscard]] KScopedLock { 21requires KLockable<T>
22class [[nodiscard]] KScopedLock {
24public: 23public:
25 explicit KScopedLock(T * l) : lock_ptr(l) { 24 explicit KScopedLock(T* l) : lock_ptr(l) {
26 this->lock_ptr->Lock(); 25 this->lock_ptr->Lock();
27 } 26 }
28 explicit KScopedLock(T & l) : KScopedLock(std::addressof(l)) {} 27 explicit KScopedLock(T& l) : KScopedLock(std::addressof(l)) {}
29 28
30 ~KScopedLock() { 29 ~KScopedLock() {
31 this->lock_ptr->Unlock(); 30 this->lock_ptr->Unlock();
@@ -34,7 +33,7 @@ public:
34 KScopedLock(const KScopedLock&) = delete; 33 KScopedLock(const KScopedLock&) = delete;
35 KScopedLock& operator=(const KScopedLock&) = delete; 34 KScopedLock& operator=(const KScopedLock&) = delete;
36 35
37 KScopedLock(KScopedLock &&) = delete; 36 KScopedLock(KScopedLock&&) = delete;
38 KScopedLock& operator=(KScopedLock&&) = delete; 37 KScopedLock& operator=(KScopedLock&&) = delete;
39 38
40private: 39private:
diff --git a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h
index a86af56dd..f6c75f2d9 100644
--- a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h
+++ b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h
@@ -17,7 +17,7 @@ namespace Kernel {
17 17
18class [[nodiscard]] KScopedSchedulerLockAndSleep { 18class [[nodiscard]] KScopedSchedulerLockAndSleep {
19public: 19public:
20 explicit KScopedSchedulerLockAndSleep(KernelCore & kernel_, KThread * t, s64 timeout) 20 explicit KScopedSchedulerLockAndSleep(KernelCore& kernel_, KThread* t, s64 timeout)
21 : kernel(kernel_), thread(t), timeout_tick(timeout) { 21 : kernel(kernel_), thread(t), timeout_tick(timeout) {
22 // Lock the scheduler. 22 // Lock the scheduler.
23 kernel.GlobalSchedulerContext().scheduler_lock.Lock(); 23 kernel.GlobalSchedulerContext().scheduler_lock.Lock();
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 6d9ec0a8a..689b36056 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -929,8 +929,7 @@ void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContex
929 } 929 }
930 930
931 const auto user_list = profile_manager->GetAllUsers(); 931 const auto user_list = profile_manager->GetAllUsers();
932 if (std::all_of(user_list.begin(), user_list.end(), 932 if (std::ranges::all_of(user_list, [](const auto& user) { return user.IsInvalid(); })) {
933 [](const auto& user) { return user.uuid == Common::INVALID_UUID; })) {
934 rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code 933 rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code
935 rb.PushRaw<u128>(Common::INVALID_UUID); 934 rb.PushRaw<u128>(Common::INVALID_UUID);
936 return; 935 return;
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp
index 24a1c9157..568303ced 100644
--- a/src/core/hle/service/acc/profile_manager.cpp
+++ b/src/core/hle/service/acc/profile_manager.cpp
@@ -208,9 +208,10 @@ bool ProfileManager::UserExists(UUID uuid) const {
208} 208}
209 209
210bool ProfileManager::UserExistsIndex(std::size_t index) const { 210bool ProfileManager::UserExistsIndex(std::size_t index) const {
211 if (index >= MAX_USERS) 211 if (index >= MAX_USERS) {
212 return false; 212 return false;
213 return profiles[index].user_uuid.uuid != Common::INVALID_UUID; 213 }
214 return profiles[index].user_uuid.IsValid();
214} 215}
215 216
216/// Opens a specific user 217/// Opens a specific user
@@ -304,7 +305,7 @@ bool ProfileManager::RemoveUser(UUID uuid) {
304 305
305bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { 306bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) {
306 const auto index = GetUserIndex(uuid); 307 const auto index = GetUserIndex(uuid);
307 if (!index || profile_new.user_uuid == UUID(Common::INVALID_UUID)) { 308 if (!index || profile_new.user_uuid.IsInvalid()) {
308 return false; 309 return false;
309 } 310 }
310 311
@@ -346,7 +347,7 @@ void ProfileManager::ParseUserSaveFile() {
346 } 347 }
347 348
348 for (const auto& user : data.users) { 349 for (const auto& user : data.users) {
349 if (user.uuid == UUID(Common::INVALID_UUID)) { 350 if (user.uuid.IsInvalid()) {
350 continue; 351 continue;
351 } 352 }
352 353
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index c3ac73131..8c2e2f920 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -275,12 +275,14 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
275 {18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"}, 275 {18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"},
276 {19, &ISelfController::SetAlbumImageOrientation, "SetAlbumImageOrientation"}, 276 {19, &ISelfController::SetAlbumImageOrientation, "SetAlbumImageOrientation"},
277 {20, nullptr, "SetDesirableKeyboardLayout"}, 277 {20, nullptr, "SetDesirableKeyboardLayout"},
278 {21, nullptr, "GetScreenShotProgramId"},
278 {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"}, 279 {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"},
279 {41, nullptr, "IsSystemBufferSharingEnabled"}, 280 {41, nullptr, "IsSystemBufferSharingEnabled"},
280 {42, nullptr, "GetSystemSharedLayerHandle"}, 281 {42, nullptr, "GetSystemSharedLayerHandle"},
281 {43, nullptr, "GetSystemSharedBufferHandle"}, 282 {43, nullptr, "GetSystemSharedBufferHandle"},
282 {44, &ISelfController::CreateManagedDisplaySeparableLayer, "CreateManagedDisplaySeparableLayer"}, 283 {44, &ISelfController::CreateManagedDisplaySeparableLayer, "CreateManagedDisplaySeparableLayer"},
283 {45, nullptr, "SetManagedDisplayLayerSeparationMode"}, 284 {45, nullptr, "SetManagedDisplayLayerSeparationMode"},
285 {46, nullptr, "SetRecordingLayerCompositionEnabled"},
284 {50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"}, 286 {50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"},
285 {51, nullptr, "ApproveToDisplay"}, 287 {51, nullptr, "ApproveToDisplay"},
286 {60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"}, 288 {60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"},
@@ -302,6 +304,7 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv
302 {100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"}, 304 {100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"},
303 {110, nullptr, "SetApplicationAlbumUserData"}, 305 {110, nullptr, "SetApplicationAlbumUserData"},
304 {120, nullptr, "SaveCurrentScreenshot"}, 306 {120, nullptr, "SaveCurrentScreenshot"},
307 {130, nullptr, "SetRecordVolumeMuted"},
305 {1000, nullptr, "GetDebugStorageChannel"}, 308 {1000, nullptr, "GetDebugStorageChannel"},
306 }; 309 };
307 // clang-format on 310 // clang-format on
@@ -683,6 +686,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_,
683 {91, nullptr, "GetCurrentPerformanceConfiguration"}, 686 {91, nullptr, "GetCurrentPerformanceConfiguration"},
684 {100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"}, 687 {100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"},
685 {110, nullptr, "OpenMyGpuErrorHandler"}, 688 {110, nullptr, "OpenMyGpuErrorHandler"},
689 {120, nullptr, "GetAppletLaunchedHistory"},
686 {200, nullptr, "GetOperationModeSystemInfo"}, 690 {200, nullptr, "GetOperationModeSystemInfo"},
687 {300, nullptr, "GetSettingsPlatformRegion"}, 691 {300, nullptr, "GetSettingsPlatformRegion"},
688 {400, nullptr, "ActivateMigrationService"}, 692 {400, nullptr, "ActivateMigrationService"},
diff --git a/src/core/hle/service/am/applets/applet_profile_select.cpp b/src/core/hle/service/am/applets/applet_profile_select.cpp
index bdc21778e..a6e891944 100644
--- a/src/core/hle/service/am/applets/applet_profile_select.cpp
+++ b/src/core/hle/service/am/applets/applet_profile_select.cpp
@@ -60,7 +60,7 @@ void ProfileSelect::Execute() {
60void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) { 60void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
61 UserSelectionOutput output{}; 61 UserSelectionOutput output{};
62 62
63 if (uuid.has_value() && uuid->uuid != Common::INVALID_UUID) { 63 if (uuid.has_value() && uuid->IsValid()) {
64 output.result = 0; 64 output.result = 0;
65 output.uuid_selected = uuid->uuid; 65 output.uuid_selected = uuid->uuid;
66 } else { 66 } else {
diff --git a/src/core/hle/service/audio/audctl.cpp b/src/core/hle/service/audio/audctl.cpp
index 8c4c49b85..2e46e7161 100644
--- a/src/core/hle/service/audio/audctl.cpp
+++ b/src/core/hle/service/audio/audctl.cpp
@@ -41,6 +41,14 @@ AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} {
41 {27, nullptr, "SetVolumeMappingTableForDev"}, 41 {27, nullptr, "SetVolumeMappingTableForDev"},
42 {28, nullptr, "GetAudioOutputChannelCountForPlayReport"}, 42 {28, nullptr, "GetAudioOutputChannelCountForPlayReport"},
43 {29, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"}, 43 {29, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"},
44 {30, nullptr, "Unknown30"},
45 {31, nullptr, "Unknown31"},
46 {32, nullptr, "Unknown32"},
47 {33, nullptr, "Unknown33"},
48 {34, nullptr, "Unknown34"},
49 {10000, nullptr, "Unknown10000"},
50 {10001, nullptr, "Unknown10001"},
51 {10002, nullptr, "Unknown10002"},
44 }; 52 };
45 // clang-format on 53 // clang-format on
46 54
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index b769fe959..1a91719f5 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -187,7 +187,8 @@ public:
187 {10, &IAudioDevice::GetActiveAudioDeviceName, "GetActiveAudioDeviceNameAuto"}, 187 {10, &IAudioDevice::GetActiveAudioDeviceName, "GetActiveAudioDeviceNameAuto"},
188 {11, &IAudioDevice::QueryAudioDeviceInputEvent, "QueryAudioDeviceInputEvent"}, 188 {11, &IAudioDevice::QueryAudioDeviceInputEvent, "QueryAudioDeviceInputEvent"},
189 {12, &IAudioDevice::QueryAudioDeviceOutputEvent, "QueryAudioDeviceOutputEvent"}, 189 {12, &IAudioDevice::QueryAudioDeviceOutputEvent, "QueryAudioDeviceOutputEvent"},
190 {13, nullptr, "GetAudioSystemMasterVolumeSetting"}, 190 {13, nullptr, "GetActiveAudioOutputDeviceName"},
191 {14, nullptr, "ListAudioOutputDeviceName"},
191 }; 192 };
192 RegisterHandlers(functions); 193 RegisterHandlers(functions);
193 } 194 }
diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp
index 46da438ef..acf791de2 100644
--- a/src/core/hle/service/btdrv/btdrv.cpp
+++ b/src/core/hle/service/btdrv/btdrv.cpp
@@ -175,6 +175,10 @@ public:
175 {143, nullptr, "GetAudioControlInputState"}, 175 {143, nullptr, "GetAudioControlInputState"},
176 {144, nullptr, "AcquireAudioConnectionStateChangedEvent"}, 176 {144, nullptr, "AcquireAudioConnectionStateChangedEvent"},
177 {145, nullptr, "GetConnectedAudioDevice"}, 177 {145, nullptr, "GetConnectedAudioDevice"},
178 {146, nullptr, "CloseAudioControlInput"},
179 {147, nullptr, "RegisterAudioControlNotification"},
180 {148, nullptr, "SendAudioControlPassthroughCommand"},
181 {149, nullptr, "SendAudioControlSetAbsoluteVolumeCommand"},
178 {256, nullptr, "IsManufacturingMode"}, 182 {256, nullptr, "IsManufacturingMode"},
179 {257, nullptr, "EmulateBluetoothCrash"}, 183 {257, nullptr, "EmulateBluetoothCrash"},
180 {258, nullptr, "GetBleChannelMap"}, 184 {258, nullptr, "GetBleChannelMap"},
diff --git a/src/core/hle/service/caps/caps_ss.cpp b/src/core/hle/service/caps/caps_ss.cpp
index 2b5314691..33a976ddf 100644
--- a/src/core/hle/service/caps/caps_ss.cpp
+++ b/src/core/hle/service/caps/caps_ss.cpp
@@ -15,6 +15,7 @@ CAPS_SS::CAPS_SS(Core::System& system_) : ServiceFramework{system_, "caps:ss"} {
15 {204, nullptr, "SaveEditedScreenShotEx0"}, 15 {204, nullptr, "SaveEditedScreenShotEx0"},
16 {206, nullptr, "Unknown206"}, 16 {206, nullptr, "Unknown206"},
17 {208, nullptr, "SaveScreenShotOfMovieEx1"}, 17 {208, nullptr, "SaveScreenShotOfMovieEx1"},
18 {1000, nullptr, "Unknown1000"},
18 }; 19 };
19 // clang-format on 20 // clang-format on
20 21
diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp
index 110c7cb1c..f6184acc9 100644
--- a/src/core/hle/service/es/es.cpp
+++ b/src/core/hle/service/es/es.cpp
@@ -55,6 +55,8 @@ public:
55 {36, nullptr, "DeleteAllInactiveELicenseRequiredPersonalizedTicket"}, 55 {36, nullptr, "DeleteAllInactiveELicenseRequiredPersonalizedTicket"},
56 {37, nullptr, "OwnTicket2"}, 56 {37, nullptr, "OwnTicket2"},
57 {38, nullptr, "OwnTicket3"}, 57 {38, nullptr, "OwnTicket3"},
58 {39, nullptr, "DeleteAllInactivePersonalizedTicket"},
59 {40, nullptr, "DeletePrepurchaseRecordByNintendoAccountId"},
58 {501, nullptr, "Unknown501"}, 60 {501, nullptr, "Unknown501"},
59 {502, nullptr, "Unknown502"}, 61 {502, nullptr, "Unknown502"},
60 {503, nullptr, "GetTitleKey"}, 62 {503, nullptr, "GetTitleKey"},
@@ -88,11 +90,15 @@ public:
88 {1503, nullptr, "Unknown1503"}, 90 {1503, nullptr, "Unknown1503"},
89 {1504, nullptr, "Unknown1504"}, 91 {1504, nullptr, "Unknown1504"},
90 {1505, nullptr, "Unknown1505"}, 92 {1505, nullptr, "Unknown1505"},
93 {1506, nullptr, "Unknown1506"},
91 {2000, nullptr, "Unknown2000"}, 94 {2000, nullptr, "Unknown2000"},
92 {2001, nullptr, "Unknown2001"}, 95 {2001, nullptr, "Unknown2001"},
96 {2002, nullptr, "Unknown2002"},
97 {2003, nullptr, "Unknown2003"},
93 {2100, nullptr, "Unknown2100"}, 98 {2100, nullptr, "Unknown2100"},
94 {2501, nullptr, "Unknown2501"}, 99 {2501, nullptr, "Unknown2501"},
95 {2502, nullptr, "Unknown2502"}, 100 {2502, nullptr, "Unknown2502"},
101 {2601, nullptr, "Unknown2601"},
96 {3001, nullptr, "Unknown3001"}, 102 {3001, nullptr, "Unknown3001"},
97 {3002, nullptr, "Unknown3002"}, 103 {3002, nullptr, "Unknown3002"},
98 }; 104 };
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index 4fcc6f93a..9ee146caf 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -507,6 +507,7 @@ private:
507 LarkNesRight = 18, 507 LarkNesRight = 18,
508 Lucia = 19, 508 Lucia = 19,
509 Verification = 20, 509 Verification = 20,
510 Lagon = 21,
510 }; 511 };
511 512
512 struct NPadEntry { 513 struct NPadEntry {
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index a1707a72a..c930996ab 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -239,6 +239,12 @@ Hid::Hid(Core::System& system_)
239 {81, &Hid::ResetGyroscopeZeroDriftMode, "ResetGyroscopeZeroDriftMode"}, 239 {81, &Hid::ResetGyroscopeZeroDriftMode, "ResetGyroscopeZeroDriftMode"},
240 {82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"}, 240 {82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"},
241 {83, &Hid::IsFirmwareUpdateAvailableForSixAxisSensor, "IsFirmwareUpdateAvailableForSixAxisSensor"}, 241 {83, &Hid::IsFirmwareUpdateAvailableForSixAxisSensor, "IsFirmwareUpdateAvailableForSixAxisSensor"},
242 {84, nullptr, "EnableSixAxisSensorUnalteredPassthrough"},
243 {85, nullptr, "IsSixAxisSensorUnalteredPassthroughEnabled"},
244 {86, nullptr, "StoreSixAxisSensorCalibrationParameter"},
245 {87, nullptr, "LoadSixAxisSensorCalibrationParameter"},
246 {88, nullptr, "GetSixAxisSensorIcInformation"},
247 {89, nullptr, "ResetIsSixAxisSensorDeviceNewlyAssigned"},
242 {91, &Hid::ActivateGesture, "ActivateGesture"}, 248 {91, &Hid::ActivateGesture, "ActivateGesture"},
243 {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"}, 249 {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"},
244 {101, &Hid::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"}, 250 {101, &Hid::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"},
@@ -1656,6 +1662,9 @@ public:
1656 {12, nullptr, "UnsetTouchScreenAutoPilotState"}, 1662 {12, nullptr, "UnsetTouchScreenAutoPilotState"},
1657 {13, nullptr, "GetTouchScreenConfiguration"}, 1663 {13, nullptr, "GetTouchScreenConfiguration"},
1658 {14, nullptr, "ProcessTouchScreenAutoTune"}, 1664 {14, nullptr, "ProcessTouchScreenAutoTune"},
1665 {15, nullptr, "ForceStopTouchScreenManagement"},
1666 {16, nullptr, "ForceRestartTouchScreenManagement"},
1667 {17, nullptr, "IsTouchScreenManaged"},
1659 {20, nullptr, "DeactivateMouse"}, 1668 {20, nullptr, "DeactivateMouse"},
1660 {21, nullptr, "SetMouseAutoPilotState"}, 1669 {21, nullptr, "SetMouseAutoPilotState"},
1661 {22, nullptr, "UnsetMouseAutoPilotState"}, 1670 {22, nullptr, "UnsetMouseAutoPilotState"},
diff --git a/src/core/hle/service/npns/npns.cpp b/src/core/hle/service/npns/npns.cpp
index e4c703da4..32533cd94 100644
--- a/src/core/hle/service/npns/npns.cpp
+++ b/src/core/hle/service/npns/npns.cpp
@@ -31,6 +31,7 @@ public:
31 {24, nullptr, "DestroyTokenWithApplicationId"}, 31 {24, nullptr, "DestroyTokenWithApplicationId"},
32 {25, nullptr, "QueryIsTokenValid"}, 32 {25, nullptr, "QueryIsTokenValid"},
33 {26, nullptr, "ListenToMyApplicationId"}, 33 {26, nullptr, "ListenToMyApplicationId"},
34 {27, nullptr, "DestroyTokenAll"},
34 {31, nullptr, "UploadTokenToBaaS"}, 35 {31, nullptr, "UploadTokenToBaaS"},
35 {32, nullptr, "DestroyTokenForBaaS"}, 36 {32, nullptr, "DestroyTokenForBaaS"},
36 {33, nullptr, "CreateTokenForBaaS"}, 37 {33, nullptr, "CreateTokenForBaaS"},
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp
index 7d85ecb6a..b9e765f1d 100644
--- a/src/core/hle/service/sockets/bsd.cpp
+++ b/src/core/hle/service/sockets/bsd.cpp
@@ -415,6 +415,18 @@ void BSD::Write(Kernel::HLERequestContext& ctx) {
415 }); 415 });
416} 416}
417 417
418void BSD::Read(Kernel::HLERequestContext& ctx) {
419 IPC::RequestParser rp{ctx};
420 const s32 fd = rp.Pop<s32>();
421
422 LOG_WARNING(Service, "(STUBBED) called. fd={} len={}", fd, ctx.GetWriteBufferSize());
423
424 IPC::ResponseBuilder rb{ctx, 4};
425 rb.Push(ResultSuccess);
426 rb.Push<u32>(0); // ret
427 rb.Push<u32>(0); // bsd errno
428}
429
418void BSD::Close(Kernel::HLERequestContext& ctx) { 430void BSD::Close(Kernel::HLERequestContext& ctx) {
419 IPC::RequestParser rp{ctx}; 431 IPC::RequestParser rp{ctx};
420 const s32 fd = rp.Pop<s32>(); 432 const s32 fd = rp.Pop<s32>();
@@ -855,7 +867,7 @@ BSD::BSD(Core::System& system_, const char* name) : ServiceFramework{system_, na
855 {22, &BSD::Shutdown, "Shutdown"}, 867 {22, &BSD::Shutdown, "Shutdown"},
856 {23, nullptr, "ShutdownAllSockets"}, 868 {23, nullptr, "ShutdownAllSockets"},
857 {24, &BSD::Write, "Write"}, 869 {24, &BSD::Write, "Write"},
858 {25, nullptr, "Read"}, 870 {25, &BSD::Read, "Read"},
859 {26, &BSD::Close, "Close"}, 871 {26, &BSD::Close, "Close"},
860 {27, nullptr, "DuplicateSocket"}, 872 {27, nullptr, "DuplicateSocket"},
861 {28, nullptr, "GetResourceStatistics"}, 873 {28, nullptr, "GetResourceStatistics"},
diff --git a/src/core/hle/service/sockets/bsd.h b/src/core/hle/service/sockets/bsd.h
index 1d2df9c61..d68beef5c 100644
--- a/src/core/hle/service/sockets/bsd.h
+++ b/src/core/hle/service/sockets/bsd.h
@@ -135,6 +135,7 @@ private:
135 void Send(Kernel::HLERequestContext& ctx); 135 void Send(Kernel::HLERequestContext& ctx);
136 void SendTo(Kernel::HLERequestContext& ctx); 136 void SendTo(Kernel::HLERequestContext& ctx);
137 void Write(Kernel::HLERequestContext& ctx); 137 void Write(Kernel::HLERequestContext& ctx);
138 void Read(Kernel::HLERequestContext& ctx);
138 void Close(Kernel::HLERequestContext& ctx); 139 void Close(Kernel::HLERequestContext& ctx);
139 void EventFd(Kernel::HLERequestContext& ctx); 140 void EventFd(Kernel::HLERequestContext& ctx);
140 141
diff --git a/src/core/hle/service/usb/usb.cpp b/src/core/hle/service/usb/usb.cpp
index 7f436c3bb..2ee103b37 100644
--- a/src/core/hle/service/usb/usb.cpp
+++ b/src/core/hle/service/usb/usb.cpp
@@ -97,7 +97,7 @@ public:
97 {3, nullptr, "GetAlternateInterface"}, 97 {3, nullptr, "GetAlternateInterface"},
98 {4, nullptr, "GetCurrentFrame"}, 98 {4, nullptr, "GetCurrentFrame"},
99 {5, nullptr, "CtrlXferAsync"}, 99 {5, nullptr, "CtrlXferAsync"},
100 {6, nullptr, "Unknown6"}, 100 {6, nullptr, "GetCtrlXferCompletionEvent"},
101 {7, nullptr, "GetCtrlXferReport"}, 101 {7, nullptr, "GetCtrlXferReport"},
102 {8, nullptr, "ResetDevice"}, 102 {8, nullptr, "ResetDevice"},
103 {9, nullptr, "OpenUsbEp"}, 103 {9, nullptr, "OpenUsbEp"},
@@ -183,8 +183,8 @@ public:
183 {4, nullptr, "GetHostPdcFirmwareRevision"}, 183 {4, nullptr, "GetHostPdcFirmwareRevision"},
184 {5, nullptr, "GetHostPdcManufactureId"}, 184 {5, nullptr, "GetHostPdcManufactureId"},
185 {6, nullptr, "GetHostPdcDeviceId"}, 185 {6, nullptr, "GetHostPdcDeviceId"},
186 {7, nullptr, "AwakeCradle"}, 186 {7, nullptr, "EnableCradleRecovery"},
187 {8, nullptr, "SleepCradle"}, 187 {8, nullptr, "DisableCradleRecovery"},
188 }; 188 };
189 // clang-format on 189 // clang-format on
190 190
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 8e8fc40ca..be3d52d54 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -831,6 +831,7 @@ public:
831 {6010, nullptr, "GetLayerPresentationAllFencesExpiredEvent"}, 831 {6010, nullptr, "GetLayerPresentationAllFencesExpiredEvent"},
832 {6011, nullptr, "EnableLayerAutoClearTransitionBuffer"}, 832 {6011, nullptr, "EnableLayerAutoClearTransitionBuffer"},
833 {6012, nullptr, "DisableLayerAutoClearTransitionBuffer"}, 833 {6012, nullptr, "DisableLayerAutoClearTransitionBuffer"},
834 {6013, nullptr, "SetLayerOpacity"},
834 {7000, nullptr, "SetContentVisibility"}, 835 {7000, nullptr, "SetContentVisibility"},
835 {8000, nullptr, "SetConductorLayer"}, 836 {8000, nullptr, "SetConductorLayer"},
836 {8001, nullptr, "SetTimestampTracking"}, 837 {8001, nullptr, "SetTimestampTracking"},
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp
index 1f1607998..191475f71 100644
--- a/src/core/telemetry_session.cpp
+++ b/src/core/telemetry_session.cpp
@@ -226,8 +226,6 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader,
226 // Log user configuration information 226 // Log user configuration information
227 constexpr auto field_type = Telemetry::FieldType::UserConfig; 227 constexpr auto field_type = Telemetry::FieldType::UserConfig;
228 AddField(field_type, "Audio_SinkId", Settings::values.sink_id.GetValue()); 228 AddField(field_type, "Audio_SinkId", Settings::values.sink_id.GetValue());
229 AddField(field_type, "Audio_EnableAudioStretching",
230 Settings::values.enable_audio_stretching.GetValue());
231 AddField(field_type, "Core_UseMultiCore", Settings::values.use_multi_core.GetValue()); 229 AddField(field_type, "Core_UseMultiCore", Settings::values.use_multi_core.GetValue());
232 AddField(field_type, "Renderer_Backend", 230 AddField(field_type, "Renderer_Backend",
233 TranslateRenderer(Settings::values.renderer_backend.GetValue())); 231 TranslateRenderer(Settings::values.renderer_backend.GetValue()));
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt
index c4283a952..dd13d948f 100644
--- a/src/input_common/CMakeLists.txt
+++ b/src/input_common/CMakeLists.txt
@@ -21,6 +21,10 @@ add_library(input_common STATIC
21 mouse/mouse_poller.h 21 mouse/mouse_poller.h
22 sdl/sdl.cpp 22 sdl/sdl.cpp
23 sdl/sdl.h 23 sdl/sdl.h
24 tas/tas_input.cpp
25 tas/tas_input.h
26 tas/tas_poller.cpp
27 tas/tas_poller.h
24 udp/client.cpp 28 udp/client.cpp
25 udp/client.h 29 udp/client.h
26 udp/protocol.cpp 30 udp/protocol.cpp
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index ff23230f0..f3907c65a 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -5,6 +5,7 @@
5#include <memory> 5#include <memory>
6#include <thread> 6#include <thread>
7#include "common/param_package.h" 7#include "common/param_package.h"
8#include "common/settings.h"
8#include "input_common/analog_from_button.h" 9#include "input_common/analog_from_button.h"
9#include "input_common/gcadapter/gc_adapter.h" 10#include "input_common/gcadapter/gc_adapter.h"
10#include "input_common/gcadapter/gc_poller.h" 11#include "input_common/gcadapter/gc_poller.h"
@@ -13,6 +14,8 @@
13#include "input_common/motion_from_button.h" 14#include "input_common/motion_from_button.h"
14#include "input_common/mouse/mouse_input.h" 15#include "input_common/mouse/mouse_input.h"
15#include "input_common/mouse/mouse_poller.h" 16#include "input_common/mouse/mouse_poller.h"
17#include "input_common/tas/tas_input.h"
18#include "input_common/tas/tas_poller.h"
16#include "input_common/touch_from_button.h" 19#include "input_common/touch_from_button.h"
17#include "input_common/udp/client.h" 20#include "input_common/udp/client.h"
18#include "input_common/udp/udp.h" 21#include "input_common/udp/udp.h"
@@ -60,6 +63,12 @@ struct InputSubsystem::Impl {
60 Input::RegisterFactory<Input::MotionDevice>("mouse", mousemotion); 63 Input::RegisterFactory<Input::MotionDevice>("mouse", mousemotion);
61 mousetouch = std::make_shared<MouseTouchFactory>(mouse); 64 mousetouch = std::make_shared<MouseTouchFactory>(mouse);
62 Input::RegisterFactory<Input::TouchDevice>("mouse", mousetouch); 65 Input::RegisterFactory<Input::TouchDevice>("mouse", mousetouch);
66
67 tas = std::make_shared<TasInput::Tas>();
68 tasbuttons = std::make_shared<TasButtonFactory>(tas);
69 Input::RegisterFactory<Input::ButtonDevice>("tas", tasbuttons);
70 tasanalog = std::make_shared<TasAnalogFactory>(tas);
71 Input::RegisterFactory<Input::AnalogDevice>("tas", tasanalog);
63 } 72 }
64 73
65 void Shutdown() { 74 void Shutdown() {
@@ -94,6 +103,12 @@ struct InputSubsystem::Impl {
94 mouseanalog.reset(); 103 mouseanalog.reset();
95 mousemotion.reset(); 104 mousemotion.reset();
96 mousetouch.reset(); 105 mousetouch.reset();
106
107 Input::UnregisterFactory<Input::ButtonDevice>("tas");
108 Input::UnregisterFactory<Input::AnalogDevice>("tas");
109
110 tasbuttons.reset();
111 tasanalog.reset();
97 } 112 }
98 113
99 [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { 114 [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const {
@@ -101,6 +116,10 @@ struct InputSubsystem::Impl {
101 Common::ParamPackage{{"display", "Any"}, {"class", "any"}}, 116 Common::ParamPackage{{"display", "Any"}, {"class", "any"}},
102 Common::ParamPackage{{"display", "Keyboard/Mouse"}, {"class", "keyboard"}}, 117 Common::ParamPackage{{"display", "Keyboard/Mouse"}, {"class", "keyboard"}},
103 }; 118 };
119 if (Settings::values.tas_enable) {
120 devices.emplace_back(
121 Common::ParamPackage{{"display", "TAS Controller"}, {"class", "tas"}});
122 }
104#ifdef HAVE_SDL2 123#ifdef HAVE_SDL2
105 auto sdl_devices = sdl->GetInputDevices(); 124 auto sdl_devices = sdl->GetInputDevices();
106 devices.insert(devices.end(), sdl_devices.begin(), sdl_devices.end()); 125 devices.insert(devices.end(), sdl_devices.begin(), sdl_devices.end());
@@ -120,6 +139,9 @@ struct InputSubsystem::Impl {
120 if (params.Get("class", "") == "gcpad") { 139 if (params.Get("class", "") == "gcpad") {
121 return gcadapter->GetAnalogMappingForDevice(params); 140 return gcadapter->GetAnalogMappingForDevice(params);
122 } 141 }
142 if (params.Get("class", "") == "tas") {
143 return tas->GetAnalogMappingForDevice(params);
144 }
123#ifdef HAVE_SDL2 145#ifdef HAVE_SDL2
124 if (params.Get("class", "") == "sdl") { 146 if (params.Get("class", "") == "sdl") {
125 return sdl->GetAnalogMappingForDevice(params); 147 return sdl->GetAnalogMappingForDevice(params);
@@ -136,6 +158,9 @@ struct InputSubsystem::Impl {
136 if (params.Get("class", "") == "gcpad") { 158 if (params.Get("class", "") == "gcpad") {
137 return gcadapter->GetButtonMappingForDevice(params); 159 return gcadapter->GetButtonMappingForDevice(params);
138 } 160 }
161 if (params.Get("class", "") == "tas") {
162 return tas->GetButtonMappingForDevice(params);
163 }
139#ifdef HAVE_SDL2 164#ifdef HAVE_SDL2
140 if (params.Get("class", "") == "sdl") { 165 if (params.Get("class", "") == "sdl") {
141 return sdl->GetButtonMappingForDevice(params); 166 return sdl->GetButtonMappingForDevice(params);
@@ -174,9 +199,12 @@ struct InputSubsystem::Impl {
174 std::shared_ptr<MouseAnalogFactory> mouseanalog; 199 std::shared_ptr<MouseAnalogFactory> mouseanalog;
175 std::shared_ptr<MouseMotionFactory> mousemotion; 200 std::shared_ptr<MouseMotionFactory> mousemotion;
176 std::shared_ptr<MouseTouchFactory> mousetouch; 201 std::shared_ptr<MouseTouchFactory> mousetouch;
202 std::shared_ptr<TasButtonFactory> tasbuttons;
203 std::shared_ptr<TasAnalogFactory> tasanalog;
177 std::shared_ptr<CemuhookUDP::Client> udp; 204 std::shared_ptr<CemuhookUDP::Client> udp;
178 std::shared_ptr<GCAdapter::Adapter> gcadapter; 205 std::shared_ptr<GCAdapter::Adapter> gcadapter;
179 std::shared_ptr<MouseInput::Mouse> mouse; 206 std::shared_ptr<MouseInput::Mouse> mouse;
207 std::shared_ptr<TasInput::Tas> tas;
180}; 208};
181 209
182InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {} 210InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {}
@@ -207,6 +235,14 @@ const MouseInput::Mouse* InputSubsystem::GetMouse() const {
207 return impl->mouse.get(); 235 return impl->mouse.get();
208} 236}
209 237
238TasInput::Tas* InputSubsystem::GetTas() {
239 return impl->tas.get();
240}
241
242const TasInput::Tas* InputSubsystem::GetTas() const {
243 return impl->tas.get();
244}
245
210std::vector<Common::ParamPackage> InputSubsystem::GetInputDevices() const { 246std::vector<Common::ParamPackage> InputSubsystem::GetInputDevices() const {
211 return impl->GetInputDevices(); 247 return impl->GetInputDevices();
212} 248}
@@ -287,6 +323,22 @@ const MouseTouchFactory* InputSubsystem::GetMouseTouch() const {
287 return impl->mousetouch.get(); 323 return impl->mousetouch.get();
288} 324}
289 325
326TasButtonFactory* InputSubsystem::GetTasButtons() {
327 return impl->tasbuttons.get();
328}
329
330const TasButtonFactory* InputSubsystem::GetTasButtons() const {
331 return impl->tasbuttons.get();
332}
333
334TasAnalogFactory* InputSubsystem::GetTasAnalogs() {
335 return impl->tasanalog.get();
336}
337
338const TasAnalogFactory* InputSubsystem::GetTasAnalogs() const {
339 return impl->tasanalog.get();
340}
341
290void InputSubsystem::ReloadInputDevices() { 342void InputSubsystem::ReloadInputDevices() {
291 if (!impl->udp) { 343 if (!impl->udp) {
292 return; 344 return;
@@ -294,8 +346,8 @@ void InputSubsystem::ReloadInputDevices() {
294 impl->udp->ReloadSockets(); 346 impl->udp->ReloadSockets();
295} 347}
296 348
297std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers([ 349std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers(
298 [maybe_unused]] Polling::DeviceType type) const { 350 [[maybe_unused]] Polling::DeviceType type) const {
299#ifdef HAVE_SDL2 351#ifdef HAVE_SDL2
300 return impl->sdl->GetPollers(type); 352 return impl->sdl->GetPollers(type);
301#else 353#else
diff --git a/src/input_common/main.h b/src/input_common/main.h
index 5d6f26385..6390d3f09 100644
--- a/src/input_common/main.h
+++ b/src/input_common/main.h
@@ -29,6 +29,10 @@ namespace MouseInput {
29class Mouse; 29class Mouse;
30} 30}
31 31
32namespace TasInput {
33class Tas;
34}
35
32namespace InputCommon { 36namespace InputCommon {
33namespace Polling { 37namespace Polling {
34 38
@@ -64,6 +68,8 @@ class MouseButtonFactory;
64class MouseAnalogFactory; 68class MouseAnalogFactory;
65class MouseMotionFactory; 69class MouseMotionFactory;
66class MouseTouchFactory; 70class MouseTouchFactory;
71class TasButtonFactory;
72class TasAnalogFactory;
67class Keyboard; 73class Keyboard;
68 74
69/** 75/**
@@ -103,6 +109,11 @@ public:
103 /// Retrieves the underlying mouse device. 109 /// Retrieves the underlying mouse device.
104 [[nodiscard]] const MouseInput::Mouse* GetMouse() const; 110 [[nodiscard]] const MouseInput::Mouse* GetMouse() const;
105 111
112 /// Retrieves the underlying tas device.
113 [[nodiscard]] TasInput::Tas* GetTas();
114
115 /// Retrieves the underlying tas device.
116 [[nodiscard]] const TasInput::Tas* GetTas() const;
106 /** 117 /**
107 * Returns all available input devices that this Factory can create a new device with. 118 * Returns all available input devices that this Factory can create a new device with.
108 * Each returned ParamPackage should have a `display` field used for display, a class field for 119 * Each returned ParamPackage should have a `display` field used for display, a class field for
@@ -144,30 +155,42 @@ public:
144 /// Retrieves the underlying udp touch handler. 155 /// Retrieves the underlying udp touch handler.
145 [[nodiscard]] const UDPTouchFactory* GetUDPTouch() const; 156 [[nodiscard]] const UDPTouchFactory* GetUDPTouch() const;
146 157
147 /// Retrieves the underlying GameCube button handler. 158 /// Retrieves the underlying mouse button handler.
148 [[nodiscard]] MouseButtonFactory* GetMouseButtons(); 159 [[nodiscard]] MouseButtonFactory* GetMouseButtons();
149 160
150 /// Retrieves the underlying GameCube button handler. 161 /// Retrieves the underlying mouse button handler.
151 [[nodiscard]] const MouseButtonFactory* GetMouseButtons() const; 162 [[nodiscard]] const MouseButtonFactory* GetMouseButtons() const;
152 163
153 /// Retrieves the underlying udp touch handler. 164 /// Retrieves the underlying mouse analog handler.
154 [[nodiscard]] MouseAnalogFactory* GetMouseAnalogs(); 165 [[nodiscard]] MouseAnalogFactory* GetMouseAnalogs();
155 166
156 /// Retrieves the underlying udp touch handler. 167 /// Retrieves the underlying mouse analog handler.
157 [[nodiscard]] const MouseAnalogFactory* GetMouseAnalogs() const; 168 [[nodiscard]] const MouseAnalogFactory* GetMouseAnalogs() const;
158 169
159 /// Retrieves the underlying udp motion handler. 170 /// Retrieves the underlying mouse motion handler.
160 [[nodiscard]] MouseMotionFactory* GetMouseMotions(); 171 [[nodiscard]] MouseMotionFactory* GetMouseMotions();
161 172
162 /// Retrieves the underlying udp motion handler. 173 /// Retrieves the underlying mouse motion handler.
163 [[nodiscard]] const MouseMotionFactory* GetMouseMotions() const; 174 [[nodiscard]] const MouseMotionFactory* GetMouseMotions() const;
164 175
165 /// Retrieves the underlying udp touch handler. 176 /// Retrieves the underlying mouse touch handler.
166 [[nodiscard]] MouseTouchFactory* GetMouseTouch(); 177 [[nodiscard]] MouseTouchFactory* GetMouseTouch();
167 178
168 /// Retrieves the underlying udp touch handler. 179 /// Retrieves the underlying mouse touch handler.
169 [[nodiscard]] const MouseTouchFactory* GetMouseTouch() const; 180 [[nodiscard]] const MouseTouchFactory* GetMouseTouch() const;
170 181
182 /// Retrieves the underlying tas button handler.
183 [[nodiscard]] TasButtonFactory* GetTasButtons();
184
185 /// Retrieves the underlying tas button handler.
186 [[nodiscard]] const TasButtonFactory* GetTasButtons() const;
187
188 /// Retrieves the underlying tas analogs handler.
189 [[nodiscard]] TasAnalogFactory* GetTasAnalogs();
190
191 /// Retrieves the underlying tas analogs handler.
192 [[nodiscard]] const TasAnalogFactory* GetTasAnalogs() const;
193
171 /// Reloads the input devices 194 /// Reloads the input devices
172 void ReloadInputDevices(); 195 void ReloadInputDevices();
173 196
diff --git a/src/input_common/tas/tas_input.cpp b/src/input_common/tas/tas_input.cpp
new file mode 100644
index 000000000..1598092b6
--- /dev/null
+++ b/src/input_common/tas/tas_input.cpp
@@ -0,0 +1,455 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#include <cstring>
6#include <regex>
7
8#include "common/fs/file.h"
9#include "common/fs/fs_types.h"
10#include "common/fs/path_util.h"
11#include "common/logging/log.h"
12#include "common/settings.h"
13#include "input_common/tas/tas_input.h"
14
15namespace TasInput {
16
17// Supported keywords and buttons from a TAS file
18constexpr std::array<std::pair<std::string_view, TasButton>, 20> text_to_tas_button = {
19 std::pair{"KEY_A", TasButton::BUTTON_A},
20 {"KEY_B", TasButton::BUTTON_B},
21 {"KEY_X", TasButton::BUTTON_X},
22 {"KEY_Y", TasButton::BUTTON_Y},
23 {"KEY_LSTICK", TasButton::STICK_L},
24 {"KEY_RSTICK", TasButton::STICK_R},
25 {"KEY_L", TasButton::TRIGGER_L},
26 {"KEY_R", TasButton::TRIGGER_R},
27 {"KEY_PLUS", TasButton::BUTTON_PLUS},
28 {"KEY_MINUS", TasButton::BUTTON_MINUS},
29 {"KEY_DLEFT", TasButton::BUTTON_LEFT},
30 {"KEY_DUP", TasButton::BUTTON_UP},
31 {"KEY_DRIGHT", TasButton::BUTTON_RIGHT},
32 {"KEY_DDOWN", TasButton::BUTTON_DOWN},
33 {"KEY_SL", TasButton::BUTTON_SL},
34 {"KEY_SR", TasButton::BUTTON_SR},
35 {"KEY_CAPTURE", TasButton::BUTTON_CAPTURE},
36 {"KEY_HOME", TasButton::BUTTON_HOME},
37 {"KEY_ZL", TasButton::TRIGGER_ZL},
38 {"KEY_ZR", TasButton::TRIGGER_ZR},
39};
40
41Tas::Tas() {
42 if (!Settings::values.tas_enable) {
43 needs_reset = true;
44 return;
45 }
46 LoadTasFiles();
47}
48
49Tas::~Tas() {
50 Stop();
51};
52
53void Tas::LoadTasFiles() {
54 script_length = 0;
55 for (size_t i = 0; i < commands.size(); i++) {
56 LoadTasFile(i);
57 if (commands[i].size() > script_length) {
58 script_length = commands[i].size();
59 }
60 }
61}
62
63void Tas::LoadTasFile(size_t player_index) {
64 if (!commands[player_index].empty()) {
65 commands[player_index].clear();
66 }
67 std::string file =
68 Common::FS::ReadStringFromFile(Common::FS::GetYuzuPath(Common::FS::YuzuPath::TASDir) /
69 fmt::format("script0-{}.txt", player_index + 1),
70 Common::FS::FileType::BinaryFile);
71 std::stringstream command_line(file);
72 std::string line;
73 int frame_no = 0;
74 while (std::getline(command_line, line, '\n')) {
75 if (line.empty()) {
76 continue;
77 }
78 LOG_DEBUG(Input, "Loading line: {}", line);
79 std::smatch m;
80
81 std::stringstream linestream(line);
82 std::string segment;
83 std::vector<std::string> seglist;
84
85 while (std::getline(linestream, segment, ' ')) {
86 seglist.push_back(segment);
87 }
88
89 if (seglist.size() < 4) {
90 continue;
91 }
92
93 while (frame_no < std::stoi(seglist.at(0))) {
94 commands[player_index].push_back({});
95 frame_no++;
96 }
97
98 TASCommand command = {
99 .buttons = ReadCommandButtons(seglist.at(1)),
100 .l_axis = ReadCommandAxis(seglist.at(2)),
101 .r_axis = ReadCommandAxis(seglist.at(3)),
102 };
103 commands[player_index].push_back(command);
104 frame_no++;
105 }
106 LOG_INFO(Input, "TAS file loaded! {} frames", frame_no);
107}
108
109void Tas::WriteTasFile(std::u8string file_name) {
110 std::string output_text;
111 for (size_t frame = 0; frame < record_commands.size(); frame++) {
112 if (!output_text.empty()) {
113 output_text += "\n";
114 }
115 const TASCommand& line = record_commands[frame];
116 output_text += std::to_string(frame) + " " + WriteCommandButtons(line.buttons) + " " +
117 WriteCommandAxis(line.l_axis) + " " + WriteCommandAxis(line.r_axis);
118 }
119 const auto bytes_written = Common::FS::WriteStringToFile(
120 Common::FS::GetYuzuPath(Common::FS::YuzuPath::TASDir) / file_name,
121 Common::FS::FileType::TextFile, output_text);
122 if (bytes_written == output_text.size()) {
123 LOG_INFO(Input, "TAS file written to file!");
124 } else {
125 LOG_ERROR(Input, "Writing the TAS-file has failed! {} / {} bytes written", bytes_written,
126 output_text.size());
127 }
128}
129
130std::pair<float, float> Tas::FlipAxisY(std::pair<float, float> old) {
131 auto [x, y] = old;
132 return {x, -y};
133}
134
135void Tas::RecordInput(u32 buttons, const std::array<std::pair<float, float>, 2>& axes) {
136 last_input = {buttons, FlipAxisY(axes[0]), FlipAxisY(axes[1])};
137}
138
139std::tuple<TasState, size_t, size_t> Tas::GetStatus() const {
140 TasState state;
141 if (is_recording) {
142 return {TasState::Recording, 0, record_commands.size()};
143 }
144
145 if (is_running) {
146 state = TasState::Running;
147 } else {
148 state = TasState::Stopped;
149 }
150
151 return {state, current_command, script_length};
152}
153
154std::string Tas::DebugButtons(u32 buttons) const {
155 return fmt::format("{{ {} }}", TasInput::Tas::ButtonsToString(buttons));
156}
157
158std::string Tas::DebugJoystick(float x, float y) const {
159 return fmt::format("[ {} , {} ]", std::to_string(x), std::to_string(y));
160}
161
162std::string Tas::DebugInput(const TasData& data) const {
163 return fmt::format("{{ {} , {} , {} }}", DebugButtons(data.buttons),
164 DebugJoystick(data.axis[0], data.axis[1]),
165 DebugJoystick(data.axis[2], data.axis[3]));
166}
167
168std::string Tas::DebugInputs(const std::array<TasData, PLAYER_NUMBER>& arr) const {
169 std::string returns = "[ ";
170 for (size_t i = 0; i < arr.size(); i++) {
171 returns += DebugInput(arr[i]);
172 if (i != arr.size() - 1) {
173 returns += " , ";
174 }
175 }
176 return returns + "]";
177}
178
179std::string Tas::ButtonsToString(u32 button) const {
180 std::string returns;
181 for (auto [text_button, tas_button] : text_to_tas_button) {
182 if ((button & static_cast<u32>(tas_button)) != 0)
183 returns += fmt::format(", {}", text_button.substr(4));
184 }
185 return returns.empty() ? "" : returns.substr(2);
186}
187
188void Tas::UpdateThread() {
189 if (!Settings::values.tas_enable) {
190 if (is_running) {
191 Stop();
192 }
193 return;
194 }
195
196 if (is_recording) {
197 record_commands.push_back(last_input);
198 }
199 if (needs_reset) {
200 current_command = 0;
201 needs_reset = false;
202 LoadTasFiles();
203 LOG_DEBUG(Input, "tas_reset done");
204 }
205
206 if (!is_running) {
207 tas_data.fill({});
208 return;
209 }
210 if (current_command < script_length) {
211 LOG_DEBUG(Input, "Playing TAS {}/{}", current_command, script_length);
212 size_t frame = current_command++;
213 for (size_t i = 0; i < commands.size(); i++) {
214 if (frame < commands[i].size()) {
215 TASCommand command = commands[i][frame];
216 tas_data[i].buttons = command.buttons;
217 auto [l_axis_x, l_axis_y] = command.l_axis;
218 tas_data[i].axis[0] = l_axis_x;
219 tas_data[i].axis[1] = l_axis_y;
220 auto [r_axis_x, r_axis_y] = command.r_axis;
221 tas_data[i].axis[2] = r_axis_x;
222 tas_data[i].axis[3] = r_axis_y;
223 } else {
224 tas_data[i] = {};
225 }
226 }
227 } else {
228 is_running = Settings::values.tas_loop.GetValue();
229 current_command = 0;
230 tas_data.fill({});
231 if (!is_running) {
232 SwapToStoredController();
233 }
234 }
235 LOG_DEBUG(Input, "TAS inputs: {}", DebugInputs(tas_data));
236}
237
238TasAnalog Tas::ReadCommandAxis(const std::string& line) const {
239 std::stringstream linestream(line);
240 std::string segment;
241 std::vector<std::string> seglist;
242
243 while (std::getline(linestream, segment, ';')) {
244 seglist.push_back(segment);
245 }
246
247 const float x = std::stof(seglist.at(0)) / 32767.0f;
248 const float y = std::stof(seglist.at(1)) / 32767.0f;
249
250 return {x, y};
251}
252
253u32 Tas::ReadCommandButtons(const std::string& data) const {
254 std::stringstream button_text(data);
255 std::string line;
256 u32 buttons = 0;
257 while (std::getline(button_text, line, ';')) {
258 for (auto [text, tas_button] : text_to_tas_button) {
259 if (text == line) {
260 buttons |= static_cast<u32>(tas_button);
261 break;
262 }
263 }
264 }
265 return buttons;
266}
267
268std::string Tas::WriteCommandAxis(TasAnalog data) const {
269 auto [x, y] = data;
270 std::string line;
271 line += std::to_string(static_cast<int>(x * 32767));
272 line += ";";
273 line += std::to_string(static_cast<int>(y * 32767));
274 return line;
275}
276
277std::string Tas::WriteCommandButtons(u32 data) const {
278 if (data == 0) {
279 return "NONE";
280 }
281
282 std::string line;
283 u32 index = 0;
284 while (data > 0) {
285 if ((data & 1) == 1) {
286 for (auto [text, tas_button] : text_to_tas_button) {
287 if (tas_button == static_cast<TasButton>(1 << index)) {
288 if (line.size() > 0) {
289 line += ";";
290 }
291 line += text;
292 break;
293 }
294 }
295 }
296 index++;
297 data >>= 1;
298 }
299 return line;
300}
301
302void Tas::StartStop() {
303 if (!Settings::values.tas_enable) {
304 return;
305 }
306 if (is_running) {
307 Stop();
308 } else {
309 is_running = true;
310 SwapToTasController();
311 }
312}
313
314void Tas::Stop() {
315 is_running = false;
316 SwapToStoredController();
317}
318
319void Tas::SwapToTasController() {
320 if (!Settings::values.tas_swap_controllers) {
321 return;
322 }
323 auto& players = Settings::values.players.GetValue();
324 for (std::size_t index = 0; index < players.size(); index++) {
325 auto& player = players[index];
326 player_mappings[index] = player;
327
328 // Only swap active controllers
329 if (!player.connected) {
330 continue;
331 }
332
333 Common::ParamPackage tas_param;
334 tas_param.Set("pad", static_cast<u8>(index));
335 auto button_mapping = GetButtonMappingForDevice(tas_param);
336 auto analog_mapping = GetAnalogMappingForDevice(tas_param);
337 auto& buttons = player.buttons;
338 auto& analogs = player.analogs;
339
340 for (std::size_t i = 0; i < buttons.size(); ++i) {
341 buttons[i] = button_mapping[static_cast<Settings::NativeButton::Values>(i)].Serialize();
342 }
343 for (std::size_t i = 0; i < analogs.size(); ++i) {
344 analogs[i] = analog_mapping[static_cast<Settings::NativeAnalog::Values>(i)].Serialize();
345 }
346 }
347 is_old_input_saved = true;
348 Settings::values.is_device_reload_pending.store(true);
349}
350
351void Tas::SwapToStoredController() {
352 if (!is_old_input_saved) {
353 return;
354 }
355 auto& players = Settings::values.players.GetValue();
356 for (std::size_t index = 0; index < players.size(); index++) {
357 players[index] = player_mappings[index];
358 }
359 is_old_input_saved = false;
360 Settings::values.is_device_reload_pending.store(true);
361}
362
363void Tas::Reset() {
364 if (!Settings::values.tas_enable) {
365 return;
366 }
367 needs_reset = true;
368}
369
370bool Tas::Record() {
371 if (!Settings::values.tas_enable) {
372 return true;
373 }
374 is_recording = !is_recording;
375 return is_recording;
376}
377
378void Tas::SaveRecording(bool overwrite_file) {
379 if (is_recording) {
380 return;
381 }
382 if (record_commands.empty()) {
383 return;
384 }
385 WriteTasFile(u8"record.txt");
386 if (overwrite_file) {
387 WriteTasFile(u8"script0-1.txt");
388 }
389 needs_reset = true;
390 record_commands.clear();
391}
392
393InputCommon::ButtonMapping Tas::GetButtonMappingForDevice(
394 const Common::ParamPackage& params) const {
395 // This list is missing ZL/ZR since those are not considered buttons.
396 // We will add those afterwards
397 // This list also excludes any button that can't be really mapped
398 static constexpr std::array<std::pair<Settings::NativeButton::Values, TasButton>, 20>
399 switch_to_tas_button = {
400 std::pair{Settings::NativeButton::A, TasButton::BUTTON_A},
401 {Settings::NativeButton::B, TasButton::BUTTON_B},
402 {Settings::NativeButton::X, TasButton::BUTTON_X},
403 {Settings::NativeButton::Y, TasButton::BUTTON_Y},
404 {Settings::NativeButton::LStick, TasButton::STICK_L},
405 {Settings::NativeButton::RStick, TasButton::STICK_R},
406 {Settings::NativeButton::L, TasButton::TRIGGER_L},
407 {Settings::NativeButton::R, TasButton::TRIGGER_R},
408 {Settings::NativeButton::Plus, TasButton::BUTTON_PLUS},
409 {Settings::NativeButton::Minus, TasButton::BUTTON_MINUS},
410 {Settings::NativeButton::DLeft, TasButton::BUTTON_LEFT},
411 {Settings::NativeButton::DUp, TasButton::BUTTON_UP},
412 {Settings::NativeButton::DRight, TasButton::BUTTON_RIGHT},
413 {Settings::NativeButton::DDown, TasButton::BUTTON_DOWN},
414 {Settings::NativeButton::SL, TasButton::BUTTON_SL},
415 {Settings::NativeButton::SR, TasButton::BUTTON_SR},
416 {Settings::NativeButton::Screenshot, TasButton::BUTTON_CAPTURE},
417 {Settings::NativeButton::Home, TasButton::BUTTON_HOME},
418 {Settings::NativeButton::ZL, TasButton::TRIGGER_ZL},
419 {Settings::NativeButton::ZR, TasButton::TRIGGER_ZR},
420 };
421
422 InputCommon::ButtonMapping mapping{};
423 for (const auto& [switch_button, tas_button] : switch_to_tas_button) {
424 Common::ParamPackage button_params({{"engine", "tas"}});
425 button_params.Set("pad", params.Get("pad", 0));
426 button_params.Set("button", static_cast<int>(tas_button));
427 mapping.insert_or_assign(switch_button, std::move(button_params));
428 }
429
430 return mapping;
431}
432
433InputCommon::AnalogMapping Tas::GetAnalogMappingForDevice(
434 const Common::ParamPackage& params) const {
435
436 InputCommon::AnalogMapping mapping = {};
437 Common::ParamPackage left_analog_params;
438 left_analog_params.Set("engine", "tas");
439 left_analog_params.Set("pad", params.Get("pad", 0));
440 left_analog_params.Set("axis_x", static_cast<int>(TasAxes::StickX));
441 left_analog_params.Set("axis_y", static_cast<int>(TasAxes::StickY));
442 mapping.insert_or_assign(Settings::NativeAnalog::LStick, std::move(left_analog_params));
443 Common::ParamPackage right_analog_params;
444 right_analog_params.Set("engine", "tas");
445 right_analog_params.Set("pad", params.Get("pad", 0));
446 right_analog_params.Set("axis_x", static_cast<int>(TasAxes::SubstickX));
447 right_analog_params.Set("axis_y", static_cast<int>(TasAxes::SubstickY));
448 mapping.insert_or_assign(Settings::NativeAnalog::RStick, std::move(right_analog_params));
449 return mapping;
450}
451
452const TasData& Tas::GetTasState(std::size_t pad) const {
453 return tas_data[pad];
454}
455} // namespace TasInput
diff --git a/src/input_common/tas/tas_input.h b/src/input_common/tas/tas_input.h
new file mode 100644
index 000000000..3e2db8f00
--- /dev/null
+++ b/src/input_common/tas/tas_input.h
@@ -0,0 +1,237 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <array>
8
9#include "common/common_types.h"
10#include "common/settings_input.h"
11#include "core/frontend/input.h"
12#include "input_common/main.h"
13
14/*
15To play back TAS scripts on Yuzu, select the folder with scripts in the configuration menu below
16Tools -> Configure TAS. The file itself has normal text format and has to be called script0-1.txt
17for controller 1, script0-2.txt for controller 2 and so forth (with max. 8 players).
18
19A script file has the same format as TAS-nx uses, so final files will look like this:
20
211 KEY_B 0;0 0;0
226 KEY_ZL 0;0 0;0
2341 KEY_ZL;KEY_Y 0;0 0;0
2443 KEY_X;KEY_A 32767;0 0;0
2544 KEY_A 32767;0 0;0
2645 KEY_A 32767;0 0;0
2746 KEY_A 32767;0 0;0
2847 KEY_A 32767;0 0;0
29
30After placing the file at the correct location, it can be read into Yuzu with the (default) hotkey
31CTRL+F6 (refresh). In the bottom left corner, it will display the amount of frames the script file
32has. Playback can be started or stopped using CTRL+F5.
33
34However, for playback to actually work, the correct input device has to be selected: In the Controls
35menu, select TAS from the device list for the controller that the script should be played on.
36
37Recording a new script file is really simple: Just make sure that the proper device (not TAS) is
38connected on P1, and press CTRL+F7 to start recording. When done, just press the same keystroke
39again (CTRL+F7). The new script will be saved at the location previously selected, as the filename
40record.txt.
41
42For debugging purposes, the common controller debugger can be used (View -> Debugging -> Controller
43P1).
44*/
45
46namespace TasInput {
47
48constexpr size_t PLAYER_NUMBER = 8;
49
50using TasAnalog = std::pair<float, float>;
51
52enum class TasState {
53 Running,
54 Recording,
55 Stopped,
56};
57
58enum class TasButton : u32 {
59 BUTTON_A = 1U << 0,
60 BUTTON_B = 1U << 1,
61 BUTTON_X = 1U << 2,
62 BUTTON_Y = 1U << 3,
63 STICK_L = 1U << 4,
64 STICK_R = 1U << 5,
65 TRIGGER_L = 1U << 6,
66 TRIGGER_R = 1U << 7,
67 TRIGGER_ZL = 1U << 8,
68 TRIGGER_ZR = 1U << 9,
69 BUTTON_PLUS = 1U << 10,
70 BUTTON_MINUS = 1U << 11,
71 BUTTON_LEFT = 1U << 12,
72 BUTTON_UP = 1U << 13,
73 BUTTON_RIGHT = 1U << 14,
74 BUTTON_DOWN = 1U << 15,
75 BUTTON_SL = 1U << 16,
76 BUTTON_SR = 1U << 17,
77 BUTTON_HOME = 1U << 18,
78 BUTTON_CAPTURE = 1U << 19,
79};
80
81enum class TasAxes : u8 {
82 StickX,
83 StickY,
84 SubstickX,
85 SubstickY,
86 Undefined,
87};
88
89struct TasData {
90 u32 buttons{};
91 std::array<float, 4> axis{};
92};
93
94class Tas {
95public:
96 Tas();
97 ~Tas();
98
99 // Changes the input status that will be stored in each frame
100 void RecordInput(u32 buttons, const std::array<std::pair<float, float>, 2>& axes);
101
102 // Main loop that records or executes input
103 void UpdateThread();
104
105 // Sets the flag to start or stop the TAS command excecution and swaps controllers profiles
106 void StartStop();
107
108 // Stop the TAS and reverts any controller profile
109 void Stop();
110
111 // Sets the flag to reload the file and start from the begining in the next update
112 void Reset();
113
114 /**
115 * Sets the flag to enable or disable recording of inputs
116 * @return Returns true if the current recording status is enabled
117 */
118 bool Record();
119
120 // Saves contents of record_commands on a file if overwrite is enabled player 1 will be
121 // overwritten with the recorded commands
122 void SaveRecording(bool overwrite_file);
123
124 /**
125 * Returns the current status values of TAS playback/recording
126 * @return Tuple of
127 * TasState indicating the current state out of Running, Recording or Stopped ;
128 * Current playback progress or amount of frames (so far) for Recording ;
129 * Total length of script file currently loaded or amount of frames (so far) for Recording
130 */
131 std::tuple<TasState, size_t, size_t> GetStatus() const;
132
133 // Retuns an array of the default button mappings
134 InputCommon::ButtonMapping GetButtonMappingForDevice(const Common::ParamPackage& params) const;
135
136 // Retuns an array of the default analog mappings
137 InputCommon::AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) const;
138 [[nodiscard]] const TasData& GetTasState(std::size_t pad) const;
139
140private:
141 struct TASCommand {
142 u32 buttons{};
143 TasAnalog l_axis{};
144 TasAnalog r_axis{};
145 };
146
147 // Loads TAS files from all players
148 void LoadTasFiles();
149
150 // Loads TAS file from the specified player
151 void LoadTasFile(size_t player_index);
152
153 // Writes a TAS file from the recorded commands
154 void WriteTasFile(std::u8string file_name);
155
156 /**
157 * Parses a string containing the axis values with the following format "x;y"
158 * X and Y have a range from -32767 to 32767
159 * @return Returns a TAS analog object with axis values with range from -1.0 to 1.0
160 */
161 TasAnalog ReadCommandAxis(const std::string& line) const;
162
163 /**
164 * Parses a string containing the button values with the following format "a;b;c;d..."
165 * Each button is represented by it's text format specified in text_to_tas_button array
166 * @return Returns a u32 with each bit representing the status of a button
167 */
168 u32 ReadCommandButtons(const std::string& line) const;
169
170 /**
171 * Converts an u32 containing the button status into the text equivalent
172 * @return Returns a string with the name of the buttons to be written to the file
173 */
174 std::string WriteCommandButtons(u32 data) const;
175
176 /**
177 * Converts an TAS analog object containing the axis status into the text equivalent
178 * @return Returns a string with the value of the axis to be written to the file
179 */
180 std::string WriteCommandAxis(TasAnalog data) const;
181
182 // Inverts the Y axis polarity
183 std::pair<float, float> FlipAxisY(std::pair<float, float> old);
184
185 /**
186 * Converts an u32 containing the button status into the text equivalent
187 * @return Returns a string with the name of the buttons to be printed on console
188 */
189 std::string DebugButtons(u32 buttons) const;
190
191 /**
192 * Converts an TAS analog object containing the axis status into the text equivalent
193 * @return Returns a string with the value of the axis to be printed on console
194 */
195 std::string DebugJoystick(float x, float y) const;
196
197 /**
198 * Converts the given TAS status into the text equivalent
199 * @return Returns a string with the value of the TAS status to be printed on console
200 */
201 std::string DebugInput(const TasData& data) const;
202
203 /**
204 * Converts the given TAS status of multiple players into the text equivalent
205 * @return Returns a string with the value of the status of all TAS players to be printed on
206 * console
207 */
208 std::string DebugInputs(const std::array<TasData, PLAYER_NUMBER>& arr) const;
209
210 /**
211 * Converts an u32 containing the button status into the text equivalent
212 * @return Returns a string with the name of the buttons
213 */
214 std::string ButtonsToString(u32 button) const;
215
216 // Stores current controller configuration and sets a TAS controller for every active controller
217 // to the current config
218 void SwapToTasController();
219
220 // Sets the stored controller configuration to the current config
221 void SwapToStoredController();
222
223 size_t script_length{0};
224 std::array<TasData, PLAYER_NUMBER> tas_data;
225 bool is_old_input_saved{false};
226 bool is_recording{false};
227 bool is_running{false};
228 bool needs_reset{false};
229 std::array<std::vector<TASCommand>, PLAYER_NUMBER> commands{};
230 std::vector<TASCommand> record_commands{};
231 size_t current_command{0};
232 TASCommand last_input{}; // only used for recording
233
234 // Old settings for swapping controllers
235 std::array<Settings::PlayerInput, 10> player_mappings;
236};
237} // namespace TasInput
diff --git a/src/input_common/tas/tas_poller.cpp b/src/input_common/tas/tas_poller.cpp
new file mode 100644
index 000000000..15810d6b0
--- /dev/null
+++ b/src/input_common/tas/tas_poller.cpp
@@ -0,0 +1,101 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <mutex>
6#include <utility>
7
8#include "common/settings.h"
9#include "common/threadsafe_queue.h"
10#include "input_common/tas/tas_input.h"
11#include "input_common/tas/tas_poller.h"
12
13namespace InputCommon {
14
15class TasButton final : public Input::ButtonDevice {
16public:
17 explicit TasButton(u32 button_, u32 pad_, const TasInput::Tas* tas_input_)
18 : button(button_), pad(pad_), tas_input(tas_input_) {}
19
20 bool GetStatus() const override {
21 return (tas_input->GetTasState(pad).buttons & button) != 0;
22 }
23
24private:
25 const u32 button;
26 const u32 pad;
27 const TasInput::Tas* tas_input;
28};
29
30TasButtonFactory::TasButtonFactory(std::shared_ptr<TasInput::Tas> tas_input_)
31 : tas_input(std::move(tas_input_)) {}
32
33std::unique_ptr<Input::ButtonDevice> TasButtonFactory::Create(const Common::ParamPackage& params) {
34 const auto button_id = params.Get("button", 0);
35 const auto pad = params.Get("pad", 0);
36
37 return std::make_unique<TasButton>(button_id, pad, tas_input.get());
38}
39
40class TasAnalog final : public Input::AnalogDevice {
41public:
42 explicit TasAnalog(u32 pad_, u32 axis_x_, u32 axis_y_, const TasInput::Tas* tas_input_)
43 : pad(pad_), axis_x(axis_x_), axis_y(axis_y_), tas_input(tas_input_) {}
44
45 float GetAxis(u32 axis) const {
46 std::lock_guard lock{mutex};
47 return tas_input->GetTasState(pad).axis.at(axis);
48 }
49
50 std::pair<float, float> GetAnalog(u32 analog_axis_x, u32 analog_axis_y) const {
51 float x = GetAxis(analog_axis_x);
52 float y = GetAxis(analog_axis_y);
53
54 // Make sure the coordinates are in the unit circle,
55 // otherwise normalize it.
56 float r = x * x + y * y;
57 if (r > 1.0f) {
58 r = std::sqrt(r);
59 x /= r;
60 y /= r;
61 }
62
63 return {x, y};
64 }
65
66 std::tuple<float, float> GetStatus() const override {
67 return GetAnalog(axis_x, axis_y);
68 }
69
70 Input::AnalogProperties GetAnalogProperties() const override {
71 return {0.0f, 1.0f, 0.5f};
72 }
73
74private:
75 const u32 pad;
76 const u32 axis_x;
77 const u32 axis_y;
78 const TasInput::Tas* tas_input;
79 mutable std::mutex mutex;
80};
81
82/// An analog device factory that creates analog devices from GC Adapter
83TasAnalogFactory::TasAnalogFactory(std::shared_ptr<TasInput::Tas> tas_input_)
84 : tas_input(std::move(tas_input_)) {}
85
86/**
87 * Creates analog device from joystick axes
88 * @param params contains parameters for creating the device:
89 * - "port": the nth gcpad on the adapter
90 * - "axis_x": the index of the axis to be bind as x-axis
91 * - "axis_y": the index of the axis to be bind as y-axis
92 */
93std::unique_ptr<Input::AnalogDevice> TasAnalogFactory::Create(const Common::ParamPackage& params) {
94 const auto pad = static_cast<u32>(params.Get("pad", 0));
95 const auto axis_x = static_cast<u32>(params.Get("axis_x", 0));
96 const auto axis_y = static_cast<u32>(params.Get("axis_y", 1));
97
98 return std::make_unique<TasAnalog>(pad, axis_x, axis_y, tas_input.get());
99}
100
101} // namespace InputCommon
diff --git a/src/input_common/tas/tas_poller.h b/src/input_common/tas/tas_poller.h
new file mode 100644
index 000000000..09e426cef
--- /dev/null
+++ b/src/input_common/tas/tas_poller.h
@@ -0,0 +1,43 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include "core/frontend/input.h"
9#include "input_common/tas/tas_input.h"
10
11namespace InputCommon {
12
13/**
14 * A button device factory representing a tas bot. It receives tas events and forward them
15 * to all button devices it created.
16 */
17class TasButtonFactory final : public Input::Factory<Input::ButtonDevice> {
18public:
19 explicit TasButtonFactory(std::shared_ptr<TasInput::Tas> tas_input_);
20
21 /**
22 * Creates a button device from a button press
23 * @param params contains parameters for creating the device:
24 * - "code": the code of the key to bind with the button
25 */
26 std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override;
27
28private:
29 std::shared_ptr<TasInput::Tas> tas_input;
30};
31
32/// An analog device factory that creates analog devices from tas
33class TasAnalogFactory final : public Input::Factory<Input::AnalogDevice> {
34public:
35 explicit TasAnalogFactory(std::shared_ptr<TasInput::Tas> tas_input_);
36
37 std::unique_ptr<Input::AnalogDevice> Create(const Common::ParamPackage& params) override;
38
39private:
40 std::shared_ptr<TasInput::Tas> tas_input;
41};
42
43} // namespace InputCommon
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
index 68f360b3c..6f60c6574 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
@@ -477,7 +477,13 @@ void EmitSetSampleMask(EmitContext& ctx, Id value) {
477} 477}
478 478
479void EmitSetFragDepth(EmitContext& ctx, Id value) { 479void EmitSetFragDepth(EmitContext& ctx, Id value) {
480 ctx.OpStore(ctx.frag_depth, value); 480 if (!ctx.runtime_info.convert_depth_mode) {
481 ctx.OpStore(ctx.frag_depth, value);
482 return;
483 }
484 const Id unit{ctx.Const(0.5f)};
485 const Id new_depth{ctx.OpFma(ctx.F32[1], value, unit, unit)};
486 ctx.OpStore(ctx.frag_depth, new_depth);
481} 487}
482 488
483void EmitGetZFlag(EmitContext&) { 489void EmitGetZFlag(EmitContext&) {
diff --git a/src/shader_recompiler/object_pool.h b/src/shader_recompiler/object_pool.h
index f3b12d04b..a12ddcc8f 100644
--- a/src/shader_recompiler/object_pool.h
+++ b/src/shader_recompiler/object_pool.h
@@ -11,14 +11,16 @@
11namespace Shader { 11namespace Shader {
12 12
13template <typename T> 13template <typename T>
14requires std::is_destructible_v<T> class ObjectPool { 14requires std::is_destructible_v<T>
15class ObjectPool {
15public: 16public:
16 explicit ObjectPool(size_t chunk_size = 8192) : new_chunk_size{chunk_size} { 17 explicit ObjectPool(size_t chunk_size = 8192) : new_chunk_size{chunk_size} {
17 node = &chunks.emplace_back(new_chunk_size); 18 node = &chunks.emplace_back(new_chunk_size);
18 } 19 }
19 20
20 template <typename... Args> 21 template <typename... Args>
21 requires std::is_constructible_v<T, Args...>[[nodiscard]] T* Create(Args&&... args) { 22 requires std::is_constructible_v<T, Args...>
23 [[nodiscard]] T* Create(Args&&... args) {
22 return std::construct_at(Memory(), std::forward<Args>(args)...); 24 return std::construct_at(Memory(), std::forward<Args>(args)...);
23 } 25 }
24 26
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index ff024f530..2ae3639b5 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -531,14 +531,6 @@ void GPU::TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const {
531 interrupt_manager.GPUInterruptSyncpt(syncpoint_id, value); 531 interrupt_manager.GPUInterruptSyncpt(syncpoint_id, value);
532} 532}
533 533
534void GPU::ShutDown() {
535 // Signal that threads should no longer block on syncpoint fences
536 shutting_down.store(true, std::memory_order_relaxed);
537 sync_cv.notify_all();
538
539 gpu_thread.ShutDown();
540}
541
542void GPU::OnCommandListEnd() { 534void GPU::OnCommandListEnd() {
543 if (is_async) { 535 if (is_async) {
544 // This command only applies to asynchronous GPU mode 536 // This command only applies to asynchronous GPU mode
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index a8e98e51b..e6a02a71b 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -219,9 +219,6 @@ public:
219 return *shader_notify; 219 return *shader_notify;
220 } 220 }
221 221
222 // Stops the GPU execution and waits for the GPU to finish working
223 void ShutDown();
224
225 /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. 222 /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame.
226 void WaitFence(u32 syncpoint_id, u32 value); 223 void WaitFence(u32 syncpoint_id, u32 value);
227 224
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp
index 46f642b19..9547f277a 100644
--- a/src/video_core/gpu_thread.cpp
+++ b/src/video_core/gpu_thread.cpp
@@ -17,9 +17,9 @@
17namespace VideoCommon::GPUThread { 17namespace VideoCommon::GPUThread {
18 18
19/// Runs the GPU thread 19/// Runs the GPU thread
20static void RunThread(Core::System& system, VideoCore::RendererBase& renderer, 20static void RunThread(std::stop_token stop_token, Core::System& system,
21 Core::Frontend::GraphicsContext& context, Tegra::DmaPusher& dma_pusher, 21 VideoCore::RendererBase& renderer, Core::Frontend::GraphicsContext& context,
22 SynchState& state) { 22 Tegra::DmaPusher& dma_pusher, SynchState& state) {
23 std::string name = "yuzu:GPU"; 23 std::string name = "yuzu:GPU";
24 MicroProfileOnThreadCreate(name.c_str()); 24 MicroProfileOnThreadCreate(name.c_str());
25 SCOPE_EXIT({ MicroProfileOnThreadExit(); }); 25 SCOPE_EXIT({ MicroProfileOnThreadExit(); });
@@ -28,20 +28,14 @@ static void RunThread(Core::System& system, VideoCore::RendererBase& renderer,
28 Common::SetCurrentThreadPriority(Common::ThreadPriority::High); 28 Common::SetCurrentThreadPriority(Common::ThreadPriority::High);
29 system.RegisterHostThread(); 29 system.RegisterHostThread();
30 30
31 // Wait for first GPU command before acquiring the window context
32 state.queue.Wait();
33
34 // If emulation was stopped during disk shader loading, abort before trying to acquire context
35 if (!state.is_running) {
36 return;
37 }
38
39 auto current_context = context.Acquire(); 31 auto current_context = context.Acquire();
40 VideoCore::RasterizerInterface* const rasterizer = renderer.ReadRasterizer(); 32 VideoCore::RasterizerInterface* const rasterizer = renderer.ReadRasterizer();
41 33
42 CommandDataContainer next; 34 while (!stop_token.stop_requested()) {
43 while (state.is_running) { 35 CommandDataContainer next = state.queue.PopWait(stop_token);
44 next = state.queue.PopWait(); 36 if (stop_token.stop_requested()) {
37 break;
38 }
45 if (auto* submit_list = std::get_if<SubmitListCommand>(&next.data)) { 39 if (auto* submit_list = std::get_if<SubmitListCommand>(&next.data)) {
46 dma_pusher.Push(std::move(submit_list->entries)); 40 dma_pusher.Push(std::move(submit_list->entries));
47 dma_pusher.DispatchCalls(); 41 dma_pusher.DispatchCalls();
@@ -55,8 +49,6 @@ static void RunThread(Core::System& system, VideoCore::RendererBase& renderer,
55 rasterizer->FlushRegion(flush->addr, flush->size); 49 rasterizer->FlushRegion(flush->addr, flush->size);
56 } else if (const auto* invalidate = std::get_if<InvalidateRegionCommand>(&next.data)) { 50 } else if (const auto* invalidate = std::get_if<InvalidateRegionCommand>(&next.data)) {
57 rasterizer->OnCPUWrite(invalidate->addr, invalidate->size); 51 rasterizer->OnCPUWrite(invalidate->addr, invalidate->size);
58 } else if (std::holds_alternative<EndProcessingCommand>(next.data)) {
59 ASSERT(state.is_running == false);
60 } else { 52 } else {
61 UNREACHABLE(); 53 UNREACHABLE();
62 } 54 }
@@ -73,16 +65,14 @@ static void RunThread(Core::System& system, VideoCore::RendererBase& renderer,
73ThreadManager::ThreadManager(Core::System& system_, bool is_async_) 65ThreadManager::ThreadManager(Core::System& system_, bool is_async_)
74 : system{system_}, is_async{is_async_} {} 66 : system{system_}, is_async{is_async_} {}
75 67
76ThreadManager::~ThreadManager() { 68ThreadManager::~ThreadManager() = default;
77 ShutDown();
78}
79 69
80void ThreadManager::StartThread(VideoCore::RendererBase& renderer, 70void ThreadManager::StartThread(VideoCore::RendererBase& renderer,
81 Core::Frontend::GraphicsContext& context, 71 Core::Frontend::GraphicsContext& context,
82 Tegra::DmaPusher& dma_pusher) { 72 Tegra::DmaPusher& dma_pusher) {
83 rasterizer = renderer.ReadRasterizer(); 73 rasterizer = renderer.ReadRasterizer();
84 thread = std::thread(RunThread, std::ref(system), std::ref(renderer), std::ref(context), 74 thread = std::jthread(RunThread, std::ref(system), std::ref(renderer), std::ref(context),
85 std::ref(dma_pusher), std::ref(state)); 75 std::ref(dma_pusher), std::ref(state));
86} 76}
87 77
88void ThreadManager::SubmitList(Tegra::CommandList&& entries) { 78void ThreadManager::SubmitList(Tegra::CommandList&& entries) {
@@ -117,26 +107,6 @@ void ThreadManager::FlushAndInvalidateRegion(VAddr addr, u64 size) {
117 rasterizer->OnCPUWrite(addr, size); 107 rasterizer->OnCPUWrite(addr, size);
118} 108}
119 109
120void ThreadManager::ShutDown() {
121 if (!state.is_running) {
122 return;
123 }
124
125 {
126 std::lock_guard lk(state.write_lock);
127 state.is_running = false;
128 state.cv.notify_all();
129 }
130
131 if (!thread.joinable()) {
132 return;
133 }
134
135 // Notify GPU thread that a shutdown is pending
136 PushCommand(EndProcessingCommand());
137 thread.join();
138}
139
140void ThreadManager::OnCommandListEnd() { 110void ThreadManager::OnCommandListEnd() {
141 PushCommand(OnCommandListEndCommand()); 111 PushCommand(OnCommandListEndCommand());
142} 112}
@@ -152,9 +122,8 @@ u64 ThreadManager::PushCommand(CommandData&& command_data, bool block) {
152 state.queue.Push(CommandDataContainer(std::move(command_data), fence, block)); 122 state.queue.Push(CommandDataContainer(std::move(command_data), fence, block));
153 123
154 if (block) { 124 if (block) {
155 state.cv.wait(lk, [this, fence] { 125 state.cv.wait(lk, thread.get_stop_token(), [this, fence] {
156 return fence <= state.signaled_fence.load(std::memory_order_relaxed) || 126 return fence <= state.signaled_fence.load(std::memory_order_relaxed);
157 !state.is_running;
158 }); 127 });
159 } 128 }
160 129
diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h
index 11a648f38..91bada925 100644
--- a/src/video_core/gpu_thread.h
+++ b/src/video_core/gpu_thread.h
@@ -33,9 +33,6 @@ class RendererBase;
33 33
34namespace VideoCommon::GPUThread { 34namespace VideoCommon::GPUThread {
35 35
36/// Command to signal to the GPU thread that processing has ended
37struct EndProcessingCommand final {};
38
39/// Command to signal to the GPU thread that a command list is ready for processing 36/// Command to signal to the GPU thread that a command list is ready for processing
40struct SubmitListCommand final { 37struct SubmitListCommand final {
41 explicit SubmitListCommand(Tegra::CommandList&& entries_) : entries{std::move(entries_)} {} 38 explicit SubmitListCommand(Tegra::CommandList&& entries_) : entries{std::move(entries_)} {}
@@ -83,7 +80,7 @@ struct OnCommandListEndCommand final {};
83struct GPUTickCommand final {}; 80struct GPUTickCommand final {};
84 81
85using CommandData = 82using CommandData =
86 std::variant<EndProcessingCommand, SubmitListCommand, SwapBuffersCommand, FlushRegionCommand, 83 std::variant<std::monostate, SubmitListCommand, SwapBuffersCommand, FlushRegionCommand,
87 InvalidateRegionCommand, FlushAndInvalidateRegionCommand, OnCommandListEndCommand, 84 InvalidateRegionCommand, FlushAndInvalidateRegionCommand, OnCommandListEndCommand,
88 GPUTickCommand>; 85 GPUTickCommand>;
89 86
@@ -100,14 +97,12 @@ struct CommandDataContainer {
100 97
101/// Struct used to synchronize the GPU thread 98/// Struct used to synchronize the GPU thread
102struct SynchState final { 99struct SynchState final {
103 std::atomic_bool is_running{true}; 100 using CommandQueue = Common::SPSCQueue<CommandDataContainer, true>;
104
105 using CommandQueue = Common::SPSCQueue<CommandDataContainer>;
106 std::mutex write_lock; 101 std::mutex write_lock;
107 CommandQueue queue; 102 CommandQueue queue;
108 u64 last_fence{}; 103 u64 last_fence{};
109 std::atomic<u64> signaled_fence{}; 104 std::atomic<u64> signaled_fence{};
110 std::condition_variable cv; 105 std::condition_variable_any cv;
111}; 106};
112 107
113/// Class used to manage the GPU thread 108/// Class used to manage the GPU thread
@@ -149,7 +144,7 @@ private:
149 VideoCore::RasterizerInterface* rasterizer = nullptr; 144 VideoCore::RasterizerInterface* rasterizer = nullptr;
150 145
151 SynchState state; 146 SynchState state;
152 std::thread thread; 147 std::jthread thread;
153}; 148};
154 149
155} // namespace VideoCommon::GPUThread 150} // namespace VideoCommon::GPUThread
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp
index 9ff0a28cd..74822814d 100644
--- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp
+++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp
@@ -97,19 +97,14 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
97 Core::Frontend::EmuWindow& emu_window, 97 Core::Frontend::EmuWindow& emu_window,
98 Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, 98 Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_,
99 std::unique_ptr<Core::Frontend::GraphicsContext> context_) try 99 std::unique_ptr<Core::Frontend::GraphicsContext> context_) try
100 : RendererBase(emu_window, std::move(context_)), 100 : RendererBase(emu_window, std::move(context_)), telemetry_session(telemetry_session_),
101 telemetry_session(telemetry_session_), 101 cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary()),
102 cpu_memory(cpu_memory_),
103 gpu(gpu_),
104 library(OpenLibrary()),
105 instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, 102 instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type,
106 true, Settings::values.renderer_debug.GetValue())), 103 true, Settings::values.renderer_debug.GetValue())),
107 debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), 104 debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr),
108 surface(CreateSurface(instance, render_window)), 105 surface(CreateSurface(instance, render_window)),
109 device(CreateDevice(instance, dld, *surface)), 106 device(CreateDevice(instance, dld, *surface)), memory_allocator(device, false),
110 memory_allocator(device, false), 107 state_tracker(gpu), scheduler(device, state_tracker),
111 state_tracker(gpu),
112 scheduler(device, state_tracker),
113 swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width, 108 swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width,
114 render_window.GetFramebufferLayout().height, false), 109 render_window.GetFramebufferLayout().height, false),
115 blit_screen(cpu_memory, render_window, device, memory_allocator, swapchain, scheduler, 110 blit_screen(cpu_memory, render_window, device, memory_allocator, swapchain, scheduler,
@@ -149,7 +144,7 @@ void RendererVulkan::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
149 const Layout::FramebufferLayout layout = render_window.GetFramebufferLayout(); 144 const Layout::FramebufferLayout layout = render_window.GetFramebufferLayout();
150 swapchain.Create(layout.width, layout.height, is_srgb); 145 swapchain.Create(layout.width, layout.height, is_srgb);
151 }; 146 };
152 if (swapchain.IsSubOptimal() || swapchain.HasColorSpaceChanged(is_srgb)) { 147 if (swapchain.NeedsRecreation(is_srgb)) {
153 recreate_swapchain(); 148 recreate_swapchain();
154 } 149 }
155 bool is_outdated; 150 bool is_outdated;
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
index 7c0f91007..11cd41ad7 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
@@ -507,8 +507,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
507 vertex_attributes.push_back({ 507 vertex_attributes.push_back({
508 .location = static_cast<u32>(index), 508 .location = static_cast<u32>(index),
509 .binding = 0, 509 .binding = 0,
510 .format = type == 1 ? VK_FORMAT_R32_SFLOAT 510 .format = type == 1 ? VK_FORMAT_R32_SFLOAT
511 : type == 2 ? VK_FORMAT_R32_SINT : VK_FORMAT_R32_UINT, 511 : type == 2 ? VK_FORMAT_R32_SINT
512 : VK_FORMAT_R32_UINT,
512 .offset = 0, 513 .offset = 0,
513 }); 514 });
514 } 515 }
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp
index 1d438787a..0c11c814f 100644
--- a/src/video_core/renderer_vulkan/vk_scheduler.cpp
+++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp
@@ -43,17 +43,10 @@ VKScheduler::VKScheduler(const Device& device_, StateTracker& state_tracker_)
43 command_pool{std::make_unique<CommandPool>(*master_semaphore, device)} { 43 command_pool{std::make_unique<CommandPool>(*master_semaphore, device)} {
44 AcquireNewChunk(); 44 AcquireNewChunk();
45 AllocateWorkerCommandBuffer(); 45 AllocateWorkerCommandBuffer();
46 worker_thread = std::thread(&VKScheduler::WorkerThread, this); 46 worker_thread = std::jthread([this](std::stop_token token) { WorkerThread(token); });
47} 47}
48 48
49VKScheduler::~VKScheduler() { 49VKScheduler::~VKScheduler() = default;
50 {
51 std::lock_guard lock{work_mutex};
52 quit = true;
53 }
54 work_cv.notify_all();
55 worker_thread.join();
56}
57 50
58void VKScheduler::Flush(VkSemaphore signal_semaphore, VkSemaphore wait_semaphore) { 51void VKScheduler::Flush(VkSemaphore signal_semaphore, VkSemaphore wait_semaphore) {
59 SubmitExecution(signal_semaphore, wait_semaphore); 52 SubmitExecution(signal_semaphore, wait_semaphore);
@@ -135,7 +128,7 @@ bool VKScheduler::UpdateGraphicsPipeline(GraphicsPipeline* pipeline) {
135 return true; 128 return true;
136} 129}
137 130
138void VKScheduler::WorkerThread() { 131void VKScheduler::WorkerThread(std::stop_token stop_token) {
139 Common::SetCurrentThreadName("yuzu:VulkanWorker"); 132 Common::SetCurrentThreadName("yuzu:VulkanWorker");
140 do { 133 do {
141 if (work_queue.empty()) { 134 if (work_queue.empty()) {
@@ -144,8 +137,8 @@ void VKScheduler::WorkerThread() {
144 std::unique_ptr<CommandChunk> work; 137 std::unique_ptr<CommandChunk> work;
145 { 138 {
146 std::unique_lock lock{work_mutex}; 139 std::unique_lock lock{work_mutex};
147 work_cv.wait(lock, [this] { return !work_queue.empty() || quit; }); 140 work_cv.wait(lock, stop_token, [this] { return !work_queue.empty(); });
148 if (quit) { 141 if (stop_token.stop_requested()) {
149 continue; 142 continue;
150 } 143 }
151 work = std::move(work_queue.front()); 144 work = std::move(work_queue.front());
@@ -158,7 +151,7 @@ void VKScheduler::WorkerThread() {
158 } 151 }
159 std::lock_guard reserve_lock{reserve_mutex}; 152 std::lock_guard reserve_lock{reserve_mutex};
160 chunk_reserve.push_back(std::move(work)); 153 chunk_reserve.push_back(std::move(work));
161 } while (!quit); 154 } while (!stop_token.stop_requested());
162} 155}
163 156
164void VKScheduler::AllocateWorkerCommandBuffer() { 157void VKScheduler::AllocateWorkerCommandBuffer() {
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h
index 759ed5a48..85fc1712f 100644
--- a/src/video_core/renderer_vulkan/vk_scheduler.h
+++ b/src/video_core/renderer_vulkan/vk_scheduler.h
@@ -187,7 +187,7 @@ private:
187 GraphicsPipeline* graphics_pipeline = nullptr; 187 GraphicsPipeline* graphics_pipeline = nullptr;
188 }; 188 };
189 189
190 void WorkerThread(); 190 void WorkerThread(std::stop_token stop_token);
191 191
192 void AllocateWorkerCommandBuffer(); 192 void AllocateWorkerCommandBuffer();
193 193
@@ -212,7 +212,6 @@ private:
212 vk::CommandBuffer current_cmdbuf; 212 vk::CommandBuffer current_cmdbuf;
213 213
214 std::unique_ptr<CommandChunk> chunk; 214 std::unique_ptr<CommandChunk> chunk;
215 std::thread worker_thread;
216 215
217 State state; 216 State state;
218 217
@@ -224,9 +223,9 @@ private:
224 std::vector<std::unique_ptr<CommandChunk>> chunk_reserve; 223 std::vector<std::unique_ptr<CommandChunk>> chunk_reserve;
225 std::mutex reserve_mutex; 224 std::mutex reserve_mutex;
226 std::mutex work_mutex; 225 std::mutex work_mutex;
227 std::condition_variable work_cv; 226 std::condition_variable_any work_cv;
228 std::condition_variable wait_cv; 227 std::condition_variable wait_cv;
229 std::atomic_bool quit{}; 228 std::jthread worker_thread;
230}; 229};
231 230
232} // namespace Vulkan 231} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp
index aadf03cb0..8972a6921 100644
--- a/src/video_core/renderer_vulkan/vk_swapchain.cpp
+++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp
@@ -9,6 +9,7 @@
9 9
10#include "common/assert.h" 10#include "common/assert.h"
11#include "common/logging/log.h" 11#include "common/logging/log.h"
12#include "common/settings.h"
12#include "core/core.h" 13#include "core/core.h"
13#include "core/frontend/framebuffer_layout.h" 14#include "core/frontend/framebuffer_layout.h"
14#include "video_core/renderer_vulkan/vk_scheduler.h" 15#include "video_core/renderer_vulkan/vk_scheduler.h"
@@ -36,8 +37,19 @@ VkSurfaceFormatKHR ChooseSwapSurfaceFormat(vk::Span<VkSurfaceFormatKHR> formats)
36 37
37VkPresentModeKHR ChooseSwapPresentMode(vk::Span<VkPresentModeKHR> modes) { 38VkPresentModeKHR ChooseSwapPresentMode(vk::Span<VkPresentModeKHR> modes) {
38 // Mailbox doesn't lock the application like fifo (vsync), prefer it 39 // Mailbox doesn't lock the application like fifo (vsync), prefer it
39 const auto found = std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_MAILBOX_KHR); 40 const auto found_mailbox = std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_MAILBOX_KHR);
40 return found != modes.end() ? *found : VK_PRESENT_MODE_FIFO_KHR; 41 if (found_mailbox != modes.end()) {
42 return VK_PRESENT_MODE_MAILBOX_KHR;
43 }
44 if (Settings::values.disable_fps_limit.GetValue()) {
45 // FIFO present mode locks the framerate to the monitor's refresh rate,
46 // Find an alternative to surpass this limitation if FPS is unlocked.
47 const auto found_imm = std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_IMMEDIATE_KHR);
48 if (found_imm != modes.end()) {
49 return VK_PRESENT_MODE_IMMEDIATE_KHR;
50 }
51 }
52 return VK_PRESENT_MODE_FIFO_KHR;
41} 53}
42 54
43VkExtent2D ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, u32 width, u32 height) { 55VkExtent2D ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, u32 width, u32 height) {
@@ -143,7 +155,7 @@ void VKSwapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities,
143 const auto present_modes{physical_device.GetSurfacePresentModesKHR(surface)}; 155 const auto present_modes{physical_device.GetSurfacePresentModesKHR(surface)};
144 156
145 const VkSurfaceFormatKHR surface_format{ChooseSwapSurfaceFormat(formats)}; 157 const VkSurfaceFormatKHR surface_format{ChooseSwapSurfaceFormat(formats)};
146 const VkPresentModeKHR present_mode{ChooseSwapPresentMode(present_modes)}; 158 present_mode = ChooseSwapPresentMode(present_modes);
147 159
148 u32 requested_image_count{capabilities.minImageCount + 1}; 160 u32 requested_image_count{capabilities.minImageCount + 1};
149 if (capabilities.maxImageCount > 0 && requested_image_count > capabilities.maxImageCount) { 161 if (capabilities.maxImageCount > 0 && requested_image_count > capabilities.maxImageCount) {
@@ -196,6 +208,7 @@ void VKSwapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities,
196 208
197 extent = swapchain_ci.imageExtent; 209 extent = swapchain_ci.imageExtent;
198 current_srgb = srgb; 210 current_srgb = srgb;
211 current_fps_unlocked = Settings::values.disable_fps_limit.GetValue();
199 212
200 images = swapchain.GetImages(); 213 images = swapchain.GetImages();
201 image_count = static_cast<u32>(images.size()); 214 image_count = static_cast<u32>(images.size());
@@ -248,4 +261,14 @@ void VKSwapchain::Destroy() {
248 swapchain.reset(); 261 swapchain.reset();
249} 262}
250 263
264bool VKSwapchain::HasFpsUnlockChanged() const {
265 return current_fps_unlocked != Settings::values.disable_fps_limit.GetValue();
266}
267
268bool VKSwapchain::NeedsPresentModeUpdate() const {
269 // Mailbox present mode is the ideal for all scenarios. If it is not available,
270 // A different present mode is needed to support unlocked FPS above the monitor's refresh rate.
271 return present_mode != VK_PRESENT_MODE_MAILBOX_KHR && HasFpsUnlockChanged();
272}
273
251} // namespace Vulkan 274} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.h b/src/video_core/renderer_vulkan/vk_swapchain.h
index 5bce41e21..61a6d959e 100644
--- a/src/video_core/renderer_vulkan/vk_swapchain.h
+++ b/src/video_core/renderer_vulkan/vk_swapchain.h
@@ -33,6 +33,11 @@ public:
33 /// Presents the rendered image to the swapchain. 33 /// Presents the rendered image to the swapchain.
34 void Present(VkSemaphore render_semaphore); 34 void Present(VkSemaphore render_semaphore);
35 35
36 /// Returns true when the swapchain needs to be recreated.
37 bool NeedsRecreation(bool is_srgb) const {
38 return HasColorSpaceChanged(is_srgb) || IsSubOptimal() || NeedsPresentModeUpdate();
39 }
40
36 /// Returns true when the color space has changed. 41 /// Returns true when the color space has changed.
37 bool HasColorSpaceChanged(bool is_srgb) const { 42 bool HasColorSpaceChanged(bool is_srgb) const {
38 return current_srgb != is_srgb; 43 return current_srgb != is_srgb;
@@ -84,6 +89,10 @@ private:
84 89
85 void Destroy(); 90 void Destroy();
86 91
92 bool HasFpsUnlockChanged() const;
93
94 bool NeedsPresentModeUpdate() const;
95
87 const VkSurfaceKHR surface; 96 const VkSurfaceKHR surface;
88 const Device& device; 97 const Device& device;
89 VKScheduler& scheduler; 98 VKScheduler& scheduler;
@@ -102,8 +111,10 @@ private:
102 111
103 VkFormat image_view_format{}; 112 VkFormat image_view_format{};
104 VkExtent2D extent{}; 113 VkExtent2D extent{};
114 VkPresentModeKHR present_mode{};
105 115
106 bool current_srgb{}; 116 bool current_srgb{};
117 bool current_fps_unlocked{};
107 bool is_outdated{}; 118 bool is_outdated{};
108 bool is_suboptimal{}; 119 bool is_suboptimal{};
109}; 120};
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
index ff979a7ac..3b87640b5 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -127,7 +127,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
127 const auto format_info = MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, format); 127 const auto format_info = MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, format);
128 VkImageCreateFlags flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; 128 VkImageCreateFlags flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
129 if (info.type == ImageType::e2D && info.resources.layers >= 6 && 129 if (info.type == ImageType::e2D && info.resources.layers >= 6 &&
130 info.size.width == info.size.height) { 130 info.size.width == info.size.height && !device.HasBrokenCubeImageCompability()) {
131 flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; 131 flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
132 } 132 }
133 if (info.type == ImageType::e3D) { 133 if (info.type == ImageType::e3D) {
diff --git a/src/video_core/texture_cache/slot_vector.h b/src/video_core/texture_cache/slot_vector.h
index 74cd3c9d8..50df06409 100644
--- a/src/video_core/texture_cache/slot_vector.h
+++ b/src/video_core/texture_cache/slot_vector.h
@@ -31,8 +31,8 @@ struct SlotId {
31}; 31};
32 32
33template <class T> 33template <class T>
34requires std::is_nothrow_move_assignable_v<T>&& 34requires std::is_nothrow_move_assignable_v<T> && std::is_nothrow_move_constructible_v<T>
35 std::is_nothrow_move_constructible_v<T> class SlotVector { 35class SlotVector {
36public: 36public:
37 class Iterator { 37 class Iterator {
38 friend SlotVector<T>; 38 friend SlotVector<T>;
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp
index c2ec9f76a..6388ed2eb 100644
--- a/src/video_core/vulkan_common/vulkan_device.cpp
+++ b/src/video_core/vulkan_common/vulkan_device.cpp
@@ -588,22 +588,27 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
588 ext_extended_dynamic_state = false; 588 ext_extended_dynamic_state = false;
589 } 589 }
590 } 590 }
591
592 sets_per_pool = 64; 591 sets_per_pool = 64;
593 if (driver_id == VK_DRIVER_ID_AMD_PROPRIETARY || driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE) { 592
593 const bool is_amd =
594 driver_id == VK_DRIVER_ID_AMD_PROPRIETARY || driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE;
595 if (is_amd) {
594 // AMD drivers need a higher amount of Sets per Pool in certain circunstances like in XC2. 596 // AMD drivers need a higher amount of Sets per Pool in certain circunstances like in XC2.
595 sets_per_pool = 96; 597 sets_per_pool = 96;
596 } 598 // Disable VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT on AMD GCN4 and lower as it is broken.
597
598 const bool is_amd = driver_id == VK_DRIVER_ID_AMD_PROPRIETARY ||
599 driver_id == VK_DRIVER_ID_MESA_RADV ||
600 driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE;
601 if (ext_sampler_filter_minmax && is_amd) {
602 // Disable ext_sampler_filter_minmax on AMD GCN4 and lower as it is broken.
603 if (!is_float16_supported) { 599 if (!is_float16_supported) {
604 LOG_WARNING( 600 LOG_WARNING(
605 Render_Vulkan, 601 Render_Vulkan,
606 "Blacklisting AMD GCN4 and lower for VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME"); 602 "AMD GCN4 and earlier do not properly support VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT");
603 has_broken_cube_compatibility = true;
604 }
605 }
606 const bool is_amd_or_radv = is_amd || driver_id == VK_DRIVER_ID_MESA_RADV;
607 if (ext_sampler_filter_minmax && is_amd_or_radv) {
608 // Disable ext_sampler_filter_minmax on AMD GCN4 and lower as it is broken.
609 if (!is_float16_supported) {
610 LOG_WARNING(Render_Vulkan,
611 "Blacklisting AMD GCN4 and earlier for VK_EXT_sampler_filter_minmax");
607 ext_sampler_filter_minmax = false; 612 ext_sampler_filter_minmax = false;
608 } 613 }
609 } 614 }
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h
index bc180a32a..d9e74f1aa 100644
--- a/src/video_core/vulkan_common/vulkan_device.h
+++ b/src/video_core/vulkan_common/vulkan_device.h
@@ -309,6 +309,11 @@ public:
309 return has_renderdoc || has_nsight_graphics; 309 return has_renderdoc || has_nsight_graphics;
310 } 310 }
311 311
312 /// Returns true when the device does not properly support cube compatibility.
313 bool HasBrokenCubeImageCompability() const {
314 return has_broken_cube_compatibility;
315 }
316
312 /// Returns the vendor name reported from Vulkan. 317 /// Returns the vendor name reported from Vulkan.
313 std::string_view GetVendorName() const { 318 std::string_view GetVendorName() const {
314 return vendor_name; 319 return vendor_name;
@@ -417,6 +422,7 @@ private:
417 bool ext_conservative_rasterization{}; ///< Support for VK_EXT_conservative_rasterization. 422 bool ext_conservative_rasterization{}; ///< Support for VK_EXT_conservative_rasterization.
418 bool ext_provoking_vertex{}; ///< Support for VK_EXT_provoking_vertex. 423 bool ext_provoking_vertex{}; ///< Support for VK_EXT_provoking_vertex.
419 bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config. 424 bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config.
425 bool has_broken_cube_compatibility{}; ///< Has broken cube compatiblity bit
420 bool has_renderdoc{}; ///< Has RenderDoc attached 426 bool has_renderdoc{}; ///< Has RenderDoc attached
421 bool has_nsight_graphics{}; ///< Has Nsight Graphics attached 427 bool has_nsight_graphics{}; ///< Has Nsight Graphics attached
422 428
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index 19ba0dbba..b6dda283d 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -108,6 +108,9 @@ add_executable(yuzu
108 configuration/configure_system.cpp 108 configuration/configure_system.cpp
109 configuration/configure_system.h 109 configuration/configure_system.h
110 configuration/configure_system.ui 110 configuration/configure_system.ui
111 configuration/configure_tas.cpp
112 configuration/configure_tas.h
113 configuration/configure_tas.ui
111 configuration/configure_touch_from_button.cpp 114 configuration/configure_touch_from_button.cpp
112 configuration/configure_touch_from_button.h 115 configuration/configure_touch_from_button.h
113 configuration/configure_touch_from_button.ui 116 configuration/configure_touch_from_button.ui
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 2e0ade815..1519a46ed 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -36,6 +36,7 @@
36#include "input_common/keyboard.h" 36#include "input_common/keyboard.h"
37#include "input_common/main.h" 37#include "input_common/main.h"
38#include "input_common/mouse/mouse_input.h" 38#include "input_common/mouse/mouse_input.h"
39#include "input_common/tas/tas_input.h"
39#include "video_core/renderer_base.h" 40#include "video_core/renderer_base.h"
40#include "video_core/video_core.h" 41#include "video_core/video_core.h"
41#include "yuzu/bootmanager.h" 42#include "yuzu/bootmanager.h"
@@ -312,6 +313,7 @@ GRenderWindow::~GRenderWindow() {
312} 313}
313 314
314void GRenderWindow::OnFrameDisplayed() { 315void GRenderWindow::OnFrameDisplayed() {
316 input_subsystem->GetTas()->UpdateThread();
315 if (!first_frame) { 317 if (!first_frame) {
316 first_frame = true; 318 first_frame = true;
317 emit FirstFrameDisplayed(); 319 emit FirstFrameDisplayed();
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 1e1756c8a..b5796a8fc 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -221,7 +221,7 @@ const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> Config::default
221// This must be in alphabetical order according to action name as it must have the same order as 221// This must be in alphabetical order according to action name as it must have the same order as
222// UISetting::values.shortcuts, which is alphabetically ordered. 222// UISetting::values.shortcuts, which is alphabetically ordered.
223// clang-format off 223// clang-format off
224const std::array<UISettings::Shortcut, 18> Config::default_hotkeys{{ 224const std::array<UISettings::Shortcut, 21> Config::default_hotkeys{{
225 {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::WidgetWithChildrenShortcut}}, 225 {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::WidgetWithChildrenShortcut}},
226 {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::ApplicationShortcut}}, 226 {QStringLiteral("Change Docked Mode"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::ApplicationShortcut}},
227 {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}}, 227 {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}},
@@ -235,6 +235,9 @@ const std::array<UISettings::Shortcut, 18> Config::default_hotkeys{{
235 {QStringLiteral("Mute Audio"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), Qt::WindowShortcut}}, 235 {QStringLiteral("Mute Audio"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), Qt::WindowShortcut}},
236 {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}}, 236 {QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}},
237 {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}}, 237 {QStringLiteral("Stop Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F5"), Qt::WindowShortcut}},
238 {QStringLiteral("TAS Start/Stop"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F5"), Qt::ApplicationShortcut}},
239 {QStringLiteral("TAS Reset"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F6"), Qt::ApplicationShortcut}},
240 {QStringLiteral("TAS Record"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F7"), Qt::ApplicationShortcut}},
238 {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, 241 {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}},
239 {QStringLiteral("Toggle Framerate Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+U"), Qt::ApplicationShortcut}}, 242 {QStringLiteral("Toggle Framerate Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+U"), Qt::ApplicationShortcut}},
240 {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), Qt::ApplicationShortcut}}, 243 {QStringLiteral("Toggle Mouse Panning"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F9"), Qt::ApplicationShortcut}},
@@ -542,7 +545,6 @@ void Config::ReadAudioValues() {
542 ReadBasicSetting(Settings::values.audio_device_id); 545 ReadBasicSetting(Settings::values.audio_device_id);
543 ReadBasicSetting(Settings::values.sink_id); 546 ReadBasicSetting(Settings::values.sink_id);
544 } 547 }
545 ReadGlobalSetting(Settings::values.enable_audio_stretching);
546 ReadGlobalSetting(Settings::values.volume); 548 ReadGlobalSetting(Settings::values.volume);
547 549
548 qt_config->endGroup(); 550 qt_config->endGroup();
@@ -569,6 +571,11 @@ void Config::ReadControlValues() {
569 Settings::values.mouse_panning = false; 571 Settings::values.mouse_panning = false;
570 ReadBasicSetting(Settings::values.mouse_panning_sensitivity); 572 ReadBasicSetting(Settings::values.mouse_panning_sensitivity);
571 573
574 ReadBasicSetting(Settings::values.tas_enable);
575 ReadBasicSetting(Settings::values.tas_loop);
576 ReadBasicSetting(Settings::values.tas_swap_controllers);
577 ReadBasicSetting(Settings::values.pause_tas_on_load);
578
572 ReadGlobalSetting(Settings::values.use_docked_mode); 579 ReadGlobalSetting(Settings::values.use_docked_mode);
573 580
574 // Disable docked mode if handheld is selected 581 // Disable docked mode if handheld is selected
@@ -666,6 +673,13 @@ void Config::ReadDataStorageValues() {
666 QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))) 673 QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)))
667 .toString() 674 .toString()
668 .toStdString()); 675 .toStdString());
676 FS::SetYuzuPath(FS::YuzuPath::TASDir,
677 qt_config
678 ->value(QStringLiteral("tas_directory"),
679 QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::TASDir)))
680 .toString()
681 .toStdString());
682
669 ReadBasicSetting(Settings::values.gamecard_inserted); 683 ReadBasicSetting(Settings::values.gamecard_inserted);
670 ReadBasicSetting(Settings::values.gamecard_current_game); 684 ReadBasicSetting(Settings::values.gamecard_current_game);
671 ReadBasicSetting(Settings::values.gamecard_path); 685 ReadBasicSetting(Settings::values.gamecard_path);
@@ -1168,7 +1182,6 @@ void Config::SaveAudioValues() {
1168 WriteBasicSetting(Settings::values.sink_id); 1182 WriteBasicSetting(Settings::values.sink_id);
1169 WriteBasicSetting(Settings::values.audio_device_id); 1183 WriteBasicSetting(Settings::values.audio_device_id);
1170 } 1184 }
1171 WriteGlobalSetting(Settings::values.enable_audio_stretching);
1172 WriteGlobalSetting(Settings::values.volume); 1185 WriteGlobalSetting(Settings::values.volume);
1173 1186
1174 qt_config->endGroup(); 1187 qt_config->endGroup();
@@ -1194,6 +1207,11 @@ void Config::SaveControlValues() {
1194 WriteBasicSetting(Settings::values.emulate_analog_keyboard); 1207 WriteBasicSetting(Settings::values.emulate_analog_keyboard);
1195 WriteBasicSetting(Settings::values.mouse_panning_sensitivity); 1208 WriteBasicSetting(Settings::values.mouse_panning_sensitivity);
1196 1209
1210 WriteBasicSetting(Settings::values.tas_enable);
1211 WriteBasicSetting(Settings::values.tas_loop);
1212 WriteBasicSetting(Settings::values.tas_swap_controllers);
1213 WriteBasicSetting(Settings::values.pause_tas_on_load);
1214
1197 qt_config->endGroup(); 1215 qt_config->endGroup();
1198} 1216}
1199 1217
@@ -1221,6 +1239,10 @@ void Config::SaveDataStorageValues() {
1221 WriteSetting(QStringLiteral("dump_directory"), 1239 WriteSetting(QStringLiteral("dump_directory"),
1222 QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)), 1240 QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)),
1223 QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))); 1241 QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)));
1242 WriteSetting(QStringLiteral("tas_directory"),
1243 QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::TASDir)),
1244 QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::TASDir)));
1245
1224 WriteBasicSetting(Settings::values.gamecard_inserted); 1246 WriteBasicSetting(Settings::values.gamecard_inserted);
1225 WriteBasicSetting(Settings::values.gamecard_current_game); 1247 WriteBasicSetting(Settings::values.gamecard_current_game);
1226 WriteBasicSetting(Settings::values.gamecard_path); 1248 WriteBasicSetting(Settings::values.gamecard_path);
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h
index 4733227b6..3ee694e7c 100644
--- a/src/yuzu/configuration/config.h
+++ b/src/yuzu/configuration/config.h
@@ -42,7 +42,7 @@ public:
42 default_mouse_buttons; 42 default_mouse_buttons;
43 static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys; 43 static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys;
44 static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods; 44 static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods;
45 static const std::array<UISettings::Shortcut, 18> default_hotkeys; 45 static const std::array<UISettings::Shortcut, 21> default_hotkeys;
46 46
47private: 47private:
48 void Initialize(const std::string& config_name); 48 void Initialize(const std::string& config_name);
diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp
index 1d84bf4ed..f437cb53d 100644
--- a/src/yuzu/configuration/configure_audio.cpp
+++ b/src/yuzu/configuration/configure_audio.cpp
@@ -50,8 +50,6 @@ void ConfigureAudio::SetConfiguration() {
50 const auto volume_value = static_cast<int>(Settings::values.volume.GetValue()); 50 const auto volume_value = static_cast<int>(Settings::values.volume.GetValue());
51 ui->volume_slider->setValue(volume_value); 51 ui->volume_slider->setValue(volume_value);
52 52
53 ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching.GetValue());
54
55 if (!Settings::IsConfiguringGlobal()) { 53 if (!Settings::IsConfiguringGlobal()) {
56 if (Settings::values.volume.UsingGlobal()) { 54 if (Settings::values.volume.UsingGlobal()) {
57 ui->volume_combo_box->setCurrentIndex(0); 55 ui->volume_combo_box->setCurrentIndex(0);
@@ -100,8 +98,6 @@ void ConfigureAudio::SetVolumeIndicatorText(int percentage) {
100} 98}
101 99
102void ConfigureAudio::ApplyConfiguration() { 100void ConfigureAudio::ApplyConfiguration() {
103 ConfigurationShared::ApplyPerGameSetting(&Settings::values.enable_audio_stretching,
104 ui->toggle_audio_stretching, enable_audio_stretching);
105 101
106 if (Settings::IsConfiguringGlobal()) { 102 if (Settings::IsConfiguringGlobal()) {
107 Settings::values.sink_id = 103 Settings::values.sink_id =
@@ -162,15 +158,10 @@ void ConfigureAudio::RetranslateUI() {
162void ConfigureAudio::SetupPerGameUI() { 158void ConfigureAudio::SetupPerGameUI() {
163 if (Settings::IsConfiguringGlobal()) { 159 if (Settings::IsConfiguringGlobal()) {
164 ui->volume_slider->setEnabled(Settings::values.volume.UsingGlobal()); 160 ui->volume_slider->setEnabled(Settings::values.volume.UsingGlobal());
165 ui->toggle_audio_stretching->setEnabled(
166 Settings::values.enable_audio_stretching.UsingGlobal());
167 161
168 return; 162 return;
169 } 163 }
170 164
171 ConfigurationShared::SetColoredTristate(ui->toggle_audio_stretching,
172 Settings::values.enable_audio_stretching,
173 enable_audio_stretching);
174 connect(ui->volume_combo_box, qOverload<int>(&QComboBox::activated), this, [this](int index) { 165 connect(ui->volume_combo_box, qOverload<int>(&QComboBox::activated), this, [this](int index) {
175 ui->volume_slider->setEnabled(index == 1); 166 ui->volume_slider->setEnabled(index == 1);
176 ConfigurationShared::SetHighlight(ui->volume_layout, index == 1); 167 ConfigurationShared::SetHighlight(ui->volume_layout, index == 1);
diff --git a/src/yuzu/configuration/configure_audio.h b/src/yuzu/configuration/configure_audio.h
index 9dbd3d93e..5a01c8de7 100644
--- a/src/yuzu/configuration/configure_audio.h
+++ b/src/yuzu/configuration/configure_audio.h
@@ -41,6 +41,4 @@ private:
41 void SetupPerGameUI(); 41 void SetupPerGameUI();
42 42
43 std::unique_ptr<Ui::ConfigureAudio> ui; 43 std::unique_ptr<Ui::ConfigureAudio> ui;
44
45 ConfigurationShared::CheckState enable_audio_stretching;
46}; 44};
diff --git a/src/yuzu/configuration/configure_audio.ui b/src/yuzu/configuration/configure_audio.ui
index 9bd0cca96..bf736fc2c 100644
--- a/src/yuzu/configuration/configure_audio.ui
+++ b/src/yuzu/configuration/configure_audio.ui
@@ -32,16 +32,6 @@
32 </layout> 32 </layout>
33 </item> 33 </item>
34 <item> 34 <item>
35 <widget class="QCheckBox" name="toggle_audio_stretching">
36 <property name="toolTip">
37 <string>This post-processing effect adjusts audio speed to match emulation speed and helps prevent audio stutter. This however increases audio latency.</string>
38 </property>
39 <property name="text">
40 <string>Enable audio stretching</string>
41 </property>
42 </widget>
43 </item>
44 <item>
45 <layout class="QHBoxLayout" name="_2"> 35 <layout class="QHBoxLayout" name="_2">
46 <item> 36 <item>
47 <widget class="QLabel" name="audio_device_label"> 37 <widget class="QLabel" name="audio_device_label">
diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui
index 3fe9ff7de..b884a56b0 100644
--- a/src/yuzu/configuration/configure_debug.ui
+++ b/src/yuzu/configuration/configure_debug.ui
@@ -2,85 +2,55 @@
2<ui version="4.0"> 2<ui version="4.0">
3 <class>ConfigureDebug</class> 3 <class>ConfigureDebug</class>
4 <widget class="QWidget" name="ConfigureDebug"> 4 <widget class="QWidget" name="ConfigureDebug">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>400</width>
10 <height>777</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout_1"> 5 <layout class="QVBoxLayout" name="verticalLayout_1">
17 <item> 6 <item>
18 <widget class="QGroupBox" name="groupBox_2"> 7 <widget class="QGroupBox" name="groupBox_2">
19 <property name="title"> 8 <property name="title">
20 <string>Logging</string> 9 <string>Logging</string>
21 </property> 10 </property>
22 <layout class="QVBoxLayout" name="verticalLayout_4"> 11 <layout class="QGridLayout" name="gridLayout_1">
23 <item> 12 <item row="0" column="0" colspan="2">
24 <layout class="QHBoxLayout" name="horizontalLayout_2"> 13 <layout class="QHBoxLayout" name="horizontalLayout_1">
25 <item> 14 <item>
26 <widget class="QLabel" name="label_1"> 15 <widget class="QLabel" name="label_1">
27 <property name="text"> 16 <property name="text">
28 <string>Global Log Filter</string> 17 <string>Global Log Filter</string>
18 </property>
19 </widget>
20 </item>
21 <item>
22 <widget class="QLineEdit" name="log_filter_edit"/>
23 </item>
24 </layout>
25 </item>
26 <item row="1" column="0">
27 <widget class="QCheckBox" name="toggle_console">
28 <property name="text">
29 <string>Show Log in Console</string>
30 </property>
31 </widget>
32 </item>
33 <item row="1" column="1">
34 <widget class="QPushButton" name="open_log_button">
35 <property name="text">
36 <string>Open Log Location</string>
37 </property>
38 </widget>
39 </item>
40 <item row="2" column="0">
41 <widget class="QCheckBox" name="extended_logging">
42 <property name="enabled">
43 <bool>true</bool>
29 </property> 44 </property>
30 </widget> 45 <property name="toolTip">
31 </item> 46 <string>When checked, the max size of the log increases from 100 MB to 1 GB</string>
32 <item>
33 <widget class="QLineEdit" name="log_filter_edit"/>
34 </item>
35 </layout>
36 </item>
37 <item>
38 <layout class="QHBoxLayout" name="horizontalLayout_3">
39 <item>
40 <widget class="QCheckBox" name="toggle_console">
41 <property name="text">
42 <string>Show Log in Console</string>
43 </property> 47 </property>
44 </widget>
45 </item>
46 <item>
47 <widget class="QPushButton" name="open_log_button">
48 <property name="text"> 48 <property name="text">
49 <string>Open Log Location</string> 49 <string>Enable Extended Logging**</string>
50 </property> 50 </property>
51 </widget> 51 </widget>
52 </item> 52 </item>
53 </layout> 53 </layout>
54 </item>
55 <item>
56 <widget class="QCheckBox" name="extended_logging">
57 <property name="enabled">
58 <bool>true</bool>
59 </property>
60 <property name="toolTip">
61 <string>When checked, the max size of the log increases from 100 MB to 1 GB</string>
62 </property>
63 <property name="text">
64 <string>Enable Extended Logging</string>
65 </property>
66 </widget>
67 </item>
68 <item>
69 <widget class="QLabel" name="label_2">
70 <property name="font">
71 <font>
72 <italic>true</italic>
73 </font>
74 </property>
75 <property name="text">
76 <string>This will be reset automatically when yuzu closes.</string>
77 </property>
78 <property name="indent">
79 <number>20</number>
80 </property>
81 </widget>
82 </item>
83 </layout>
84 </widget> 54 </widget>
85 </item> 55 </item>
86 <item> 56 <item>
@@ -111,7 +81,7 @@
111 <property name="title"> 81 <property name="title">
112 <string>Graphics</string> 82 <string>Graphics</string>
113 </property> 83 </property>
114 <layout class="QGridLayout" name="gridLayout_3"> 84 <layout class="QGridLayout" name="gridLayout_2">
115 <item row="0" column="0"> 85 <item row="0" column="0">
116 <widget class="QCheckBox" name="enable_graphics_debugging"> 86 <widget class="QCheckBox" name="enable_graphics_debugging">
117 <property name="enabled"> 87 <property name="enabled">
@@ -176,33 +146,18 @@
176 <property name="title"> 146 <property name="title">
177 <string>Debugging</string> 147 <string>Debugging</string>
178 </property> 148 </property>
179 <layout class="QVBoxLayout" name="verticalLayout_7"> 149 <layout class="QGridLayout" name="gridLayout_3">
180 <item> 150 <item row="0" column="0">
181 <widget class="QCheckBox" name="fs_access_log"> 151 <widget class="QCheckBox" name="fs_access_log">
182 <property name="text"> 152 <property name="text">
183 <string>Enable FS Access Log</string> 153 <string>Enable FS Access Log</string>
184 </property> 154 </property>
185 </widget> 155 </widget>
186 </item> 156 </item>
187 <item> 157 <item row="1" column="0">
188 <widget class="QCheckBox" name="reporting_services"> 158 <widget class="QCheckBox" name="reporting_services">
189 <property name="text"> 159 <property name="text">
190 <string>Enable Verbose Reporting Services</string> 160 <string>Enable Verbose Reporting Services**</string>
191 </property>
192 </widget>
193 </item>
194 <item>
195 <widget class="QLabel" name="label_4">
196 <property name="font">
197 <font>
198 <italic>true</italic>
199 </font>
200 </property>
201 <property name="text">
202 <string>This will be reset automatically when yuzu closes.</string>
203 </property>
204 <property name="indent">
205 <number>20</number>
206 </property> 161 </property>
207 </widget> 162 </widget>
208 </item> 163 </item>
@@ -214,47 +169,32 @@
214 <property name="title"> 169 <property name="title">
215 <string>Advanced</string> 170 <string>Advanced</string>
216 </property> 171 </property>
217 <layout class="QVBoxLayout" name="verticalLayout_8"> 172 <layout class="QGridLayout" name="gridLayout_4">
218 <item> 173 <item> row="0" column="0">
219 <widget class="QCheckBox" name="quest_flag"> 174 <widget class="QCheckBox" name="quest_flag">
220 <property name="text"> 175 <property name="text">
221 <string>Kiosk (Quest) Mode</string> 176 <string>Kiosk (Quest) Mode</string>
222 </property> 177 </property>
223 </widget> 178 </widget>
224 </item> 179 </item>
225 <item> 180 <item row="1" column="0">
226 <widget class="QCheckBox" name="enable_cpu_debugging"> 181 <widget class="QCheckBox" name="enable_cpu_debugging">
227 <property name="text"> 182 <property name="text">
228 <string>Enable CPU Debugging</string> 183 <string>Enable CPU Debugging</string>
229 </property> 184 </property>
230 </widget> 185 </widget>
231 </item> 186 </item>
232 <item> 187 <item row="2" column="0">
233 <widget class="QCheckBox" name="use_debug_asserts"> 188 <widget class="QCheckBox" name="use_debug_asserts">
234 <property name="text"> 189 <property name="text">
235 <string>Enable Debug Asserts</string> 190 <string>Enable Debug Asserts</string>
236 </property> 191 </property>
237 </widget> 192 </widget>
238 </item> 193 </item>
239 <item> 194 <item row="0" column="1">
240 <widget class="QCheckBox" name="use_auto_stub"> 195 <widget class="QCheckBox" name="use_auto_stub">
241 <property name="text"> 196 <property name="text">
242 <string>Enable Auto-Stub</string> 197 <string>Enable Auto-Stub**</string>
243 </property>
244 </widget>
245 </item>
246 <item>
247 <widget class="QLabel" name="label_5">
248 <property name="font">
249 <font>
250 <italic>true</italic>
251 </font>
252 </property>
253 <property name="text">
254 <string>This will be reset automatically when yuzu closes.</string>
255 </property>
256 <property name="indent">
257 <number>20</number>
258 </property> 198 </property>
259 </widget> 199 </widget>
260 </item> 200 </item>
@@ -262,20 +202,19 @@
262 </widget> 202 </widget>
263 </item> 203 </item>
264 <item> 204 <item>
265 <spacer name="verticalSpacer"> 205 <widget class="QLabel" name="label_5">
266 <property name="orientation"> 206 <property name="font">
267 <enum>Qt::Vertical</enum> 207 <font>
208 <italic>true</italic>
209 </font>
268 </property> 210 </property>
269 <property name="sizeType"> 211 <property name="text">
270 <enum>QSizePolicy::Expanding</enum> 212 <string>**This will be reset automatically when yuzu closes.</string>
271 </property> 213 </property>
272 <property name="sizeHint" stdset="0"> 214 <property name="indent">
273 <size> 215 <number>20</number>
274 <width>20</width>
275 <height>40</height>
276 </size>
277 </property> 216 </property>
278 </spacer> 217 </widget>
279 </item> 218 </item>
280 </layout> 219 </layout>
281 </widget> 220 </widget>
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 7527c068b..88f4bf388 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -124,6 +124,19 @@ QString ButtonToText(const Common::ParamPackage& param) {
124 return GetKeyName(param.Get("code", 0)); 124 return GetKeyName(param.Get("code", 0));
125 } 125 }
126 126
127 if (param.Get("engine", "") == "tas") {
128 if (param.Has("axis")) {
129 const QString axis_str = QString::fromStdString(param.Get("axis", ""));
130
131 return QObject::tr("TAS Axis %1").arg(axis_str);
132 }
133 if (param.Has("button")) {
134 const QString button_str = QString::number(int(std::log2(param.Get("button", 0))));
135 return QObject::tr("TAS Btn %1").arg(button_str);
136 }
137 return GetKeyName(param.Get("code", 0));
138 }
139
127 if (param.Get("engine", "") == "cemuhookudp") { 140 if (param.Get("engine", "") == "cemuhookudp") {
128 if (param.Has("pad_index")) { 141 if (param.Has("pad_index")) {
129 const QString motion_str = QString::fromStdString(param.Get("pad_index", "")); 142 const QString motion_str = QString::fromStdString(param.Get("pad_index", ""));
@@ -187,7 +200,8 @@ QString AnalogToText(const Common::ParamPackage& param, const std::string& dir)
187 const QString axis_y_str = QString::fromStdString(param.Get("axis_y", "")); 200 const QString axis_y_str = QString::fromStdString(param.Get("axis_y", ""));
188 const bool invert_x = param.Get("invert_x", "+") == "-"; 201 const bool invert_x = param.Get("invert_x", "+") == "-";
189 const bool invert_y = param.Get("invert_y", "+") == "-"; 202 const bool invert_y = param.Get("invert_y", "+") == "-";
190 if (engine_str == "sdl" || engine_str == "gcpad" || engine_str == "mouse") { 203 if (engine_str == "sdl" || engine_str == "gcpad" || engine_str == "mouse" ||
204 engine_str == "tas") {
191 if (dir == "modifier") { 205 if (dir == "modifier") {
192 return QObject::tr("[unused]"); 206 return QObject::tr("[unused]");
193 } 207 }
@@ -926,9 +940,9 @@ void ConfigureInputPlayer::UpdateUI() {
926 940
927 int slider_value; 941 int slider_value;
928 auto& param = analogs_param[analog_id]; 942 auto& param = analogs_param[analog_id];
929 const bool is_controller = param.Get("engine", "") == "sdl" || 943 const bool is_controller =
930 param.Get("engine", "") == "gcpad" || 944 param.Get("engine", "") == "sdl" || param.Get("engine", "") == "gcpad" ||
931 param.Get("engine", "") == "mouse"; 945 param.Get("engine", "") == "mouse" || param.Get("engine", "") == "tas";
932 946
933 if (is_controller) { 947 if (is_controller) {
934 if (!param.Has("deadzone")) { 948 if (!param.Has("deadzone")) {
@@ -1045,8 +1059,12 @@ int ConfigureInputPlayer::GetIndexFromControllerType(Settings::ControllerType ty
1045void ConfigureInputPlayer::UpdateInputDevices() { 1059void ConfigureInputPlayer::UpdateInputDevices() {
1046 input_devices = input_subsystem->GetInputDevices(); 1060 input_devices = input_subsystem->GetInputDevices();
1047 ui->comboDevices->clear(); 1061 ui->comboDevices->clear();
1048 for (auto device : input_devices) { 1062 for (auto& device : input_devices) {
1049 ui->comboDevices->addItem(QString::fromStdString(device.Get("display", "Unknown")), {}); 1063 const std::string display = device.Get("display", "Unknown");
1064 ui->comboDevices->addItem(QString::fromStdString(display), {});
1065 if (display == "TAS") {
1066 device.Set("pad", static_cast<u8>(player_index));
1067 }
1050 } 1068 }
1051} 1069}
1052 1070
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 9c890ed5d..da328d904 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -175,7 +175,7 @@ void PlayerControlPreview::ResetInputs() {
175} 175}
176 176
177void PlayerControlPreview::UpdateInput() { 177void PlayerControlPreview::UpdateInput() {
178 if (!is_enabled && !mapping_active) { 178 if (!is_enabled && !mapping_active && !Settings::values.tas_enable) {
179 return; 179 return;
180 } 180 }
181 bool input_changed = false; 181 bool input_changed = false;
@@ -222,6 +222,19 @@ void PlayerControlPreview::UpdateInput() {
222 222
223 if (input_changed) { 223 if (input_changed) {
224 update(); 224 update();
225 if (controller_callback.input != nullptr) {
226 ControllerInput input{
227 .axis_values = {std::pair<float, float>{
228 axis_values[Settings::NativeAnalog::LStick].value.x(),
229 axis_values[Settings::NativeAnalog::LStick].value.y()},
230 std::pair<float, float>{
231 axis_values[Settings::NativeAnalog::RStick].value.x(),
232 axis_values[Settings::NativeAnalog::RStick].value.y()}},
233 .button_values = button_values,
234 .changed = true,
235 };
236 controller_callback.input(std::move(input));
237 }
225 } 238 }
226 239
227 if (mapping_active) { 240 if (mapping_active) {
@@ -229,6 +242,10 @@ void PlayerControlPreview::UpdateInput() {
229 } 242 }
230} 243}
231 244
245void PlayerControlPreview::SetCallBack(ControllerCallback callback_) {
246 controller_callback = std::move(callback_);
247}
248
232void PlayerControlPreview::paintEvent(QPaintEvent* event) { 249void PlayerControlPreview::paintEvent(QPaintEvent* event) {
233 QFrame::paintEvent(event); 250 QFrame::paintEvent(event);
234 QPainter p(this); 251 QPainter p(this);
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index f4a6a5e1b..f4bbfa528 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -9,6 +9,7 @@
9#include <QPointer> 9#include <QPointer>
10#include "common/settings.h" 10#include "common/settings.h"
11#include "core/frontend/input.h" 11#include "core/frontend/input.h"
12#include "yuzu/debugger/controller.h"
12 13
13class QLabel; 14class QLabel;
14 15
@@ -33,6 +34,7 @@ public:
33 void BeginMappingAnalog(std::size_t button_id); 34 void BeginMappingAnalog(std::size_t button_id);
34 void EndMapping(); 35 void EndMapping();
35 void UpdateInput(); 36 void UpdateInput();
37 void SetCallBack(ControllerCallback callback_);
36 38
37protected: 39protected:
38 void paintEvent(QPaintEvent* event) override; 40 void paintEvent(QPaintEvent* event) override;
@@ -181,6 +183,7 @@ private:
181 using StickArray = 183 using StickArray =
182 std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>; 184 std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>;
183 185
186 ControllerCallback controller_callback;
184 bool is_enabled{}; 187 bool is_enabled{};
185 bool mapping_active{}; 188 bool mapping_active{};
186 int blink_counter{}; 189 int blink_counter{};
diff --git a/src/yuzu/configuration/configure_tas.cpp b/src/yuzu/configuration/configure_tas.cpp
new file mode 100644
index 000000000..b666b175a
--- /dev/null
+++ b/src/yuzu/configuration/configure_tas.cpp
@@ -0,0 +1,84 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <QFileDialog>
6#include <QMessageBox>
7#include "common/fs/fs.h"
8#include "common/fs/path_util.h"
9#include "common/settings.h"
10#include "ui_configure_tas.h"
11#include "yuzu/configuration/configure_tas.h"
12#include "yuzu/uisettings.h"
13
14ConfigureTasDialog::ConfigureTasDialog(QWidget* parent)
15 : QDialog(parent), ui(std::make_unique<Ui::ConfigureTas>()) {
16
17 ui->setupUi(this);
18
19 setFocusPolicy(Qt::ClickFocus);
20 setWindowTitle(tr("TAS Configuration"));
21
22 connect(ui->tas_path_button, &QToolButton::pressed, this,
23 [this] { SetDirectory(DirectoryTarget::TAS, ui->tas_path_edit); });
24
25 LoadConfiguration();
26}
27
28ConfigureTasDialog::~ConfigureTasDialog() = default;
29
30void ConfigureTasDialog::LoadConfiguration() {
31 ui->tas_path_edit->setText(
32 QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASDir)));
33 ui->tas_enable->setChecked(Settings::values.tas_enable.GetValue());
34 ui->tas_control_swap->setChecked(Settings::values.tas_swap_controllers.GetValue());
35 ui->tas_loop_script->setChecked(Settings::values.tas_loop.GetValue());
36 ui->tas_pause_on_load->setChecked(Settings::values.pause_tas_on_load.GetValue());
37}
38
39void ConfigureTasDialog::ApplyConfiguration() {
40 Common::FS::SetYuzuPath(Common::FS::YuzuPath::TASDir, ui->tas_path_edit->text().toStdString());
41 Settings::values.tas_enable.SetValue(ui->tas_enable->isChecked());
42 Settings::values.tas_swap_controllers.SetValue(ui->tas_control_swap->isChecked());
43 Settings::values.tas_loop.SetValue(ui->tas_loop_script->isChecked());
44 Settings::values.pause_tas_on_load.SetValue(ui->tas_pause_on_load->isChecked());
45}
46
47void ConfigureTasDialog::SetDirectory(DirectoryTarget target, QLineEdit* edit) {
48 QString caption;
49
50 switch (target) {
51 case DirectoryTarget::TAS:
52 caption = tr("Select TAS Load Directory...");
53 break;
54 }
55
56 QString str = QFileDialog::getExistingDirectory(this, caption, edit->text());
57
58 if (str.isEmpty()) {
59 return;
60 }
61
62 if (str.back() != QChar::fromLatin1('/')) {
63 str.append(QChar::fromLatin1('/'));
64 }
65
66 edit->setText(str);
67}
68
69void ConfigureTasDialog::changeEvent(QEvent* event) {
70 if (event->type() == QEvent::LanguageChange) {
71 RetranslateUI();
72 }
73
74 QDialog::changeEvent(event);
75}
76
77void ConfigureTasDialog::RetranslateUI() {
78 ui->retranslateUi(this);
79}
80
81void ConfigureTasDialog::HandleApplyButtonClicked() {
82 UISettings::values.configuration_applied = true;
83 ApplyConfiguration();
84}
diff --git a/src/yuzu/configuration/configure_tas.h b/src/yuzu/configuration/configure_tas.h
new file mode 100644
index 000000000..1546bf16f
--- /dev/null
+++ b/src/yuzu/configuration/configure_tas.h
@@ -0,0 +1,38 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <QDialog>
8
9namespace Ui {
10class ConfigureTas;
11}
12
13class ConfigureTasDialog : public QDialog {
14 Q_OBJECT
15
16public:
17 explicit ConfigureTasDialog(QWidget* parent);
18 ~ConfigureTasDialog() override;
19
20 /// Save all button configurations to settings file
21 void ApplyConfiguration();
22
23private:
24 enum class DirectoryTarget {
25 TAS,
26 };
27
28 void LoadConfiguration();
29
30 void SetDirectory(DirectoryTarget target, QLineEdit* edit);
31
32 void changeEvent(QEvent* event) override;
33 void RetranslateUI();
34
35 void HandleApplyButtonClicked();
36
37 std::unique_ptr<Ui::ConfigureTas> ui;
38};
diff --git a/src/yuzu/configuration/configure_tas.ui b/src/yuzu/configuration/configure_tas.ui
new file mode 100644
index 000000000..95575ed9d
--- /dev/null
+++ b/src/yuzu/configuration/configure_tas.ui
@@ -0,0 +1,153 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>ConfigureTas</class>
4 <widget class="QDialog" name="ConfigureTas">
5 <layout class="QVBoxLayout" name="verticalLayout_1">
6 <item>
7 <layout class="QHBoxLayout" name="horizontalLayout_1">
8 <item>
9 <widget class="QGroupBox" name="groupBox_1">
10 <property name="title">
11 <string>TAS</string>
12 </property>
13 <layout class="QGridLayout" name="gridLayout_1">
14 <item row="0" column="0" colspan="4">
15 <widget class="QLabel" name="label_1">
16 <property name="text">
17 <string>Reads controller input from scripts in the same format as TAS-nx scripts.&lt;br/&gt;For a more detailed explanation please consult the FAQ on the yuzu website.</string>
18 </property>
19 </widget>
20 </item>
21 <item row="1" column="0" colspan="4">
22 <widget class="QLabel" name="label_2">
23 <property name="text">
24 <string>To check which hotkeys control the playback/recording, please refer to the Hotkey settings (General -> Hotkeys).</string>
25 </property>
26 <property name="wordWrap">
27 <bool>true</bool>
28 </property>
29 </widget>
30 </item>
31 <item row="2" column="0" colspan="4">
32 <widget class="QLabel" name="label_3">
33 <property name="text">
34 <string>WARNING: This is an experimental feature.&lt;br/&gt;It will not play back scripts frame perfectly with the current, imperfect syncing method.</string>
35 </property>
36 <property name="wordWrap">
37 <bool>true</bool>
38 </property>
39 </widget>
40 </item>
41 </layout>
42 </widget>
43 </item>
44 </layout>
45 </item>
46 <item>
47 <layout class="QHBoxLayout" name="horizontalLayout_2">
48 <item>
49 <widget class="QGroupBox" name="groupBox_2">
50 <property name="title">
51 <string>Settings</string>
52 </property>
53 <layout class="QGridLayout" name="gridLayout_2">
54 <item row="0" column="0" colspan="4">
55 <widget class="QCheckBox" name="tas_enable">
56 <property name="text">
57 <string>Enable TAS features</string>
58 </property>
59 </widget>
60 </item>
61 <item row="1" column="0" colspan="4">
62 <widget class="QCheckBox" name="tas_control_swap">
63 <property name="text">
64 <string>Automatic controller profile swapping</string>
65 </property>
66 </widget>
67 </item>
68 <item row="2" column="0" colspan="4">
69 <widget class="QCheckBox" name="tas_loop_script">
70 <property name="text">
71 <string>Loop script</string>
72 </property>
73 </widget>
74 </item>
75 <item row="3" column="0" colspan="4">
76 <widget class="QCheckBox" name="tas_pause_on_load">
77 <property name="enabled">
78 <bool>false</bool>
79 </property>
80 <property name="text">
81 <string>Pause execution during loads</string>
82 </property>
83 </widget>
84 </item>
85 </layout>
86 </widget>
87 </item>
88 </layout>
89 </item>
90 <item>
91 <layout class="QHBoxLayout" name="horizontalLayout_3">
92 <item>
93 <widget class="QGroupBox" name="groupBox_3">
94 <property name="title">
95 <string>Script Directory</string>
96 </property>
97 <layout class="QGridLayout" name="gridLayout_3">
98 <item row="0" column="0">
99 <widget class="QLabel" name="label_4">
100 <property name="text">
101 <string>Path</string>
102 </property>
103 </widget>
104 </item>
105 <item row="0" column="3">
106 <widget class="QToolButton" name="tas_path_button">
107 <property name="text">
108 <string>...</string>
109 </property>
110 </widget>
111 </item>
112 <item row="0" column="2">
113 <widget class="QLineEdit" name="tas_path_edit"/>
114 </item>
115 </layout>
116 </widget>
117 </item>
118 </layout>
119 </item>
120 <item>
121 <widget class="QDialogButtonBox" name="buttonBox">
122 <property name="sizePolicy">
123 <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
124 <horstretch>0</horstretch>
125 <verstretch>0</verstretch>
126 </sizepolicy>
127 </property>
128 <property name="orientation">
129 <enum>Qt::Horizontal</enum>
130 </property>
131 <property name="standardButtons">
132 <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
133 </property>
134 </widget>
135 </item>
136 </layout>
137 </widget>
138 <resources/>
139 <connections>
140 <connection>
141 <sender>buttonBox</sender>
142 <signal>accepted()</signal>
143 <receiver>ConfigureTas</receiver>
144 <slot>accept()</slot>
145 </connection>
146 <connection>
147 <sender>buttonBox</sender>
148 <signal>rejected()</signal>
149 <receiver>ConfigureTas</receiver>
150 <slot>reject()</slot>
151 </connection>
152 </connections>
153</ui>
diff --git a/src/yuzu/configuration/configure_vibration.cpp b/src/yuzu/configuration/configure_vibration.cpp
index 9d92c4949..46a0f3025 100644
--- a/src/yuzu/configuration/configure_vibration.cpp
+++ b/src/yuzu/configuration/configure_vibration.cpp
@@ -99,7 +99,7 @@ void ConfigureVibration::SetVibrationDevices(std::size_t player_index) {
99 const auto guid = param.Get("guid", ""); 99 const auto guid = param.Get("guid", "");
100 const auto port = param.Get("port", ""); 100 const auto port = param.Get("port", "");
101 101
102 if (engine.empty() || engine == "keyboard" || engine == "mouse") { 102 if (engine.empty() || engine == "keyboard" || engine == "mouse" || engine == "tas") {
103 continue; 103 continue;
104 } 104 }
105 105
diff --git a/src/yuzu/debugger/controller.cpp b/src/yuzu/debugger/controller.cpp
index c1fc69578..5a844409b 100644
--- a/src/yuzu/debugger/controller.cpp
+++ b/src/yuzu/debugger/controller.cpp
@@ -6,10 +6,13 @@
6#include <QLayout> 6#include <QLayout>
7#include <QString> 7#include <QString>
8#include "common/settings.h" 8#include "common/settings.h"
9#include "input_common/main.h"
10#include "input_common/tas/tas_input.h"
9#include "yuzu/configuration/configure_input_player_widget.h" 11#include "yuzu/configuration/configure_input_player_widget.h"
10#include "yuzu/debugger/controller.h" 12#include "yuzu/debugger/controller.h"
11 13
12ControllerDialog::ControllerDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { 14ControllerDialog::ControllerDialog(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_)
15 : QWidget(parent, Qt::Dialog), input_subsystem{input_subsystem_} {
13 setObjectName(QStringLiteral("Controller")); 16 setObjectName(QStringLiteral("Controller"));
14 setWindowTitle(tr("Controller P1")); 17 setWindowTitle(tr("Controller P1"));
15 resize(500, 350); 18 resize(500, 350);
@@ -38,6 +41,9 @@ void ControllerDialog::refreshConfiguration() {
38 constexpr std::size_t player = 0; 41 constexpr std::size_t player = 0;
39 widget->SetPlayerInputRaw(player, players[player].buttons, players[player].analogs); 42 widget->SetPlayerInputRaw(player, players[player].buttons, players[player].analogs);
40 widget->SetControllerType(players[player].controller_type); 43 widget->SetControllerType(players[player].controller_type);
44 ControllerCallback callback{[this](ControllerInput input) { InputController(input); }};
45 widget->SetCallBack(callback);
46 widget->repaint();
41 widget->SetConnectedStatus(players[player].connected); 47 widget->SetConnectedStatus(players[player].connected);
42} 48}
43 49
@@ -67,3 +73,13 @@ void ControllerDialog::hideEvent(QHideEvent* ev) {
67 widget->SetConnectedStatus(false); 73 widget->SetConnectedStatus(false);
68 QWidget::hideEvent(ev); 74 QWidget::hideEvent(ev);
69} 75}
76
77void ControllerDialog::InputController(ControllerInput input) {
78 u32 buttons = 0;
79 int index = 0;
80 for (bool btn : input.button_values) {
81 buttons |= (btn ? 1U : 0U) << index;
82 index++;
83 }
84 input_subsystem->GetTas()->RecordInput(buttons, input.axis_values);
85}
diff --git a/src/yuzu/debugger/controller.h b/src/yuzu/debugger/controller.h
index c54750070..7742db58b 100644
--- a/src/yuzu/debugger/controller.h
+++ b/src/yuzu/debugger/controller.h
@@ -4,18 +4,35 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <QFileSystemWatcher>
7#include <QWidget> 8#include <QWidget>
9#include "common/settings.h"
8 10
9class QAction; 11class QAction;
10class QHideEvent; 12class QHideEvent;
11class QShowEvent; 13class QShowEvent;
12class PlayerControlPreview; 14class PlayerControlPreview;
13 15
16namespace InputCommon {
17class InputSubsystem;
18}
19
20struct ControllerInput {
21 std::array<std::pair<float, float>, Settings::NativeAnalog::NUM_STICKS_HID> axis_values{};
22 std::array<bool, Settings::NativeButton::NumButtons> button_values{};
23 bool changed{};
24};
25
26struct ControllerCallback {
27 std::function<void(ControllerInput)> input;
28};
29
14class ControllerDialog : public QWidget { 30class ControllerDialog : public QWidget {
15 Q_OBJECT 31 Q_OBJECT
16 32
17public: 33public:
18 explicit ControllerDialog(QWidget* parent = nullptr); 34 explicit ControllerDialog(QWidget* parent = nullptr,
35 InputCommon::InputSubsystem* input_subsystem_ = nullptr);
19 36
20 /// Returns a QAction that can be used to toggle visibility of this dialog. 37 /// Returns a QAction that can be used to toggle visibility of this dialog.
21 QAction* toggleViewAction(); 38 QAction* toggleViewAction();
@@ -26,6 +43,9 @@ protected:
26 void hideEvent(QHideEvent* ev) override; 43 void hideEvent(QHideEvent* ev) override;
27 44
28private: 45private:
46 void InputController(ControllerInput input);
29 QAction* toggle_view_action = nullptr; 47 QAction* toggle_view_action = nullptr;
48 QFileSystemWatcher* watcher = nullptr;
30 PlayerControlPreview* widget; 49 PlayerControlPreview* widget;
50 InputCommon::InputSubsystem* input_subsystem;
31}; 51};
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index f4e49001d..3c2824362 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -19,6 +19,7 @@
19#include "common/nvidia_flags.h" 19#include "common/nvidia_flags.h"
20#include "configuration/configure_input.h" 20#include "configuration/configure_input.h"
21#include "configuration/configure_per_game.h" 21#include "configuration/configure_per_game.h"
22#include "configuration/configure_tas.h"
22#include "configuration/configure_vibration.h" 23#include "configuration/configure_vibration.h"
23#include "core/file_sys/vfs.h" 24#include "core/file_sys/vfs.h"
24#include "core/file_sys/vfs_real.h" 25#include "core/file_sys/vfs_real.h"
@@ -102,6 +103,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
102#include "core/perf_stats.h" 103#include "core/perf_stats.h"
103#include "core/telemetry_session.h" 104#include "core/telemetry_session.h"
104#include "input_common/main.h" 105#include "input_common/main.h"
106#include "input_common/tas/tas_input.h"
105#include "util/overlay_dialog.h" 107#include "util/overlay_dialog.h"
106#include "video_core/gpu.h" 108#include "video_core/gpu.h"
107#include "video_core/renderer_base.h" 109#include "video_core/renderer_base.h"
@@ -747,6 +749,11 @@ void GMainWindow::InitializeWidgets() {
747 statusBar()->addPermanentWidget(label); 749 statusBar()->addPermanentWidget(label);
748 } 750 }
749 751
752 tas_label = new QLabel();
753 tas_label->setObjectName(QStringLiteral("TASlabel"));
754 tas_label->setFocusPolicy(Qt::NoFocus);
755 statusBar()->insertPermanentWidget(0, tas_label);
756
750 // Setup Dock button 757 // Setup Dock button
751 dock_status_button = new QPushButton(); 758 dock_status_button = new QPushButton();
752 dock_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton")); 759 dock_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton"));
@@ -841,7 +848,7 @@ void GMainWindow::InitializeDebugWidgets() {
841 waitTreeWidget->hide(); 848 waitTreeWidget->hide();
842 debug_menu->addAction(waitTreeWidget->toggleViewAction()); 849 debug_menu->addAction(waitTreeWidget->toggleViewAction());
843 850
844 controller_dialog = new ControllerDialog(this); 851 controller_dialog = new ControllerDialog(this, input_subsystem.get());
845 controller_dialog->hide(); 852 controller_dialog->hide();
846 debug_menu->addAction(controller_dialog->toggleViewAction()); 853 debug_menu->addAction(controller_dialog->toggleViewAction());
847 854
@@ -1014,6 +1021,28 @@ void GMainWindow::InitializeHotkeys() {
1014 render_window->setAttribute(Qt::WA_Hover, true); 1021 render_window->setAttribute(Qt::WA_Hover, true);
1015 } 1022 }
1016 }); 1023 });
1024 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Start/Stop"), this),
1025 &QShortcut::activated, this, [&] {
1026 if (!emulation_running) {
1027 return;
1028 }
1029 input_subsystem->GetTas()->StartStop();
1030 });
1031 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Reset"), this),
1032 &QShortcut::activated, this, [&] { input_subsystem->GetTas()->Reset(); });
1033 connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Record"), this),
1034 &QShortcut::activated, this, [&] {
1035 if (!emulation_running) {
1036 return;
1037 }
1038 bool is_recording = input_subsystem->GetTas()->Record();
1039 if (!is_recording) {
1040 const auto res = QMessageBox::question(this, tr("TAS Recording"),
1041 tr("Overwrite file of player 1?"),
1042 QMessageBox::Yes | QMessageBox::No);
1043 input_subsystem->GetTas()->SaveRecording(res == QMessageBox::Yes);
1044 }
1045 });
1017} 1046}
1018 1047
1019void GMainWindow::SetDefaultUIGeometry() { 1048void GMainWindow::SetDefaultUIGeometry() {
@@ -1132,6 +1161,7 @@ void GMainWindow::ConnectMenuEvents() {
1132 connect(ui.action_Open_FAQ, &QAction::triggered, this, &GMainWindow::OnOpenFAQ); 1161 connect(ui.action_Open_FAQ, &QAction::triggered, this, &GMainWindow::OnOpenFAQ);
1133 connect(ui.action_Restart, &QAction::triggered, this, [this] { BootGame(QString(game_path)); }); 1162 connect(ui.action_Restart, &QAction::triggered, this, [this] { BootGame(QString(game_path)); });
1134 connect(ui.action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure); 1163 connect(ui.action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure);
1164 connect(ui.action_Configure_Tas, &QAction::triggered, this, &GMainWindow::OnConfigureTas);
1135 connect(ui.action_Configure_Current_Game, &QAction::triggered, this, 1165 connect(ui.action_Configure_Current_Game, &QAction::triggered, this,
1136 &GMainWindow::OnConfigurePerGame); 1166 &GMainWindow::OnConfigurePerGame);
1137 1167
@@ -1464,6 +1494,8 @@ void GMainWindow::ShutdownGame() {
1464 game_list->show(); 1494 game_list->show();
1465 } 1495 }
1466 game_list->SetFilterFocus(); 1496 game_list->SetFilterFocus();
1497 tas_label->clear();
1498 input_subsystem->GetTas()->Stop();
1467 1499
1468 render_window->removeEventFilter(render_window); 1500 render_window->removeEventFilter(render_window);
1469 render_window->setAttribute(Qt::WA_Hover, false); 1501 render_window->setAttribute(Qt::WA_Hover, false);
@@ -2698,6 +2730,19 @@ void GMainWindow::OnConfigure() {
2698 UpdateStatusButtons(); 2730 UpdateStatusButtons();
2699} 2731}
2700 2732
2733void GMainWindow::OnConfigureTas() {
2734 const auto& system = Core::System::GetInstance();
2735 ConfigureTasDialog dialog(this);
2736 const auto result = dialog.exec();
2737
2738 if (result != QDialog::Accepted && !UISettings::values.configuration_applied) {
2739 Settings::RestoreGlobalState(system.IsPoweredOn());
2740 return;
2741 } else if (result == QDialog::Accepted) {
2742 dialog.ApplyConfiguration();
2743 }
2744}
2745
2701void GMainWindow::OnConfigurePerGame() { 2746void GMainWindow::OnConfigurePerGame() {
2702 const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); 2747 const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID();
2703 OpenPerGameConfiguration(title_id, game_path.toStdString()); 2748 OpenPerGameConfiguration(title_id, game_path.toStdString());
@@ -2874,12 +2919,32 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie
2874 } 2919 }
2875} 2920}
2876 2921
2922QString GMainWindow::GetTasStateDescription() const {
2923 auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus();
2924 switch (tas_status) {
2925 case TasInput::TasState::Running:
2926 return tr("TAS state: Running %1/%2").arg(current_tas_frame).arg(total_tas_frames);
2927 case TasInput::TasState::Recording:
2928 return tr("TAS state: Recording %1").arg(total_tas_frames);
2929 case TasInput::TasState::Stopped:
2930 return tr("TAS state: Idle %1/%2").arg(current_tas_frame).arg(total_tas_frames);
2931 default:
2932 return tr("TAS State: Invalid");
2933 }
2934}
2935
2877void GMainWindow::UpdateStatusBar() { 2936void GMainWindow::UpdateStatusBar() {
2878 if (emu_thread == nullptr) { 2937 if (emu_thread == nullptr) {
2879 status_bar_update_timer.stop(); 2938 status_bar_update_timer.stop();
2880 return; 2939 return;
2881 } 2940 }
2882 2941
2942 if (Settings::values.tas_enable) {
2943 tas_label->setText(GetTasStateDescription());
2944 } else {
2945 tas_label->clear();
2946 }
2947
2883 auto& system = Core::System::GetInstance(); 2948 auto& system = Core::System::GetInstance();
2884 auto results = system.GetAndResetPerfStats(); 2949 auto results = system.GetAndResetPerfStats();
2885 auto& shader_notify = system.GPU().ShaderNotify(); 2950 auto& shader_notify = system.GPU().ShaderNotify();
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 38e66ccd0..36eed6103 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -259,6 +259,7 @@ private slots:
259 void OnMenuInstallToNAND(); 259 void OnMenuInstallToNAND();
260 void OnMenuRecentFile(); 260 void OnMenuRecentFile();
261 void OnConfigure(); 261 void OnConfigure();
262 void OnConfigureTas();
262 void OnConfigurePerGame(); 263 void OnConfigurePerGame();
263 void OnLoadAmiibo(); 264 void OnLoadAmiibo();
264 void OnOpenYuzuFolder(); 265 void OnOpenYuzuFolder();
@@ -300,6 +301,7 @@ private:
300 void OpenURL(const QUrl& url); 301 void OpenURL(const QUrl& url);
301 void LoadTranslation(); 302 void LoadTranslation();
302 void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); 303 void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
304 QString GetTasStateDescription() const;
303 305
304 Ui::MainWindow ui; 306 Ui::MainWindow ui;
305 307
@@ -318,6 +320,7 @@ private:
318 QLabel* emu_speed_label = nullptr; 320 QLabel* emu_speed_label = nullptr;
319 QLabel* game_fps_label = nullptr; 321 QLabel* game_fps_label = nullptr;
320 QLabel* emu_frametime_label = nullptr; 322 QLabel* emu_frametime_label = nullptr;
323 QLabel* tas_label = nullptr;
321 QPushButton* gpu_accuracy_button = nullptr; 324 QPushButton* gpu_accuracy_button = nullptr;
322 QPushButton* renderer_status_button = nullptr; 325 QPushButton* renderer_status_button = nullptr;
323 QPushButton* dock_status_button = nullptr; 326 QPushButton* dock_status_button = nullptr;
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui
index 048870687..653c010d8 100644
--- a/src/yuzu/main.ui
+++ b/src/yuzu/main.ui
@@ -100,6 +100,7 @@
100 <addaction name="action_Rederive"/> 100 <addaction name="action_Rederive"/>
101 <addaction name="separator"/> 101 <addaction name="separator"/>
102 <addaction name="action_Capture_Screenshot"/> 102 <addaction name="action_Capture_Screenshot"/>
103 <addaction name="action_Configure_Tas"/>
103 </widget> 104 </widget>
104 <widget class="QMenu" name="menu_Help"> 105 <widget class="QMenu" name="menu_Help">
105 <property name="title"> 106 <property name="title">
@@ -294,6 +295,11 @@
294 <string>&amp;Capture Screenshot</string> 295 <string>&amp;Capture Screenshot</string>
295 </property> 296 </property>
296 </action> 297 </action>
298 <action name="action_Configure_Tas">
299 <property name="text">
300 <string>Configure &amp;TAS...</string>
301 </property>
302 </action>
297 <action name="action_Configure_Current_Game"> 303 <action name="action_Configure_Current_Game">
298 <property name="enabled"> 304 <property name="enabled">
299 <bool>false</bool> 305 <bool>false</bool>
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index 891f7be6f..d74eb7e2b 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -475,7 +475,6 @@ void Config::ReadValues() {
475 475
476 // Audio 476 // Audio
477 ReadSetting("Audio", Settings::values.sink_id); 477 ReadSetting("Audio", Settings::values.sink_id);
478 ReadSetting("Audio", Settings::values.enable_audio_stretching);
479 ReadSetting("Audio", Settings::values.audio_device_id); 478 ReadSetting("Audio", Settings::values.audio_device_id);
480 ReadSetting("Audio", Settings::values.volume); 479 ReadSetting("Audio", Settings::values.volume);
481 480