diff options
| author | Thomas Guillemard <thog@protonmail.com> | 2018-10-27 20:36:49 +0200 |
|---|---|---|
| committer | Ac_K <Acoustik666@gmail.com> | 2018-10-27 18:36:49 +0000 |
| commit | 19152def95d3def857159fbf0014dc09b3b9bac0 (patch) | |
| tree | b28c29ad5b1696d900d69b62f23c827f342629f4 | |
| parent | 00d4f44bbb3c7cf768cdd2bf7676b8ea7e6034e2 (diff) | |
hid: Implement KEY_RSTICK_* & KEY_LSTICK_* (#466)
* hid: Implement KEY_RSTICK_* & KEY_LSTICK_*
* Fix KEY_RSTICK_UP
| -rw-r--r-- | Ryujinx.HLE/Hid/Hid.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Ryujinx.HLE/Hid/Hid.cs b/Ryujinx.HLE/Hid/Hid.cs index 0353b3ba..66b38db5 100644 --- a/Ryujinx.HLE/Hid/Hid.cs +++ b/Ryujinx.HLE/Hid/Hid.cs @@ -114,6 +114,55 @@ namespace Ryujinx.HLE.Input Device.Memory.WriteInt32(BaseControllerOffset + 0x24, (int)RightColorButtons); } + private HidControllerButtons UpdateStickButtons( + HidJoystickPosition LeftStick, + HidJoystickPosition RightStick) + { + HidControllerButtons Result = 0; + + if (RightStick.DX < 0) + { + Result |= HidControllerButtons.KEY_RSTICK_LEFT; + } + + if (RightStick.DX > 0) + { + Result |= HidControllerButtons.KEY_RSTICK_RIGHT; + } + + if (RightStick.DY < 0) + { + Result |= HidControllerButtons.KEY_RSTICK_DOWN; + } + + if (RightStick.DY > 0) + { + Result |= HidControllerButtons.KEY_RSTICK_UP; + } + + if (LeftStick.DX < 0) + { + Result |= HidControllerButtons.KEY_LSTICK_LEFT; + } + + if (LeftStick.DX > 0) + { + Result |= HidControllerButtons.KEY_LSTICK_RIGHT; + } + + if (LeftStick.DY < 0) + { + Result |= HidControllerButtons.KEY_LSTICK_DOWN; + } + + if (LeftStick.DY > 0) + { + Result |= HidControllerButtons.KEY_LSTICK_UP; + } + + return Result; + } + public void SetJoyconButton( HidControllerId ControllerId, HidControllerLayouts ControllerLayout, @@ -121,6 +170,8 @@ namespace Ryujinx.HLE.Input HidJoystickPosition LeftStick, HidJoystickPosition RightStick) { + Buttons |= UpdateStickButtons(LeftStick, RightStick); + long ControllerOffset = HidPosition + HidControllersOffset; ControllerOffset += (int)ControllerId * HidControllerSize; |
