From b42c3ce21db249d5e3bc04b4f73202e757da317c Mon Sep 17 00:00:00 2001 From: MonsterDruide1 Date: Fri, 18 Jun 2021 16:15:42 +0200 Subject: input_common/tas: Base playback & recording system The base playback system supports up to 8 controllers (specified by `PLAYER_NUMBER` in `tas_input.h`), which all change their inputs simulataneously when `TAS::UpdateThread` is called. The recording system uses the controller debugger to read the state of the first controller and forwards that data to the TASing system for recording. Currently, this process sadly is not frame-perfect and pixel-accurate. Co-authored-by: Naii-the-Baf Co-authored-by: Narr-the-Reg --- src/common/settings.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index b1bddb895..29b888f10 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -14,6 +14,7 @@ #include #include +#include #include "common/common_types.h" #include "common/settings_input.h" @@ -499,6 +500,7 @@ struct Values { // Controls InputSetting> players; + std::shared_ptr inputSubsystem = NULL; Setting use_docked_mode{true, "use_docked_mode"}; @@ -512,9 +514,14 @@ struct Values { "motion_device"}; BasicSetting udp_input_servers{"127.0.0.1:26760", "udp_input_servers"}; + BasicSetting tas_enable{false, "tas_enable"}; + BasicSetting tas_reset{ false, "tas_reset" }; + BasicSetting tas_record{ false, "tas_record" }; + BasicSetting mouse_panning{false, "mouse_panning"}; BasicRangedSetting mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; BasicSetting mouse_enabled{false, "mouse_enabled"}; + std::string mouse_device; MouseButtonsRaw mouse_buttons; -- cgit v1.2.3 From f25d6ebc45dc02904ef3ca6ad8efea9a0853d194 Mon Sep 17 00:00:00 2001 From: MonsterDruide1 Date: Fri, 18 Jun 2021 16:20:10 +0200 Subject: settings: File selector & other settings First of all, TASing requires a script to play back. The user can select the parent directory at `System -> Filesystem`, next to an option to pause TAS during loads: This requires a "hacky" setup deeper in the code and will be added in the last commit. Also, Hotkeys are being introduced: CTRL+F5 for playback start/stop, CTRL+F6 for re-reading the script and CTRL+F7 for recording a new script. --- src/common/fs/path_util.cpp | 2 ++ src/common/fs/path_util.h | 2 ++ src/common/settings.h | 3 +++ 3 files changed, 7 insertions(+) (limited to 'src/common') diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index 6cdd14f13..5f76adedb 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp @@ -116,6 +116,8 @@ private: GenerateYuzuPath(YuzuPath::ScreenshotsDir, yuzu_path / SCREENSHOTS_DIR); GenerateYuzuPath(YuzuPath::SDMCDir, yuzu_path / SDMC_DIR); GenerateYuzuPath(YuzuPath::ShaderDir, yuzu_path / SHADER_DIR); + + GenerateYuzuPath(YuzuPath::TASFile, fs::path{""}); } ~PathManagerImpl() = default; diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h index f956ac9a2..6079de4c6 100644 --- a/src/common/fs/path_util.h +++ b/src/common/fs/path_util.h @@ -23,6 +23,8 @@ enum class YuzuPath { ScreenshotsDir, // Where yuzu screenshots are stored. SDMCDir, // Where the emulated SDMC is stored. ShaderDir, // Where shaders are stored. + + TASFile, // Where the current script file is stored. }; /** diff --git a/src/common/settings.h b/src/common/settings.h index 29b888f10..884ea55f8 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -550,6 +550,9 @@ struct Values { BasicSetting gamecard_current_game{false, "gamecard_current_game"}; BasicSetting gamecard_path{std::string(), "gamecard_path"}; + // TAS + bool pauseTasOnLoad; + // Debugging bool record_frame_times; BasicSetting use_gdbstub{false, "use_gdbstub"}; -- cgit v1.2.3 From 4297d2fea2228ff4afe2a7c244fb8b3f1a97491a Mon Sep 17 00:00:00 2001 From: MonsterDruide1 Date: Fri, 18 Jun 2021 16:32:46 +0200 Subject: core: Hacky TAS syncing & load pausing To keep the TAS inputs synced to the game speed even through lag spikes and loading zones, deeper access is required. First, the `TAS::UpdateThread` has to be executed exactly once per frame. This is done by connecting it to the service method the game calls to pass parameters to the GPU: `Service::VI::QueueBuffer`. Second, the loading time of new subareas and/or kingdoms (SMO) can vary. To counteract that, the `CPU_BOOST_MODE` can be detected: In the `APM`-interface, the call to enabling/disabling the boost mode can be caught and forwarded to the TASing system, which can pause the script execution if neccessary and enabled in the settings. --- src/common/fs/fs_paths.h | 1 + src/common/fs/path_util.cpp | 3 +-- src/common/settings.h | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src/common') diff --git a/src/common/fs/fs_paths.h b/src/common/fs/fs_paths.h index b32614797..84968b8e0 100644 --- a/src/common/fs/fs_paths.h +++ b/src/common/fs/fs_paths.h @@ -21,6 +21,7 @@ #define SCREENSHOTS_DIR "screenshots" #define SDMC_DIR "sdmc" #define SHADER_DIR "shader" +#define TAS_DIR "scripts" // yuzu-specific files diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index 5f76adedb..97d026eb8 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp @@ -116,8 +116,7 @@ private: GenerateYuzuPath(YuzuPath::ScreenshotsDir, yuzu_path / SCREENSHOTS_DIR); GenerateYuzuPath(YuzuPath::SDMCDir, yuzu_path / SDMC_DIR); GenerateYuzuPath(YuzuPath::ShaderDir, yuzu_path / SHADER_DIR); - - GenerateYuzuPath(YuzuPath::TASFile, fs::path{""}); + GenerateYuzuPath(YuzuPath::TASFile, yuzu_path / TAS_DIR); } ~PathManagerImpl() = default; diff --git a/src/common/settings.h b/src/common/settings.h index 884ea55f8..7333a64dc 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -500,7 +500,6 @@ struct Values { // Controls InputSetting> players; - std::shared_ptr inputSubsystem = NULL; Setting use_docked_mode{true, "use_docked_mode"}; @@ -514,9 +513,12 @@ struct Values { "motion_device"}; BasicSetting udp_input_servers{"127.0.0.1:26760", "udp_input_servers"}; - BasicSetting tas_enable{false, "tas_enable"}; + BasicSetting pause_tas_on_load { false, "pause_tas_on_load" }; + BasicSetting tas_enable{ false, "tas_enable" }; BasicSetting tas_reset{ false, "tas_reset" }; BasicSetting tas_record{ false, "tas_record" }; + BasicSetting is_cpu_boxted{ false, " BasicSetting is_cpu_boxted{ false, "cpuBoosted" }; +" }; BasicSetting mouse_panning{false, "mouse_panning"}; BasicRangedSetting mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; @@ -550,9 +552,6 @@ struct Values { BasicSetting gamecard_current_game{false, "gamecard_current_game"}; BasicSetting gamecard_path{std::string(), "gamecard_path"}; - // TAS - bool pauseTasOnLoad; - // Debugging bool record_frame_times; BasicSetting use_gdbstub{false, "use_gdbstub"}; -- cgit v1.2.3 From c01a872c8efa90065b6ba1a74079ddf6ec12058f Mon Sep 17 00:00:00 2001 From: german77 Date: Sat, 19 Jun 2021 14:38:49 -0500 Subject: config: Move TAS options to it's own menu --- src/common/fs/fs_paths.h | 2 +- src/common/fs/path_util.cpp | 2 +- src/common/fs/path_util.h | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/fs/fs_paths.h b/src/common/fs/fs_paths.h index 84968b8e0..5d447f108 100644 --- a/src/common/fs/fs_paths.h +++ b/src/common/fs/fs_paths.h @@ -21,7 +21,7 @@ #define SCREENSHOTS_DIR "screenshots" #define SDMC_DIR "sdmc" #define SHADER_DIR "shader" -#define TAS_DIR "scripts" +#define TAS_DIR "tas" // yuzu-specific files diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index 97d026eb8..43b79bd6d 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp @@ -116,7 +116,7 @@ private: GenerateYuzuPath(YuzuPath::ScreenshotsDir, yuzu_path / SCREENSHOTS_DIR); GenerateYuzuPath(YuzuPath::SDMCDir, yuzu_path / SDMC_DIR); GenerateYuzuPath(YuzuPath::ShaderDir, yuzu_path / SHADER_DIR); - GenerateYuzuPath(YuzuPath::TASFile, yuzu_path / TAS_DIR); + GenerateYuzuPath(YuzuPath::TASDir, yuzu_path / TAS_DIR); } ~PathManagerImpl() = default; diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h index 6079de4c6..52e4670e2 100644 --- a/src/common/fs/path_util.h +++ b/src/common/fs/path_util.h @@ -23,8 +23,7 @@ enum class YuzuPath { ScreenshotsDir, // Where yuzu screenshots are stored. SDMCDir, // Where the emulated SDMC is stored. ShaderDir, // Where shaders are stored. - - TASFile, // Where the current script file is stored. + TASDir, // Where the current script file is stored. }; /** -- cgit v1.2.3 From f078b15565c8cab08587b8f8629d878615705cfb Mon Sep 17 00:00:00 2001 From: MonsterDruide1 Date: Sun, 20 Jun 2021 00:04:34 +0200 Subject: input_common/tas: Fallback to simple update --- src/common/settings.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index 7333a64dc..cf12c325c 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -14,7 +14,6 @@ #include #include -#include #include "common/common_types.h" #include "common/settings_input.h" @@ -515,9 +514,9 @@ struct Values { BasicSetting pause_tas_on_load { false, "pause_tas_on_load" }; BasicSetting tas_enable{ false, "tas_enable" }; - BasicSetting tas_reset{ false, "tas_reset" }; - BasicSetting tas_record{ false, "tas_record" }; - BasicSetting is_cpu_boxted{ false, " BasicSetting is_cpu_boxted{ false, "cpuBoosted" }; + BasicSetting tas_loop{ false, "tas_loop" }; + BasicSetting tas_swap_controllers{ false, "tas_swap_controllers" }; + BasicSetting is_cpu_boosted{ false, "is_cpu_boosted" }; " }; BasicSetting mouse_panning{false, "mouse_panning"}; -- cgit v1.2.3 From e6c4bf52f0eb2c9c78e983ffbc667891463d3253 Mon Sep 17 00:00:00 2001 From: german77 Date: Sun, 27 Jun 2021 14:02:38 -0500 Subject: input_common/tas: Add swap controller --- src/common/fs/path_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h index 52e4670e2..0a9e3a145 100644 --- a/src/common/fs/path_util.h +++ b/src/common/fs/path_util.h @@ -23,7 +23,7 @@ enum class YuzuPath { ScreenshotsDir, // Where yuzu screenshots are stored. SDMCDir, // Where the emulated SDMC is stored. ShaderDir, // Where shaders are stored. - TASDir, // Where the current script file is stored. + TASDir, // Where TAS scripts are stored. }; /** -- cgit v1.2.3 From 33a1d790e8a5f67c73d0eef4a141f936345f104f Mon Sep 17 00:00:00 2001 From: german77 Date: Mon, 5 Jul 2021 20:58:52 -0500 Subject: input_common/tas: Document the main class --- src/common/settings.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.h b/src/common/settings.h index cf12c325c..c53d5acc3 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -512,17 +512,14 @@ struct Values { "motion_device"}; BasicSetting udp_input_servers{"127.0.0.1:26760", "udp_input_servers"}; - BasicSetting pause_tas_on_load { false, "pause_tas_on_load" }; - BasicSetting tas_enable{ false, "tas_enable" }; - BasicSetting tas_loop{ false, "tas_loop" }; - BasicSetting tas_swap_controllers{ false, "tas_swap_controllers" }; - BasicSetting is_cpu_boosted{ false, "is_cpu_boosted" }; -" }; + BasicSetting pause_tas_on_load{true, "pause_tas_on_load"}; + BasicSetting tas_enable{false, "tas_enable"}; + BasicSetting tas_loop{false, "tas_loop"}; + BasicSetting tas_swap_controllers{true, "tas_swap_controllers"}; BasicSetting mouse_panning{false, "mouse_panning"}; BasicRangedSetting mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; BasicSetting mouse_enabled{false, "mouse_enabled"}; - std::string mouse_device; MouseButtonsRaw mouse_buttons; -- cgit v1.2.3