diff options
Diffstat (limited to 'src/input_common')
| -rw-r--r-- | src/input_common/drivers/tas_input.cpp | 23 | ||||
| -rw-r--r-- | src/input_common/drivers/tas_input.h | 14 |
2 files changed, 19 insertions, 18 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 | ||
| 144 | void Tas::RecordInput(u32 buttons, TasAnalog left_axis, TasAnalog right_axis) { | 144 | void 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 | ||
| 247 | u32 Tas::ReadCommandButtons(const std::string& data) const { | 247 | u64 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 | ||
| 262 | std::string Tas::WriteCommandButtons(u32 buttons) const { | 262 | std::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 | ||
| 271 | std::string Tas::WriteCommandAxis(TasAnalog analog) const { | 272 | std::string Tas::WriteCommandAxis(TasAnalog analog) const { |
diff --git a/src/input_common/drivers/tas_input.h b/src/input_common/drivers/tas_input.h index 9fadc118b..5f5c3267c 100644 --- a/src/input_common/drivers/tas_input.h +++ b/src/input_common/drivers/tas_input.h | |||
| @@ -47,7 +47,7 @@ namespace InputCommon::TasInput { | |||
| 47 | 47 | ||
| 48 | constexpr size_t PLAYER_NUMBER = 10; | 48 | constexpr size_t PLAYER_NUMBER = 10; |
| 49 | 49 | ||
| 50 | enum class TasButton : u32 { | 50 | enum class TasButton : u64 { |
| 51 | BUTTON_A = 1U << 0, | 51 | BUTTON_A = 1U << 0, |
| 52 | BUTTON_B = 1U << 1, | 52 | BUTTON_B = 1U << 1, |
| 53 | BUTTON_X = 1U << 2, | 53 | BUTTON_X = 1U << 2, |
| @@ -92,7 +92,7 @@ public: | |||
| 92 | * @param left_axis: value of the left axis | 92 | * @param left_axis: value of the left axis |
| 93 | * @param right_axis: value of the right axis | 93 | * @param right_axis: value of the right axis |
| 94 | */ | 94 | */ |
| 95 | void RecordInput(u32 buttons, TasAnalog left_axis, TasAnalog right_axis); | 95 | void RecordInput(u64 buttons, TasAnalog left_axis, TasAnalog right_axis); |
| 96 | 96 | ||
| 97 | // Main loop that records or executes input | 97 | // Main loop that records or executes input |
| 98 | void UpdateThread(); | 98 | void UpdateThread(); |
| @@ -129,7 +129,7 @@ public: | |||
| 129 | 129 | ||
| 130 | private: | 130 | private: |
| 131 | struct TASCommand { | 131 | struct TASCommand { |
| 132 | u32 buttons{}; | 132 | u64 buttons{}; |
| 133 | TasAnalog l_axis{}; | 133 | TasAnalog l_axis{}; |
| 134 | TasAnalog r_axis{}; | 134 | TasAnalog r_axis{}; |
| 135 | }; | 135 | }; |
| @@ -164,9 +164,9 @@ private: | |||
| 164 | * Parses a string containing the button values. Each button is represented by it's text format | 164 | * Parses a string containing the button values. Each button is represented by it's text format |
| 165 | * specified in text_to_tas_button array | 165 | * specified in text_to_tas_button array |
| 166 | * @param line: string containing button name with the following format "a;b;c;d..." | 166 | * @param line: string containing button name with the following format "a;b;c;d..." |
| 167 | * @return Returns a u32 with each bit representing the status of a button | 167 | * @return Returns a u64 with each bit representing the status of a button |
| 168 | */ | 168 | */ |
| 169 | u32 ReadCommandButtons(const std::string& line) const; | 169 | u64 ReadCommandButtons(const std::string& line) const; |
| 170 | 170 | ||
| 171 | /** | 171 | /** |
| 172 | * Reset state of all players | 172 | * Reset state of all players |
| @@ -174,11 +174,11 @@ private: | |||
| 174 | void ClearInput(); | 174 | void ClearInput(); |
| 175 | 175 | ||
| 176 | /** | 176 | /** |
| 177 | * Converts an u32 containing the button status into the text equivalent | 177 | * Converts an u64 containing the button status into the text equivalent |
| 178 | * @param buttons: bitfield with the status of the buttons | 178 | * @param buttons: bitfield with the status of the buttons |
| 179 | * @return Returns a string with the name of the buttons to be written to the file | 179 | * @return Returns a string with the name of the buttons to be written to the file |
| 180 | */ | 180 | */ |
| 181 | std::string WriteCommandButtons(u32 buttons) const; | 181 | std::string WriteCommandButtons(u64 buttons) const; |
| 182 | 182 | ||
| 183 | /** | 183 | /** |
| 184 | * Converts an TAS analog object containing the axis status into the text equivalent | 184 | * Converts an TAS analog object containing the axis status into the text equivalent |