HidProController.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. namespace Ryujinx.HLE.Input
  2. {
  3. public class HidProController : HidControllerBase
  4. {
  5. bool _wired = false;
  6. public HidProController(Switch device) : base(HidControllerType.ProController, device)
  7. {
  8. _wired = true;
  9. }
  10. public override void Connect(HidControllerId controllerId)
  11. {
  12. base.Connect(controllerId);
  13. HidControllerColorDesc singleColorDesc =
  14. HidControllerColorDesc.ColorDescColorsNonexistent;
  15. HidControllerColorDesc splitColorDesc = 0;
  16. NpadColor singleColorBody = NpadColor.Black;
  17. NpadColor singleColorButtons = NpadColor.Black;
  18. Device.Memory.WriteInt32(Offset + 0x08, (int)singleColorDesc);
  19. Device.Memory.WriteInt32(Offset + 0x0c, (int)singleColorBody);
  20. Device.Memory.WriteInt32(Offset + 0x10, (int)singleColorButtons);
  21. Device.Memory.WriteInt32(Offset + 0x14, (int)splitColorDesc);
  22. Connected = true;
  23. }
  24. public override void SendInput(
  25. HidControllerButtons buttons,
  26. HidJoystickPosition leftStick,
  27. HidJoystickPosition rightStick)
  28. {
  29. long controllerOffset = WriteInput(buttons, leftStick, rightStick, HidControllerLayouts.ProController);
  30. Device.Memory.WriteInt64(controllerOffset + 0x28,
  31. (Connected ? (uint)HidControllerConnState.ControllerStateConnected : 0) |
  32. (_wired ? (uint)HidControllerConnState.ControllerStateWired : 0));
  33. controllerOffset = WriteInput(buttons, leftStick, rightStick, HidControllerLayouts.Main);
  34. Device.Memory.WriteInt64(controllerOffset + 0x28,
  35. (Connected ? (uint)HidControllerConnState.ControllerStateWired : 0) |
  36. (uint)HidControllerConnState.ControllerStateWired);
  37. }
  38. }
  39. }