sixaxis.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2009,2017 Bastien Nocera <hadess@hadess.net>
  7. * Copyright (C) 2011 Antonio Ospite <ospite@studenti.unina.it>
  8. * Copyright (C) 2013 Szymon Janc <szymon.janc@gmail.com>
  9. *
  10. *
  11. */
  12. #ifndef _SIXAXIS_H_
  13. #define _SIXAXIS_H_
  14. typedef enum {
  15. CABLE_PAIRING_UNSUPPORTED = 0,
  16. CABLE_PAIRING_SIXAXIS,
  17. CABLE_PAIRING_DS4,
  18. } CablePairingType;
  19. struct cable_pairing {
  20. const char *name;
  21. uint16_t source;
  22. uint16_t vid;
  23. uint16_t pid;
  24. uint16_t version;
  25. CablePairingType type;
  26. };
  27. static inline const struct cable_pairing *
  28. get_pairing(uint16_t vid, uint16_t pid, const char *name)
  29. {
  30. static const struct cable_pairing devices[] = {
  31. {
  32. .name = "Sony PLAYSTATION(R)3 Controller",
  33. .source = 0x0002,
  34. .vid = 0x054c,
  35. .pid = 0x0268,
  36. .version = 0x0000,
  37. .type = CABLE_PAIRING_SIXAXIS,
  38. },
  39. {
  40. .name = "SHANWAN PS3 GamePad",
  41. .source = 0x0002,
  42. .vid = 0x054c,
  43. .pid = 0x0268,
  44. .version = 0x0000,
  45. .type = CABLE_PAIRING_SIXAXIS,
  46. },
  47. {
  48. .name = "Navigation Controller",
  49. .source = 0x0002,
  50. .vid = 0x054c,
  51. .pid = 0x042f,
  52. .version = 0x0000,
  53. .type = CABLE_PAIRING_SIXAXIS,
  54. },
  55. {
  56. .name = "Wireless Controller",
  57. .source = 0x0002,
  58. .vid = 0x054c,
  59. .pid = 0x05c4,
  60. .version = 0x0001,
  61. .type = CABLE_PAIRING_DS4,
  62. },
  63. {
  64. .name = "Wireless Controller",
  65. .source = 0x0002,
  66. .vid = 0x054c,
  67. .pid = 0x09cc,
  68. .version = 0x0001,
  69. .type = CABLE_PAIRING_DS4,
  70. },
  71. };
  72. guint i;
  73. for (i = 0; i < G_N_ELEMENTS(devices); i++) {
  74. if (devices[i].vid != vid)
  75. continue;
  76. if (devices[i].pid != pid)
  77. continue;
  78. if (name && strcmp(name, devices[i].name))
  79. continue;
  80. return &devices[i];
  81. }
  82. return NULL;
  83. }
  84. #endif /* _SIXAXIS_H_ */