testevdev.c 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249
  1. /*
  2. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  3. Copyright (C) 2020-2022 Collabora Ltd.
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely.
  10. */
  11. /* Hack #1: avoid inclusion of SDL_main.h by SDL_internal.h */
  12. #define SDL_main_h_
  13. /* Hack #2: avoid dynapi renaming (must be done before #include <SDL3/SDL.h>) */
  14. #include "../src/dynapi/SDL_dynapi.h"
  15. #ifdef SDL_DYNAMIC_API
  16. #undef SDL_DYNAMIC_API
  17. #endif
  18. #define SDL_DYNAMIC_API 0
  19. #ifndef NO_BUILD_CONFIG
  20. #include "../src/SDL_internal.h"
  21. #endif
  22. /* Hack #3: undo Hack #1 */
  23. #ifdef SDL_main_h_
  24. #undef SDL_main_h_
  25. #endif
  26. #ifdef SDL_MAIN_NOIMPL
  27. #undef SDL_MAIN_NOIMPL
  28. #endif
  29. #include <SDL3/SDL.h>
  30. #include <SDL3/SDL_main.h>
  31. #include <SDL3/SDL_test.h>
  32. #include <stdio.h>
  33. #include <string.h>
  34. static int run_test(void);
  35. /* FIXME: Need CMake tests for this */
  36. #if (defined(HAVE_LIBUDEV_H) || defined(SDL_JOYSTICK_LINUX)) && defined(HAVE_LINUX_INPUT_H)
  37. #include <stdint.h>
  38. #include "../src/core/linux/SDL_evdev_capabilities.h"
  39. #include "../src/core/linux/SDL_evdev_capabilities.c"
  40. static const struct
  41. {
  42. int code;
  43. const char *name;
  44. } device_classes[] = {
  45. #define CLS(x) \
  46. { \
  47. SDL_UDEV_DEVICE_##x, #x \
  48. }
  49. CLS(MOUSE),
  50. CLS(KEYBOARD),
  51. CLS(HAS_KEYS),
  52. CLS(JOYSTICK),
  53. CLS(SOUND),
  54. CLS(TOUCHSCREEN),
  55. CLS(ACCELEROMETER),
  56. CLS(TOUCHPAD),
  57. #undef CLS
  58. { 0, NULL }
  59. };
  60. typedef struct
  61. {
  62. const char *name;
  63. const char *eviocgname;
  64. const char *usb_vendor_name;
  65. const char *usb_product_name;
  66. uint16_t bus_type;
  67. uint16_t vendor_id;
  68. uint16_t product_id;
  69. uint16_t version;
  70. uint16_t usb_device_version;
  71. uint8_t ev[(EV_MAX + 1) / 8];
  72. uint8_t keys[(KEY_MAX + 1) / 8];
  73. uint8_t abs[(ABS_MAX + 1) / 8];
  74. uint8_t rel[(REL_MAX + 1) / 8];
  75. uint8_t ff[(FF_MAX + 1) / 8];
  76. uint8_t props[(INPUT_PROP_MAX + 1) / 8];
  77. int expected;
  78. const char *todo;
  79. size_t hid_report_descriptor_length;
  80. const unsigned char *hid_report_descriptor;
  81. } GuessTest;
  82. /*
  83. * Test-cases for guessing a device type from its capabilities.
  84. *
  85. * The bytes in ev, etc. are in little-endian byte order
  86. * Trailing zeroes can be omitted.
  87. *
  88. * The evemu-describe tool is a convenient way to add a test-case for
  89. * a physically available device. To contribute new test-cases, see:
  90. * https://github.com/libsdl-org/SDL/issues/7801#issuecomment-1589114910
  91. */
  92. #define ZEROx4 0, 0, 0, 0
  93. #define ZEROx8 ZEROx4, ZEROx4
  94. #define FFx4 0xff, 0xff, 0xff, 0xff
  95. #define FFx8 FFx4, FFx4
  96. static unsigned char xbox_one_elite_2_hid_report_descriptor[] =
  97. {
  98. /* Generic Desktop / Game Pad, Generic Desktop / Keyboard */
  99. 0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01,
  100. 0x09, 0x01, 0xa1, 0x00, 0x09, 0x30, 0x09, 0x31,
  101. 0x15, 0x00, 0x27, 0xff, 0xff, 0x00, 0x00, 0x95,
  102. 0x02, 0x75, 0x10, 0x81, 0x02, 0xc0, 0x09, 0x01,
  103. 0xa1, 0x00, 0x09, 0x32, 0x09, 0x35, 0x15, 0x00,
  104. 0x27, 0xff, 0xff, 0x00, 0x00, 0x95, 0x02, 0x75,
  105. 0x10, 0x81, 0x02, 0xc0, 0x05, 0x02, 0x09, 0xc5,
  106. 0x15, 0x00, 0x26, 0xff, 0x03, 0x95, 0x01, 0x75,
  107. 0x0a, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00, 0x75,
  108. 0x06, 0x95, 0x01, 0x81, 0x03, 0x05, 0x02, 0x09,
  109. 0xc4, 0x15, 0x00, 0x26, 0xff, 0x03, 0x95, 0x01,
  110. 0x75, 0x0a, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00,
  111. 0x75, 0x06, 0x95, 0x01, 0x81, 0x03, 0x05, 0x01,
  112. 0x09, 0x39, 0x15, 0x01, 0x25, 0x08, 0x35, 0x00,
  113. 0x46, 0x3b, 0x01, 0x66, 0x14, 0x00, 0x75, 0x04,
  114. 0x95, 0x01, 0x81, 0x42, 0x75, 0x04, 0x95, 0x01,
  115. 0x15, 0x00, 0x25, 0x00, 0x35, 0x00, 0x45, 0x00,
  116. 0x65, 0x00, 0x81, 0x03, 0x05, 0x09, 0x19, 0x01,
  117. 0x29, 0x0f, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01,
  118. 0x95, 0x0f, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00,
  119. 0x75, 0x01, 0x95, 0x01, 0x81, 0x03, 0x05, 0x0c,
  120. 0x0a, 0xb2, 0x00, 0x15, 0x00, 0x25, 0x01, 0x95,
  121. 0x01, 0x75, 0x01, 0x81, 0x02, 0x15, 0x00, 0x25,
  122. 0x00, 0x75, 0x07, 0x95, 0x01, 0x81, 0x03, 0x05,
  123. 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x0a, 0x85, 0x00,
  124. 0x15, 0x00, 0x26, 0xff, 0x00, 0x95, 0x01, 0x75,
  125. 0x08, 0x81, 0x02, 0x0a, 0x99, 0x00, 0x15, 0x00,
  126. 0x26, 0xff, 0x00, 0x95, 0x01, 0x75, 0x04, 0x81,
  127. 0x02, 0x15, 0x00, 0x25, 0x00, 0x95, 0x01, 0x75,
  128. 0x04, 0x81, 0x03, 0x0a, 0x81, 0x00, 0x15, 0x00,
  129. 0x26, 0xff, 0x00, 0x95, 0x01, 0x75, 0x04, 0x81,
  130. 0x02, 0x15, 0x00, 0x25, 0x00, 0x95, 0x01, 0x75,
  131. 0x04, 0x81, 0x03, 0xc0, 0x05, 0x0f, 0x09, 0x21,
  132. 0x85, 0x03, 0xa1, 0x02, 0x09, 0x97, 0x15, 0x00,
  133. 0x25, 0x01, 0x75, 0x04, 0x95, 0x01, 0x91, 0x02,
  134. 0x15, 0x00, 0x25, 0x00, 0x75, 0x04, 0x95, 0x01,
  135. 0x91, 0x03, 0x09, 0x70, 0x15, 0x00, 0x25, 0x64,
  136. 0x75, 0x08, 0x95, 0x04, 0x91, 0x02, 0x09, 0x50,
  137. 0x66, 0x01, 0x10, 0x55, 0x0e, 0x15, 0x00, 0x26,
  138. 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x91, 0x02,
  139. 0x09, 0xa7, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
  140. 0x08, 0x95, 0x01, 0x91, 0x02, 0x65, 0x00, 0x55,
  141. 0x00, 0x09, 0x7c, 0x15, 0x00, 0x26, 0xff, 0x00,
  142. 0x75, 0x08, 0x95, 0x01, 0x91, 0x02, 0xc0, 0x05,
  143. 0x0c, 0x09, 0x01, 0x85, 0x0c, 0xa1, 0x01, 0x0a,
  144. 0x9e, 0x00, 0x15, 0x00, 0x26, 0xff, 0x00, 0x95,
  145. 0x01, 0x75, 0x08, 0x81, 0x02, 0x0a, 0xa1, 0x00,
  146. 0x15, 0x00, 0x26, 0xff, 0x00, 0x95, 0x01, 0x75,
  147. 0x08, 0x81, 0x02, 0x0a, 0xa2, 0x00, 0x15, 0x00,
  148. 0x26, 0xff, 0x00, 0x95, 0x01, 0x75, 0x08, 0x81,
  149. 0x02, 0x0a, 0xa3, 0x00, 0x15, 0x00, 0x26, 0xff,
  150. 0x00, 0x95, 0x01, 0x75, 0x08, 0x81, 0x02, 0xc0,
  151. 0xc0, 0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x85,
  152. 0x05, 0x05, 0x07, 0x19, 0xe0, 0x29, 0xe7, 0x15,
  153. 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81,
  154. 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x03, 0x95,
  155. 0x06, 0x75, 0x08, 0x15, 0x00, 0x25, 0x65, 0x05,
  156. 0x07, 0x19, 0x00, 0x29, 0x65, 0x81, 0x00, 0xc0,
  157. };
  158. SDL_COMPILE_TIME_ASSERT (xbox_one_elite_2, sizeof (xbox_one_elite_2_hid_report_descriptor) == 0720);
  159. static unsigned char ps3_hid_report_descriptor[] =
  160. {
  161. /* Generic Desktop / Joystick */
  162. 0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0xa1, 0x02,
  163. 0x85, 0x01, 0x75, 0x08, 0x95, 0x01, 0x15, 0x00,
  164. 0x26, 0xff, 0x00, 0x81, 0x03, 0x75, 0x01, 0x95,
  165. 0x13, 0x15, 0x00, 0x25, 0x01, 0x35, 0x00, 0x45,
  166. 0x01, 0x05, 0x09, 0x19, 0x01, 0x29, 0x13, 0x81,
  167. 0x02, 0x75, 0x01, 0x95, 0x0d, 0x06, 0x00, 0xff,
  168. 0x81, 0x03, 0x15, 0x00, 0x26, 0xff, 0x00, 0x05,
  169. 0x01, 0x09, 0x01, 0xa1, 0x00, 0x75, 0x08, 0x95,
  170. 0x04, 0x35, 0x00, 0x46, 0xff, 0x00, 0x09, 0x30,
  171. 0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x81, 0x02,
  172. 0xc0, 0x05, 0x01, 0x75, 0x08, 0x95, 0x27, 0x09,
  173. 0x01, 0x81, 0x02, 0x75, 0x08, 0x95, 0x30, 0x09,
  174. 0x01, 0x91, 0x02, 0x75, 0x08, 0x95, 0x30, 0x09,
  175. 0x01, 0xb1, 0x02, 0xc0, 0xa1, 0x02, 0x85, 0x02,
  176. 0x75, 0x08, 0x95, 0x30, 0x09, 0x01, 0xb1, 0x02,
  177. 0xc0, 0xa1, 0x02, 0x85, 0xee, 0x75, 0x08, 0x95,
  178. 0x30, 0x09, 0x01, 0xb1, 0x02, 0xc0, 0xa1, 0x02,
  179. 0x85, 0xef, 0x75, 0x08, 0x95, 0x30, 0x09, 0x01,
  180. 0xb1, 0x02, 0xc0, 0xc0, 0x00,
  181. };
  182. SDL_COMPILE_TIME_ASSERT (ps3, sizeof (ps3_hid_report_descriptor) == 149);
  183. /* Same for Steam Deck LCD (jupiter) and OLED (galileo) */
  184. static unsigned char steam_deck_mouse_hid_report_descriptor[] =
  185. {
  186. 0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01,
  187. 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x02,
  188. 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x02,
  189. 0x81, 0x02, 0x75, 0x06, 0x95, 0x01, 0x81, 0x01,
  190. 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81,
  191. 0x25, 0x7f, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06,
  192. 0x95, 0x01, 0x09, 0x38, 0x81, 0x06, 0x05, 0x0c,
  193. 0x0a, 0x38, 0x02, 0x95, 0x01, 0x81, 0x06, 0xc0,
  194. 0xc0,
  195. };
  196. SDL_COMPILE_TIME_ASSERT (steam_deck_mouse,
  197. sizeof (steam_deck_mouse_hid_report_descriptor) == 65);
  198. /* Same for Steam Deck LCD (jupiter) and OLED (galileo) */
  199. static unsigned char steam_deck_kb_hid_report_descriptor[] =
  200. {
  201. 0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07,
  202. 0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01,
  203. 0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0x81, 0x01,
  204. 0x19, 0x00, 0x29, 0x65, 0x15, 0x00, 0x25, 0x65,
  205. 0x75, 0x08, 0x95, 0x06, 0x81, 0x00, 0xc0,
  206. };
  207. SDL_COMPILE_TIME_ASSERT (steam_deck_oled_kb,
  208. sizeof (steam_deck_kb_hid_report_descriptor) == 39);
  209. static unsigned char steam_deck_lcd_js_hid_report_descriptor[] =
  210. {
  211. 0x06, 0xff, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x15,
  212. 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x40,
  213. 0x09, 0x01, 0x81, 0x02, 0x09, 0x01, 0xb1, 0x02,
  214. 0xc0,
  215. };
  216. SDL_COMPILE_TIME_ASSERT (steam_deck_lcd_js,
  217. sizeof (steam_deck_lcd_js_hid_report_descriptor) == 25);
  218. static unsigned char steam_deck_oled_js_hid_report_descriptor[] =
  219. {
  220. 0x06, 0xff, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x09,
  221. 0x02, 0x09, 0x03, 0x15, 0x00, 0x26, 0xff, 0x00,
  222. 0x75, 0x08, 0x95, 0x40, 0x81, 0x02, 0x09, 0x06,
  223. 0x09, 0x07, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
  224. 0x08, 0x95, 0x40, 0xb1, 0x02, 0xc0,
  225. };
  226. SDL_COMPILE_TIME_ASSERT (steam_deck_oled_js,
  227. sizeof (steam_deck_oled_js_hid_report_descriptor) == 38);
  228. static unsigned char vrs_pedals_hid_report_descriptor[] =
  229. {
  230. /* Generic Desktop / Joystick */
  231. 0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x05, 0x01,
  232. 0xa1, 0x02, 0x85, 0x01, 0x09, 0x30, 0x09, 0x31,
  233. 0x09, 0x32, 0x15, 0x00, 0x27, 0xff, 0xff, 0x00,
  234. 0x00, 0x35, 0x00, 0x47, 0xff, 0xff, 0x00, 0x00,
  235. 0x75, 0x10, 0x95, 0x03, 0x81, 0x02, 0x06, 0x00,
  236. 0xff, 0x09, 0x01, 0x95, 0x39, 0x75, 0x08, 0x26,
  237. 0xff, 0x00, 0x15, 0x00, 0x81, 0x02, 0xc0, 0x06,
  238. 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x64,
  239. 0x95, 0x3f, 0x75, 0x08, 0x26, 0xff, 0x00, 0x15,
  240. 0x00, 0x09, 0x01, 0x91, 0x02, 0x85, 0x65, 0x95,
  241. 0x3f, 0x75, 0x08, 0x26, 0xff, 0x00, 0x15, 0x00,
  242. 0x09, 0x01, 0x81, 0x02, 0xc0, 0xc0,
  243. };
  244. SDL_COMPILE_TIME_ASSERT (vrs_pedals, sizeof (vrs_pedals_hid_report_descriptor) == 0136);
  245. static unsigned char thinkpad_usb_keyboard_hid_report_descriptor[] =
  246. {
  247. /* Generic Desktop / Keyboard */
  248. 0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07,
  249. 0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01,
  250. 0x95, 0x08, 0x75, 0x01, 0x81, 0x02, 0x95, 0x08,
  251. 0x75, 0x01, 0x81, 0x01, 0x05, 0x08, 0x19, 0x01,
  252. 0x29, 0x03, 0x95, 0x03, 0x75, 0x01, 0x91, 0x02,
  253. 0x95, 0x01, 0x75, 0x05, 0x91, 0x01, 0x05, 0x07,
  254. 0x19, 0x00, 0x2a, 0xff, 0x00, 0x15, 0x00, 0x26,
  255. 0xff, 0x00, 0x95, 0x06, 0x75, 0x08, 0x81, 0x00,
  256. 0xc0,
  257. };
  258. SDL_COMPILE_TIME_ASSERT (thinkpad_usb_keyboard, sizeof (thinkpad_usb_keyboard_hid_report_descriptor) == 65);
  259. static unsigned char thinkpad_usb_trackpoint_hid_report_descriptor[] =
  260. {
  261. /* Generic Desktop / Mouse, Generic Desktop / System Control,
  262. * Consumer Devices / Consumer Control */
  263. 0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x01,
  264. 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01,
  265. 0x29, 0x03, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03,
  266. 0x75, 0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05,
  267. 0x81, 0x01, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
  268. 0x15, 0x81, 0x25, 0x7f, 0x95, 0x02, 0x75, 0x08,
  269. 0x81, 0x06, 0xc0, 0xc0, 0x05, 0x01, 0x09, 0x80,
  270. 0xa1, 0x01, 0x85, 0x02, 0x05, 0x01, 0x15, 0x00,
  271. 0x25, 0x01, 0x95, 0x08, 0x75, 0x01, 0x19, 0x81,
  272. 0x29, 0x88, 0x81, 0x02, 0xc0, 0x05, 0x0c, 0x09,
  273. 0x01, 0xa1, 0x01, 0x85, 0x03, 0x95, 0x08, 0x75,
  274. 0x01, 0x15, 0x00, 0x25, 0x01, 0x09, 0xe9, 0x09,
  275. 0xea, 0x09, 0xe2, 0x09, 0xb7, 0x09, 0xcd, 0x09,
  276. 0xb5, 0x09, 0xb6, 0x0a, 0x94, 0x01, 0x81, 0x02,
  277. 0x09, 0x03, 0xa1, 0x02, 0x05, 0x09, 0x19, 0x10,
  278. 0x29, 0x17, 0x81, 0x02, 0x05, 0x09, 0x19, 0x18,
  279. 0x29, 0x1f, 0x81, 0x02, 0xc0, 0x05, 0x08, 0x95,
  280. 0x02, 0x09, 0x09, 0x09, 0x21, 0x91, 0x02, 0x95,
  281. 0x01, 0x75, 0x06, 0x91, 0x03, 0xc0, 0x06, 0x01,
  282. 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x04, 0x95,
  283. 0x01, 0x75, 0x08, 0x15, 0x00, 0x26, 0xff, 0x00,
  284. 0x09, 0x20, 0xb1, 0x03, 0x09, 0x21, 0xb1, 0x03,
  285. 0x09, 0x22, 0xb1, 0x03, 0x09, 0x23, 0xb1, 0x03,
  286. 0xc0,
  287. };
  288. SDL_COMPILE_TIME_ASSERT (thinkpad_usb_trackpoint, sizeof (thinkpad_usb_trackpoint_hid_report_descriptor) == 185);
  289. static unsigned char heusinkveld_pedals_hid_report_descriptor[] =
  290. {
  291. /* Generic Desktop / Joystick */
  292. 0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x09, 0x33,
  293. 0x09, 0x34, 0x09, 0x35, 0x15, 0x00, 0x26, 0xff,
  294. 0x0f, 0x85, 0x01, 0x75, 0x10, 0x95, 0x03, 0x81,
  295. 0x02, 0x09, 0x00, 0x75, 0x10, 0x95, 0x06, 0x82,
  296. 0x01, 0x01, 0x85, 0x02, 0x75, 0x10, 0x95, 0x03,
  297. 0x09, 0x00, 0x09, 0x00, 0xb1, 0x02, 0x85, 0x03,
  298. 0x75, 0x08, 0x95, 0x03, 0x09, 0x00, 0x82, 0x01,
  299. 0x01, 0xc0,
  300. };
  301. SDL_COMPILE_TIME_ASSERT (heusinkveld_pedals, sizeof (heusinkveld_pedals_hid_report_descriptor) == 072);
  302. static unsigned char fanatec_handbrake_hid_report_descriptor[] =
  303. {
  304. /* Generic Desktop / Joystick */
  305. 0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x15, 0x00,
  306. 0x26, 0xff, 0x00, 0x95, 0x01, 0x75, 0x08, 0x09,
  307. 0x30, 0x81, 0x02, 0x06, 0x00, 0xff, 0x09, 0x01,
  308. 0x95, 0x03, 0x81, 0x02, 0x06, 0x00, 0xff, 0x09,
  309. 0x01, 0x95, 0x02, 0x91, 0x02, 0xc0,
  310. };
  311. SDL_COMPILE_TIME_ASSERT (fanatec_handbrake, sizeof (fanatec_handbrake_hid_report_descriptor) == 046);
  312. static unsigned char xpadneo09_xb1s_hid_report_descriptor[] =
  313. {
  314. 0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01,
  315. 0x09, 0x01, 0xa1, 0x00, 0x09, 0x30, 0x09, 0x31,
  316. 0x15, 0x00, 0x27, 0xff, 0xff, 0x00, 0x00, 0x95,
  317. 0x02, 0x75, 0x10, 0x81, 0x02, 0xc0, 0x09, 0x01,
  318. 0xa1, 0x00, 0x09, 0x33, 0x09, 0x34, 0x15, 0x00,
  319. 0x27, 0xff, 0xff, 0x00, 0x00, 0x95, 0x02, 0x75,
  320. 0x10, 0x81, 0x02, 0xc0, 0x05, 0x01, 0x09, 0x32,
  321. 0x15, 0x00, 0x26, 0xff, 0x03, 0x95, 0x01, 0x75,
  322. 0x0a, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00, 0x75,
  323. 0x06, 0x95, 0x01, 0x81, 0x03, 0x05, 0x01, 0x09,
  324. 0x35, 0x15, 0x00, 0x26, 0xff, 0x03, 0x95, 0x01,
  325. 0x75, 0x0a, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00,
  326. 0x75, 0x06, 0x95, 0x01, 0x81, 0x03, 0x05, 0x01,
  327. 0x09, 0x39, 0x15, 0x01, 0x25, 0x08, 0x35, 0x00,
  328. 0x46, 0x3b, 0x01, 0x66, 0x14, 0x00, 0x75, 0x04,
  329. 0x95, 0x01, 0x81, 0x42, 0x75, 0x04, 0x95, 0x01,
  330. 0x15, 0x00, 0x25, 0x00, 0x35, 0x00, 0x45, 0x00,
  331. 0x65, 0x00, 0x81, 0x03, 0x05, 0x09, 0x19, 0x01,
  332. 0x29, 0x0c, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01,
  333. 0x95, 0x0c, 0x81, 0x02, 0x15, 0x00, 0x25, 0x00,
  334. 0x75, 0x01, 0x95, 0x04, 0x81, 0x03, 0x05, 0x0c,
  335. 0x0a, 0xb2, 0x00, 0x15, 0x00, 0x25, 0x01, 0x95,
  336. 0x01, 0x75, 0x01, 0x81, 0x02, 0x15, 0x00, 0x25,
  337. 0x00, 0x75, 0x07, 0x95, 0x01, 0x81, 0x03, 0x05,
  338. 0x0f, 0x09, 0x21, 0x85, 0x03, 0xa1, 0x02, 0x09,
  339. 0x97, 0x15, 0x00, 0x25, 0x01, 0x75, 0x04, 0x95,
  340. 0x01, 0x91, 0x02, 0x15, 0x00, 0x25, 0x00, 0x75,
  341. 0x04, 0x95, 0x01, 0x91, 0x03, 0x09, 0x70, 0x15,
  342. 0x00, 0x25, 0x64, 0x75, 0x08, 0x95, 0x04, 0x91,
  343. 0x02, 0x09, 0x50, 0x66, 0x01, 0x10, 0x55, 0x0e,
  344. 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95,
  345. 0x01, 0x91, 0x02, 0x09, 0xa7, 0x15, 0x00, 0x26,
  346. 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x91, 0x02,
  347. 0x65, 0x00, 0x55, 0x00, 0x09, 0x7c, 0x15, 0x00,
  348. 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x91,
  349. 0x02, 0xc0, 0xc0,
  350. };
  351. SDL_COMPILE_TIME_ASSERT (xpadneo09_xb1s, sizeof (xpadneo09_xb1s_hid_report_descriptor) == 283);
  352. /* Test-cases derived from real devices or from Linux kernel source */
  353. /* *INDENT-OFF* */ /* clang-format off */
  354. static const GuessTest guess_tests[] =
  355. {
  356. {
  357. .name = "Xbox 360 wired USB controller",
  358. .eviocgname = "Microsoft X-Box 360 pad",
  359. .usb_vendor_name = "©Microsoft Corporation",
  360. .usb_product_name = "Controller",
  361. /* 8BitDo N30 Pro 2 v0114 via USB-C (with the xpad driver) is
  362. * reported as 0003:045e:028e v0114, and is functionally equivalent */
  363. .bus_type = 0x0003,
  364. .vendor_id = 0x045e,
  365. .product_id = 0x028e,
  366. .version = 0x0114,
  367. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  368. /* SYN, KEY, ABS, FF */
  369. .ev = { 0x0b, 0x00, 0x20 },
  370. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  371. .abs = { 0x3f, 0x00, 0x03 },
  372. .keys = {
  373. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  374. /* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  375. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  376. },
  377. },
  378. {
  379. .name = "X-Box One Elite",
  380. .bus_type = 0x0003,
  381. .vendor_id = 0x045e,
  382. .product_id = 0x02e3,
  383. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  384. /* SYN, KEY, ABS */
  385. .ev = { 0x0b },
  386. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  387. .abs = { 0x3f, 0x00, 0x03 },
  388. .keys = {
  389. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  390. /* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  391. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  392. },
  393. },
  394. { /* Reference: https://github.com/libsdl-org/SDL/issues/7814 */
  395. .name = "X-Box One Elite 2 via USB",
  396. /* The same physical device via Bluetooth, 0005:045e:0b22 v0517,
  397. * is reported differently (below). */
  398. /* Version 0407 is functionally equivalent. */
  399. .bus_type = 0x0003,
  400. .vendor_id = 0x045e,
  401. .product_id = 0x0b00,
  402. .version = 0x0511,
  403. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  404. /* SYN, KEY, ABS, FF */
  405. .ev = { 0x0b, 0x00, 0x20 },
  406. /* XY (left stick), RX/RY (right stick), Z/RZ (triggers), HAT0 (dpad) */
  407. .abs = { 0x3f, 0x00, 0x03 },
  408. .keys = {
  409. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  410. /* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  411. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  412. /* 0x140 */ ZEROx8,
  413. /* 0x180 */ ZEROx8,
  414. /* 0x1c0 */ ZEROx8,
  415. /* 0x200 */ ZEROx8,
  416. /* 0x240 */ ZEROx8,
  417. /* 0x280 */ ZEROx8,
  418. /* BTN_TRIGGER_HAPPY5 up to BTN_TRIGGER_HAPPY8 inclusive are the
  419. * back buttons (paddles) */
  420. /* 0x2c0 */ 0xf0,
  421. },
  422. },
  423. { /* Reference: https://github.com/libsdl-org/SDL/issues/7814 */
  424. .name = "X-Box One Elite 2 via Bluetooth",
  425. /* The same physical device via USB, 0003:045e:0b00 v0511,
  426. * is reported differently (above). */
  427. .bus_type = 0x0003,
  428. .vendor_id = 0x045e,
  429. .product_id = 0x0b22,
  430. .version = 0x0517,
  431. .expected = SDL_UDEV_DEVICE_JOYSTICK | SDL_UDEV_DEVICE_HAS_KEYS,
  432. /* SYN, KEY, ABS, FF */
  433. .ev = { 0x0b, 0x00, 0x20 },
  434. /* Android-style mapping:
  435. * XY (left stick), Z/RZ (right stick), GAS/BRAKE (triggers), HAT0 (dpad) */
  436. .abs = { 0x27, 0x06, 0x03 },
  437. .keys = {
  438. /* 0x00 */ ZEROx8,
  439. /* 0x40 */ ZEROx8,
  440. /* KEY_RECORD is advertised but isn't generated in practice */
  441. /* 0x80 */ ZEROx4, 0x80, 0x00, 0x00, 0x00,
  442. /* KEY_UNKNOWN (240) is reported for the profile selector and all
  443. * four back buttons (paddles) */
  444. /* 0xc0 */ ZEROx4, 0x00, 0x00, 0x01, 0x00,
  445. /* ABXY, TL, TR, TL2, TR2, SELECT, START, MODE, THUMBL,
  446. * THUMBR have their obvious meanings; C and Z are also
  447. * advertised, but are not generated in practice. */
  448. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x7f,
  449. },
  450. .hid_report_descriptor_length = sizeof (xbox_one_elite_2_hid_report_descriptor),
  451. .hid_report_descriptor = &xbox_one_elite_2_hid_report_descriptor[0],
  452. },
  453. {
  454. .name = "X-Box One S via Bluetooth",
  455. .bus_type = 0x0005,
  456. .vendor_id = 0x045e,
  457. .product_id = 0x02e0,
  458. .version = 0x1130,
  459. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  460. /* SYN, KEY, ABS */
  461. .ev = { 0x0b },
  462. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  463. .abs = { 0x3f, 0x00, 0x03 },
  464. .keys = {
  465. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  466. /* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  467. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  468. },
  469. },
  470. {
  471. .name = "X-Box One S wired",
  472. .bus_type = 0x0003,
  473. .vendor_id = 0x045e,
  474. .product_id = 0x02ea,
  475. .version = 0x0301,
  476. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  477. /* SYN, KEY, ABS */
  478. .ev = { 0x0b },
  479. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  480. .abs = { 0x3f, 0x00, 0x03 },
  481. .keys = {
  482. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  483. /* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  484. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  485. },
  486. },
  487. {
  488. .name = "X-Box One S via xpadneo 0.9.x",
  489. /* Reference: https://github.com/libsdl-org/SDL/issues/7823 */
  490. .eviocgname = "Xbox Wireless Controller",
  491. .bus_type = 0x0005,
  492. .vendor_id = 0x045e,
  493. .product_id = 0x028e,
  494. .version = 0x1130,
  495. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  496. /* SYN, KEY, ABS, MSC, FF */
  497. .ev = { 0x1b },
  498. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y
  499. * plus MISC as a deprecated axis reporting (rz - z) */
  500. .abs = { 0x3f, 0x00, 0x03, 0x00, 0x00, 0x01 },
  501. .keys = {
  502. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  503. /* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  504. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  505. /* 0x140 */ ZEROx8,
  506. /* 0x180 */ ZEROx8,
  507. /* 0x1c0 */ ZEROx8,
  508. /* 0x200 */ ZEROx8,
  509. /* 0x240 */ ZEROx8,
  510. /* 0x280 */ ZEROx8,
  511. /* BTN_TRIGGER_HAPPY33 up to BTN_TRIGGER_HAPPY36 inclusive:
  512. * used to represent the current profile */
  513. /* 0x2c0 */ ZEROx4, 0xf0,
  514. },
  515. .hid_report_descriptor_length = sizeof (xpadneo09_xb1s_hid_report_descriptor),
  516. .hid_report_descriptor = &xpadneo09_xb1s_hid_report_descriptor[0],
  517. },
  518. {
  519. .name = "DualSense (PS5) - gamepad",
  520. .bus_type = 0x0003,
  521. .vendor_id = 0x054c,
  522. .product_id = 0x0ce6,
  523. .version = 0x111,
  524. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  525. /* SYN, KEY, ABS */
  526. .ev = { 0x0b },
  527. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  528. .abs = { 0x3f, 0x00, 0x03 },
  529. .keys = {
  530. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  531. /* ABC, XYZ, TL, TR, TL2, TR2, select, start, mode, thumbl,
  532. * thumbr; note that C and Z don't physically exist */
  533. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x7f,
  534. },
  535. },
  536. {
  537. .name = "DualSense (PS5) v8111 - gamepad",
  538. .eviocgname = "Sony Interactive Entertainment Wireless Controller",
  539. .usb_vendor_name = "Sony Interactive Entertainment",
  540. .usb_product_name = "Wireless Controller",
  541. /* Same physical device via Bluetooth is 0005:054c:0ce6 v8100
  542. * and EVIOCGNAME is just "Wireless Controller", otherwise equivalent */
  543. .bus_type = 0x0003,
  544. .vendor_id = 0x054c,
  545. .product_id = 0x0ce6,
  546. .version = 0x8111,
  547. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  548. /* SYN, KEY, ABS */
  549. .ev = { 0x0b },
  550. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  551. .abs = { 0x3f, 0x00, 0x03 },
  552. .keys = {
  553. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  554. /* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE,
  555. * THUMBL, THUMBR */
  556. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f,
  557. },
  558. },
  559. {
  560. .name = "DualShock 4 - gamepad",
  561. /* EVIOCGNAME is just "Wireless Controller" when seen via Bluetooth */
  562. .eviocgname = "Sony Interactive Entertainment Wireless Controller",
  563. .usb_vendor_name = "Sony Interactive Entertainment",
  564. .usb_product_name = "Wireless Controller",
  565. /* Same physical device via Bluetooth is 0005:054c:09cc v8100,
  566. * but otherwise equivalent */
  567. .bus_type = 0x0003,
  568. .vendor_id = 0x054c,
  569. .product_id = 0x09cc,
  570. .version = 0x8111,
  571. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  572. /* SYN, KEY, ABS, MSC, FF */
  573. /* Some versions only have 0x0b, SYN, KEY, ABS, like the
  574. * Bluetooth example below */
  575. .ev = { 0x1b, 0x00, 0x20 },
  576. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  577. .abs = { 0x3f, 0x00, 0x03 },
  578. .keys = {
  579. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  580. /* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE,
  581. * THUMBL, THUMBR */
  582. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f,
  583. },
  584. },
  585. {
  586. .name = "DualShock 4 - gamepad via Bluetooth (unknown version)",
  587. .bus_type = 0x0005,
  588. .vendor_id = 0x054c,
  589. .product_id = 0x09cc,
  590. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  591. /* SYN, KEY, ABS */
  592. .ev = { 0x0b },
  593. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  594. .abs = { 0x3f, 0x00, 0x03 },
  595. .keys = {
  596. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  597. /* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE,
  598. * THUMBL, THUMBR */
  599. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f,
  600. },
  601. },
  602. {
  603. .name = "DualShock 4 - touchpad",
  604. /* EVIOCGNAME is just "Wireless Controller Touchpad" when seen via Bluetooth */
  605. .eviocgname = "Sony Interactive Entertainment Wireless Controller Touchpad",
  606. .usb_vendor_name = "Sony Interactive Entertainment",
  607. .usb_product_name = "Wireless Controller",
  608. /* Same physical device via Bluetooth is 0005:054c:09cc v8100 and is
  609. * functionally equivalent. */
  610. /* DualSense (PS5), 0003:054c:0ce6 v8111, is functionally equivalent.
  611. * Same physical device via Bluetooth is 0005:054c:0ce6 v8100 and also
  612. * functionally equivalent. */
  613. .bus_type = 0x0003,
  614. .vendor_id = 0x054c,
  615. .product_id = 0x09cc,
  616. .version = 0x8111,
  617. .expected = SDL_UDEV_DEVICE_TOUCHPAD,
  618. /* SYN, KEY, ABS */
  619. .ev = { 0x0b },
  620. /* X, Y, multitouch */
  621. .abs = { 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x02 },
  622. .keys = {
  623. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  624. /* Left mouse button */
  625. /* 0x100 */ 0x00, 0x00, 0x01, 0x00, ZEROx4,
  626. /* BTN_TOOL_FINGER and some multitouch stuff */
  627. /* 0x140 */ 0x20, 0x24, 0x00, 0x00
  628. },
  629. /* POINTER, BUTTONPAD */
  630. .props = { 0x05 },
  631. },
  632. {
  633. .name = "DualShock 4 - accelerometer",
  634. /* EVIOCGNAME is just "Wireless Controller Motion Sensors" when seen via Bluetooth */
  635. .eviocgname = "Sony Interactive Entertainment Wireless Controller Motion Sensors",
  636. .usb_vendor_name = "Sony Interactive Entertainment",
  637. .usb_product_name = "Wireless Controller",
  638. /* Same physical device via Bluetooth is 0005:054c:09cc v8100 and is
  639. * functionally equivalent. */
  640. /* DualSense (PS5), 0003:054c:0ce6 v8111, is functionally equivalent.
  641. * Same physical device via Bluetooth is 0005:054c:0ce6 v8100 and also
  642. * functionally equivalent. */
  643. .bus_type = 0x0003,
  644. .vendor_id = 0x054c,
  645. .product_id = 0x09cc,
  646. .version = 0x8111,
  647. .expected = SDL_UDEV_DEVICE_ACCELEROMETER,
  648. /* SYN, ABS, MSC */
  649. .ev = { 0x19 },
  650. /* X, Y, Z, RX, RY, RZ */
  651. .abs = { 0x3f },
  652. /* ACCELEROMETER */
  653. .props = { 0x40 },
  654. },
  655. {
  656. .name = "DualShock 4 via USB dongle",
  657. .bus_type = 0x0003,
  658. .vendor_id = 0x054c,
  659. .product_id = 0x0ba0,
  660. .version = 0x8111,
  661. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  662. /* SYN, ABS, KEY */
  663. .ev = { 0x0b },
  664. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  665. .abs = { 0x3f, 0x00, 0x03 },
  666. .keys = {
  667. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  668. /* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE,
  669. * THUMBL, THUMBR */
  670. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f,
  671. },
  672. },
  673. {
  674. .name = "DualShock 3 - gamepad",
  675. .eviocgname = "Sony PLAYSTATION(R)3 Controller",
  676. .usb_vendor_name = "Sony",
  677. .usb_product_name = "PLAYSTATION(R)3 Controller",
  678. .bus_type = 0x0003,
  679. .vendor_id = 0x054c,
  680. .product_id = 0x0268,
  681. .version = 0x8111,
  682. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  683. /* SYN, KEY, ABS, MSC, FF */
  684. .ev = { 0x1b, 0x00, 0x20 },
  685. /* X, Y, Z, RX, RY, RZ */
  686. .abs = { 0x3f },
  687. .keys = {
  688. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  689. /* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE,
  690. * THUMBL, THUMBR */
  691. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f,
  692. /* 0x140 */ ZEROx8,
  693. /* 0x180 */ ZEROx8,
  694. /* 0x1c0 */ ZEROx8,
  695. /* Digital dpad */
  696. /* 0x200 */ ZEROx4, 0x0f, 0x00, 0x00, 0x00,
  697. },
  698. .hid_report_descriptor_length = sizeof (ps3_hid_report_descriptor),
  699. .hid_report_descriptor = &ps3_hid_report_descriptor[0],
  700. },
  701. {
  702. .name = "DualShock 3 - accelerometer",
  703. .eviocgname = "Sony PLAYSTATION(R)3 Controller Motion Sensors",
  704. .usb_vendor_name = "Sony",
  705. .usb_product_name = "PLAYSTATION(R)3 Controller",
  706. .bus_type = 0x0003,
  707. .vendor_id = 0x054c,
  708. .product_id = 0x0268,
  709. .expected = SDL_UDEV_DEVICE_ACCELEROMETER,
  710. /* SYN, ABS */
  711. .ev = { 0x09 },
  712. /* X, Y, Z */
  713. .abs = { 0x07 },
  714. /* ACCELEROMETER */
  715. .props = { 0x40 },
  716. .hid_report_descriptor_length = sizeof (ps3_hid_report_descriptor),
  717. .hid_report_descriptor = &ps3_hid_report_descriptor[0],
  718. },
  719. {
  720. .name = "Steam Controller - gamepad",
  721. .bus_type = 0x0003,
  722. .vendor_id = 0x28de,
  723. .product_id = 0x1142,
  724. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  725. /* SYN, KEY, ABS */
  726. .ev = { 0x0b },
  727. /* X, Y, RX, RY, HAT0X, HAT0Y, HAT2X, HAT2Y */
  728. .abs = { 0x1b, 0x00, 0x33 },
  729. .keys = {
  730. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  731. /* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE,
  732. * THUMBL, THUMBR, joystick THUMB, joystick THUMB2 */
  733. /* 0x100 */ ZEROx4, 0x06, 0x00, 0xdb, 0x7f,
  734. /* GEAR_DOWN, GEAR_UP */
  735. /* 0x140 */ 0x00, 0x00, 0x03, 0x00, ZEROx4,
  736. /* 0x180 */ ZEROx8,
  737. /* 0x1c0 */ ZEROx8,
  738. /* Digital dpad */
  739. /* 0x200 */ ZEROx4, 0x0f, 0x00, 0x00, 0x00,
  740. },
  741. },
  742. {
  743. /* Present to support lizard mode, even if no Steam Controller
  744. * is connected */
  745. .name = "Steam Controller - dongle",
  746. .bus_type = 0x0003,
  747. .vendor_id = 0x28de,
  748. .product_id = 0x1142,
  749. .expected = (SDL_UDEV_DEVICE_HAS_KEYS
  750. | SDL_UDEV_DEVICE_KEYBOARD
  751. | SDL_UDEV_DEVICE_MOUSE),
  752. /* SYN, KEY, REL, MSC, LED, REP */
  753. .ev = { 0x17, 0x00, 0x12 },
  754. /* X, Y, mouse wheel, high-res mouse wheel */
  755. .rel = { 0x03, 0x09 },
  756. .keys = {
  757. /* 0x00 */ 0xfe, 0xff, 0xff, 0xff, FFx4,
  758. /* 0x40 */ 0xff, 0xff, 0xcf, 0x01, 0xdf, 0xff, 0x80, 0xe0,
  759. /* 0x80 */ ZEROx8,
  760. /* 0xc0 */ ZEROx8,
  761. /* 0x100 */ 0x00, 0x00, 0x1f, 0x00, ZEROx4,
  762. },
  763. },
  764. {
  765. .name = "Steam Deck - mouse",
  766. /* This is the LCD model (jupiter).
  767. * Steam Deck OLED (galileo, possibly pre-production) has
  768. * .eviocgname = "Valve Software Steam Controller"
  769. * .version = 0x0110
  770. * .usb_device_version = 0x0300
  771. * but is otherwise equivalent.
  772. */
  773. .eviocgname = "Valve Software Steam Deck Controller",
  774. .usb_vendor_name = "Valve Software",
  775. .usb_product_name = "Steam Deck Controller",
  776. .bus_type = 0x0003,
  777. .vendor_id = 0x28de,
  778. .product_id = 0x1205,
  779. .version = 0x011,
  780. .usb_device_version = 0x0200,
  781. /* SYN, KEY, REL, MSC */
  782. .ev = { 0x17 },
  783. /* X, Y, mouse wheel v/h, high-res mouse wheel v/h */
  784. .rel = { 0x43, 0x19 },
  785. .keys = {
  786. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  787. /* left/right mouse button */
  788. /* 0x100 */ 0x00, 0x00, 0x03, 0x00, ZEROx4,
  789. },
  790. .expected = SDL_UDEV_DEVICE_MOUSE,
  791. .hid_report_descriptor_length = sizeof (steam_deck_mouse_hid_report_descriptor),
  792. .hid_report_descriptor = &steam_deck_mouse_hid_report_descriptor[0],
  793. },
  794. {
  795. .name = "Steam Deck - keyboard",
  796. /* This is the LCD model (jupiter).
  797. * Steam Deck OLED (galileo, possibly pre-production) has
  798. * .eviocgname = "Valve Software Steam Controller"
  799. * .version = 0x0110
  800. * .usb_device_version = 0x0300
  801. * but is otherwise equivalent.
  802. */
  803. .eviocgname = "Valve Software Steam Deck Controller",
  804. .usb_vendor_name = "Valve Software",
  805. .usb_product_name = "Steam Deck Controller",
  806. .bus_type = 0x0003,
  807. .vendor_id = 0x28de,
  808. .product_id = 0x1205,
  809. .version = 0x0110,
  810. .usb_device_version = 0x0300,
  811. /* SYN, KEY, MSC, REP */
  812. .ev = { 0x13, 0x00, 0x10 },
  813. .keys = {
  814. /* 0x00 */ 0xfe, 0xff, 0xff, 0xff, FFx4,
  815. /* 0x40 */ 0xff, 0xff, 0xcf, 0x01, 0xdf, 0xff, 0x80, 0xe0,
  816. },
  817. .expected = SDL_UDEV_DEVICE_KEYBOARD | SDL_UDEV_DEVICE_HAS_KEYS,
  818. .hid_report_descriptor_length = sizeof (steam_deck_kb_hid_report_descriptor),
  819. .hid_report_descriptor = &steam_deck_kb_hid_report_descriptor[0],
  820. },
  821. {
  822. .name = "Steam Deck LCD - gamepad",
  823. .eviocgname = "Valve Software Steam Deck Controller",
  824. .usb_vendor_name = "Valve Software",
  825. .usb_product_name = "Steam Deck Controller",
  826. .bus_type = 0x0003,
  827. .vendor_id = 0x28de,
  828. .product_id = 0x1205,
  829. .version = 0x0111,
  830. .usb_device_version = 0x0200,
  831. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  832. /* TODO: The data I have for Steam Deck LCD didn't seem to have
  833. * an evdev device available, so this is extrapolated from
  834. * kernel source code as being the same as the OLED model
  835. * (the kernel driver doesn't distinguish). */
  836. /* SYN, KEY, ABS */
  837. .ev = { 0x0b },
  838. /* X, Y, RX, RY, hat 0-2 x/y */
  839. .abs = { 0x1b, 0x00, 0x3f },
  840. .keys = {
  841. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  842. /* 0x120 0x46: joystick THUMB, THUMB2, BASE */
  843. /* 0x130 0xdb: gamepad ABXY, TL/TR */
  844. /* 0x138 0x7f: gamepad TL2/TR2, SELECT/START, MODE, THUMBL/R */
  845. /* 0x100 */ ZEROx4, 0x46, 0x00, 0xdb, 0x7f,
  846. /* 0x140 */ ZEROx8,
  847. /* 0x180 */ ZEROx8,
  848. /* 0x1c0 */ ZEROx8,
  849. /* 0x220 0x0f: dpad up/down/left/right */
  850. /* 0x200 */ ZEROx4, 0x0f, 0x00, 0x00, 0x00,
  851. /* 0x240 */ ZEROx8,
  852. /* 0x280 */ ZEROx8,
  853. /* 0x2c0 0x0f: joystick TRIGGER_HAPPY1..TRIGGER_HAPPY4 */
  854. /* 0x2c0 */ 0x0f,
  855. },
  856. .hid_report_descriptor_length = sizeof (steam_deck_lcd_js_hid_report_descriptor),
  857. .hid_report_descriptor = &steam_deck_lcd_js_hid_report_descriptor[0],
  858. },
  859. {
  860. .name = "Steam Deck OLED - gamepad",
  861. .eviocgname = "Valve Software Steam Controller",
  862. .usb_vendor_name = "Valve Software",
  863. .usb_product_name = "Steam Controller",
  864. .bus_type = 0x0003,
  865. .vendor_id = 0x28de,
  866. .product_id = 0x1205,
  867. .version = 0x0110,
  868. .usb_device_version = 0x0300,
  869. /* SYN, KEY, ABS */
  870. .ev = { 0x0b },
  871. /* X, Y, RX, RY, hat 0-2 x/y */
  872. .abs = { 0x1b, 0x00, 0x3f },
  873. .keys = {
  874. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  875. /* 0x120 0x46: joystick THUMB, THUMB2, BASE */
  876. /* 0x130 0xdb: gamepad ABXY, TL/TR */
  877. /* 0x138 0x7f: gamepad TL2/TR2, SELECT/START, MODE, THUMBL/R */
  878. /* 0x100 */ ZEROx4, 0x46, 0x00, 0xdb, 0x7f,
  879. /* 0x140 */ ZEROx8,
  880. /* 0x180 */ ZEROx8,
  881. /* 0x1c0 */ ZEROx8,
  882. /* 0x220 0x0f: dpad up/down/left/right */
  883. /* 0x200 */ ZEROx4, 0x0f, 0x00, 0x00, 0x00,
  884. /* 0x240 */ ZEROx8,
  885. /* 0x280 */ ZEROx8,
  886. /* 0x2c0 0x0f: joystick TRIGGER_HAPPY1..TRIGGER_HAPPY4 */
  887. /* 0x2c0 */ 0x0f,
  888. },
  889. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  890. .hid_report_descriptor_length = sizeof (steam_deck_oled_js_hid_report_descriptor),
  891. .hid_report_descriptor = &steam_deck_oled_js_hid_report_descriptor[0],
  892. },
  893. {
  894. .name = "Steam Input virtual controller",
  895. .eviocgname = "Microsoft X-Box 360 pad 0",
  896. .bus_type = 0x0003,
  897. .vendor_id = 0x28de,
  898. .product_id = 0x11ff,
  899. .version = 0x0001,
  900. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  901. /* SYN, KEY, ABS, FF */
  902. .ev = { 0x0b, 0x00, 0x20 },
  903. /* XYZ, RXYZ, hat 0 */
  904. .abs = { 0x3f, 0x00, 0x03 },
  905. .keys = {
  906. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  907. /* 0x130 0xdb: gamepad ABXY, TL/TR */
  908. /* 0x138 0x7f: gamepad SELECT/START, MODE, THUMBL/R */
  909. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  910. },
  911. },
  912. {
  913. .name = "Guitar Hero for PS3",
  914. /* SWITCH CO.,LTD. Controller (Dinput) off-brand N64-style USB controller
  915. * 0003:2563:0575 v0111 is functionally equivalent.
  916. * https://linux-hardware.org/?id=usb:2563-0575 reports the same IDs as
  917. * ShenZhen ShanWan Technology ZD-V+ Wired Gaming Controller */
  918. .bus_type = 0x0003,
  919. .vendor_id = 0x12ba,
  920. .product_id = 0x0100,
  921. .version = 0x0110,
  922. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  923. /* SYN, KEY, ABS */
  924. .ev = { 0x0b },
  925. /* X, Y, Z, RZ, HAT0X, HAT0Y */
  926. .abs = { 0x27, 0x00, 0x03 },
  927. .keys = {
  928. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  929. /* ABC, XYZ, TL, TR, TL2, TR2, SELECT, START, MODE */
  930. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x1f,
  931. },
  932. },
  933. {
  934. .name = "G27 Racing Wheel, 0003:046d:c29b v0111",
  935. .bus_type = 0x0003,
  936. .vendor_id = 0x046d,
  937. .product_id = 0xc29b,
  938. .version = 0x0111,
  939. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  940. /* SYN, KEY, ABS */
  941. .ev = { 0x0b },
  942. /* X, Y, Z, RZ, HAT0X, HAT0Y */
  943. .abs = { 0x27, 0x00, 0x03 },
  944. .keys = {
  945. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  946. /* 16 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE,
  947. * BASE2..BASE6, unregistered event codes 0x12c-0x12e, DEAD */
  948. /* 0x100 */ ZEROx4, 0xff, 0xff, 0x00, 0x00,
  949. /* 0x140 */ ZEROx8,
  950. /* 0x180 */ ZEROx8,
  951. /* 0x1c0 */ ZEROx8,
  952. /* 0x200 */ ZEROx8,
  953. /* 0x240 */ ZEROx8,
  954. /* 0x280 */ ZEROx8,
  955. /* TRIGGER_HAPPY1..TRIGGER_HAPPY7 */
  956. /* 0x2c0 */ 0x7f,
  957. },
  958. },
  959. {
  960. .name = "Logitech Driving Force, 0003:046d:c294 v0100",
  961. .bus_type = 0x0003,
  962. .vendor_id = 0x046d,
  963. .product_id = 0xc294,
  964. .version = 0x0100,
  965. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  966. /* SYN, KEY, ABS */
  967. .ev = { 0x0b },
  968. /* X, Y, RZ, HAT0X, HAT0Y */
  969. .abs = { 0x23, 0x00, 0x03 },
  970. .keys = {
  971. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  972. /* 12 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE,
  973. * BASE2..BASE6 */
  974. /* 0x100 */ ZEROx4, 0xff, 0x0f, 0x00, 0x00,
  975. },
  976. },
  977. {
  978. .name = "Logitech Dual Action",
  979. .bus_type = 0x0003,
  980. .vendor_id = 0x046d,
  981. .product_id = 0xc216,
  982. .version = 0x0110,
  983. /* Logitech RumblePad 2 USB, 0003:046d:c218 v0110, is the same
  984. * except for having force feedback, which we don't use in our
  985. * heuristic */
  986. /* Jess Tech GGE909 PC Recoil Pad, 0003:0f30:010b v0110, is the same */
  987. /* 8BitDo SNES30 via USB, 0003:2dc8:ab20 v0110, is the same;
  988. * see below for the same physical device via Bluetooth,
  989. * 0005:2dc8:2840 v0100 */
  990. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  991. /* SYN, KEY, ABS */
  992. .ev = { 0x0b },
  993. /* X, Y, Z, RZ, HAT0X, HAT0Y */
  994. .abs = { 0x27, 0x00, 0x03 },
  995. .keys = {
  996. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  997. /* 12 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE,
  998. * BASE2..BASE6 */
  999. /* 0x100 */ ZEROx4, 0xff, 0x0f, 0x00, 0x00,
  1000. },
  1001. },
  1002. {
  1003. .name = "8BitDo SNES30 v0100 via Bluetooth",
  1004. .eviocgname = "8Bitdo SNES30 GamePad",
  1005. /* The same physical device via USB, 0003:2dc8:ab20 v0110,
  1006. * is reported differently (above). */
  1007. /* 8BitDo NES30 Pro (aka N30 Pro) via Bluetooth, 0005:2dc8:3820 v0100,
  1008. * is functionally equivalent; but the same physical device via USB,
  1009. * 0003:2dc8:9001 v0111, matches N30 Pro 2 v0111. */
  1010. .bus_type = 0x0005,
  1011. .vendor_id = 0x2dc8,
  1012. .product_id = 0x2840,
  1013. .version = 0x0100,
  1014. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1015. /* SYN, KEY, ABS, MSC */
  1016. .ev = { 0x1b },
  1017. /* XYZ, RZ, GAS, BRAKE, HAT0X, HAT0Y */
  1018. .abs = { 0x27, 0x06, 0x03 },
  1019. .keys = {
  1020. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1021. /* ABC, XYZ, TL, TR, TL2, TR2, SELECT, START, MODE, THUMBL, THUMBR,
  1022. * and an unassigned button code */
  1023. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0xff,
  1024. },
  1025. },
  1026. {
  1027. .name = "Saitek ST290 Pro flight stick",
  1028. .bus_type = 0x0003,
  1029. .vendor_id = 0x06a3,
  1030. .product_id = 0x0160, /* 0x0460 seems to be the same */
  1031. .version = 0x0100,
  1032. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1033. /* SYN, KEY, ABS, MSC */
  1034. .ev = { 0x1b },
  1035. /* X, Y, Z, RZ, HAT0X, HAT0Y */
  1036. .abs = { 0x27, 0x00, 0x03 },
  1037. .keys = {
  1038. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1039. /* TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE */
  1040. /* 0x100 */ ZEROx4, 0x3f, 0x00, 0x00, 0x00,
  1041. },
  1042. },
  1043. {
  1044. .name = "Saitek X52 Pro Flight Control System",
  1045. .bus_type = 0x0003,
  1046. .vendor_id = 0x06a3,
  1047. .product_id = 0x0762,
  1048. .version = 0x0111,
  1049. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1050. .ev = { 0x0b },
  1051. /* XYZ, RXYZ, throttle, hat0, MISC, unregistered event code 0x29 */
  1052. .abs = { 0x7f, 0x00, 0x03, 0x00, 0x00, 0x03 },
  1053. .keys = {
  1054. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1055. /* 16 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE,
  1056. * BASE2..BASE6, unregistered event codes 0x12c-0x12e, DEAD */
  1057. /* 0x100 */ ZEROx4, 0xff, 0xff, 0x00, 0x00,
  1058. /* 0x140 */ ZEROx8,
  1059. /* 0x180 */ ZEROx8,
  1060. /* 0x1c0 */ ZEROx8,
  1061. /* 0x200 */ ZEROx8,
  1062. /* 0x240 */ ZEROx8,
  1063. /* 0x280 */ ZEROx8,
  1064. /* TRIGGER_HAPPY1..TRIGGER_HAPPY23 */
  1065. /* 0x2c0 */ 0xff, 0xff, 0x7f,
  1066. },
  1067. },
  1068. {
  1069. .name = "Logitech Extreme 3D",
  1070. .bus_type = 0x0003,
  1071. .vendor_id = 0x046d,
  1072. .product_id = 0xc215,
  1073. .version = 0x0110,
  1074. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1075. /* SYN, KEY, ABS, MSC */
  1076. .ev = { 0x0b },
  1077. /* X, Y, RZ, throttle, hat 0 */
  1078. .abs = { 0x63, 0x00, 0x03 },
  1079. .keys = {
  1080. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1081. /* 12 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE,
  1082. * BASE2..BASE6 */
  1083. /* 0x100 */ ZEROx4, 0xff, 0x0f, 0x00, 0x00,
  1084. },
  1085. },
  1086. {
  1087. .name = "Hori Real Arcade Pro VX-SA",
  1088. .bus_type = 0x0003,
  1089. .vendor_id = 0x24c6,
  1090. .product_id = 0x5501,
  1091. .version = 0x0533,
  1092. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1093. /* SYN, KEY, ABS */
  1094. .ev = { 0x0b },
  1095. /* X, Y, Z, RX, RY, RZ, hat 0 */
  1096. .abs = { 0x3f, 0x00, 0x03 },
  1097. .keys = {
  1098. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1099. /* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  1100. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  1101. },
  1102. },
  1103. {
  1104. /* https://github.com/ValveSoftware/steam-devices/pull/42
  1105. * PS4 mode is functionally equivalent, but with product ID 0x011c
  1106. * and version 0x1101. */
  1107. .name = "Hori Fighting Stick Alpha - PS5 mode",
  1108. .bus_type = 0x0003, /* USB */
  1109. .vendor_id = 0x0f0d, /* Hori Co., Ltd. */
  1110. .product_id = 0x0184, /* HORI FIGHTING STICK α (PS5 mode) */
  1111. .version = 0x0111,
  1112. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1113. /* SYN, KEY, ABS, MSC */
  1114. .ev = { 0x1b },
  1115. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  1116. .abs = { 0x3f, 0x00, 0x03 },
  1117. .keys = {
  1118. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1119. /* ABC, XYZ, TL, TR, TL2, TR2, SELECT, START, MODE,
  1120. * THUMBL */
  1121. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x3f,
  1122. },
  1123. },
  1124. { /* https://github.com/ValveSoftware/steam-devices/pull/42 */
  1125. .name = "Hori Fighting Stick Alpha - PC mode",
  1126. .bus_type = 0x0003, /* USB */
  1127. .vendor_id = 0x0f0d, /* Hori Co., Ltd. */
  1128. .product_id = 0x011e, /* HORI FIGHTING STICK α (PC mode) */
  1129. .version = 0x0116,
  1130. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1131. /* SYN, KEY, ABS, FF */
  1132. .ev = { 0x0b, 0x00, 0x20 },
  1133. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  1134. .abs = { 0x3f, 0x00, 0x03 },
  1135. .keys = {
  1136. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1137. /* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  1138. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  1139. },
  1140. },
  1141. { /* https://github.com/ValveSoftware/steam-devices/issues/29 */
  1142. .name = "HORIPAD S for Nintendo",
  1143. .bus_type = 0x0003, /* USB */
  1144. .vendor_id = 0x0f0d, /* Hori Co., Ltd. */
  1145. .product_id = 0x00dc, /* HORIPAD S */
  1146. .version = 0x0112,
  1147. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1148. /* SYN, KEY, ABS, FF */
  1149. .ev = { 0x0b, 0x00, 0x20 },
  1150. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  1151. .abs = { 0x3f, 0x00, 0x03 },
  1152. .keys = {
  1153. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1154. /* A, B, X, Y, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  1155. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  1156. },
  1157. },
  1158. {
  1159. .name = "Switch Pro Controller via Bluetooth",
  1160. .bus_type = 0x0005,
  1161. .vendor_id = 0x057e,
  1162. .product_id = 0x2009,
  1163. .version = 0x0001,
  1164. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1165. /* SYN, KEY, ABS */
  1166. .ev = { 0x0b },
  1167. /* X, Y, RX, RY, hat 0 */
  1168. .abs = { 0x1b, 0x00, 0x03 },
  1169. .keys = {
  1170. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1171. /* 16 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE,
  1172. * BASE2..BASE6, unregistered event codes 0x12c-0x12e, DEAD */
  1173. /* 0x100 */ ZEROx4, 0xff, 0xff, 0x00, 0x00,
  1174. /* 0x140 */ ZEROx8,
  1175. /* 0x180 */ ZEROx8,
  1176. /* 0x1c0 */ ZEROx8,
  1177. /* 0x200 */ ZEROx8,
  1178. /* 0x240 */ ZEROx8,
  1179. /* 0x280 */ ZEROx8,
  1180. /* TRIGGER_HAPPY1..TRIGGER_HAPPY2 */
  1181. /* 0x2c0 */ 0x03,
  1182. },
  1183. },
  1184. {
  1185. .name = "Switch Pro Controller via Bluetooth (Linux 6.2.11)",
  1186. .eviocgname = "Pro Controller",
  1187. .bus_type = 0x0005,
  1188. .vendor_id = 0x057e,
  1189. .product_id = 0x2009,
  1190. .version = 0x0001,
  1191. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1192. /* SYN, KEY, ABS */
  1193. .ev = { 0x0b },
  1194. /* X, Y, RX, RY, hat 0 */
  1195. .abs = { 0x1b, 0x00, 0x03 },
  1196. .keys = {
  1197. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1198. /* ABC, XYZ, TL, TR, TL2, TR2, SELECT, START, MODE, THUMBL, THUMBR,
  1199. * and an unassigned button code */
  1200. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0xff,
  1201. },
  1202. },
  1203. {
  1204. .name = "Switch Pro Controller via USB",
  1205. .eviocgname = "Nintendo Co., Ltd. Pro Controller",
  1206. .usb_vendor_name = "Nintendo Co., Ltd.",
  1207. .usb_product_name = "Pro Controller",
  1208. .bus_type = 0x0003,
  1209. .vendor_id = 0x057e,
  1210. .product_id = 0x2009,
  1211. .version = 0x0111,
  1212. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1213. /* SYN, KEY, ABS */
  1214. .ev = { 0x0b },
  1215. /* X, Y, Z, RZ, HAT0X, HAT0Y */
  1216. .abs = { 0x27, 0x00, 0x03 },
  1217. .keys = {
  1218. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1219. /* 16 buttons: TRIGGER, THUMB, THUMB2, TOP, TOP2, PINKIE, BASE,
  1220. * BASE2..BASE6, unregistered event codes 0x12c-0x12e, DEAD */
  1221. /* 0x100 */ ZEROx4, 0xff, 0xff, 0x00, 0x00,
  1222. /* 0x140 */ ZEROx8,
  1223. /* 0x180 */ ZEROx8,
  1224. /* 0x1c0 */ ZEROx8,
  1225. /* 0x200 */ ZEROx8,
  1226. /* 0x240 */ ZEROx8,
  1227. /* 0x280 */ ZEROx8,
  1228. /* TRIGGER_HAPPY1..TRIGGER_HAPPY2 */
  1229. /* 0x2c0 */ 0x03,
  1230. },
  1231. },
  1232. { /* https://github.com/ValveSoftware/steam-devices/pull/40 */
  1233. .name = "PDP wired Pro Controller for Switch",
  1234. /* 0003:0e6f:0184 "Performance Designed Products" /
  1235. * "Faceoff Deluxe+ Audio Wired Controller for Nintendo Switch" appears
  1236. * to be functionally equivalent */
  1237. .eviocgname = "PDP CO.,LTD. Faceoff Wired Pro Controller for Nintendo Switch",
  1238. .usb_vendor_name = "PDP CO.,LTD.",
  1239. .usb_product_name = "Faceoff Wired Pro Controller for Nintendo Switch",
  1240. .bus_type = 0x0003,
  1241. .vendor_id = 0x0e6f,
  1242. .product_id = 0x0180,
  1243. .version = 0x0111,
  1244. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1245. /* SYN, KEY, ABS, MSC */
  1246. .ev = { 0x1b },
  1247. /* X, Y, Z, RZ, HAT0X, HAT0Y */
  1248. .abs = { 0x27, 0x00, 0x03 },
  1249. .keys = {
  1250. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1251. /* ABC, XYZ, TL, TR, TL2, TR2, SELECT, START, MODE,
  1252. * THUMBL */
  1253. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x3f,
  1254. },
  1255. },
  1256. {
  1257. .name = "NES Controller (R) NES-style Joycon from Nintendo Online",
  1258. .eviocgname = "NES Controller (R)",
  1259. /* Joy-Con (L), 0005:057e:2006 v0001, is functionally equivalent.
  1260. * Ordinary Joy-Con (R) and NES-style Joy-Con (L) are assumed to be
  1261. * functionally equivalent as well. */
  1262. .bus_type = 0x0005, /* Bluetooth-only */
  1263. .vendor_id = 0x057e,
  1264. .product_id = 0x2007,
  1265. .version = 0x0001,
  1266. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1267. /* SYN, KEY, ABS */
  1268. .ev = { 0x0b },
  1269. /* X, Y, RX, RY, hat 0 */
  1270. .abs = { 0x1b, 0x00, 0x03 },
  1271. .keys = {
  1272. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1273. /* ABC, XYZ, TL, TR, TL2, TR2, SELECT, START, MODE, THUMBL, THUMBR,
  1274. * and an unassigned button code */
  1275. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0xff,
  1276. },
  1277. },
  1278. {
  1279. .name = "Thrustmaster Racing Wheel FFB",
  1280. /* Several devices intended for PS4 are functionally equivalent to this:
  1281. * https://github.com/ValveSoftware/steam-devices/pull/34
  1282. * Mad Catz FightStick TE S+ PS4, 0003:0738:8384:0111 v0111
  1283. * (aka Street Fighter V Arcade FightStick TES+)
  1284. * Mad Catz FightStick TE2+ PS4, 0003:0738:8481 v0100
  1285. * (aka Street Fighter V Arcade FightStick TE2+)
  1286. * Bigben Interactive DAIJA Arcade Stick, 0003:146b:0d09 v0111
  1287. * (aka Nacon Daija PS4 Arcade Stick)
  1288. * Razer Razer Raiju Ultimate Wired, 0003:1532:1009 v0000
  1289. * Razer Razer Raiju Ultimate (Bluetooth), 0005:1532:1009 v0001
  1290. */
  1291. .bus_type = 0x0003,
  1292. .vendor_id = 0x044f,
  1293. .product_id = 0xb66d,
  1294. .version = 0x0110,
  1295. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1296. .ev = { 0x0b },
  1297. /* XYZ, RXYZ, hat 0 */
  1298. .abs = { 0x3f, 0x00, 0x03 },
  1299. .keys = {
  1300. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1301. /* ABC, XYZ, TL, TR, TL2, TR2, SELECT, START, MODE,
  1302. * THUMBL */
  1303. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x3f,
  1304. },
  1305. },
  1306. {
  1307. .name = "Thrustmaster T.Flight Hotas X",
  1308. .bus_type = 0x0003,
  1309. .vendor_id = 0x044f,
  1310. .product_id = 0xb108,
  1311. .version = 0x0100,
  1312. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1313. .ev = { 0x0b },
  1314. /* XYZ, RZ, throttle, hat 0 */
  1315. .abs = { 0x67, 0x00, 0x03 },
  1316. .keys = {
  1317. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1318. /* trigger, thumb, thumb2, top, top2, pinkie, base,
  1319. * base2..base6 */
  1320. /* 0x100 */ ZEROx4, 0xff, 0x0f
  1321. },
  1322. },
  1323. {
  1324. .name = "8BitDo N30 Pro via Bluetooth",
  1325. /* This device has also been seen reported with an additional
  1326. * unassigned button code, the same as the SNES30 v0100 via Bluetooth */
  1327. .bus_type = 0x0005,
  1328. .vendor_id = 0x2dc8,
  1329. .product_id = 0x3820,
  1330. .version = 0x0100,
  1331. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1332. /* SYN, KEY, ABS, MSC */
  1333. .ev = { 0x1b },
  1334. /* XYZ, RZ, gas, brake, hat0 */
  1335. .abs = { 0x27, 0x06, 0x03 },
  1336. .keys = {
  1337. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1338. /* ABC, XYZ, TL, TR, TL2, TR2, select, start, mode, thumbl,
  1339. * thumbr */
  1340. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x7f,
  1341. },
  1342. },
  1343. {
  1344. .name = "8BitDo N30 Pro 2 v0111",
  1345. .bus_type = 0x0003,
  1346. .vendor_id = 0x2dc8,
  1347. .product_id = 0x9015,
  1348. .version = 0x0111,
  1349. /* 8BitDo NES30 Pro via USB, 0003:2dc8:9001 v0111, is the same;
  1350. * but the same physical device via Bluetooth, 0005:2dc8:3820 v0100,
  1351. * matches 8BitDo SNES30 v0100 via Bluetooth instead (see above). */
  1352. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1353. .ev = { 0x0b },
  1354. /* XYZ, RZ, gas, brake, hat0 */
  1355. .abs = { 0x27, 0x06, 0x03 },
  1356. .keys = {
  1357. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1358. /* ABC, XYZ, TL, TR, TL2, TR2, select, start, mode, thumbl,
  1359. * thumbr */
  1360. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x7f,
  1361. },
  1362. },
  1363. {
  1364. .name = "8BitDo N30 Pro 2 via Bluetooth",
  1365. /* Physically the same device as the one that mimics an Xbox 360
  1366. * USB controller when wired */
  1367. .bus_type = 0x0005,
  1368. .vendor_id = 0x045e,
  1369. .product_id = 0x02e0,
  1370. .version = 0x0903,
  1371. .expected = SDL_UDEV_DEVICE_JOYSTICK | SDL_UDEV_DEVICE_HAS_KEYS,
  1372. /* SYN, KEY, ABS, MSC, FF */
  1373. .ev = { 0x1b, 0x00, 0x20 },
  1374. /* X, Y, Z, RX, RY, RZ, HAT0X, HAT0Y */
  1375. .abs = { 0x3f, 0x00, 0x03 },
  1376. .keys = {
  1377. /* 0x00 */ ZEROx8,
  1378. /* 0x40 */ ZEROx8,
  1379. /* KEY_MENU */
  1380. /* 0x80 */ 0x00, 0x08, 0x00, 0x00, ZEROx4,
  1381. /* 0xc0 */ ZEROx8,
  1382. /* ABC, XYZ, TL, TR, TL2, TR2 */
  1383. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x03,
  1384. },
  1385. },
  1386. {
  1387. .name = "Retro Power SNES-style controller, 0003:0079:0011 v0110",
  1388. .bus_type = 0x0003,
  1389. .vendor_id = 0x0079,
  1390. .product_id = 0x0011,
  1391. .version = 0x0110,
  1392. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1393. .ev = { 0x0b },
  1394. /* X, Y */
  1395. .abs = { 0x03 },
  1396. .keys = {
  1397. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1398. /* trigger, thumb, thumb2, top, top2, pinkie, base,
  1399. * base2..base4 */
  1400. /* 0x100 */ ZEROx4, 0xff, 0x03, 0x00, 0x00,
  1401. },
  1402. },
  1403. {
  1404. .name = "Google Stadia Controller rev.A",
  1405. .eviocgname = "Google LLC Stadia Controller rev. A",
  1406. .usb_vendor_name = "Google LLC",
  1407. .usb_product_name = "Stadia Controller rev. A",
  1408. /* This data is with USB-C, but the same physical device via Bluetooth,
  1409. * 0005:18d1:9400 v0000, is functionally equivalent other than having
  1410. * EVIOCGNAME = StadiaXXXX-YYYY where XXXX is the last 4 digits of
  1411. * the serial number and YYYY is some other mystery number */
  1412. .bus_type = 0x0003,
  1413. .vendor_id = 0x18d1,
  1414. .product_id = 0x9400,
  1415. .version = 0x0100,
  1416. .expected = SDL_UDEV_DEVICE_JOYSTICK | SDL_UDEV_DEVICE_HAS_KEYS,
  1417. .ev = { 0x0b },
  1418. /* XYZ, RZ, gas, brake, hat0 */
  1419. .abs = { 0x27, 0x06, 0x03 },
  1420. .keys = {
  1421. /* 0x00 */ ZEROx8,
  1422. /* Volume up/down */
  1423. /* 0x40 */ ZEROx4, 0x00, 0x00, 0x0c, 0x00,
  1424. /* Media play/pause */
  1425. /* 0x80 */ ZEROx4, 0x10, 0x00, 0x00, 0x00,
  1426. /* 0xc0 */ ZEROx8,
  1427. /* ABXY, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  1428. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  1429. /* 0x140 */ ZEROx8,
  1430. /* 0x180 */ ZEROx8,
  1431. /* 0x1c0 */ ZEROx8,
  1432. /* 0x200 */ ZEROx8,
  1433. /* 0x240 */ ZEROx8,
  1434. /* 0x280 */ ZEROx8,
  1435. /* TRIGGER_HAPPY 1-4 */
  1436. /* 0x2c0 */ 0x0f, 0x00, 0x00, 0x00, ZEROx4,
  1437. },
  1438. },
  1439. {
  1440. .name = "Microsoft Xbox Series S|X Controller (model 1914) via USB",
  1441. .eviocgname = "Microsoft Xbox Series S|X Controller",
  1442. .usb_vendor_name = "Microsoft",
  1443. .usb_product_name = "Controller",
  1444. /* Physically the same device as 0003:045e:0b13 v0515 below,
  1445. * but some functionality is mapped differently */
  1446. .bus_type = 0x0003,
  1447. .vendor_id = 0x045e,
  1448. .product_id = 0x0b12,
  1449. .version = 0x050f,
  1450. .expected = SDL_UDEV_DEVICE_JOYSTICK | SDL_UDEV_DEVICE_HAS_KEYS,
  1451. .ev = { 0x0b },
  1452. /* X, Y, Z, RX, RY, RZ, hat 0 */
  1453. .abs = { 0x3f, 0x00, 0x03 },
  1454. .keys = {
  1455. /* 0x00 */ ZEROx8,
  1456. /* 0x40 */ ZEROx8,
  1457. /* Record */
  1458. /* 0x80 */ ZEROx4, 0x80, 0x00, 0x00, 0x00,
  1459. /* 0xc0 */ ZEROx8,
  1460. /* ABXY, TL, TR, SELECT, START, MODE, THUMBL, THUMBR */
  1461. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7c,
  1462. },
  1463. },
  1464. {
  1465. .name = "Microsoft Xbox Series S|X Controller (model 1914) via Bluetooth",
  1466. .eviocgname = "Xbox Wireless Controller",
  1467. /* Physically the same device as 0003:045e:0b12 v050f above,
  1468. * but some functionality is mapped differently */
  1469. .bus_type = 0x0005,
  1470. .vendor_id = 0x045e,
  1471. .product_id = 0x0b13,
  1472. .version = 0x0515,
  1473. .expected = SDL_UDEV_DEVICE_JOYSTICK | SDL_UDEV_DEVICE_HAS_KEYS,
  1474. .ev = { 0x0b },
  1475. /* XYZ, RZ, gas, brake, hat0 */
  1476. .abs = { 0x27, 0x06, 0x03 },
  1477. .keys = {
  1478. /* 0x00 */ ZEROx8,
  1479. /* 0x40 */ ZEROx8,
  1480. /* Record */
  1481. /* 0x80 */ ZEROx4, 0x80, 0x00, 0x00, 0x00,
  1482. /* 0xc0 */ ZEROx8,
  1483. /* ABC, XYZ, TL, TR, TL2, TR2, select, start, mode, thumbl,
  1484. * thumbr */
  1485. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xff, 0x7f,
  1486. },
  1487. },
  1488. {
  1489. .name = "Wiimote - buttons",
  1490. .eviocgname = "Nintendo Wii Remote",
  1491. .bus_type = 0x0005,
  1492. .vendor_id = 0x057e,
  1493. .product_id = 0x0306,
  1494. .version = 0x0600,
  1495. /* This one is a bit weird because some of the buttons are mapped
  1496. * to the arrow, page up and page down keys, so it's a joystick
  1497. * with a subset of a keyboard attached. */
  1498. /* TODO: Should this be JOYSTICK, or even JOYSTICK|HAS_KEYS? */
  1499. .expected = SDL_UDEV_DEVICE_HAS_KEYS,
  1500. /* SYN, KEY, FF */
  1501. .ev = { 0x03, 0x00, 0x20 },
  1502. .keys = {
  1503. /* 0x00 */ ZEROx8,
  1504. /* left, right, up down */
  1505. /* 0x40 */ ZEROx4, 0x80, 0x16, 0x00, 0x00,
  1506. /* 0x80 */ ZEROx8,
  1507. /* 0xc0 */ ZEROx8,
  1508. /* BTN_1, BTN_2, BTN_A, BTN_B, BTN_MODE */
  1509. /* 0x100 */ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x10,
  1510. /* 0x140 */ ZEROx8,
  1511. /* next (keyboard page down), previous (keyboard page up) */
  1512. /* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4,
  1513. },
  1514. },
  1515. {
  1516. .name = "Wiimote - accelerometer",
  1517. .eviocgname = "Nintendo Wii Remote Accelerometer",
  1518. .bus_type = 0x0005,
  1519. .vendor_id = 0x057e,
  1520. .product_id = 0x0306,
  1521. .version = 0x0600,
  1522. .expected = SDL_UDEV_DEVICE_ACCELEROMETER,
  1523. /* SYN, ABS */
  1524. .ev = { 0x09 },
  1525. /* RX, RY, RZ - even though it would more conventionally be X, Y, Z */
  1526. .abs = { 0x38 },
  1527. },
  1528. {
  1529. .name = "Wiimote - Motion Plus gyroscope",
  1530. .eviocgname = "Nintendo Wii Remote Motion Plus",
  1531. /* Note that if we only look at the bus type, vendor, product, version
  1532. * and axes, this is indistinguishable from the accelerometer */
  1533. .bus_type = 0x0005,
  1534. .vendor_id = 0x057e,
  1535. .product_id = 0x0306,
  1536. .version = 0x0600,
  1537. .expected = SDL_UDEV_DEVICE_ACCELEROMETER,
  1538. /* SYN, ABS */
  1539. .ev = { 0x09 },
  1540. /* RX, RY, RZ */
  1541. .abs = { 0x38 },
  1542. },
  1543. {
  1544. .name = "Wiimote - IR positioning",
  1545. .eviocgname = "Nintendo Wii Remote IR",
  1546. .bus_type = 0x0005,
  1547. .vendor_id = 0x057e,
  1548. .product_id = 0x0306,
  1549. .version = 0x0600,
  1550. .expected = SDL_UDEV_DEVICE_UNKNOWN,
  1551. /* SYN, ABS */
  1552. .ev = { 0x09 },
  1553. /* HAT0X, Y to HAT3X, Y */
  1554. .abs = { 0x00, 0x00, 0xff },
  1555. },
  1556. {
  1557. .name = "Wiimote - Nunchuck",
  1558. .eviocgname = "Nintendo Wii Remote Nunchuk",
  1559. .bus_type = 0x0005,
  1560. .vendor_id = 0x057e,
  1561. .product_id = 0x0306,
  1562. .version = 0x0600,
  1563. /* TODO: Should this be JOYSTICK? It has one stick and two buttons */
  1564. .expected = SDL_UDEV_DEVICE_UNKNOWN,
  1565. /* SYN, KEY, ABS */
  1566. .ev = { 0x0b },
  1567. /* RX, RY, RZ, hat 0 - even though this is an accelerometer, which
  1568. * would more conventionally be X, Y, Z, and a left joystick, which
  1569. * would more conventionally be X, Y */
  1570. .abs = { 0x38, 0x00, 0x03 },
  1571. .keys = {
  1572. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1573. /* C and Z buttons */
  1574. /* 0x100 */ ZEROx4, 0x00, 0x00, 0x24, 0x00,
  1575. },
  1576. },
  1577. {
  1578. .name = "Wiimote - Classic Controller",
  1579. .eviocgname = "Nintendo Wii Remote Classic Controller",
  1580. .bus_type = 0x0005,
  1581. .vendor_id = 0x057e,
  1582. .product_id = 0x0306,
  1583. .version = 0x0600,
  1584. /* TODO: Should this be JOYSTICK, or maybe JOYSTICK|HAS_KEYS?
  1585. * It's unusual in the same ways as the Wiimote */
  1586. .expected = SDL_UDEV_DEVICE_HAS_KEYS,
  1587. /* SYN, KEY, ABS */
  1588. .ev = { 0x0b },
  1589. /* Hat 1-3 X and Y */
  1590. .abs = { 0x00, 0x00, 0xfc },
  1591. .keys = {
  1592. /* 0x00 */ ZEROx8,
  1593. /* left, right, up down */
  1594. /* 0x40 */ ZEROx4, 0x80, 0x16, 0x00, 0x00,
  1595. /* 0x80 */ ZEROx8,
  1596. /* 0xc0 */ ZEROx8,
  1597. /* A, B, X, Y, MODE, TL, TL2, TR, TR2 */
  1598. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x13,
  1599. /* 0x140 */ ZEROx8,
  1600. /* next (keyboard page down), previous (keyboard page up) */
  1601. /* 0x180 */ 0x00, 0x00, 0x80, 0x10, ZEROx4,
  1602. },
  1603. },
  1604. {
  1605. /* Flags guessed from kernel source code, not confirmed with real
  1606. * hardware */
  1607. .name = "Wiimote - Balance Board",
  1608. /* TODO: Should this be JOYSTICK? */
  1609. .expected = SDL_UDEV_DEVICE_UNKNOWN,
  1610. /* SYN, KEY, ABS */
  1611. .ev = { 0x0b },
  1612. /* Hat 0-1 */
  1613. .abs = { 0x00, 0x00, 0x0f },
  1614. .keys = {
  1615. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1616. /* BTN_A */
  1617. /* 0x100 */ ZEROx4, 0x00, 0x00, 0x01, 0x00,
  1618. },
  1619. },
  1620. {
  1621. /* Flags guessed from kernel source code, not confirmed with real
  1622. * hardware */
  1623. .name = "Wiimote - Wii U Pro Controller",
  1624. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1625. /* SYN, KEY, ABS */
  1626. .ev = { 0x0b },
  1627. /* X, Y, RX, RY */
  1628. .abs = { 0x1b },
  1629. .keys = {
  1630. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1631. /* A, B, X, Y, TL, TR, TL2, TR2, SELECT, START, MODE,
  1632. * THUMBL, THUMBR */
  1633. /* 0x100 */ ZEROx4, 0x00, 0x00, 0xdb, 0x7f,
  1634. /* 0x140 */ ZEROx8,
  1635. /* 0x180 */ ZEROx8,
  1636. /* 0x1c0 */ ZEROx8,
  1637. /* Digital dpad */
  1638. /* 0x200 */ ZEROx4, 0x0f, 0x00, 0x00, 0x00,
  1639. },
  1640. },
  1641. {
  1642. .name = "Synaptics TM3381-002 (Thinkpad X280 trackpad)",
  1643. .eviocgname = "Synaptics TM3381-002",
  1644. .bus_type = 0x001d, /* BUS_RMI */
  1645. .vendor_id = 0x06cb,
  1646. .product_id = 0x0000,
  1647. .version = 0x0000,
  1648. .expected = SDL_UDEV_DEVICE_TOUCHPAD,
  1649. /* SYN, KEY, ABS */
  1650. .ev = { 0x0b },
  1651. /* X, Y, pressure, multitouch */
  1652. .abs = { 0x03, 0x00, 0x00, 0x01, 0x00, 0x80, 0xf3, 0x06 },
  1653. .keys = {
  1654. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1655. /* Left mouse button */
  1656. /* 0x100 */ 0x00, 0x00, 0x01, 0x00, ZEROx4,
  1657. /* BTN_TOOL_FINGER and some multitouch gestures */
  1658. /* 0x140 */ 0x20, 0xe5
  1659. },
  1660. /* POINTER, BUTTONPAD */
  1661. .props = { 0x05 },
  1662. },
  1663. {
  1664. .name = "DELL08AF:00 (Dell XPS laptop touchpad)",
  1665. .bus_type = 0x18,
  1666. .vendor_id = 0x6cb,
  1667. .product_id = 0x76af,
  1668. .version = 0x100,
  1669. .ev = { 0x0b },
  1670. .expected = SDL_UDEV_DEVICE_TOUCHPAD,
  1671. /* X, Y, multitouch */
  1672. .abs = { 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0x02 },
  1673. .keys = {
  1674. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1675. /* Left mouse button */
  1676. /* 0x100 */ 0x00, 0x00, 0x01, 0x00, ZEROx4,
  1677. /* BTN_TOOL_FINGER and some multitouch gestures */
  1678. /* 0x140 */ 0x20, 0xe5
  1679. },
  1680. /* POINTER, BUTTONPAD */
  1681. .props = { 0x05 },
  1682. },
  1683. {
  1684. .name = "TPPS/2 Elan TrackPoint (Thinkpad X280)",
  1685. .eviocgname = "TPPS/2 Elan TrackPoint",
  1686. .bus_type = 0x0011, /* BUS_I8042 */
  1687. .vendor_id = 0x0002,
  1688. .product_id = 0x000a,
  1689. .version = 0x0000,
  1690. .expected = SDL_UDEV_DEVICE_MOUSE,
  1691. /* SYN, KEY, REL */
  1692. .ev = { 0x07 },
  1693. /* X, Y */
  1694. .rel = { 0x03 },
  1695. .keys = {
  1696. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  1697. /* Left, middle, right mouse buttons */
  1698. /* 0x100 */ 0x00, 0x00, 0x07,
  1699. },
  1700. /* POINTER, POINTING_STICK */
  1701. .props = { 0x21 },
  1702. },
  1703. {
  1704. .name = "Thinkpad ACPI buttons",
  1705. .eviocgname = "ThinkPad Extra Buttons",
  1706. .bus_type = 0x0019,
  1707. .vendor_id = 0x17aa,
  1708. .product_id = 0x5054,
  1709. .version = 0x4101,
  1710. .expected = SDL_UDEV_DEVICE_HAS_KEYS,
  1711. /* SYN, KEY, MSC, SW */
  1712. .ev = { 0x33 },
  1713. .keys = {
  1714. /* 0x00 */ ZEROx8,
  1715. /* 0x40 */ ZEROx4, 0x00, 0x00, 0x0e, 0x01,
  1716. /* 0x80 */ 0x00, 0x50, 0x11, 0x51, 0x00, 0x28, 0x00, 0xc0,
  1717. /* 0xc0 */ 0x04, 0x20, 0x10, 0x02, 0x1b, 0x70, 0x01, 0x00,
  1718. /* 0x100 */ ZEROx8,
  1719. /* 0x140 */ ZEROx4, 0x00, 0x00, 0x50, 0x00,
  1720. /* 0x180 */ ZEROx8,
  1721. /* 0x1c0 */ 0x00, 0x00, 0x04, 0x18, ZEROx4,
  1722. /* 0x200 */ ZEROx8,
  1723. /* 0x240 */ 0x40, 0x00, 0x01, 0x00, ZEROx4,
  1724. },
  1725. },
  1726. {
  1727. .name = "Thinkpad ACPI buttons (Linux 6.1)",
  1728. .eviocgname = "ThinkPad Extra Buttons",
  1729. .bus_type = 0x0019,
  1730. .vendor_id = 0x17aa,
  1731. .product_id = 0x5054,
  1732. .version = 0x4101,
  1733. .expected = SDL_UDEV_DEVICE_HAS_KEYS,
  1734. /* SYN, KEY, MSC, SW */
  1735. .ev = { 0x33 },
  1736. .keys = {
  1737. /* 0x00 */ ZEROx8,
  1738. /* 0x40 */ ZEROx4, 0x00, 0x00, 0x0e, 0x01,
  1739. /* 0x80 */ 0x00, 0x50, 0x11, 0x51, 0x00, 0x28, 0x00, 0xc0,
  1740. /* 0xc0 */ 0x04, 0x20, 0x10, 0x02, 0x1b, 0x70, 0x01, 0x00,
  1741. /* 0x100 */ ZEROx8,
  1742. /* 0x140 */ ZEROx4, 0x00, 0x00, 0x50, 0x00,
  1743. /* 0x180 */ ZEROx4, 0x00, 0x00, 0x00, 0x70,
  1744. /* 0x1c0 */ 0x00, 0x00, 0x04, 0x18, 0x20, 0x00, 0x00, 0x00,
  1745. /* 0x200 */ ZEROx8,
  1746. /* 0x240 */ ZEROx8,
  1747. },
  1748. },
  1749. {
  1750. .name = "PC speaker",
  1751. .eviocgname = "PC Speaker",
  1752. .bus_type = 0x0010, /* BUS_ISA */
  1753. .vendor_id = 0x001f,
  1754. .product_id = 0x0001,
  1755. .version = 0x0100,
  1756. .expected = SDL_UDEV_DEVICE_UNKNOWN,
  1757. /* SYN, SND */
  1758. .ev = { 0x01, 0x00, 0x04 },
  1759. },
  1760. {
  1761. .name = "HDA Digital PCBeep",
  1762. .eviocgname = "HDA Digital PCBeep",
  1763. .bus_type = 0x0001,
  1764. .vendor_id = 0x10ec,
  1765. .product_id = 0x0257,
  1766. .version = 0x0001,
  1767. .expected = SDL_UDEV_DEVICE_UNKNOWN,
  1768. /* SYN, SND */
  1769. .ev = { 0x01, 0x00, 0x04 },
  1770. },
  1771. {
  1772. .name = "ALSA headphone detection, etc.",
  1773. .eviocgname = "HDA Intel PCH Mic",
  1774. /* HDA Intel PCH Headphone is functionally equivalent */
  1775. /* HDA Intel PCH HDMI/DP,pcm=3 is functionally equivalent */
  1776. /* HDA Intel PCH HDMI/DP,pcm=7 is functionally equivalent */
  1777. /* HDA Intel PCH HDMI/DP,pcm=8 is functionally equivalent */
  1778. .bus_type = 0x0000,
  1779. .vendor_id = 0x0000,
  1780. .product_id = 0x0000,
  1781. .version = 0x0000,
  1782. .expected = SDL_UDEV_DEVICE_UNKNOWN,
  1783. /* SYN, SW */
  1784. .ev = { 0x21 },
  1785. },
  1786. {
  1787. /* Assumed to be a reasonably typical i8042 (PC AT) keyboard */
  1788. .name = "Thinkpad T520 and X280 keyboards",
  1789. /* Steam Deck LCD/OLED keyboard interface is version 0xab83 but
  1790. * otherwise equivalent */
  1791. .eviocgname = "AT Translated Set 2 keyboard",
  1792. .bus_type = 0x0011, /* BUS_I8042 */
  1793. .vendor_id = 0x0001,
  1794. .product_id = 0x0001,
  1795. .version = 0xab54,
  1796. .expected = SDL_UDEV_DEVICE_HAS_KEYS | SDL_UDEV_DEVICE_KEYBOARD,
  1797. /* SYN, KEY, MSC, LED, REP */
  1798. .ev = { 0x13, 0x00, 0x12 },
  1799. .keys = {
  1800. /* 0x00 */ 0xfe, 0xff, 0xff, 0xff, FFx4,
  1801. /* 0x40 */ 0xff, 0xff, 0xef, 0xff, 0xdf, 0xff, 0xff, 0xfe,
  1802. /* 0x80 */ 0x01, 0xd0, 0x00, 0xf8, 0x78, 0x30, 0x80, 0x03,
  1803. /* 0xc0 */ 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00,
  1804. },
  1805. },
  1806. {
  1807. .name = "Thinkpad X280 sleep button",
  1808. .eviocgname = "Sleep Button",
  1809. .bus_type = 0x0019, /* BUS_HOST */
  1810. .vendor_id = 0x0000,
  1811. .product_id = 0x0003,
  1812. .version = 0x0000,
  1813. .expected = SDL_UDEV_DEVICE_HAS_KEYS,
  1814. /* SYN, KEY */
  1815. .ev = { 0x03 },
  1816. .keys = {
  1817. /* 0x00 */ ZEROx8,
  1818. /* 0x40 */ ZEROx8,
  1819. /* KEY_SLEEP */
  1820. /* 0x80 */ 0x00, 0x40,
  1821. },
  1822. },
  1823. {
  1824. /* As seen on Thinkpad X280, Steam Deck LCD, Steam Deck OLED */
  1825. .name = "ACPI lid switch",
  1826. .eviocgname = "Lid Switch",
  1827. .bus_type = 0x0019, /* BUS_HOST */
  1828. .vendor_id = 0x0000,
  1829. .product_id = 0x0005,
  1830. .version = 0x0000,
  1831. .expected = SDL_UDEV_DEVICE_UNKNOWN,
  1832. /* SYN, SW */
  1833. .ev = { 0x21 },
  1834. },
  1835. {
  1836. /* As seen on Thinkpad X280, Steam Deck LCD, Steam Deck OLED */
  1837. .name = "ACPI power button",
  1838. .eviocgname = "Power Button",
  1839. .bus_type = 0x0019, /* BUS_HOST */
  1840. .vendor_id = 0x0000,
  1841. .product_id = 0x0001,
  1842. .version = 0x0000,
  1843. .expected = SDL_UDEV_DEVICE_HAS_KEYS,
  1844. /* SYN, KEY */
  1845. .ev = { 0x03 },
  1846. .keys = {
  1847. /* 0x00 */ ZEROx8,
  1848. /* KEY_POWER */
  1849. /* 0x40 */ ZEROx4, 0x00, 0x00, 0x10, 0x00,
  1850. },
  1851. },
  1852. {
  1853. /* As seen on Thinkpad X280, Steam Deck LCD, Steam Deck OLED */
  1854. .name = "ACPI video bus",
  1855. .eviocgname = "Video Bus",
  1856. .bus_type = 0x0019, /* BUS_HOST */
  1857. .vendor_id = 0x0000,
  1858. .product_id = 0x0006,
  1859. .version = 0x0000,
  1860. .expected = SDL_UDEV_DEVICE_HAS_KEYS,
  1861. /* SYN, KEY */
  1862. .ev = { 0x03 },
  1863. .keys = {
  1864. /* 0x00 */ ZEROx8,
  1865. /* 0x40 */ ZEROx8,
  1866. /* 0x80 */ ZEROx8,
  1867. /* brightness control, video mode, display off */
  1868. /* 0xc0 */ ZEROx4, 0x0b, 0x00, 0x3e, 0x00,
  1869. },
  1870. },
  1871. {
  1872. .name = "Thinkpad X280 webcam",
  1873. .eviocgname = "Integrated Camera: Integrated C",
  1874. .usb_vendor_name = "Chicony Electronics Co.,Ltd.",
  1875. .usb_product_name = "Integrated Camera",
  1876. .bus_type = 0x0003,
  1877. .vendor_id = 0x04f2,
  1878. .product_id = 0xb604,
  1879. .version = 0x0027,
  1880. .expected = SDL_UDEV_DEVICE_HAS_KEYS,
  1881. /* SYN, KEY */
  1882. .ev = { 0x03 },
  1883. .keys = {
  1884. /* 0x00 */ ZEROx8,
  1885. /* 0x40 */ ZEROx8,
  1886. /* 0x80 */ ZEROx8,
  1887. /* KEY_CAMERA */
  1888. /* 0xc0 */ 0x00, 0x00, 0x10, 0x00, ZEROx4,
  1889. },
  1890. },
  1891. {
  1892. .name = "Thinkpad X280 extra buttons",
  1893. .bus_type = 0x0019, /* BUS_HOST */
  1894. .vendor_id = 0x17aa,
  1895. .product_id = 0x5054,
  1896. .version = 0x4101,
  1897. .expected = SDL_UDEV_DEVICE_HAS_KEYS,
  1898. /* SYN, KEY */
  1899. .ev = { 0x03 },
  1900. .keys = {
  1901. /* 0x00 */ ZEROx8,
  1902. /* 0x40 */ ZEROx4, 0x00, 0x00, 0x0e, 0x01,
  1903. /* 0x80 */ 0x00, 0x50, 0x11, 0x51, 0x00, 0x28, 0x00, 0xc0,
  1904. /* 0xc0 */ 0x04, 0x20, 0x10, 0x02, 0x1b, 0x70, 0x01, 0x00,
  1905. /* 0x100 */ ZEROx8,
  1906. /* 0x140 */ ZEROx4, 0x00, 0x00, 0x50, 0x00,
  1907. /* 0x180 */ ZEROx8,
  1908. /* 0x1c0 */ 0x00, 0x00, 0x04, 0x18, ZEROx4,
  1909. /* 0x200 */ ZEROx8,
  1910. /* 0x240 */ 0x40, 0x00, 0x01, 0x00, ZEROx4,
  1911. },
  1912. },
  1913. {
  1914. .name = "Thinkpad USB keyboard with Trackpoint - keyboard",
  1915. .eviocgname = "Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint",
  1916. .usb_vendor_name = "Lite-On Technology Corp.",
  1917. .usb_product_name = "ThinkPad USB Keyboard with TrackPoint",
  1918. .bus_type = 0x0003,
  1919. .vendor_id = 0x17ef,
  1920. .product_id = 0x6009,
  1921. .expected = SDL_UDEV_DEVICE_HAS_KEYS | SDL_UDEV_DEVICE_KEYBOARD,
  1922. /* SYN, KEY, MSC, LED, REP */
  1923. .ev = { 0x13, 0x00, 0x12 },
  1924. .keys = {
  1925. /* 0x00 */ 0xfe, 0xff, 0xff, 0xff, FFx4,
  1926. /* 0x40 */ 0xff, 0xff, 0xef, 0xff, 0xdf, 0xff, 0xbe, 0xfe,
  1927. /* 0x80 */ 0xff, 0x57, 0x40, 0xc1, 0x7a, 0x20, 0x9f, 0xff,
  1928. /* 0xc0 */ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
  1929. },
  1930. .hid_report_descriptor_length = sizeof (thinkpad_usb_keyboard_hid_report_descriptor),
  1931. .hid_report_descriptor = &thinkpad_usb_keyboard_hid_report_descriptor[0],
  1932. },
  1933. {
  1934. .name = "Thinkpad USB keyboard with Trackpoint - Trackpoint",
  1935. .eviocgname = "Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint",
  1936. .usb_vendor_name = "Lite-On Technology Corp.",
  1937. .usb_product_name = "ThinkPad USB Keyboard with TrackPoint",
  1938. .bus_type = 0x0003,
  1939. .vendor_id = 0x17ef,
  1940. .product_id = 0x6009,
  1941. .version = 0x0110,
  1942. /* For some reason the special keys like mute and wlan toggle
  1943. * show up here instead of, or in addition to, as part of
  1944. * the keyboard - so both udev and SDL report this as having keys too. */
  1945. .expected = SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_HAS_KEYS,
  1946. /* SYN, KEY, REL, MSC, LED */
  1947. .ev = { 0x17, 0x00, 0x02 },
  1948. /* X, Y */
  1949. .rel = { 0x03 },
  1950. .keys = {
  1951. /* 0x00 */ ZEROx8,
  1952. /* 0x40 */ ZEROx4, 0x00, 0x00, 0x1e, 0x00,
  1953. /* 0x80 */ 0x00, 0xcc, 0x11, 0x01, 0x78, 0x40, 0x00, 0xc0,
  1954. /* 0xc0 */ 0x00, 0x20, 0x10, 0x00, 0x0b, 0x50, 0x00, 0x00,
  1955. /* Mouse buttons: left, right, middle, "task" */
  1956. /* 0x100 */ 0x00, 0x00, 0x87, 0x68, ZEROx4,
  1957. /* 0x140 */ ZEROx4, 0x00, 0x00, 0x10, 0x00,
  1958. /* 0x180 */ ZEROx4, 0x00, 0x00, 0x40, 0x00,
  1959. },
  1960. .hid_report_descriptor_length = sizeof (thinkpad_usb_trackpoint_hid_report_descriptor),
  1961. .hid_report_descriptor = &thinkpad_usb_trackpoint_hid_report_descriptor[0],
  1962. },
  1963. { /* https://github.com/ValveSoftware/Proton/issues/5126 */
  1964. .name = "Smarty Co. VRS DirectForce Pro Pedals",
  1965. .bus_type = 0x0003,
  1966. .vendor_id = 0x0483, /* STMicroelectronics */
  1967. .product_id = 0xa3be, /* VRS DirectForce Pro Pedals */
  1968. .version = 0x0111,
  1969. /* TODO: Ideally we would identify this as a joystick, but there
  1970. * isn't currently enough information to do that without a table
  1971. * of known devices. */
  1972. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1973. .todo = "https://github.com/ValveSoftware/Proton/issues/5126",
  1974. /* SYN, ABS */
  1975. .ev = { 0x09 },
  1976. /* X, Y, Z */
  1977. .abs = { 0x07 },
  1978. .hid_report_descriptor_length = sizeof (vrs_pedals_hid_report_descriptor),
  1979. .hid_report_descriptor = &vrs_pedals_hid_report_descriptor[0],
  1980. },
  1981. { /* https://github.com/ValveSoftware/Proton/issues/5126 */
  1982. .name = "Heusinkveld Heusinkveld Sim Pedals Ultimate",
  1983. .bus_type = 0x0003,
  1984. .vendor_id = 0x30b7, /* Heusinkveld Engineering */
  1985. .product_id = 0x1003, /* Heusinkveld Sim Pedals Ultimate */
  1986. .version = 0x0000,
  1987. /* TODO: Ideally we would identify this as a joystick, but there
  1988. * isn't currently enough information to do that without a table
  1989. * of known devices. */
  1990. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  1991. .todo = "https://github.com/ValveSoftware/Proton/issues/5126",
  1992. /* SYN, ABS */
  1993. .ev = { 0x09 },
  1994. /* RX, RY, RZ */
  1995. .abs = { 0x38 },
  1996. .hid_report_descriptor_length = sizeof (heusinkveld_pedals_hid_report_descriptor),
  1997. .hid_report_descriptor = &heusinkveld_pedals_hid_report_descriptor[0],
  1998. },
  1999. { /* https://github.com/ValveSoftware/Proton/issues/5126 */
  2000. .name = "Vitaly [mega_mozg] Naidentsev ODDOR-handbrake",
  2001. .bus_type = 0x0003,
  2002. .vendor_id = 0x0000,
  2003. .product_id = 0x0000,
  2004. .version = 0x0001,
  2005. /* TODO: Ideally we would identify this as a joystick by it having
  2006. * the joystick-specific THROTTLE axis and TRIGGER/THUMB buttons */
  2007. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  2008. .todo = "https://github.com/ValveSoftware/Proton/issues/5126",
  2009. /* SYN, KEY, ABS, MSC */
  2010. .ev = { 0x1b },
  2011. /* THROTTLE only */
  2012. .abs = { 0x40 },
  2013. .keys = {
  2014. /* 0x00-0xff */ ZEROx8, ZEROx8, ZEROx8, ZEROx8,
  2015. /* TRIGGER = 0x120, THUMB = 0x121 */
  2016. /* 0x100 */ ZEROx4, 0x03, 0x00, 0x00, 0x00,
  2017. },
  2018. },
  2019. { /* https://github.com/ValveSoftware/Proton/issues/5126 */
  2020. .name = "Leo Bodnar Logitech® G25 Pedals",
  2021. .bus_type = 0x0003,
  2022. .vendor_id = 0x1dd2, /* Leo Bodnar Electronics Ltd */
  2023. .product_id = 0x100c,
  2024. .version = 0x0110,
  2025. /* TODO: Ideally we would identify this as a joystick, but there
  2026. * isn't currently enough information to do that without a table
  2027. * of known devices. */
  2028. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  2029. .todo = "https://github.com/ValveSoftware/Proton/issues/5126",
  2030. /* SYN, ABS */
  2031. .ev = { 0x09 },
  2032. /* RX, RY, RZ */
  2033. .abs = { 0x38 },
  2034. },
  2035. { /* https://github.com/ValveSoftware/Proton/issues/5126 */
  2036. .name = "FANATEC ClubSport USB Handbrake",
  2037. .bus_type = 0x0003,
  2038. .vendor_id = 0x0eb7,
  2039. .product_id = 0x1a93,
  2040. .version = 0x0111,
  2041. /* TODO: Ideally we would identify this as a joystick, but there
  2042. * isn't currently enough information to do that without a table
  2043. * of known devices. */
  2044. .expected = SDL_UDEV_DEVICE_JOYSTICK,
  2045. .todo = "https://github.com/ValveSoftware/Proton/issues/5126",
  2046. /* SYN, ABS */
  2047. .ev = { 0x09 },
  2048. /* X only */
  2049. .abs = { 0x01 },
  2050. .hid_report_descriptor_length = sizeof (fanatec_handbrake_hid_report_descriptor),
  2051. .hid_report_descriptor = &fanatec_handbrake_hid_report_descriptor[0],
  2052. },
  2053. { /* Artificial test data, not a real device */
  2054. .name = "Fake accelerometer with fewer than usual axes reported",
  2055. .expected = SDL_UDEV_DEVICE_ACCELEROMETER,
  2056. /* SYN, ABS */
  2057. .ev = { 0x09 },
  2058. /* X only */
  2059. .abs = { 0x01 },
  2060. /* ACCELEROMETER */
  2061. .props = { 0x40 },
  2062. },
  2063. { /* Artificial test data, not a real device */
  2064. .name = "Fake pointing stick with no buttons",
  2065. .expected = SDL_UDEV_DEVICE_MOUSE,
  2066. /* SYN, REL */
  2067. .ev = { 0x05 },
  2068. /* X,Y */
  2069. .rel = { 0x03 },
  2070. /* POINTER, POINTING_STICK */
  2071. .props = { 0x21 },
  2072. },
  2073. { /* Artificial test data, not a real device */
  2074. .name = "Fake buttonpad",
  2075. .expected = SDL_UDEV_DEVICE_TOUCHPAD,
  2076. /* SYN, ABS */
  2077. .ev = { 0x09 },
  2078. /* X,Y */
  2079. .abs = { 0x03 },
  2080. /* POINTER, BUTTONPAD */
  2081. .props = { 0x05 },
  2082. },
  2083. {
  2084. .name = "No information",
  2085. .expected = SDL_UDEV_DEVICE_UNKNOWN,
  2086. }
  2087. };
  2088. /* *INDENT-ON* */ /* clang-format on */
  2089. /* The Linux kernel provides capability info in EVIOCGBIT and in /sys
  2090. * as an array of unsigned long in native byte order, rather than an array
  2091. * of bytes, an array of native-endian 32-bit words or an array of
  2092. * native-endian 64-bit words like you might have reasonably expected.
  2093. * The order of words in the array is always lowest-valued first: for
  2094. * instance, the first unsigned long in abs[] contains the bit representing
  2095. * absolute axis 0 (ABS_X).
  2096. *
  2097. * The constant arrays above provide test data in little-endian, because
  2098. * that's the easiest representation for hard-coding into a test like this.
  2099. * On a big-endian platform we need to byteswap it, one unsigned long at a
  2100. * time, to match what the kernel would produce. This requires us to choose
  2101. * an appropriate byteswapping function for the architecture's word size. */
  2102. SDL_COMPILE_TIME_ASSERT(sizeof_long, sizeof(unsigned long) == 4 || sizeof(unsigned long) == 8);
  2103. #define SwapLongLE(X) \
  2104. ((sizeof(unsigned long) == 4) ? SDL_Swap32LE(X) : SDL_Swap64LE(X))
  2105. static int
  2106. run_test(void)
  2107. {
  2108. int success = 1;
  2109. size_t i;
  2110. for (i = 0; i < SDL_arraysize(guess_tests); i++) {
  2111. const GuessTest *t = &guess_tests[i];
  2112. size_t j;
  2113. int actual;
  2114. struct
  2115. {
  2116. unsigned long props[NBITS(INPUT_PROP_MAX)];
  2117. unsigned long ev[NBITS(EV_MAX)];
  2118. unsigned long abs[NBITS(ABS_MAX)];
  2119. unsigned long keys[NBITS(KEY_MAX)];
  2120. unsigned long rel[NBITS(REL_MAX)];
  2121. } caps;
  2122. printf("%s...\n", t->name);
  2123. SDL_memset(&caps, '\0', sizeof(caps));
  2124. SDL_memcpy(caps.props, t->props, sizeof(t->props));
  2125. SDL_memcpy(caps.ev, t->ev, sizeof(t->ev));
  2126. SDL_memcpy(caps.keys, t->keys, sizeof(t->keys));
  2127. SDL_memcpy(caps.abs, t->abs, sizeof(t->abs));
  2128. SDL_memcpy(caps.rel, t->rel, sizeof(t->rel));
  2129. for (j = 0; j < SDL_arraysize(caps.props); j++) {
  2130. caps.props[j] = SwapLongLE(caps.props[j]);
  2131. }
  2132. for (j = 0; j < SDL_arraysize(caps.ev); j++) {
  2133. caps.ev[j] = SwapLongLE(caps.ev[j]);
  2134. }
  2135. for (j = 0; j < SDL_arraysize(caps.keys); j++) {
  2136. caps.keys[j] = SwapLongLE(caps.keys[j]);
  2137. }
  2138. for (j = 0; j < SDL_arraysize(caps.abs); j++) {
  2139. caps.abs[j] = SwapLongLE(caps.abs[j]);
  2140. }
  2141. for (j = 0; j < SDL_arraysize(caps.rel); j++) {
  2142. caps.rel[j] = SwapLongLE(caps.rel[j]);
  2143. }
  2144. actual = SDL_EVDEV_GuessDeviceClass(caps.props, caps.ev, caps.abs,
  2145. caps.keys, caps.rel);
  2146. if (actual == t->expected) {
  2147. printf("\tOK\n");
  2148. } else {
  2149. printf("\tExpected 0x%08x\n", t->expected);
  2150. for (j = 0; device_classes[j].code != 0; j++) {
  2151. if (t->expected & device_classes[j].code) {
  2152. printf("\t\t%s\n", device_classes[j].name);
  2153. }
  2154. }
  2155. printf("\tGot 0x%08x\n", actual);
  2156. for (j = 0; device_classes[j].code != 0; j++) {
  2157. if (actual & device_classes[j].code) {
  2158. printf("\t\t%s\n", device_classes[j].name);
  2159. }
  2160. }
  2161. if (t->todo) {
  2162. printf("\tKnown issue, ignoring: %s\n", t->todo);
  2163. } else {
  2164. printf("\tFailed\n");
  2165. success = 0;
  2166. }
  2167. }
  2168. }
  2169. return success;
  2170. }
  2171. #else /* !(HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX)) */
  2172. static int
  2173. run_test(void)
  2174. {
  2175. printf("SDL compiled without evdev capability check.\n");
  2176. return 1;
  2177. }
  2178. #endif
  2179. int main(int argc, char *argv[])
  2180. {
  2181. int result;
  2182. SDLTest_CommonState *state;
  2183. /* Initialize test framework */
  2184. state = SDLTest_CommonCreateState(argv, 0);
  2185. if (!state) {
  2186. return 1;
  2187. }
  2188. /* Parse commandline */
  2189. if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
  2190. return 1;
  2191. }
  2192. result = run_test() ? 0 : 1;
  2193. SDL_Quit();
  2194. SDLTest_CommonDestroyState(state);
  2195. return result;
  2196. }