diff options
| author | 2020-01-15 11:25:15 +0100 | |
|---|---|---|
| committer | 2020-01-15 11:25:15 +0100 | |
| commit | 635deb70d4c7b09749d9d7edb9515ede496f7f3e (patch) | |
| tree | 05b9fd2d60b606ca01f45fa9739b498235d6296a /src/core | |
| parent | Corrected directional states sensitivity (diff) | |
| download | yuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.tar.gz yuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.tar.xz yuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.zip | |
Moved analog direction logic to sdl_impl
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/frontend/input.h | 10 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 31 |
2 files changed, 32 insertions, 9 deletions
diff --git a/src/core/frontend/input.h b/src/core/frontend/input.h index 7c11d7546..2b098b7c6 100644 --- a/src/core/frontend/input.h +++ b/src/core/frontend/input.h | |||
| @@ -15,6 +15,13 @@ | |||
| 15 | 15 | ||
| 16 | namespace Input { | 16 | namespace Input { |
| 17 | 17 | ||
| 18 | enum class AnalogDirection : u8 { | ||
| 19 | RIGHT, | ||
| 20 | LEFT, | ||
| 21 | UP, | ||
| 22 | DOWN, | ||
| 23 | }; | ||
| 24 | |||
| 18 | /// An abstract class template for an input device (a button, an analog input, etc.). | 25 | /// An abstract class template for an input device (a button, an analog input, etc.). |
| 19 | template <typename StatusType> | 26 | template <typename StatusType> |
| 20 | class InputDevice { | 27 | class InputDevice { |
| @@ -23,6 +30,9 @@ public: | |||
| 23 | virtual StatusType GetStatus() const { | 30 | virtual StatusType GetStatus() const { |
| 24 | return {}; | 31 | return {}; |
| 25 | } | 32 | } |
| 33 | virtual bool GetAnalogDirectionStatus(AnalogDirection direction) const { | ||
| 34 | return {}; | ||
| 35 | } | ||
| 26 | }; | 36 | }; |
| 27 | 37 | ||
| 28 | /// An abstract class template for a factory that can create input devices. | 38 | /// An abstract class template for a factory that can create input devices. |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 12c8350bf..15c09f04c 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -274,15 +274,28 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) { | |||
| 274 | pad_state.d_right.Assign(button_state[DRight - BUTTON_HID_BEGIN]->GetStatus()); | 274 | pad_state.d_right.Assign(button_state[DRight - BUTTON_HID_BEGIN]->GetStatus()); |
| 275 | pad_state.d_down.Assign(button_state[DDown - BUTTON_HID_BEGIN]->GetStatus()); | 275 | pad_state.d_down.Assign(button_state[DDown - BUTTON_HID_BEGIN]->GetStatus()); |
| 276 | 276 | ||
| 277 | pad_state.l_stick_right.Assign(stick_l_x_f > 0.3f); | 277 | pad_state.l_stick_right.Assign( |
| 278 | pad_state.l_stick_left.Assign(stick_l_x_f < -0.3f); | 278 | analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus( |
| 279 | pad_state.l_stick_up.Assign(stick_l_y_f > 0.3f); | 279 | Input::AnalogDirection::RIGHT)); |
| 280 | pad_state.l_stick_down.Assign(stick_l_y_f < -0.3f); | 280 | pad_state.l_stick_left.Assign( |
| 281 | 281 | analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus( | |
| 282 | pad_state.r_stick_right.Assign(stick_r_x_f > 0.3f); | 282 | Input::AnalogDirection::LEFT)); |
| 283 | pad_state.r_stick_left.Assign(stick_r_x_f < -0.3f); | 283 | pad_state.l_stick_up.Assign( |
| 284 | pad_state.r_stick_up.Assign(stick_r_y_f > 0.3f); | 284 | analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus( |
| 285 | pad_state.r_stick_down.Assign(stick_r_y_f < -0.3f); | 285 | Input::AnalogDirection::UP)); |
| 286 | pad_state.l_stick_down.Assign( | ||
| 287 | analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus( | ||
| 288 | Input::AnalogDirection::DOWN)); | ||
| 289 | |||
| 290 | pad_state.r_stick_up.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)] | ||
| 291 | ->GetAnalogDirectionStatus(Input::AnalogDirection::RIGHT)); | ||
| 292 | pad_state.r_stick_left.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)] | ||
| 293 | ->GetAnalogDirectionStatus(Input::AnalogDirection::LEFT)); | ||
| 294 | pad_state.r_stick_right.Assign( | ||
| 295 | analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)] | ||
| 296 | ->GetAnalogDirectionStatus(Input::AnalogDirection::UP)); | ||
| 297 | pad_state.r_stick_down.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)] | ||
| 298 | ->GetAnalogDirectionStatus(Input::AnalogDirection::DOWN)); | ||
| 286 | 299 | ||
| 287 | pad_state.left_sl.Assign(button_state[SL - BUTTON_HID_BEGIN]->GetStatus()); | 300 | pad_state.left_sl.Assign(button_state[SL - BUTTON_HID_BEGIN]->GetStatus()); |
| 288 | pad_state.left_sr.Assign(button_state[SR - BUTTON_HID_BEGIN]->GetStatus()); | 301 | pad_state.left_sr.Assign(button_state[SR - BUTTON_HID_BEGIN]->GetStatus()); |