summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorCJBok <cjbok@ziggo.nl>2020-01-15 11:25:15 +0100
committerCJBok <cjbok@ziggo.nl>2020-01-15 11:25:15 +0100
commit635deb70d4c7b09749d9d7edb9515ede496f7f3e (patch)
tree05b9fd2d60b606ca01f45fa9739b498235d6296a /src/core
parentCorrected directional states sensitivity (diff)
downloadyuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.tar
yuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.tar.gz
yuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.tar.bz2
yuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.tar.lz
yuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.tar.xz
yuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.tar.zst
yuzu-635deb70d4c7b09749d9d7edb9515ede496f7f3e.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/frontend/input.h10
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp31
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 @@
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 <typename StatusType>
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<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
+ Input::AnalogDirection::RIGHT));
+ pad_state.l_stick_left.Assign(
+ analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
+ Input::AnalogDirection::LEFT));
+ pad_state.l_stick_up.Assign(
+ analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
+ Input::AnalogDirection::UP));
+ pad_state.l_stick_down.Assign(
+ analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
+ Input::AnalogDirection::DOWN));
+
+ pad_state.r_stick_up.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
+ ->GetAnalogDirectionStatus(Input::AnalogDirection::RIGHT));
+ pad_state.r_stick_left.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
+ ->GetAnalogDirectionStatus(Input::AnalogDirection::LEFT));
+ pad_state.r_stick_right.Assign(
+ analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
+ ->GetAnalogDirectionStatus(Input::AnalogDirection::UP));
+ pad_state.r_stick_down.Assign(analog_state[static_cast<std::size_t>(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());