tas_input: Make TasAxes enum an enum class

Prevents these values from potentially clashing with anything in other
headers.
This commit is contained in:
Lioncash 2021-12-13 10:41:30 -05:00
parent 3592628302
commit c126b0718c
2 changed files with 14 additions and 5 deletions

View file

@ -15,7 +15,7 @@
namespace InputCommon::TasInput { namespace InputCommon::TasInput {
enum TasAxes : u8 { enum class Tas::TasAxis : u8 {
StickX, StickX,
StickY, StickY,
SubstickX, SubstickX,
@ -205,10 +205,10 @@ void Tas::UpdateThread() {
const int button = static_cast<int>(i); const int button = static_cast<int>(i);
SetButton(identifier, button, button_status); SetButton(identifier, button, button_status);
} }
SetAxis(identifier, TasAxes::StickX, command.l_axis.x); SetTasAxis(identifier, TasAxis::StickX, command.l_axis.x);
SetAxis(identifier, TasAxes::StickY, command.l_axis.y); SetTasAxis(identifier, TasAxis::StickY, command.l_axis.y);
SetAxis(identifier, TasAxes::SubstickX, command.r_axis.x); SetTasAxis(identifier, TasAxis::SubstickX, command.r_axis.x);
SetAxis(identifier, TasAxes::SubstickY, command.r_axis.y); SetTasAxis(identifier, TasAxis::SubstickY, command.r_axis.y);
} }
} else { } else {
is_running = Settings::values.tas_loop.GetValue(); is_running = Settings::values.tas_loop.GetValue();
@ -267,6 +267,10 @@ std::string Tas::WriteCommandAxis(TasAnalog analog) const {
return fmt::format("{};{}", analog.x * 32767, analog.y * 32767); return fmt::format("{};{}", analog.x * 32767, analog.y * 32767);
} }
void Tas::SetTasAxis(const PadIdentifier& identifier, TasAxis axis, f32 value) {
SetAxis(identifier, static_cast<int>(axis), value);
}
void Tas::StartStop() { void Tas::StartStop() {
if (!Settings::values.tas_enable) { if (!Settings::values.tas_enable) {
return; return;

View file

@ -128,6 +128,8 @@ public:
std::tuple<TasState, size_t, size_t> GetStatus() const; std::tuple<TasState, size_t, size_t> GetStatus() const;
private: private:
enum class TasAxis : u8;
struct TASCommand { struct TASCommand {
u64 buttons{}; u64 buttons{};
TasAnalog l_axis{}; TasAnalog l_axis{};
@ -182,6 +184,9 @@ private:
*/ */
std::string WriteCommandAxis(TasAnalog data) const; std::string WriteCommandAxis(TasAnalog data) const;
/// Sets an axis for a particular pad to the given value.
void SetTasAxis(const PadIdentifier& identifier, TasAxis axis, f32 value);
size_t script_length{0}; size_t script_length{0};
bool is_recording{false}; bool is_recording{false};
bool is_running{false}; bool is_running{false};