HidUtils.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Ryujinx.HLE.Input;
  2. using System;
  3. namespace Ryujinx.HLE.HOS.Services.Hid
  4. {
  5. static class HidUtils
  6. {
  7. public static ControllerId GetIndexFromNpadIdType(NpadIdType npadIdType)
  8. {
  9. switch (npadIdType)
  10. {
  11. case NpadIdType.Player1: return ControllerId.ControllerPlayer1;
  12. case NpadIdType.Player2: return ControllerId.ControllerPlayer2;
  13. case NpadIdType.Player3: return ControllerId.ControllerPlayer3;
  14. case NpadIdType.Player4: return ControllerId.ControllerPlayer4;
  15. case NpadIdType.Player5: return ControllerId.ControllerPlayer5;
  16. case NpadIdType.Player6: return ControllerId.ControllerPlayer6;
  17. case NpadIdType.Player7: return ControllerId.ControllerPlayer7;
  18. case NpadIdType.Player8: return ControllerId.ControllerPlayer8;
  19. case NpadIdType.Handheld: return ControllerId.ControllerHandheld;
  20. case NpadIdType.Unknown: return ControllerId.ControllerUnknown;
  21. default: throw new ArgumentOutOfRangeException(nameof(npadIdType));
  22. }
  23. }
  24. public static NpadIdType GetNpadIdTypeFromIndex(ControllerId index)
  25. {
  26. switch (index)
  27. {
  28. case ControllerId.ControllerPlayer1: return NpadIdType.Player1;
  29. case ControllerId.ControllerPlayer2: return NpadIdType.Player2;
  30. case ControllerId.ControllerPlayer3: return NpadIdType.Player3;
  31. case ControllerId.ControllerPlayer4: return NpadIdType.Player4;
  32. case ControllerId.ControllerPlayer5: return NpadIdType.Player5;
  33. case ControllerId.ControllerPlayer6: return NpadIdType.Player6;
  34. case ControllerId.ControllerPlayer7: return NpadIdType.Player7;
  35. case ControllerId.ControllerPlayer8: return NpadIdType.Player8;
  36. case ControllerId.ControllerHandheld: return NpadIdType.Handheld;
  37. case ControllerId.ControllerUnknown: return NpadIdType.Unknown;
  38. default: throw new ArgumentOutOfRangeException(nameof(index));
  39. }
  40. }
  41. }
  42. }