mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 09:12:46 +01:00
Merge pull request #3431 from CJBok/npad-fix
InputCommon: analog_from_button get direction implementation
This commit is contained in:
commit
01a05b48b7
2 changed files with 19 additions and 5 deletions
|
@ -287,12 +287,12 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) {
|
||||||
analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
|
analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
|
||||||
Input::AnalogDirection::DOWN));
|
Input::AnalogDirection::DOWN));
|
||||||
|
|
||||||
pad_state.r_stick_up.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
|
pad_state.r_stick_right.Assign(
|
||||||
|
analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
|
||||||
->GetAnalogDirectionStatus(Input::AnalogDirection::RIGHT));
|
->GetAnalogDirectionStatus(Input::AnalogDirection::RIGHT));
|
||||||
pad_state.r_stick_left.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
|
pad_state.r_stick_left.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
|
||||||
->GetAnalogDirectionStatus(Input::AnalogDirection::LEFT));
|
->GetAnalogDirectionStatus(Input::AnalogDirection::LEFT));
|
||||||
pad_state.r_stick_right.Assign(
|
pad_state.r_stick_up.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
|
||||||
analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
|
|
||||||
->GetAnalogDirectionStatus(Input::AnalogDirection::UP));
|
->GetAnalogDirectionStatus(Input::AnalogDirection::UP));
|
||||||
pad_state.r_stick_down.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
|
pad_state.r_stick_down.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
|
||||||
->GetAnalogDirectionStatus(Input::AnalogDirection::DOWN));
|
->GetAnalogDirectionStatus(Input::AnalogDirection::DOWN));
|
||||||
|
|
|
@ -34,6 +34,20 @@ public:
|
||||||
y * coef * (x == 0 ? 1.0f : SQRT_HALF));
|
y * coef * (x == 0 ? 1.0f : SQRT_HALF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetAnalogDirectionStatus(Input::AnalogDirection direction) const override {
|
||||||
|
switch (direction) {
|
||||||
|
case Input::AnalogDirection::RIGHT:
|
||||||
|
return right->GetStatus();
|
||||||
|
case Input::AnalogDirection::LEFT:
|
||||||
|
return left->GetStatus();
|
||||||
|
case Input::AnalogDirection::UP:
|
||||||
|
return up->GetStatus();
|
||||||
|
case Input::AnalogDirection::DOWN:
|
||||||
|
return down->GetStatus();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Button up;
|
Button up;
|
||||||
Button down;
|
Button down;
|
||||||
|
|
Loading…
Reference in a new issue