HidProController.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.ColorDesc_ColorsNonexistent;
  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.Pro_Controller);
  30. Device.Memory.WriteInt64(ControllerOffset + 0x28,
  31. (Connected ? (uint)HidControllerConnState.Controller_State_Connected : 0) |
  32. (Wired ? (uint)HidControllerConnState.Controller_State_Wired : 0));
  33. }
  34. }
  35. }