diff options
author | german77 <juangerman-13@hotmail.com> | 2021-10-31 02:16:10 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2021-11-25 03:30:26 +0100 |
commit | 61d9eb9f690d6afe141f24ba75c99b54e122dfa3 (patch) | |
tree | 895bee43d85f4013ce9c45e7d89b67e923888246 /src/input_common/drivers/tas_input.cpp | |
parent | core/hid: Explain better what a temporary value does (diff) | |
download | yuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.tar yuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.tar.gz yuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.tar.bz2 yuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.tar.lz yuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.tar.xz yuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.tar.zst yuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.zip |
Diffstat (limited to 'src/input_common/drivers/tas_input.cpp')
-rw-r--r-- | src/input_common/drivers/tas_input.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp index 7e7a1d58f..d2748b240 100644 --- a/src/input_common/drivers/tas_input.cpp +++ b/src/input_common/drivers/tas_input.cpp @@ -141,7 +141,7 @@ void Tas::WriteTasFile(std::u8string file_name) { } } -void Tas::RecordInput(u32 buttons, TasAnalog left_axis, TasAnalog right_axis) { +void Tas::RecordInput(u64 buttons, TasAnalog left_axis, TasAnalog right_axis) { last_input = { .buttons = buttons, .l_axis = FlipAxisY(left_axis), @@ -195,7 +195,7 @@ void Tas::UpdateThread() { } if (current_command < script_length) { LOG_DEBUG(Input, "Playing TAS {}/{}", current_command, script_length); - size_t frame = current_command++; + const size_t frame = current_command++; for (size_t player_index = 0; player_index < commands.size(); player_index++) { TASCommand command{}; if (frame < commands[player_index].size()) { @@ -207,8 +207,8 @@ void Tas::UpdateThread() { .port = player_index, .pad = 0, }; - for (std::size_t i = 0; i < sizeof(command.buttons); ++i) { - const bool button_status = (command.buttons & (1U << i)) != 0; + for (std::size_t i = 0; i < sizeof(command.buttons) * 8; ++i) { + const bool button_status = (command.buttons & (1LLU << i)) != 0; const int button = static_cast<int>(i); SetButton(identifier, button, button_status); } @@ -244,14 +244,14 @@ TasAnalog Tas::ReadCommandAxis(const std::string& line) const { return {x, y}; } -u32 Tas::ReadCommandButtons(const std::string& data) const { +u64 Tas::ReadCommandButtons(const std::string& data) const { std::stringstream button_text(data); std::string line; - u32 buttons = 0; + u64 buttons = 0; while (std::getline(button_text, line, ';')) { for (auto [text, tas_button] : text_to_tas_button) { if (text == line) { - buttons |= static_cast<u32>(tas_button); + buttons |= static_cast<u64>(tas_button); break; } } @@ -259,13 +259,14 @@ u32 Tas::ReadCommandButtons(const std::string& data) const { return buttons; } -std::string Tas::WriteCommandButtons(u32 buttons) const { +std::string Tas::WriteCommandButtons(u64 buttons) const { std::string returns = ""; for (auto [text_button, tas_button] : text_to_tas_button) { - if ((buttons & static_cast<u32>(tas_button)) != 0) - returns += fmt::format("{};", text_button.substr(4)); + if ((buttons & static_cast<u64>(tas_button)) != 0) { + returns += fmt::format("{};", text_button); + } } - return returns.empty() ? "NONE" : returns.substr(2); + return returns.empty() ? "NONE" : returns; } std::string Tas::WriteCommandAxis(TasAnalog analog) const { |