Controller: Make InAnalogMode() virtual

This commit is contained in:
Connor McLaughlin 2022-10-09 14:10:42 +10:00
parent 21da5036c0
commit 4feb5ad548
6 changed files with 20 additions and 1 deletions

View file

@ -23,6 +23,11 @@ ControllerType AnalogController::GetType() const
return ControllerType::AnalogController; return ControllerType::AnalogController;
} }
bool AnalogController::InAnalogMode() const
{
return m_analog_mode;
}
void AnalogController::Reset() void AnalogController::Reset()
{ {
m_command = Command::Idle; m_command = Command::Idle;

View file

@ -62,7 +62,7 @@ public:
static std::unique_ptr<AnalogController> Create(u32 index); static std::unique_ptr<AnalogController> Create(u32 index);
ControllerType GetType() const override; ControllerType GetType() const override;
bool InAnalogMode() const { return m_analog_mode; } bool InAnalogMode() const override;
void Reset() override; void Reset() override;
bool DoState(StateWrapper& sw, bool ignore_input_state) override; bool DoState(StateWrapper& sw, bool ignore_input_state) override;

View file

@ -20,6 +20,11 @@ ControllerType AnalogJoystick::GetType() const
return ControllerType::AnalogJoystick; return ControllerType::AnalogJoystick;
} }
bool AnalogJoystick::InAnalogMode() const
{
return m_analog_mode;
}
void AnalogJoystick::Reset() void AnalogJoystick::Reset()
{ {
m_transfer_state = TransferState::Idle; m_transfer_state = TransferState::Idle;

View file

@ -60,6 +60,7 @@ public:
static std::unique_ptr<AnalogJoystick> Create(u32 index); static std::unique_ptr<AnalogJoystick> Create(u32 index);
ControllerType GetType() const override; ControllerType GetType() const override;
bool InAnalogMode() const override;
void Reset() override; void Reset() override;
bool DoState(StateWrapper& sw, bool apply_input_state) override; bool DoState(StateWrapper& sw, bool apply_input_state) override;

View file

@ -53,6 +53,11 @@ u32 Controller::GetButtonStateBits() const
return 0; return 0;
} }
bool Controller::InAnalogMode() const
{
return false;
}
std::optional<u32> Controller::GetAnalogInputBytes() const std::optional<u32> Controller::GetAnalogInputBytes() const
{ {
return std::nullopt; return std::nullopt;

View file

@ -86,6 +86,9 @@ public:
/// Returns a bitmask of the current button states, 1 = on. /// Returns a bitmask of the current button states, 1 = on.
virtual u32 GetButtonStateBits() const; virtual u32 GetButtonStateBits() const;
/// Returns true if the controller supports analog mode, and it is active.
virtual bool InAnalogMode() const;
/// Returns analog input bytes packed as a u32. Values are specific to controller type. /// Returns analog input bytes packed as a u32. Values are specific to controller type.
virtual std::optional<u32> GetAnalogInputBytes() const; virtual std::optional<u32> GetAnalogInputBytes() const;