diff options
Diffstat (limited to 'src')
27 files changed, 1426 insertions, 21 deletions
diff --git a/src/common/fs/fs_paths.h b/src/common/fs/fs_paths.h index b32614797..5d447f108 100644 --- a/src/common/fs/fs_paths.h +++ b/src/common/fs/fs_paths.h | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #define SCREENSHOTS_DIR "screenshots" | 21 | #define SCREENSHOTS_DIR "screenshots" |
| 22 | #define SDMC_DIR "sdmc" | 22 | #define SDMC_DIR "sdmc" |
| 23 | #define SHADER_DIR "shader" | 23 | #define SHADER_DIR "shader" |
| 24 | #define TAS_DIR "tas" | ||
| 24 | 25 | ||
| 25 | // yuzu-specific files | 26 | // yuzu-specific files |
| 26 | 27 | ||
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index 6cdd14f13..43b79bd6d 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp | |||
| @@ -116,6 +116,7 @@ private: | |||
| 116 | GenerateYuzuPath(YuzuPath::ScreenshotsDir, yuzu_path / SCREENSHOTS_DIR); | 116 | GenerateYuzuPath(YuzuPath::ScreenshotsDir, yuzu_path / SCREENSHOTS_DIR); |
| 117 | GenerateYuzuPath(YuzuPath::SDMCDir, yuzu_path / SDMC_DIR); | 117 | GenerateYuzuPath(YuzuPath::SDMCDir, yuzu_path / SDMC_DIR); |
| 118 | GenerateYuzuPath(YuzuPath::ShaderDir, yuzu_path / SHADER_DIR); | 118 | GenerateYuzuPath(YuzuPath::ShaderDir, yuzu_path / SHADER_DIR); |
| 119 | GenerateYuzuPath(YuzuPath::TASDir, yuzu_path / TAS_DIR); | ||
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | ~PathManagerImpl() = default; | 122 | ~PathManagerImpl() = default; |
diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h index f956ac9a2..0a9e3a145 100644 --- a/src/common/fs/path_util.h +++ b/src/common/fs/path_util.h | |||
| @@ -23,6 +23,7 @@ enum class YuzuPath { | |||
| 23 | ScreenshotsDir, // Where yuzu screenshots are stored. | 23 | ScreenshotsDir, // Where yuzu screenshots are stored. |
| 24 | SDMCDir, // Where the emulated SDMC is stored. | 24 | SDMCDir, // Where the emulated SDMC is stored. |
| 25 | ShaderDir, // Where shaders are stored. | 25 | ShaderDir, // Where shaders are stored. |
| 26 | TASDir, // Where TAS scripts are stored. | ||
| 26 | }; | 27 | }; |
| 27 | 28 | ||
| 28 | /** | 29 | /** |
diff --git a/src/common/settings.h b/src/common/settings.h index b1bddb895..c53d5acc3 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -512,6 +512,11 @@ struct Values { | |||
| 512 | "motion_device"}; | 512 | "motion_device"}; |
| 513 | 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"}; |
| 514 | 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 | |||
| 515 | BasicSetting<bool> mouse_panning{false, "mouse_panning"}; | 520 | BasicSetting<bool> mouse_panning{false, "mouse_panning"}; |
| 516 | BasicRangedSetting<u8> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; | 521 | BasicRangedSetting<u8> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; |
| 517 | BasicSetting<bool> mouse_enabled{false, "mouse_enabled"}; | 522 | BasicSetting<bool> mouse_enabled{false, "mouse_enabled"}; |
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..18d7d8817 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 | ||
| 182 | InputSubsystem::InputSubsystem() : impl{std::make_unique<Impl>()} {} | 210 | InputSubsystem::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 | ||
| 238 | TasInput::Tas* InputSubsystem::GetTas() { | ||
| 239 | return impl->tas.get(); | ||
| 240 | } | ||
| 241 | |||
| 242 | const TasInput::Tas* InputSubsystem::GetTas() const { | ||
| 243 | return impl->tas.get(); | ||
| 244 | } | ||
| 245 | |||
| 210 | std::vector<Common::ParamPackage> InputSubsystem::GetInputDevices() const { | 246 | std::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 | ||
| 326 | TasButtonFactory* InputSubsystem::GetTasButtons() { | ||
| 327 | return impl->tasbuttons.get(); | ||
| 328 | } | ||
| 329 | |||
| 330 | const TasButtonFactory* InputSubsystem::GetTasButtons() const { | ||
| 331 | return impl->tasbuttons.get(); | ||
| 332 | } | ||
| 333 | |||
| 334 | TasAnalogFactory* InputSubsystem::GetTasAnalogs() { | ||
| 335 | return impl->tasanalog.get(); | ||
| 336 | } | ||
| 337 | |||
| 338 | const TasAnalogFactory* InputSubsystem::GetTasAnalogs() const { | ||
| 339 | return impl->tasanalog.get(); | ||
| 340 | } | ||
| 341 | |||
| 290 | void InputSubsystem::ReloadInputDevices() { | 342 | void InputSubsystem::ReloadInputDevices() { |
| 291 | if (!impl->udp) { | 343 | if (!impl->udp) { |
| 292 | return; | 344 | return; |
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 { | |||
| 29 | class Mouse; | 29 | class Mouse; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | namespace TasInput { | ||
| 33 | class Tas; | ||
| 34 | } | ||
| 35 | |||
| 32 | namespace InputCommon { | 36 | namespace InputCommon { |
| 33 | namespace Polling { | 37 | namespace Polling { |
| 34 | 38 | ||
| @@ -64,6 +68,8 @@ class MouseButtonFactory; | |||
| 64 | class MouseAnalogFactory; | 68 | class MouseAnalogFactory; |
| 65 | class MouseMotionFactory; | 69 | class MouseMotionFactory; |
| 66 | class MouseTouchFactory; | 70 | class MouseTouchFactory; |
| 71 | class TasButtonFactory; | ||
| 72 | class TasAnalogFactory; | ||
| 67 | class Keyboard; | 73 | class 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 | |||
| 15 | namespace TasInput { | ||
| 16 | |||
| 17 | // Supported keywords and buttons from a TAS file | ||
| 18 | constexpr 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 | |||
| 41 | Tas::Tas() { | ||
| 42 | if (!Settings::values.tas_enable) { | ||
| 43 | needs_reset = true; | ||
| 44 | return; | ||
| 45 | } | ||
| 46 | LoadTasFiles(); | ||
| 47 | } | ||
| 48 | |||
| 49 | Tas::~Tas() { | ||
| 50 | Stop(); | ||
| 51 | }; | ||
| 52 | |||
| 53 | void 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 | |||
| 63 | void 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 | |||
| 109 | void 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 | |||
| 130 | std::pair<float, float> Tas::FlipAxisY(std::pair<float, float> old) { | ||
| 131 | auto [x, y] = old; | ||
| 132 | return {x, -y}; | ||
| 133 | } | ||
| 134 | |||
| 135 | void 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 | |||
| 139 | std::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 | |||
| 154 | std::string Tas::DebugButtons(u32 buttons) const { | ||
| 155 | return fmt::format("{{ {} }}", TasInput::Tas::ButtonsToString(buttons)); | ||
| 156 | } | ||
| 157 | |||
| 158 | std::string Tas::DebugJoystick(float x, float y) const { | ||
| 159 | return fmt::format("[ {} , {} ]", std::to_string(x), std::to_string(y)); | ||
| 160 | } | ||
| 161 | |||
| 162 | std::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 | |||
| 168 | std::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 | |||
| 179 | std::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 | |||
| 188 | void 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 | |||
| 238 | TasAnalog 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 | |||
| 253 | u32 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 | |||
| 268 | std::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 | |||
| 277 | std::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 | |||
| 302 | void 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 | |||
| 314 | void Tas::Stop() { | ||
| 315 | is_running = false; | ||
| 316 | SwapToStoredController(); | ||
| 317 | } | ||
| 318 | |||
| 319 | void 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 | |||
| 351 | void 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 | |||
| 363 | void Tas::Reset() { | ||
| 364 | if (!Settings::values.tas_enable) { | ||
| 365 | return; | ||
| 366 | } | ||
| 367 | needs_reset = true; | ||
| 368 | } | ||
| 369 | |||
| 370 | bool Tas::Record() { | ||
| 371 | if (!Settings::values.tas_enable) { | ||
| 372 | return true; | ||
| 373 | } | ||
| 374 | is_recording = !is_recording; | ||
| 375 | return is_recording; | ||
| 376 | } | ||
| 377 | |||
| 378 | void 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 | |||
| 393 | InputCommon::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 | |||
| 433 | InputCommon::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 | |||
| 452 | const 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 | /* | ||
| 15 | To play back TAS scripts on Yuzu, select the folder with scripts in the configuration menu below | ||
| 16 | Tools -> Configure TAS. The file itself has normal text format and has to be called script0-1.txt | ||
| 17 | for controller 1, script0-2.txt for controller 2 and so forth (with max. 8 players). | ||
| 18 | |||
| 19 | A script file has the same format as TAS-nx uses, so final files will look like this: | ||
| 20 | |||
| 21 | 1 KEY_B 0;0 0;0 | ||
| 22 | 6 KEY_ZL 0;0 0;0 | ||
| 23 | 41 KEY_ZL;KEY_Y 0;0 0;0 | ||
| 24 | 43 KEY_X;KEY_A 32767;0 0;0 | ||
| 25 | 44 KEY_A 32767;0 0;0 | ||
| 26 | 45 KEY_A 32767;0 0;0 | ||
| 27 | 46 KEY_A 32767;0 0;0 | ||
| 28 | 47 KEY_A 32767;0 0;0 | ||
| 29 | |||
| 30 | After placing the file at the correct location, it can be read into Yuzu with the (default) hotkey | ||
| 31 | CTRL+F6 (refresh). In the bottom left corner, it will display the amount of frames the script file | ||
| 32 | has. Playback can be started or stopped using CTRL+F5. | ||
| 33 | |||
| 34 | However, for playback to actually work, the correct input device has to be selected: In the Controls | ||
| 35 | menu, select TAS from the device list for the controller that the script should be played on. | ||
| 36 | |||
| 37 | Recording a new script file is really simple: Just make sure that the proper device (not TAS) is | ||
| 38 | connected on P1, and press CTRL+F7 to start recording. When done, just press the same keystroke | ||
| 39 | again (CTRL+F7). The new script will be saved at the location previously selected, as the filename | ||
| 40 | record.txt. | ||
| 41 | |||
| 42 | For debugging purposes, the common controller debugger can be used (View -> Debugging -> Controller | ||
| 43 | P1). | ||
| 44 | */ | ||
| 45 | |||
| 46 | namespace TasInput { | ||
| 47 | |||
| 48 | constexpr size_t PLAYER_NUMBER = 8; | ||
| 49 | |||
| 50 | using TasAnalog = std::pair<float, float>; | ||
| 51 | |||
| 52 | enum class TasState { | ||
| 53 | Running, | ||
| 54 | Recording, | ||
| 55 | Stopped, | ||
| 56 | }; | ||
| 57 | |||
| 58 | enum 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 | |||
| 81 | enum class TasAxes : u8 { | ||
| 82 | StickX, | ||
| 83 | StickY, | ||
| 84 | SubstickX, | ||
| 85 | SubstickY, | ||
| 86 | Undefined, | ||
| 87 | }; | ||
| 88 | |||
| 89 | struct TasData { | ||
| 90 | u32 buttons{}; | ||
| 91 | std::array<float, 4> axis{}; | ||
| 92 | }; | ||
| 93 | |||
| 94 | class Tas { | ||
| 95 | public: | ||
| 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 | |||
| 140 | private: | ||
| 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 | |||
| 13 | namespace InputCommon { | ||
| 14 | |||
| 15 | class TasButton final : public Input::ButtonDevice { | ||
| 16 | public: | ||
| 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 | |||
| 24 | private: | ||
| 25 | const u32 button; | ||
| 26 | const u32 pad; | ||
| 27 | const TasInput::Tas* tas_input; | ||
| 28 | }; | ||
| 29 | |||
| 30 | TasButtonFactory::TasButtonFactory(std::shared_ptr<TasInput::Tas> tas_input_) | ||
| 31 | : tas_input(std::move(tas_input_)) {} | ||
| 32 | |||
| 33 | std::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 | |||
| 40 | class TasAnalog final : public Input::AnalogDevice { | ||
| 41 | public: | ||
| 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 | |||
| 74 | private: | ||
| 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 | ||
| 83 | TasAnalogFactory::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 | */ | ||
| 93 | std::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 | |||
| 11 | namespace 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 | */ | ||
| 17 | class TasButtonFactory final : public Input::Factory<Input::ButtonDevice> { | ||
| 18 | public: | ||
| 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 | |||
| 28 | private: | ||
| 29 | std::shared_ptr<TasInput::Tas> tas_input; | ||
| 30 | }; | ||
| 31 | |||
| 32 | /// An analog device factory that creates analog devices from tas | ||
| 33 | class TasAnalogFactory final : public Input::Factory<Input::AnalogDevice> { | ||
| 34 | public: | ||
| 35 | explicit TasAnalogFactory(std::shared_ptr<TasInput::Tas> tas_input_); | ||
| 36 | |||
| 37 | std::unique_ptr<Input::AnalogDevice> Create(const Common::ParamPackage& params) override; | ||
| 38 | |||
| 39 | private: | ||
| 40 | std::shared_ptr<TasInput::Tas> tas_input; | ||
| 41 | }; | ||
| 42 | |||
| 43 | } // namespace InputCommon | ||
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 | ||
| 314 | void GRenderWindow::OnFrameDisplayed() { | 315 | void 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 952e96769..27b67fd9e 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 |
| 224 | const std::array<UISettings::Shortcut, 18> Config::default_hotkeys{{ | 224 | const 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}}, |
| @@ -564,6 +567,11 @@ void Config::ReadControlValues() { | |||
| 564 | Settings::values.mouse_panning = false; | 567 | Settings::values.mouse_panning = false; |
| 565 | ReadBasicSetting(Settings::values.mouse_panning_sensitivity); | 568 | ReadBasicSetting(Settings::values.mouse_panning_sensitivity); |
| 566 | 569 | ||
| 570 | ReadBasicSetting(Settings::values.tas_enable); | ||
| 571 | ReadBasicSetting(Settings::values.tas_loop); | ||
| 572 | ReadBasicSetting(Settings::values.tas_swap_controllers); | ||
| 573 | ReadBasicSetting(Settings::values.pause_tas_on_load); | ||
| 574 | |||
| 567 | ReadGlobalSetting(Settings::values.use_docked_mode); | 575 | ReadGlobalSetting(Settings::values.use_docked_mode); |
| 568 | 576 | ||
| 569 | // Disable docked mode if handheld is selected | 577 | // Disable docked mode if handheld is selected |
| @@ -661,6 +669,13 @@ void Config::ReadDataStorageValues() { | |||
| 661 | QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))) | 669 | QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))) |
| 662 | .toString() | 670 | .toString() |
| 663 | .toStdString()); | 671 | .toStdString()); |
| 672 | FS::SetYuzuPath(FS::YuzuPath::TASDir, | ||
| 673 | qt_config | ||
| 674 | ->value(QStringLiteral("tas_directory"), | ||
| 675 | QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::TASDir))) | ||
| 676 | .toString() | ||
| 677 | .toStdString()); | ||
| 678 | |||
| 664 | ReadBasicSetting(Settings::values.gamecard_inserted); | 679 | ReadBasicSetting(Settings::values.gamecard_inserted); |
| 665 | ReadBasicSetting(Settings::values.gamecard_current_game); | 680 | ReadBasicSetting(Settings::values.gamecard_current_game); |
| 666 | ReadBasicSetting(Settings::values.gamecard_path); | 681 | ReadBasicSetting(Settings::values.gamecard_path); |
| @@ -1188,6 +1203,11 @@ void Config::SaveControlValues() { | |||
| 1188 | WriteBasicSetting(Settings::values.emulate_analog_keyboard); | 1203 | WriteBasicSetting(Settings::values.emulate_analog_keyboard); |
| 1189 | WriteBasicSetting(Settings::values.mouse_panning_sensitivity); | 1204 | WriteBasicSetting(Settings::values.mouse_panning_sensitivity); |
| 1190 | 1205 | ||
| 1206 | WriteBasicSetting(Settings::values.tas_enable); | ||
| 1207 | WriteBasicSetting(Settings::values.tas_loop); | ||
| 1208 | WriteBasicSetting(Settings::values.tas_swap_controllers); | ||
| 1209 | WriteBasicSetting(Settings::values.pause_tas_on_load); | ||
| 1210 | |||
| 1191 | qt_config->endGroup(); | 1211 | qt_config->endGroup(); |
| 1192 | } | 1212 | } |
| 1193 | 1213 | ||
| @@ -1215,6 +1235,10 @@ void Config::SaveDataStorageValues() { | |||
| 1215 | WriteSetting(QStringLiteral("dump_directory"), | 1235 | WriteSetting(QStringLiteral("dump_directory"), |
| 1216 | QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)), | 1236 | QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)), |
| 1217 | QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))); | 1237 | QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir))); |
| 1238 | WriteSetting(QStringLiteral("tas_directory"), | ||
| 1239 | QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::TASDir)), | ||
| 1240 | QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::TASDir))); | ||
| 1241 | |||
| 1218 | WriteBasicSetting(Settings::values.gamecard_inserted); | 1242 | WriteBasicSetting(Settings::values.gamecard_inserted); |
| 1219 | WriteBasicSetting(Settings::values.gamecard_current_game); | 1243 | WriteBasicSetting(Settings::values.gamecard_current_game); |
| 1220 | WriteBasicSetting(Settings::values.gamecard_path); | 1244 | 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 | ||
| 47 | private: | 47 | private: |
| 48 | void Initialize(const std::string& config_name); | 48 | void Initialize(const std::string& config_name); |
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 | |||
| 1045 | void ConfigureInputPlayer::UpdateInputDevices() { | 1059 | void 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 | ||
| 177 | void PlayerControlPreview::UpdateInput() { | 177 | void 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 | ||
| 245 | void PlayerControlPreview::SetCallBack(ControllerCallback callback_) { | ||
| 246 | controller_callback = std::move(callback_); | ||
| 247 | } | ||
| 248 | |||
| 232 | void PlayerControlPreview::paintEvent(QPaintEvent* event) { | 249 | void 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 | ||
| 13 | class QLabel; | 14 | class 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 | ||
| 37 | protected: | 39 | protected: |
| 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 | |||
| 14 | ConfigureTasDialog::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 | |||
| 28 | ConfigureTasDialog::~ConfigureTasDialog() = default; | ||
| 29 | |||
| 30 | void 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 | |||
| 39 | void 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 | |||
| 47 | void 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 | |||
| 69 | void ConfigureTasDialog::changeEvent(QEvent* event) { | ||
| 70 | if (event->type() == QEvent::LanguageChange) { | ||
| 71 | RetranslateUI(); | ||
| 72 | } | ||
| 73 | |||
| 74 | QDialog::changeEvent(event); | ||
| 75 | } | ||
| 76 | |||
| 77 | void ConfigureTasDialog::RetranslateUI() { | ||
| 78 | ui->retranslateUi(this); | ||
| 79 | } | ||
| 80 | |||
| 81 | void 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 | |||
| 9 | namespace Ui { | ||
| 10 | class ConfigureTas; | ||
| 11 | } | ||
| 12 | |||
| 13 | class ConfigureTasDialog : public QDialog { | ||
| 14 | Q_OBJECT | ||
| 15 | |||
| 16 | public: | ||
| 17 | explicit ConfigureTasDialog(QWidget* parent); | ||
| 18 | ~ConfigureTasDialog() override; | ||
| 19 | |||
| 20 | /// Save all button configurations to settings file | ||
| 21 | void ApplyConfiguration(); | ||
| 22 | |||
| 23 | private: | ||
| 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..8a3ecb834 --- /dev/null +++ b/src/yuzu/configuration/configure_tas.ui | |||
| @@ -0,0 +1,183 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <ui version="4.0"> | ||
| 3 | <class>ConfigureTas</class> | ||
| 4 | <widget class="QDialog" name="ConfigureTas"> | ||
| 5 | <property name="geometry"> | ||
| 6 | <rect> | ||
| 7 | <x>0</x> | ||
| 8 | <y>0</y> | ||
| 9 | <width>800</width> | ||
| 10 | <height>300</height> | ||
| 11 | </rect> | ||
| 12 | </property> | ||
| 13 | <property name="windowTitle"> | ||
| 14 | <string>Dialog</string> | ||
| 15 | </property> | ||
| 16 | <layout class="QVBoxLayout" name="verticalLayout_1"> | ||
| 17 | <item> | ||
| 18 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
| 19 | <item> | ||
| 20 | <widget class="QGroupBox" name="groupBox"> | ||
| 21 | <property name="title"> | ||
| 22 | <string>TAS</string> | ||
| 23 | </property> | ||
| 24 | <layout class="QGridLayout" name="gridLayout"> | ||
| 25 | <item row="0" column="0" colspan="1"> | ||
| 26 | <widget class="QLabel" name="label_1"> | ||
| 27 | <property name="text"> | ||
| 28 | <string>Reads controller input from scripts in the same format as TAS-nx scripts. For a more detailed explanation please consult the FAQ on the yuzu website.</string> | ||
| 29 | </property> | ||
| 30 | <property name="wordWrap"> | ||
| 31 | <bool>true</bool> | ||
| 32 | </property> | ||
| 33 | </widget> | ||
| 34 | </item> | ||
| 35 | <item row="1" column="0" colspan="1"> | ||
| 36 | <widget class="QLabel" name="label_2"> | ||
| 37 | <property name="text"> | ||
| 38 | <string>To check which hotkeys control the playback/recording, please refer to the Hotkey settings (General -> Hotkeys).</string> | ||
| 39 | </property> | ||
| 40 | <property name="wordWrap"> | ||
| 41 | <bool>true</bool> | ||
| 42 | </property> | ||
| 43 | </widget> | ||
| 44 | </item> | ||
| 45 | <item row="2" column="0" colspan="1"> | ||
| 46 | <widget class="QLabel" name="label_2"> | ||
| 47 | <property name="text"> | ||
| 48 | <string>WARNING: This is an experimental feature. It will not play back scripts frame perfectly with the current, imperfect syncing method.</string> | ||
| 49 | </property> | ||
| 50 | <property name="wordWrap"> | ||
| 51 | <bool>true</bool> | ||
| 52 | </property> | ||
| 53 | </widget> | ||
| 54 | </item> | ||
| 55 | </layout> | ||
| 56 | </widget> | ||
| 57 | </item> | ||
| 58 | </layout> | ||
| 59 | </item> | ||
| 60 | <item> | ||
| 61 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
| 62 | <item> | ||
| 63 | <widget class="QGroupBox" name="groupBox"> | ||
| 64 | <property name="title"> | ||
| 65 | <string>Settings</string> | ||
| 66 | </property> | ||
| 67 | <layout class="QGridLayout" name="gridLayout"> | ||
| 68 | <item row="0" column="0" colspan="4"> | ||
| 69 | <widget class="QCheckBox" name="tas_enable"> | ||
| 70 | <property name="text"> | ||
| 71 | <string>Enable TAS features</string> | ||
| 72 | </property> | ||
| 73 | </widget> | ||
| 74 | </item> | ||
| 75 | <item row="1" column="0" colspan="4"> | ||
| 76 | <widget class="QCheckBox" name="tas_control_swap"> | ||
| 77 | <property name="text"> | ||
| 78 | <string>Automatic controller profile swapping</string> | ||
| 79 | </property> | ||
| 80 | </widget> | ||
| 81 | </item> | ||
| 82 | <item row="2" column="0" colspan="4"> | ||
| 83 | <widget class="QCheckBox" name="tas_loop_script"> | ||
| 84 | <property name="text"> | ||
| 85 | <string>Loop script</string> | ||
| 86 | </property> | ||
| 87 | </widget> | ||
| 88 | </item> | ||
| 89 | <item row="3" column="0" colspan="4"> | ||
| 90 | <widget class="QCheckBox" name="tas_pause_on_load"> | ||
| 91 | <property name="enabled"> | ||
| 92 | <bool>false</bool> | ||
| 93 | </property> | ||
| 94 | <property name="text"> | ||
| 95 | <string>Pause execution during loads</string> | ||
| 96 | </property> | ||
| 97 | </widget> | ||
| 98 | </item> | ||
| 99 | </layout> | ||
| 100 | </widget> | ||
| 101 | </item> | ||
| 102 | </layout> | ||
| 103 | </item> | ||
| 104 | <item> | ||
| 105 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
| 106 | <item> | ||
| 107 | <widget class="QGroupBox" name="groupBox"> | ||
| 108 | <property name="title"> | ||
| 109 | <string>Script Directory</string> | ||
| 110 | </property> | ||
| 111 | <layout class="QGridLayout" name="gridLayout"> | ||
| 112 | <item row="0" column="0"> | ||
| 113 | <widget class="QLabel" name="label"> | ||
| 114 | <property name="text"> | ||
| 115 | <string>Path</string> | ||
| 116 | </property> | ||
| 117 | </widget> | ||
| 118 | </item> | ||
| 119 | <item row="0" column="3"> | ||
| 120 | <widget class="QToolButton" name="tas_path_button"> | ||
| 121 | <property name="text"> | ||
| 122 | <string>...</string> | ||
| 123 | </property> | ||
| 124 | </widget> | ||
| 125 | </item> | ||
| 126 | <item row="0" column="2"> | ||
| 127 | <widget class="QLineEdit" name="tas_path_edit"/> | ||
| 128 | </item> | ||
| 129 | <item row="0" column="1"> | ||
| 130 | <spacer name="horizontalSpacer"> | ||
| 131 | <property name="orientation"> | ||
| 132 | <enum>Qt::Horizontal</enum> | ||
| 133 | </property> | ||
| 134 | <property name="sizeType"> | ||
| 135 | <enum>QSizePolicy::Maximum</enum> | ||
| 136 | </property> | ||
| 137 | <property name="sizeHint" stdset="0"> | ||
| 138 | <size> | ||
| 139 | <width>60</width> | ||
| 140 | <height>20</height> | ||
| 141 | </size> | ||
| 142 | </property> | ||
| 143 | </spacer> | ||
| 144 | </item> | ||
| 145 | </layout> | ||
| 146 | </widget> | ||
| 147 | </item> | ||
| 148 | </layout> | ||
| 149 | </item> | ||
| 150 | <item> | ||
| 151 | <widget class="QDialogButtonBox" name="buttonBox"> | ||
| 152 | <property name="sizePolicy"> | ||
| 153 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||
| 154 | <horstretch>0</horstretch> | ||
| 155 | <verstretch>0</verstretch> | ||
| 156 | </sizepolicy> | ||
| 157 | </property> | ||
| 158 | <property name="orientation"> | ||
| 159 | <enum>Qt::Horizontal</enum> | ||
| 160 | </property> | ||
| 161 | <property name="standardButtons"> | ||
| 162 | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
| 163 | </property> | ||
| 164 | </widget> | ||
| 165 | </item> | ||
| 166 | </layout> | ||
| 167 | </widget> | ||
| 168 | <resources/> | ||
| 169 | <connections> | ||
| 170 | <connection> | ||
| 171 | <sender>buttonBox</sender> | ||
| 172 | <signal>accepted()</signal> | ||
| 173 | <receiver>ConfigureTas</receiver> | ||
| 174 | <slot>accept()</slot> | ||
| 175 | </connection> | ||
| 176 | <connection> | ||
| 177 | <sender>buttonBox</sender> | ||
| 178 | <signal>rejected()</signal> | ||
| 179 | <receiver>ConfigureTas</receiver> | ||
| 180 | <slot>reject()</slot> | ||
| 181 | </connection> | ||
| 182 | </connections> | ||
| 183 | </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 | ||
| 12 | ControllerDialog::ControllerDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { | 14 | ControllerDialog::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 | |||
| 77 | void 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 | ||
| 9 | class QAction; | 11 | class QAction; |
| 10 | class QHideEvent; | 12 | class QHideEvent; |
| 11 | class QShowEvent; | 13 | class QShowEvent; |
| 12 | class PlayerControlPreview; | 14 | class PlayerControlPreview; |
| 13 | 15 | ||
| 16 | namespace InputCommon { | ||
| 17 | class InputSubsystem; | ||
| 18 | } | ||
| 19 | |||
| 20 | struct 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 | |||
| 26 | struct ControllerCallback { | ||
| 27 | std::function<void(ControllerInput)> input; | ||
| 28 | }; | ||
| 29 | |||
| 14 | class ControllerDialog : public QWidget { | 30 | class ControllerDialog : public QWidget { |
| 15 | Q_OBJECT | 31 | Q_OBJECT |
| 16 | 32 | ||
| 17 | public: | 33 | public: |
| 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 | ||
| 28 | private: | 45 | private: |
| 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 | ||
| 1019 | void GMainWindow::SetDefaultUIGeometry() { | 1048 | void 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 | ||
| 2733 | void 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 | |||
| 2701 | void GMainWindow::OnConfigurePerGame() { | 2746 | void 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 | ||
| 2922 | QString 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 | |||
| 2877 | void GMainWindow::UpdateStatusBar() { | 2936 | void 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>&Capture Screenshot</string> | 295 | <string>&Capture Screenshot</string> |
| 295 | </property> | 296 | </property> |
| 296 | </action> | 297 | </action> |
| 298 | <action name="action_Configure_Tas"> | ||
| 299 | <property name="text"> | ||
| 300 | <string>Configure &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> |