diff options
| author | emmauss <emmausssss@gmail.com> | 2018-11-20 02:01:36 +0200 |
|---|---|---|
| committer | Ac_K <Acoustik666@gmail.com> | 2018-11-20 01:01:36 +0100 |
| commit | dc02ac08caa84456e8b280a3347ac8907b5249ff (patch) | |
| tree | ef71cf05cba18da65c930328f955352f4859e67f /Ryujinx.HLE/Input/HidProController.cs | |
| parent | 0c36835f6de563cd6b4a4c82cac25fbcfb0a6231 (diff) | |
Support other switch controller types (#487)
* Make controllers modular, support changing controller type
* return readable events
* signal hid events
* fix style
Diffstat (limited to 'Ryujinx.HLE/Input/HidProController.cs')
| -rw-r--r-- | Ryujinx.HLE/Input/HidProController.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Ryujinx.HLE/Input/HidProController.cs b/Ryujinx.HLE/Input/HidProController.cs new file mode 100644 index 00000000..40c79fed --- /dev/null +++ b/Ryujinx.HLE/Input/HidProController.cs @@ -0,0 +1,44 @@ +namespace Ryujinx.HLE.Input +{ + public class HidProController : HidControllerBase + { + bool Wired = false; + + public HidProController(Switch Device) : base(HidControllerType.ProController, Device) + { + Wired = true; + } + + public override void Connect(HidControllerId ControllerId) + { + base.Connect(ControllerId); + + HidControllerColorDesc SingleColorDesc = + HidControllerColorDesc.ColorDesc_ColorsNonexistent; + + HidControllerColorDesc SplitColorDesc = 0; + + NpadColor SingleColorBody = NpadColor.Black; + NpadColor SingleColorButtons = NpadColor.Black; + + Device.Memory.WriteInt32(Offset + 0x08, (int)SingleColorDesc); + Device.Memory.WriteInt32(Offset + 0x0c, (int)SingleColorBody); + Device.Memory.WriteInt32(Offset + 0x10, (int)SingleColorButtons); + Device.Memory.WriteInt32(Offset + 0x14, (int)SplitColorDesc); + + Connected = true; + } + + public override void SendInput( + HidControllerButtons Buttons, + HidJoystickPosition LeftStick, + HidJoystickPosition RightStick) + { + long ControllerOffset = WriteInput(Buttons, LeftStick, RightStick, HidControllerLayouts.Pro_Controller); + + Device.Memory.WriteInt64(ControllerOffset + 0x28, + (Connected ? (uint)HidControllerConnState.Controller_State_Connected : 0) | + (Wired ? (uint)HidControllerConnState.Controller_State_Wired : 0)); + } + } +} |
