From ae7fd01e38a1f187f83fa151cc30f1a9201ddfe7 Mon Sep 17 00:00:00 2001 From: CJBok Date: Thu, 9 Jan 2020 02:40:55 +0100 Subject: hid: Fix analog sticks directional states --- src/core/hle/service/hid/controllers/npad.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 4d952adc0..c3ce74e2b 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -250,6 +250,10 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) { auto& rstick_entry = npad_pad_states[controller_idx].r_stick; const auto& button_state = buttons[controller_idx]; const auto& analog_state = sticks[controller_idx]; + const auto [stick_l_x_f, stick_l_y_f] = + analog_state[static_cast(JoystickId::Joystick_Left)]->GetStatus(); + const auto [stick_r_x_f, stick_r_y_f] = + analog_state[static_cast(JoystickId::Joystick_Right)]->GetStatus(); using namespace Settings::NativeButton; pad_state.a.Assign(button_state[A - BUTTON_HID_BEGIN]->GetStatus()); @@ -270,23 +274,19 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) { pad_state.d_right.Assign(button_state[DRight - BUTTON_HID_BEGIN]->GetStatus()); pad_state.d_down.Assign(button_state[DDown - BUTTON_HID_BEGIN]->GetStatus()); - pad_state.l_stick_left.Assign(button_state[LStick_Left - BUTTON_HID_BEGIN]->GetStatus()); - pad_state.l_stick_up.Assign(button_state[LStick_Up - BUTTON_HID_BEGIN]->GetStatus()); - pad_state.l_stick_right.Assign(button_state[LStick_Right - BUTTON_HID_BEGIN]->GetStatus()); - pad_state.l_stick_down.Assign(button_state[LStick_Down - BUTTON_HID_BEGIN]->GetStatus()); + pad_state.l_stick_left.Assign(stick_l_x_f < 0.0); + pad_state.l_stick_up.Assign(stick_l_y_f > 0.0); + pad_state.l_stick_right.Assign(stick_l_x_f > 0.0); + pad_state.l_stick_down.Assign(stick_l_y_f < 0.0); - pad_state.r_stick_left.Assign(button_state[RStick_Left - BUTTON_HID_BEGIN]->GetStatus()); - pad_state.r_stick_up.Assign(button_state[RStick_Up - BUTTON_HID_BEGIN]->GetStatus()); - pad_state.r_stick_right.Assign(button_state[RStick_Right - BUTTON_HID_BEGIN]->GetStatus()); - pad_state.r_stick_down.Assign(button_state[RStick_Down - BUTTON_HID_BEGIN]->GetStatus()); + pad_state.r_stick_left.Assign(stick_r_x_f < 0.0); + pad_state.r_stick_up.Assign(stick_r_y_f > 0.0); + pad_state.r_stick_right.Assign(stick_r_x_f > 0.0); + pad_state.r_stick_down.Assign(stick_r_y_f < 0.0); pad_state.left_sl.Assign(button_state[SL - BUTTON_HID_BEGIN]->GetStatus()); pad_state.left_sr.Assign(button_state[SR - BUTTON_HID_BEGIN]->GetStatus()); - const auto [stick_l_x_f, stick_l_y_f] = - analog_state[static_cast(JoystickId::Joystick_Left)]->GetStatus(); - const auto [stick_r_x_f, stick_r_y_f] = - analog_state[static_cast(JoystickId::Joystick_Right)]->GetStatus(); lstick_entry.x = static_cast(stick_l_x_f * HID_JOYSTICK_MAX); lstick_entry.y = static_cast(stick_l_y_f * HID_JOYSTICK_MAX); rstick_entry.x = static_cast(stick_r_x_f * HID_JOYSTICK_MAX); -- cgit v1.2.3 From 231d9c10f3eb17ebb36c47f0a91ebb6da78c0e87 Mon Sep 17 00:00:00 2001 From: CJBok Date: Tue, 14 Jan 2020 21:51:58 +0100 Subject: Corrected directional states sensitivity --- src/core/hle/service/hid/controllers/npad.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index c3ce74e2b..12c8350bf 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -274,15 +274,15 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) { pad_state.d_right.Assign(button_state[DRight - BUTTON_HID_BEGIN]->GetStatus()); pad_state.d_down.Assign(button_state[DDown - BUTTON_HID_BEGIN]->GetStatus()); - pad_state.l_stick_left.Assign(stick_l_x_f < 0.0); - pad_state.l_stick_up.Assign(stick_l_y_f > 0.0); - pad_state.l_stick_right.Assign(stick_l_x_f > 0.0); - pad_state.l_stick_down.Assign(stick_l_y_f < 0.0); - - pad_state.r_stick_left.Assign(stick_r_x_f < 0.0); - pad_state.r_stick_up.Assign(stick_r_y_f > 0.0); - pad_state.r_stick_right.Assign(stick_r_x_f > 0.0); - pad_state.r_stick_down.Assign(stick_r_y_f < 0.0); + pad_state.l_stick_right.Assign(stick_l_x_f > 0.3f); + pad_state.l_stick_left.Assign(stick_l_x_f < -0.3f); + pad_state.l_stick_up.Assign(stick_l_y_f > 0.3f); + pad_state.l_stick_down.Assign(stick_l_y_f < -0.3f); + + pad_state.r_stick_right.Assign(stick_r_x_f > 0.3f); + pad_state.r_stick_left.Assign(stick_r_x_f < -0.3f); + pad_state.r_stick_up.Assign(stick_r_y_f > 0.3f); + pad_state.r_stick_down.Assign(stick_r_y_f < -0.3f); pad_state.left_sl.Assign(button_state[SL - BUTTON_HID_BEGIN]->GetStatus()); pad_state.left_sr.Assign(button_state[SR - BUTTON_HID_BEGIN]->GetStatus()); -- cgit v1.2.3 From 635deb70d4c7b09749d9d7edb9515ede496f7f3e Mon Sep 17 00:00:00 2001 From: CJBok Date: Wed, 15 Jan 2020 11:25:15 +0100 Subject: Moved analog direction logic to sdl_impl --- src/core/frontend/input.h | 10 +++++++++ src/core/hle/service/hid/controllers/npad.cpp | 31 +++++++++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) (limited to 'src/core') 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 @@ namespace Input { +enum class AnalogDirection : u8 { + RIGHT, + LEFT, + UP, + DOWN, +}; + /// An abstract class template for an input device (a button, an analog input, etc.). template class InputDevice { @@ -23,6 +30,9 @@ public: virtual StatusType GetStatus() const { return {}; } + virtual bool GetAnalogDirectionStatus(AnalogDirection direction) const { + return {}; + } }; /// 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) { pad_state.d_right.Assign(button_state[DRight - BUTTON_HID_BEGIN]->GetStatus()); pad_state.d_down.Assign(button_state[DDown - BUTTON_HID_BEGIN]->GetStatus()); - pad_state.l_stick_right.Assign(stick_l_x_f > 0.3f); - pad_state.l_stick_left.Assign(stick_l_x_f < -0.3f); - pad_state.l_stick_up.Assign(stick_l_y_f > 0.3f); - pad_state.l_stick_down.Assign(stick_l_y_f < -0.3f); - - pad_state.r_stick_right.Assign(stick_r_x_f > 0.3f); - pad_state.r_stick_left.Assign(stick_r_x_f < -0.3f); - pad_state.r_stick_up.Assign(stick_r_y_f > 0.3f); - pad_state.r_stick_down.Assign(stick_r_y_f < -0.3f); + pad_state.l_stick_right.Assign( + analog_state[static_cast(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus( + Input::AnalogDirection::RIGHT)); + pad_state.l_stick_left.Assign( + analog_state[static_cast(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus( + Input::AnalogDirection::LEFT)); + pad_state.l_stick_up.Assign( + analog_state[static_cast(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus( + Input::AnalogDirection::UP)); + pad_state.l_stick_down.Assign( + analog_state[static_cast(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus( + Input::AnalogDirection::DOWN)); + + pad_state.r_stick_up.Assign(analog_state[static_cast(JoystickId::Joystick_Right)] + ->GetAnalogDirectionStatus(Input::AnalogDirection::RIGHT)); + pad_state.r_stick_left.Assign(analog_state[static_cast(JoystickId::Joystick_Right)] + ->GetAnalogDirectionStatus(Input::AnalogDirection::LEFT)); + pad_state.r_stick_right.Assign( + analog_state[static_cast(JoystickId::Joystick_Right)] + ->GetAnalogDirectionStatus(Input::AnalogDirection::UP)); + pad_state.r_stick_down.Assign(analog_state[static_cast(JoystickId::Joystick_Right)] + ->GetAnalogDirectionStatus(Input::AnalogDirection::DOWN)); pad_state.left_sl.Assign(button_state[SL - BUTTON_HID_BEGIN]->GetStatus()); pad_state.left_sr.Assign(button_state[SR - BUTTON_HID_BEGIN]->GetStatus()); -- cgit v1.2.3