SDL_hidapi_xboxone.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
  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, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "../../SDL_internal.h"
  19. #ifdef SDL_JOYSTICK_HIDAPI
  20. #include "SDL_hints.h"
  21. #include "SDL_events.h"
  22. #include "SDL_timer.h"
  23. #include "SDL_joystick.h"
  24. #include "SDL_gamecontroller.h"
  25. #include "../SDL_sysjoystick.h"
  26. #include "SDL_hidapijoystick_c.h"
  27. #include "SDL_hidapi_rumble.h"
  28. #ifdef SDL_JOYSTICK_HIDAPI_XBOXONE
  29. /* Define this if you want to log all packets from the controller */
  30. /*#define DEBUG_XBOX_PROTOCOL*/
  31. /* The amount of time to wait after hotplug to send controller init sequence */
  32. #define CONTROLLER_INIT_DELAY_MS 1500 /* 475 for Xbox One S, 1275 for the PDP Battlefield 1 */
  33. /* The amount of time to wait after init for valid input */
  34. #define CONTROLLER_INPUT_DELAY_MS 50 /* 42 for Razer Wolverine Ultimate */
  35. /* Connect controller */
  36. static const Uint8 xboxone_init0[] = {
  37. 0x04, 0x20, 0x00, 0x00
  38. };
  39. /* Initial ack */
  40. static const Uint8 xboxone_init1[] = {
  41. 0x01, 0x20, 0x01, 0x09, 0x00, 0x04, 0x20, 0x3a,
  42. 0x00, 0x00, 0x00, 0x80, 0x00
  43. };
  44. /* Start controller - extended? */
  45. static const Uint8 xboxone_init2[] = {
  46. 0x05, 0x20, 0x00, 0x0F, 0x06, 0x00, 0x00, 0x00,
  47. 0x00, 0x00, 0x00, 0x55, 0x53, 0x00, 0x00, 0x00,
  48. 0x00, 0x00, 0x00
  49. };
  50. /* Start controller with input */
  51. static const Uint8 xboxone_init3[] = {
  52. 0x05, 0x20, 0x03, 0x01, 0x00
  53. };
  54. /* Enable LED */
  55. static const Uint8 xboxone_init4[] = {
  56. 0x0A, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14
  57. };
  58. /* Start input reports? */
  59. static const Uint8 xboxone_init5[] = {
  60. 0x06, 0x20, 0x00, 0x02, 0x01, 0x00
  61. };
  62. /* Start rumble? */
  63. static const Uint8 xboxone_init6[] = {
  64. 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
  65. 0x00, 0x00, 0xFF, 0x00, 0xEB
  66. };
  67. /*
  68. * This specifies the selection of init packets that a gamepad
  69. * will be sent on init *and* the order in which they will be
  70. * sent. The correct sequence number will be added when the
  71. * packet is going to be sent.
  72. */
  73. typedef struct {
  74. Uint16 vendor_id;
  75. Uint16 product_id;
  76. Uint16 exclude_vendor_id;
  77. Uint16 exclude_product_id;
  78. const Uint8 *data;
  79. int size;
  80. const Uint8 response[2];
  81. } SDL_DriverXboxOne_InitPacket;
  82. static const SDL_DriverXboxOne_InitPacket xboxone_init_packets[] = {
  83. { 0x0000, 0x0000, 0x0000, 0x0000, xboxone_init0, sizeof(xboxone_init0), { 0x04, 0xf0 } },
  84. { 0x0000, 0x0000, 0x0000, 0x0000, xboxone_init1, sizeof(xboxone_init1), { 0x04, 0xb0 } },
  85. { 0x0000, 0x0000, 0x0000, 0x0000, xboxone_init2, sizeof(xboxone_init2), { 0x00, 0x00 } },
  86. { 0x0000, 0x0000, 0x0000, 0x0000, xboxone_init3, sizeof(xboxone_init3), { 0x00, 0x00 } },
  87. { 0x0000, 0x0000, 0x0000, 0x0000, xboxone_init4, sizeof(xboxone_init4), { 0x00, 0x00 } },
  88. /* These next packets are required for third party controllers (PowerA, PDP, HORI),
  89. but aren't the correct protocol for Microsoft Xbox controllers.
  90. */
  91. { 0x0000, 0x0000, 0x045e, 0x0000, xboxone_init5, sizeof(xboxone_init5), { 0x00, 0x00 } },
  92. { 0x0000, 0x0000, 0x045e, 0x0000, xboxone_init6, sizeof(xboxone_init6), { 0x00, 0x00 } },
  93. };
  94. typedef enum {
  95. XBOX_ONE_WIRELESS_PROTOCOL_UNKNOWN,
  96. XBOX_ONE_WIRELESS_PROTOCOL_V1,
  97. XBOX_ONE_WIRELESS_PROTOCOL_V2,
  98. } SDL_XboxOneWirelessProtocol;
  99. typedef struct {
  100. Uint16 vendor_id;
  101. Uint16 product_id;
  102. SDL_bool bluetooth;
  103. SDL_XboxOneWirelessProtocol wireless_protocol;
  104. SDL_bool initialized;
  105. SDL_bool input_ready;
  106. Uint32 start_time;
  107. Uint32 initialized_time;
  108. Uint8 sequence;
  109. Uint8 last_state[USB_PACKET_LENGTH];
  110. SDL_bool has_paddles;
  111. SDL_bool has_share_button;
  112. } SDL_DriverXboxOne_Context;
  113. static SDL_bool
  114. IsBluetoothXboxOneController(Uint16 vendor_id, Uint16 product_id)
  115. {
  116. /* Check to see if it's the Xbox One S or Xbox One Elite Series 2 in Bluetooth mode */
  117. if (vendor_id == USB_VENDOR_MICROSOFT) {
  118. if (product_id == USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH ||
  119. product_id == USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH ||
  120. product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH) {
  121. return SDL_TRUE;
  122. }
  123. }
  124. return SDL_FALSE;
  125. }
  126. static SDL_bool
  127. ControllerHasPaddles(Uint16 vendor_id, Uint16 product_id)
  128. {
  129. return SDL_IsJoystickXboxOneElite(vendor_id, product_id);
  130. }
  131. static SDL_bool
  132. ControllerHasShareButton(Uint16 vendor_id, Uint16 product_id)
  133. {
  134. return SDL_IsJoystickXboxOneSeriesX(vendor_id, product_id);
  135. }
  136. /* Return true if this controller sends the 0x02 "waiting for init" packet */
  137. static SDL_bool
  138. ControllerSendsWaitingForInit(Uint16 vendor_id, Uint16 product_id)
  139. {
  140. if (vendor_id == USB_VENDOR_HYPERKIN) {
  141. /* The Hyperkin controllers always send 0x02 when waiting for init,
  142. and the Hyperkin Duke plays an Xbox startup animation, so we want
  143. to make sure we don't send the init sequence if it isn't needed.
  144. */
  145. return SDL_TRUE;
  146. }
  147. if (vendor_id == USB_VENDOR_PDP) {
  148. /* The PDP Rock Candy (PID 0x0246) doesn't send 0x02 on Linux for some reason */
  149. return SDL_FALSE;
  150. }
  151. /* It doesn't hurt to reinit, especially if a driver has misconfigured the controller */
  152. /*return SDL_TRUE;*/
  153. return SDL_FALSE;
  154. }
  155. static SDL_bool
  156. SendControllerInit(SDL_HIDAPI_Device *device, SDL_DriverXboxOne_Context *ctx)
  157. {
  158. Uint16 vendor_id = ctx->vendor_id;
  159. Uint16 product_id = ctx->product_id;
  160. int i;
  161. Uint8 init_packet[USB_PACKET_LENGTH];
  162. for (i = 0; i < SDL_arraysize(xboxone_init_packets); ++i) {
  163. const SDL_DriverXboxOne_InitPacket *packet = &xboxone_init_packets[i];
  164. if (packet->vendor_id && (vendor_id != packet->vendor_id)) {
  165. continue;
  166. }
  167. if (packet->product_id && (product_id != packet->product_id)) {
  168. continue;
  169. }
  170. if (packet->exclude_vendor_id && (vendor_id == packet->exclude_vendor_id)) {
  171. continue;
  172. }
  173. if (packet->exclude_product_id && (product_id == packet->exclude_product_id)) {
  174. continue;
  175. }
  176. SDL_memcpy(init_packet, packet->data, packet->size);
  177. if (init_packet[0] != 0x01) {
  178. init_packet[2] = ctx->sequence++;
  179. }
  180. if (hid_write(device->dev, init_packet, packet->size) != packet->size) {
  181. SDL_SetError("Couldn't write Xbox One initialization packet");
  182. return SDL_FALSE;
  183. }
  184. if (packet->response[0]) {
  185. const Uint32 RESPONSE_TIMEOUT_MS = 100;
  186. Uint32 start = SDL_GetTicks();
  187. SDL_bool got_response = SDL_FALSE;
  188. while (!got_response && !SDL_TICKS_PASSED(SDL_GetTicks(), start + RESPONSE_TIMEOUT_MS)) {
  189. Uint8 data[USB_PACKET_LENGTH];
  190. int size;
  191. while ((size = hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) {
  192. #ifdef DEBUG_XBOX_PROTOCOL
  193. HIDAPI_DumpPacket("Xbox One INIT packet: size = %d", data, size);
  194. #endif
  195. if (size >= 2 && data[0] == packet->response[0] && data[1] == packet->response[1]) {
  196. got_response = SDL_TRUE;
  197. }
  198. }
  199. }
  200. #ifdef DEBUG_XBOX_PROTOCOL
  201. SDL_Log("Init sequence %d got response after %u ms: %s\n", i, (SDL_GetTicks() - start), got_response ? "TRUE" : "FALSE");
  202. #endif
  203. }
  204. }
  205. return SDL_TRUE;
  206. }
  207. static SDL_bool
  208. HIDAPI_DriverXboxOne_IsSupportedDevice(const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
  209. {
  210. #ifdef __LINUX__
  211. if (vendor_id == USB_VENDOR_POWERA && product_id == 0x541a) {
  212. /* The PowerA Mini controller, model 1240245-01, blocks while writing feature reports */
  213. return SDL_FALSE;
  214. }
  215. #endif
  216. #ifdef __MACOSX__
  217. /* Wired Xbox One controllers are handled by the 360Controller driver */
  218. if (!IsBluetoothXboxOneController(vendor_id, product_id)) {
  219. return SDL_FALSE;
  220. }
  221. #endif
  222. return (type == SDL_CONTROLLER_TYPE_XBOXONE);
  223. }
  224. static const char *
  225. HIDAPI_DriverXboxOne_GetDeviceName(Uint16 vendor_id, Uint16 product_id)
  226. {
  227. return NULL;
  228. }
  229. static SDL_bool
  230. HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device)
  231. {
  232. return HIDAPI_JoystickConnected(device, NULL, SDL_FALSE);
  233. }
  234. static int
  235. HIDAPI_DriverXboxOne_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id)
  236. {
  237. return -1;
  238. }
  239. static void
  240. HIDAPI_DriverXboxOne_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index)
  241. {
  242. }
  243. static SDL_bool
  244. HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
  245. {
  246. SDL_DriverXboxOne_Context *ctx;
  247. ctx = (SDL_DriverXboxOne_Context *)SDL_calloc(1, sizeof(*ctx));
  248. if (!ctx) {
  249. SDL_OutOfMemory();
  250. return SDL_FALSE;
  251. }
  252. device->dev = hid_open_path(device->path, 0);
  253. if (!device->dev) {
  254. SDL_free(ctx);
  255. SDL_SetError("Couldn't open %s", device->path);
  256. return SDL_FALSE;
  257. }
  258. device->context = ctx;
  259. ctx->vendor_id = device->vendor_id;
  260. ctx->product_id = device->product_id;
  261. ctx->bluetooth = IsBluetoothXboxOneController(device->vendor_id, device->product_id);
  262. ctx->initialized = ctx->bluetooth ? SDL_TRUE : SDL_FALSE;
  263. ctx->start_time = SDL_GetTicks();
  264. ctx->input_ready = SDL_TRUE;
  265. ctx->sequence = 1;
  266. ctx->has_paddles = ControllerHasPaddles(ctx->vendor_id, ctx->product_id);
  267. ctx->has_share_button = ControllerHasShareButton(ctx->vendor_id, ctx->product_id);
  268. /* Initialize the joystick capabilities */
  269. joystick->nbuttons = 15;
  270. if (ctx->has_share_button) {
  271. joystick->nbuttons += 1;
  272. }
  273. if (ctx->has_paddles) {
  274. joystick->nbuttons += 4;
  275. }
  276. joystick->naxes = SDL_CONTROLLER_AXIS_MAX;
  277. joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
  278. return SDL_TRUE;
  279. }
  280. static int
  281. HIDAPI_DriverXboxOne_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
  282. {
  283. SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context;
  284. if (ctx->bluetooth) {
  285. Uint8 rumble_packet[] = { 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 };
  286. rumble_packet[4] = (low_frequency_rumble >> 8);
  287. rumble_packet[5] = (high_frequency_rumble >> 8);
  288. if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
  289. return SDL_SetError("Couldn't send rumble packet");
  290. }
  291. } else {
  292. Uint8 rumble_packet[] = { 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF };
  293. /* Magnitude is 1..100 so scale the 16-bit input here */
  294. rumble_packet[8] = low_frequency_rumble / 655;
  295. rumble_packet[9] = high_frequency_rumble / 655;
  296. if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
  297. return SDL_SetError("Couldn't send rumble packet");
  298. }
  299. }
  300. return 0;
  301. }
  302. static int
  303. HIDAPI_DriverXboxOne_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
  304. {
  305. return SDL_Unsupported();
  306. }
  307. static SDL_bool
  308. HIDAPI_DriverXboxOne_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
  309. {
  310. /* Doesn't have an RGB LED, so don't return true here */
  311. return SDL_FALSE;
  312. }
  313. static int
  314. HIDAPI_DriverXboxOne_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
  315. {
  316. return SDL_Unsupported();
  317. }
  318. static void
  319. HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
  320. {
  321. Sint16 axis;
  322. if (ctx->last_state[4] != data[4]) {
  323. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, (data[4] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
  324. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, (data[4] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
  325. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[4] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
  326. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B, (data[4] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
  327. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X, (data[4] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
  328. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y, (data[4] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
  329. }
  330. if (ctx->last_state[5] != data[5]) {
  331. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, (data[5] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  332. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, (data[5] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
  333. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, (data[5] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
  334. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, (data[5] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
  335. if (ctx->vendor_id == USB_VENDOR_RAZER && ctx->product_id == USB_PRODUCT_RAZER_ATROX) {
  336. /* The Razer Atrox has the right and left shoulder bits reversed */
  337. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, (data[5] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
  338. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, (data[5] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
  339. } else {
  340. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, (data[5] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
  341. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, (data[5] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
  342. }
  343. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data[5] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
  344. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data[5] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
  345. }
  346. if (ctx->has_share_button && ctx->last_state[18] != data[18]) {
  347. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[18] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  348. }
  349. /* Xbox One S report is 18 bytes
  350. Xbox One Elite Series 1 report is 33 bytes, paddles in data[32], mode in data[32] & 0x10, both modes have mapped paddles by default
  351. Paddle bits:
  352. P3: 0x01 (A) P1: 0x02 (B)
  353. P4: 0x04 (X) P2: 0x08 (Y)
  354. Xbox One Elite Series 2 report is 38 bytes, paddles in data[18], mode in data[19], mode 0 has no mapped paddles by default
  355. Paddle bits:
  356. P3: 0x04 (A) P1: 0x01 (B)
  357. P4: 0x08 (X) P2: 0x02 (Y)
  358. */
  359. if (ctx->has_paddles && (size == 33 || size == 38)) {
  360. int paddle_index;
  361. int button1_bit;
  362. int button2_bit;
  363. int button3_bit;
  364. int button4_bit;
  365. SDL_bool paddles_mapped;
  366. if (size == 33) {
  367. /* XBox One Elite Series 1 */
  368. paddle_index = 32;
  369. button1_bit = 0x02;
  370. button2_bit = 0x08;
  371. button3_bit = 0x01;
  372. button4_bit = 0x04;
  373. /* The mapped controller state is at offset 4, the raw state is at offset 18, compare them to see if the paddles are mapped */
  374. paddles_mapped = (SDL_memcmp(&data[4], &data[18], 14) != 0);
  375. } else /* if (size == 38) */ {
  376. /* XBox One Elite Series 2 */
  377. paddle_index = 18;
  378. button1_bit = 0x01;
  379. button2_bit = 0x02;
  380. button3_bit = 0x04;
  381. button4_bit = 0x08;
  382. paddles_mapped = (data[19] != 0);
  383. }
  384. #ifdef DEBUG_XBOX_PROTOCOL
  385. SDL_Log(">>> Paddles: %d,%d,%d,%d mapped = %s\n",
  386. (data[paddle_index] & button1_bit) ? 1 : 0,
  387. (data[paddle_index] & button2_bit) ? 1 : 0,
  388. (data[paddle_index] & button3_bit) ? 1 : 0,
  389. (data[paddle_index] & button4_bit) ? 1 : 0,
  390. paddles_mapped ? "TRUE" : "FALSE"
  391. );
  392. #endif
  393. if (paddles_mapped) {
  394. /* Respect that the paddles are being used for other controls and don't pass them on to the app */
  395. data[paddle_index] = 0;
  396. }
  397. if (ctx->last_state[paddle_index] != data[paddle_index]) {
  398. int nButton = SDL_CONTROLLER_BUTTON_MISC1 + ctx->has_share_button;
  399. SDL_PrivateJoystickButton(joystick, nButton++, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED);
  400. SDL_PrivateJoystickButton(joystick, nButton++, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED);
  401. SDL_PrivateJoystickButton(joystick, nButton++, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED);
  402. SDL_PrivateJoystickButton(joystick, nButton++, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED);
  403. }
  404. }
  405. axis = ((int)*(Sint16*)(&data[6]) * 64) - 32768;
  406. if (axis == 32704) {
  407. axis = 32767;
  408. }
  409. if (axis == -32768 && size == 30 && (data[22] & 0x80) != 0) {
  410. axis = 32767;
  411. }
  412. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
  413. axis = ((int)*(Sint16*)(&data[8]) * 64) - 32768;
  414. if (axis == -32768 && size == 30 && (data[22] & 0x40) != 0) {
  415. axis = 32767;
  416. }
  417. if (axis == 32704) {
  418. axis = 32767;
  419. }
  420. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
  421. axis = *(Sint16*)(&data[10]);
  422. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
  423. axis = *(Sint16*)(&data[12]);
  424. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, ~axis);
  425. axis = *(Sint16*)(&data[14]);
  426. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis);
  427. axis = *(Sint16*)(&data[16]);
  428. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, ~axis);
  429. SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
  430. }
  431. static void
  432. HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, hid_device *dev, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
  433. {
  434. if (data[1] == 0x30) {
  435. /* The Xbox One S controller needs acks for mode reports */
  436. const Uint8 seqnum = data[2];
  437. const Uint8 ack[] = { 0x01, 0x20, seqnum, 0x09, 0x00, 0x07, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 };
  438. hid_write(dev, ack, sizeof(ack));
  439. }
  440. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[4] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  441. }
  442. static void
  443. HIDAPI_DriverXboxOneBluetooth_HandleStatePacketV1(SDL_Joystick *joystick, hid_device *dev, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
  444. {
  445. Sint16 axis;
  446. if (ctx->last_state[14] != data[14]) {
  447. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  448. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
  449. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X, (data[14] & 0x04) ? SDL_PRESSED : SDL_RELEASED);
  450. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
  451. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
  452. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, (data[14] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
  453. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, (data[14] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
  454. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, (data[14] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
  455. }
  456. if (ctx->last_state[15] != data[15]) {
  457. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data[15] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  458. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data[15] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
  459. }
  460. if (ctx->last_state[13] != data[13]) {
  461. SDL_bool dpad_up = SDL_FALSE;
  462. SDL_bool dpad_down = SDL_FALSE;
  463. SDL_bool dpad_left = SDL_FALSE;
  464. SDL_bool dpad_right = SDL_FALSE;
  465. switch (data[13]) {
  466. case 1:
  467. dpad_up = SDL_TRUE;
  468. break;
  469. case 2:
  470. dpad_up = SDL_TRUE;
  471. dpad_right = SDL_TRUE;
  472. break;
  473. case 3:
  474. dpad_right = SDL_TRUE;
  475. break;
  476. case 4:
  477. dpad_right = SDL_TRUE;
  478. dpad_down = SDL_TRUE;
  479. break;
  480. case 5:
  481. dpad_down = SDL_TRUE;
  482. break;
  483. case 6:
  484. dpad_left = SDL_TRUE;
  485. dpad_down = SDL_TRUE;
  486. break;
  487. case 7:
  488. dpad_left = SDL_TRUE;
  489. break;
  490. case 8:
  491. dpad_up = SDL_TRUE;
  492. dpad_left = SDL_TRUE;
  493. break;
  494. default:
  495. break;
  496. }
  497. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_down);
  498. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_up);
  499. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, dpad_right);
  500. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left);
  501. }
  502. axis = (int)*(Uint16*)(&data[1]) - 0x8000;
  503. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
  504. axis = (int)*(Uint16*)(&data[3]) - 0x8000;
  505. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, axis);
  506. axis = (int)*(Uint16*)(&data[5]) - 0x8000;
  507. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis);
  508. axis = (int)*(Uint16*)(&data[7]) - 0x8000;
  509. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
  510. axis = ((int)*(Sint16*)(&data[9]) * 64) - 32768;
  511. if (axis == 32704) {
  512. axis = 32767;
  513. }
  514. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
  515. axis = ((int)*(Sint16*)(&data[11]) * 64) - 32768;
  516. if (axis == 32704) {
  517. axis = 32767;
  518. }
  519. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
  520. SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
  521. }
  522. static void
  523. HIDAPI_DriverXboxOneBluetooth_HandleStatePacketV2(SDL_Joystick *joystick, hid_device *dev, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
  524. {
  525. Sint16 axis;
  526. if (ctx->last_state[14] != data[14]) {
  527. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[14] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  528. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B, (data[14] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
  529. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X, (data[14] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
  530. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y, (data[14] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
  531. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, (data[14] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
  532. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, (data[14] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
  533. }
  534. if (ctx->last_state[15] != data[15]) {
  535. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, (data[15] & 0x08) ? SDL_PRESSED : SDL_RELEASED);
  536. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data[15] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
  537. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data[15] & 0x40) ? SDL_PRESSED : SDL_RELEASED);
  538. if (ctx->wireless_protocol == XBOX_ONE_WIRELESS_PROTOCOL_UNKNOWN)
  539. {
  540. if (data[15] & 0x10) {
  541. ctx->wireless_protocol = XBOX_ONE_WIRELESS_PROTOCOL_V2;
  542. }
  543. }
  544. if (ctx->wireless_protocol == XBOX_ONE_WIRELESS_PROTOCOL_V2)
  545. {
  546. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[15] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
  547. }
  548. }
  549. if (ctx->last_state[16] != data[16]) {
  550. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, (data[16] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  551. }
  552. if (ctx->last_state[13] != data[13]) {
  553. SDL_bool dpad_up = SDL_FALSE;
  554. SDL_bool dpad_down = SDL_FALSE;
  555. SDL_bool dpad_left = SDL_FALSE;
  556. SDL_bool dpad_right = SDL_FALSE;
  557. switch (data[13]) {
  558. case 1:
  559. dpad_up = SDL_TRUE;
  560. break;
  561. case 2:
  562. dpad_up = SDL_TRUE;
  563. dpad_right = SDL_TRUE;
  564. break;
  565. case 3:
  566. dpad_right = SDL_TRUE;
  567. break;
  568. case 4:
  569. dpad_right = SDL_TRUE;
  570. dpad_down = SDL_TRUE;
  571. break;
  572. case 5:
  573. dpad_down = SDL_TRUE;
  574. break;
  575. case 6:
  576. dpad_left = SDL_TRUE;
  577. dpad_down = SDL_TRUE;
  578. break;
  579. case 7:
  580. dpad_left = SDL_TRUE;
  581. break;
  582. case 8:
  583. dpad_up = SDL_TRUE;
  584. dpad_left = SDL_TRUE;
  585. break;
  586. default:
  587. break;
  588. }
  589. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_down);
  590. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_up);
  591. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, dpad_right);
  592. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left);
  593. }
  594. /*
  595. Paddle bits:
  596. P3: 0x04 (A) P1: 0x01 (B)
  597. P4: 0x08 (X) P2: 0x02 (Y)
  598. */
  599. if (ctx->has_paddles && (size == 39 || size == 55)) {
  600. int paddle_index;
  601. int button1_bit;
  602. int button2_bit;
  603. int button3_bit;
  604. int button4_bit;
  605. SDL_bool paddles_mapped;
  606. if (size == 55) {
  607. /* Initial firmware for the Xbox Elite Series 2 controller */
  608. paddle_index = 33;
  609. button1_bit = 0x01;
  610. button2_bit = 0x02;
  611. button3_bit = 0x04;
  612. button4_bit = 0x08;
  613. paddles_mapped = (data[35] != 0);
  614. } else /* if (size == 39) */ {
  615. /* Updated firmware for the Xbox Elite Series 2 controller */
  616. paddle_index = 17;
  617. button1_bit = 0x01;
  618. button2_bit = 0x02;
  619. button3_bit = 0x04;
  620. button4_bit = 0x08;
  621. paddles_mapped = (data[19] != 0);
  622. }
  623. #ifdef DEBUG_XBOX_PROTOCOL
  624. SDL_Log(">>> Paddles: %d,%d,%d,%d mapped = %s\n",
  625. (data[paddle_index] & button1_bit) ? 1 : 0,
  626. (data[paddle_index] & button2_bit) ? 1 : 0,
  627. (data[paddle_index] & button3_bit) ? 1 : 0,
  628. (data[paddle_index] & button4_bit) ? 1 : 0,
  629. paddles_mapped ? "TRUE" : "FALSE"
  630. );
  631. #endif
  632. if (paddles_mapped) {
  633. /* Respect that the paddles are being used for other controls and don't pass them on to the app */
  634. data[paddle_index] = 0;
  635. }
  636. if (ctx->last_state[paddle_index] != data[paddle_index]) {
  637. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 0, (data[paddle_index] & button1_bit) ? SDL_PRESSED : SDL_RELEASED);
  638. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 1, (data[paddle_index] & button2_bit) ? SDL_PRESSED : SDL_RELEASED);
  639. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 2, (data[paddle_index] & button3_bit) ? SDL_PRESSED : SDL_RELEASED);
  640. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1 + 3, (data[paddle_index] & button4_bit) ? SDL_PRESSED : SDL_RELEASED);
  641. }
  642. }
  643. axis = (int)*(Uint16*)(&data[1]) - 0x8000;
  644. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
  645. axis = (int)*(Uint16*)(&data[3]) - 0x8000;
  646. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, axis);
  647. axis = (int)*(Uint16*)(&data[5]) - 0x8000;
  648. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis);
  649. axis = (int)*(Uint16*)(&data[7]) - 0x8000;
  650. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
  651. axis = ((int)*(Sint16*)(&data[9]) * 64) - 32768;
  652. if (axis == 32704) {
  653. axis = 32767;
  654. }
  655. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
  656. axis = ((int)*(Sint16*)(&data[11]) * 64) - 32768;
  657. if (axis == 32704) {
  658. axis = 32767;
  659. }
  660. SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
  661. SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
  662. }
  663. static void
  664. HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(SDL_Joystick *joystick, hid_device *dev, SDL_DriverXboxOne_Context *ctx, Uint8 *data, int size)
  665. {
  666. ctx->wireless_protocol = XBOX_ONE_WIRELESS_PROTOCOL_V1;
  667. SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
  668. }
  669. static SDL_bool
  670. HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device)
  671. {
  672. SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)device->context;
  673. SDL_Joystick *joystick = NULL;
  674. Uint8 data[USB_PACKET_LENGTH];
  675. int size;
  676. if (device->num_joysticks > 0) {
  677. joystick = SDL_JoystickFromInstanceID(device->joysticks[0]);
  678. }
  679. if (!joystick) {
  680. return SDL_FALSE;
  681. }
  682. if (!ctx->initialized &&
  683. !ControllerSendsWaitingForInit(device->vendor_id, device->product_id)) {
  684. if (SDL_TICKS_PASSED(SDL_GetTicks(), ctx->start_time + CONTROLLER_INIT_DELAY_MS)) {
  685. if (!SendControllerInit(device, ctx)) {
  686. HIDAPI_JoystickDisconnected(device, joystick->instance_id, SDL_FALSE);
  687. return SDL_FALSE;
  688. }
  689. ctx->initialized = SDL_TRUE;
  690. ctx->initialized_time = SDL_GetTicks();
  691. ctx->input_ready = SDL_FALSE;
  692. }
  693. }
  694. while ((size = hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) {
  695. #ifdef DEBUG_XBOX_PROTOCOL
  696. HIDAPI_DumpPacket("Xbox One packet: size = %d", data, size);
  697. #endif
  698. if (ctx->bluetooth) {
  699. switch (data[0]) {
  700. case 0x01:
  701. if (size == 16) {
  702. HIDAPI_DriverXboxOneBluetooth_HandleStatePacketV1(joystick, device->dev, ctx, data, size);
  703. } else if (size > 16) {
  704. HIDAPI_DriverXboxOneBluetooth_HandleStatePacketV2(joystick, device->dev, ctx, data, size);
  705. } else {
  706. #ifdef DEBUG_JOYSTICK
  707. SDL_Log("Unknown Xbox One Bluetooth packet size: %d\n", size);
  708. #endif
  709. }
  710. break;
  711. case 0x02:
  712. HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(joystick, device->dev, ctx, data, size);
  713. break;
  714. default:
  715. #ifdef DEBUG_JOYSTICK
  716. SDL_Log("Unknown Xbox One packet: 0x%.2x\n", data[0]);
  717. #endif
  718. break;
  719. }
  720. } else {
  721. switch (data[0]) {
  722. case 0x02:
  723. /* Controller is connected and waiting for initialization */
  724. if (!ctx->initialized) {
  725. #ifdef DEBUG_XBOX_PROTOCOL
  726. SDL_Log("Delay after init: %ums\n", SDL_GetTicks() - ctx->start_time);
  727. #endif
  728. if (!SendControllerInit(device, ctx)) {
  729. HIDAPI_JoystickDisconnected(device, joystick->instance_id, SDL_FALSE);
  730. return SDL_FALSE;
  731. }
  732. ctx->initialized = SDL_TRUE;
  733. ctx->initialized_time = SDL_GetTicks();
  734. ctx->input_ready = SDL_FALSE;
  735. }
  736. break;
  737. case 0x03:
  738. /* Controller heartbeat */
  739. break;
  740. case 0x20:
  741. if (!ctx->input_ready) {
  742. if (!SDL_TICKS_PASSED(SDL_GetTicks(), ctx->initialized_time + CONTROLLER_INPUT_DELAY_MS)) {
  743. #ifdef DEBUG_XBOX_PROTOCOL
  744. SDL_Log("Spurious input at %ums\n", SDL_GetTicks() - ctx->initialized_time);
  745. #endif
  746. break;
  747. }
  748. ctx->input_ready = SDL_TRUE;
  749. }
  750. HIDAPI_DriverXboxOne_HandleStatePacket(joystick, device->dev, ctx, data, size);
  751. break;
  752. case 0x07:
  753. HIDAPI_DriverXboxOne_HandleModePacket(joystick, device->dev, ctx, data, size);
  754. break;
  755. default:
  756. #ifdef DEBUG_JOYSTICK
  757. SDL_Log("Unknown Xbox One packet: 0x%.2x\n", data[0]);
  758. #endif
  759. break;
  760. }
  761. }
  762. }
  763. if (size < 0) {
  764. /* Read error, device is disconnected */
  765. HIDAPI_JoystickDisconnected(device, joystick->instance_id, SDL_FALSE);
  766. }
  767. return (size >= 0);
  768. }
  769. static void
  770. HIDAPI_DriverXboxOne_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
  771. {
  772. hid_close(device->dev);
  773. device->dev = NULL;
  774. SDL_free(device->context);
  775. device->context = NULL;
  776. }
  777. static void
  778. HIDAPI_DriverXboxOne_FreeDevice(SDL_HIDAPI_Device *device)
  779. {
  780. }
  781. SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne =
  782. {
  783. SDL_HINT_JOYSTICK_HIDAPI_XBOX,
  784. SDL_TRUE,
  785. HIDAPI_DriverXboxOne_IsSupportedDevice,
  786. HIDAPI_DriverXboxOne_GetDeviceName,
  787. HIDAPI_DriverXboxOne_InitDevice,
  788. HIDAPI_DriverXboxOne_GetDevicePlayerIndex,
  789. HIDAPI_DriverXboxOne_SetDevicePlayerIndex,
  790. HIDAPI_DriverXboxOne_UpdateDevice,
  791. HIDAPI_DriverXboxOne_OpenJoystick,
  792. HIDAPI_DriverXboxOne_RumbleJoystick,
  793. HIDAPI_DriverXboxOne_RumbleJoystickTriggers,
  794. HIDAPI_DriverXboxOne_HasJoystickLED,
  795. HIDAPI_DriverXboxOne_SetJoystickLED,
  796. HIDAPI_DriverXboxOne_CloseJoystick,
  797. HIDAPI_DriverXboxOne_FreeDevice,
  798. NULL
  799. };
  800. #endif /* SDL_JOYSTICK_HIDAPI_XBOXONE */
  801. #endif /* SDL_JOYSTICK_HIDAPI */
  802. /* vi: set ts=4 sw=4 expandtab: */