Skip to content

Commit

Permalink
Controller: Make InAnalogMode() virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Oct 9, 2022
1 parent 21da503 commit 4feb5ad
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/core/analog_controller.cpp
Expand Up @@ -23,6 +23,11 @@ ControllerType AnalogController::GetType() const
return ControllerType::AnalogController;
}

bool AnalogController::InAnalogMode() const
{
return m_analog_mode;
}

void AnalogController::Reset()
{
m_command = Command::Idle;
Expand Down
2 changes: 1 addition & 1 deletion src/core/analog_controller.h
Expand Up @@ -62,7 +62,7 @@ class AnalogController final : public Controller
static std::unique_ptr<AnalogController> Create(u32 index);

ControllerType GetType() const override;
bool InAnalogMode() const { return m_analog_mode; }
bool InAnalogMode() const override;

void Reset() override;
bool DoState(StateWrapper& sw, bool ignore_input_state) override;
Expand Down
5 changes: 5 additions & 0 deletions src/core/analog_joystick.cpp
Expand Up @@ -20,6 +20,11 @@ ControllerType AnalogJoystick::GetType() const
return ControllerType::AnalogJoystick;
}

bool AnalogJoystick::InAnalogMode() const
{
return m_analog_mode;
}

void AnalogJoystick::Reset()
{
m_transfer_state = TransferState::Idle;
Expand Down
1 change: 1 addition & 0 deletions src/core/analog_joystick.h
Expand Up @@ -60,6 +60,7 @@ class AnalogJoystick final : public Controller
static std::unique_ptr<AnalogJoystick> Create(u32 index);

ControllerType GetType() const override;
bool InAnalogMode() const override;

void Reset() override;
bool DoState(StateWrapper& sw, bool apply_input_state) override;
Expand Down
5 changes: 5 additions & 0 deletions src/core/controller.cpp
Expand Up @@ -53,6 +53,11 @@ u32 Controller::GetButtonStateBits() const
return 0;
}

bool Controller::InAnalogMode() const
{
return false;
}

std::optional<u32> Controller::GetAnalogInputBytes() const
{
return std::nullopt;
Expand Down
3 changes: 3 additions & 0 deletions src/core/controller.h
Expand Up @@ -86,6 +86,9 @@ class Controller
/// Returns a bitmask of the current button states, 1 = on.
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.
virtual std::optional<u32> GetAnalogInputBytes() const;

Expand Down

0 comments on commit 4feb5ad

Please sign in to comment.