summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/tas_input.cpp
diff options
context:
space:
mode:
authorGravatar german772021-10-30 20:16:10 -0500
committerGravatar Narr the Reg2021-11-24 20:30:26 -0600
commit61d9eb9f690d6afe141f24ba75c99b54e122dfa3 (patch)
tree895bee43d85f4013ce9c45e7d89b67e923888246 /src/input_common/drivers/tas_input.cpp
parentcore/hid: Explain better what a temporary value does (diff)
downloadyuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.tar.gz
yuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.tar.xz
yuzu-61d9eb9f690d6afe141f24ba75c99b54e122dfa3.zip
input_common: Revert deleted TAS functions
Diffstat (limited to '')
-rw-r--r--src/input_common/drivers/tas_input.cpp23
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) {
141 } 141 }
142} 142}
143 143
144void Tas::RecordInput(u32 buttons, TasAnalog left_axis, TasAnalog right_axis) { 144void Tas::RecordInput(u64 buttons, TasAnalog left_axis, TasAnalog right_axis) {
145 last_input = { 145 last_input = {
146 .buttons = buttons, 146 .buttons = buttons,
147 .l_axis = FlipAxisY(left_axis), 147 .l_axis = FlipAxisY(left_axis),
@@ -195,7 +195,7 @@ void Tas::UpdateThread() {
195 } 195 }
196 if (current_command < script_length) { 196 if (current_command < script_length) {
197 LOG_DEBUG(Input, "Playing TAS {}/{}", current_command, script_length); 197 LOG_DEBUG(Input, "Playing TAS {}/{}", current_command, script_length);
198 size_t frame = current_command++; 198 const size_t frame = current_command++;
199 for (size_t player_index = 0; player_index < commands.size(); player_index++) { 199 for (size_t player_index = 0; player_index < commands.size(); player_index++) {
200 TASCommand command{}; 200 TASCommand command{};
201 if (frame < commands[player_index].size()) { 201 if (frame < commands[player_index].size()) {
@@ -207,8 +207,8 @@ void Tas::UpdateThread() {
207 .port = player_index, 207 .port = player_index,
208 .pad = 0, 208 .pad = 0,
209 }; 209 };
210 for (std::size_t i = 0; i < sizeof(command.buttons); ++i) { 210 for (std::size_t i = 0; i < sizeof(command.buttons) * 8; ++i) {
211 const bool button_status = (command.buttons & (1U << i)) != 0; 211 const bool button_status = (command.buttons & (1LLU << i)) != 0;
212 const int button = static_cast<int>(i); 212 const int button = static_cast<int>(i);
213 SetButton(identifier, button, button_status); 213 SetButton(identifier, button, button_status);
214 } 214 }
@@ -244,14 +244,14 @@ TasAnalog Tas::ReadCommandAxis(const std::string& line) const {
244 return {x, y}; 244 return {x, y};
245} 245}
246 246
247u32 Tas::ReadCommandButtons(const std::string& data) const { 247u64 Tas::ReadCommandButtons(const std::string& data) const {
248 std::stringstream button_text(data); 248 std::stringstream button_text(data);
249 std::string line; 249 std::string line;
250 u32 buttons = 0; 250 u64 buttons = 0;
251 while (std::getline(button_text, line, ';')) { 251 while (std::getline(button_text, line, ';')) {
252 for (auto [text, tas_button] : text_to_tas_button) { 252 for (auto [text, tas_button] : text_to_tas_button) {
253 if (text == line) { 253 if (text == line) {
254 buttons |= static_cast<u32>(tas_button); 254 buttons |= static_cast<u64>(tas_button);
255 break; 255 break;
256 } 256 }
257 } 257 }
@@ -259,13 +259,14 @@ u32 Tas::ReadCommandButtons(const std::string& data) const {
259 return buttons; 259 return buttons;
260} 260}
261 261
262std::string Tas::WriteCommandButtons(u32 buttons) const { 262std::string Tas::WriteCommandButtons(u64 buttons) const {
263 std::string returns = ""; 263 std::string returns = "";
264 for (auto [text_button, tas_button] : text_to_tas_button) { 264 for (auto [text_button, tas_button] : text_to_tas_button) {
265 if ((buttons & static_cast<u32>(tas_button)) != 0) 265 if ((buttons & static_cast<u64>(tas_button)) != 0) {
266 returns += fmt::format("{};", text_button.substr(4)); 266 returns += fmt::format("{};", text_button);
267 }
267 } 268 }
268 return returns.empty() ? "NONE" : returns.substr(2); 269 return returns.empty() ? "NONE" : returns;
269} 270}
270 271
271std::string Tas::WriteCommandAxis(TasAnalog analog) const { 272std::string Tas::WriteCommandAxis(TasAnalog analog) const {