summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/tas_input.cpp23
-rw-r--r--src/input_common/drivers/tas_input.h14
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) {
}
}
-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 {
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 {
constexpr size_t PLAYER_NUMBER = 10;
-enum class TasButton : u32 {
+enum class TasButton : u64 {
BUTTON_A = 1U << 0,
BUTTON_B = 1U << 1,
BUTTON_X = 1U << 2,
@@ -92,7 +92,7 @@ public:
* @param left_axis: value of the left axis
* @param right_axis: value of the right axis
*/
- void RecordInput(u32 buttons, TasAnalog left_axis, TasAnalog right_axis);
+ void RecordInput(u64 buttons, TasAnalog left_axis, TasAnalog right_axis);
// Main loop that records or executes input
void UpdateThread();
@@ -129,7 +129,7 @@ public:
private:
struct TASCommand {
- u32 buttons{};
+ u64 buttons{};
TasAnalog l_axis{};
TasAnalog r_axis{};
};
@@ -164,9 +164,9 @@ private:
* Parses a string containing the button values. Each button is represented by it's text format
* specified in text_to_tas_button array
* @param line: string containing button name with the following format "a;b;c;d..."
- * @return Returns a u32 with each bit representing the status of a button
+ * @return Returns a u64 with each bit representing the status of a button
*/
- u32 ReadCommandButtons(const std::string& line) const;
+ u64 ReadCommandButtons(const std::string& line) const;
/**
* Reset state of all players
@@ -174,11 +174,11 @@ private:
void ClearInput();
/**
- * Converts an u32 containing the button status into the text equivalent
+ * Converts an u64 containing the button status into the text equivalent
* @param buttons: bitfield with the status of the buttons
* @return Returns a string with the name of the buttons to be written to the file
*/
- std::string WriteCommandButtons(u32 buttons) const;
+ std::string WriteCommandButtons(u64 buttons) const;
/**
* Converts an TAS analog object containing the axis status into the text equivalent