SDL  2.0
SDL_hidapi_ps4.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 /* This driver supports both simplified reports and the extended input reports enabled by Steam.
22  Code and logic contributed by Valve Corporation under the SDL zlib license.
23 */
24 #include "../../SDL_internal.h"
25 
26 #ifdef SDL_JOYSTICK_HIDAPI
27 
28 #include "SDL_hints.h"
29 #include "SDL_log.h"
30 #include "SDL_events.h"
31 #include "SDL_timer.h"
32 #include "SDL_joystick.h"
33 #include "SDL_gamecontroller.h"
34 #include "../SDL_sysjoystick.h"
35 #include "SDL_hidapijoystick_c.h"
36 #include "SDL_hidapi_rumble.h"
37 
38 
39 #ifdef SDL_JOYSTICK_HIDAPI_PS4
40 
41 typedef enum
42 {
43  k_EPS4ReportIdUsbState = 1,
44  k_EPS4ReportIdUsbEffects = 5,
45  k_EPS4ReportIdBluetoothState = 17,
46  k_EPS4ReportIdBluetoothEffects = 17,
47  k_EPS4ReportIdDisconnectMessage = 226,
48 } EPS4ReportId;
49 
50 typedef enum
51 {
52  k_ePS4FeatureReportIdGyroCalibration_USB = 0x02,
53  k_ePS4FeatureReportIdGyroCalibration_BT = 0x05,
54  k_ePS4FeatureReportIdSerialNumber = 0x12,
55 } EPS4FeatureReportID;
56 
57 typedef struct
58 {
59  Uint8 ucLeftJoystickX;
60  Uint8 ucLeftJoystickY;
61  Uint8 ucRightJoystickX;
62  Uint8 ucRightJoystickY;
63  Uint8 rgucButtonsHatAndCounter[ 3 ];
64  Uint8 ucTriggerLeft;
65  Uint8 ucTriggerRight;
66  Uint8 _rgucPad0[ 3 ];
67  Sint16 sGyroX;
68  Sint16 sGyroY;
69  Sint16 sGyroZ;
70  Sint16 sAccelX;
71  Sint16 sAccelY;
72  Sint16 sAccelZ;
73  Uint8 _rgucPad1[ 5 ];
74  Uint8 ucBatteryLevel;
75  Uint8 _rgucPad2[ 4 ];
76  Uint8 ucTrackpadCounter1;
77  Uint8 rgucTrackpadData1[ 3 ];
78  Uint8 ucTrackpadCounter2;
79  Uint8 rgucTrackpadData2[ 3 ];
80 } PS4StatePacket_t;
81 
82 typedef struct
83 {
84  Uint8 ucRumbleRight;
85  Uint8 ucRumbleLeft;
86  Uint8 ucLedRed;
87  Uint8 ucLedGreen;
88  Uint8 ucLedBlue;
89  Uint8 ucLedDelayOn;
90  Uint8 ucLedDelayOff;
91  Uint8 _rgucPad0[ 8 ];
92  Uint8 ucVolumeLeft;
93  Uint8 ucVolumeRight;
94  Uint8 ucVolumeMic;
95  Uint8 ucVolumeSpeaker;
96 } DS4EffectsState_t;
97 
98 typedef struct {
99  SDL_bool is_dongle;
100  SDL_bool is_bluetooth;
101  SDL_bool audio_supported;
102  SDL_bool rumble_supported;
103  int player_index;
104  Uint8 volume;
105  Uint32 last_volume_check;
106  PS4StatePacket_t last_state;
107 } SDL_DriverPS4_Context;
108 
109 
110 /* Public domain CRC implementation adapted from:
111  http://home.thep.lu.se/~bjorn/crc/crc32_simple.c
112 */
113 static Uint32 crc32_for_byte(Uint32 r)
114 {
115  int i;
116  for(i = 0; i < 8; ++i) {
117  r = (r & 1? 0: (Uint32)0xEDB88320L) ^ r >> 1;
118  }
119  return r ^ (Uint32)0xFF000000L;
120 }
121 
122 static Uint32 crc32(Uint32 crc, const void *data, int count)
123 {
124  int i;
125  for(i = 0; i < count; ++i) {
126  crc = crc32_for_byte((Uint8)crc ^ ((const Uint8*)data)[i]) ^ crc >> 8;
127  }
128  return crc;
129 }
130 
131 static SDL_bool
132 HIDAPI_DriverPS4_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)
133 {
134  return (type == SDL_CONTROLLER_TYPE_PS4);
135 }
136 
137 static const char *
138 HIDAPI_DriverPS4_GetDeviceName(Uint16 vendor_id, Uint16 product_id)
139 {
140  if (vendor_id == USB_VENDOR_SONY) {
141  return "PS4 Controller";
142  }
143  return NULL;
144 }
145 
146 static SDL_bool ReadFeatureReport(hid_device *dev, Uint8 report_id, Uint8 *data, size_t size)
147 {
148  Uint8 report[USB_PACKET_LENGTH + 1];
149 
150  SDL_memset(report, 0, sizeof(report));
151  report[0] = report_id;
152  if (hid_get_feature_report(dev, report, sizeof(report)) < 0) {
153  return SDL_FALSE;
154  }
155  SDL_memcpy(data, report, SDL_min(size, sizeof(report)));
156  return SDL_TRUE;
157 }
158 
159 static SDL_bool CheckUSBConnected(hid_device *dev)
160 {
161  int i;
162  Uint8 data[16];
163 
164  /* This will fail if we're on Bluetooth */
165  if (ReadFeatureReport(dev, k_ePS4FeatureReportIdSerialNumber, data, sizeof(data))) {
166  for (i = 0; i < sizeof(data); ++i) {
167  if (data[i] != 0x00) {
168  return SDL_TRUE;
169  }
170  }
171  /* Maybe the dongle without a connected controller? */
172  }
173  return SDL_FALSE;
174 }
175 
176 static SDL_bool HIDAPI_DriverPS4_CanRumble(Uint16 vendor_id, Uint16 product_id)
177 {
178  /* The Razer Panthera fight stick hangs when trying to rumble */
179  if (vendor_id == USB_VENDOR_RAZER &&
180  (product_id == USB_PRODUCT_RAZER_PANTHERA || product_id == USB_PRODUCT_RAZER_PANTHERA_EVO)) {
181  return SDL_FALSE;
182  }
183  return SDL_TRUE;
184 }
185 
186 static void
187 SetLedsForPlayerIndex(DS4EffectsState_t *effects, int player_index)
188 {
189  /* This list is the same as what hid-sony.c uses in the Linux kernel.
190  The first 4 values correspond to what the PS4 assigns.
191  */
192  static const Uint8 colors[7][3] = {
193  { 0x00, 0x00, 0x40 }, /* Blue */
194  { 0x40, 0x00, 0x00 }, /* Red */
195  { 0x00, 0x40, 0x00 }, /* Green */
196  { 0x20, 0x00, 0x20 }, /* Pink */
197  { 0x02, 0x01, 0x00 }, /* Orange */
198  { 0x00, 0x01, 0x01 }, /* Teal */
199  { 0x01, 0x01, 0x01 } /* White */
200  };
201 
202  if (player_index >= 0) {
203  player_index %= SDL_arraysize(colors);
204  } else {
205  player_index = 0;
206  }
207 
208  effects->ucLedRed = colors[player_index][0];
209  effects->ucLedGreen = colors[player_index][1];
210  effects->ucLedBlue = colors[player_index][2];
211 }
212 
213 static SDL_bool
214 HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
215 {
217 }
218 
219 static int
220 HIDAPI_DriverPS4_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id)
221 {
222  return -1;
223 }
224 
225 static int HIDAPI_DriverPS4_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble);
226 
227 static void
228 HIDAPI_DriverPS4_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index)
229 {
230  SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context;
231 
232  if (!ctx) {
233  return;
234  }
235 
236  ctx->player_index = player_index;
237 
238  /* This will set the new LED state based on the new player index */
239  HIDAPI_DriverPS4_RumbleJoystick(device, SDL_JoystickFromInstanceID(instance_id), 0, 0);
240 }
241 
242 static SDL_bool
243 HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
244 {
245  SDL_DriverPS4_Context *ctx;
246 
247  ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx));
248  if (!ctx) {
249  SDL_OutOfMemory();
250  return SDL_FALSE;
251  }
252 
253  device->dev = hid_open_path(device->path, 0);
254  if (!device->dev) {
255  SDL_free(ctx);
256  SDL_SetError("Couldn't open %s", device->path);
257  return SDL_FALSE;
258  }
259  device->context = ctx;
260 
261  /* Check for type of connection */
262  ctx->is_dongle = (device->vendor_id == USB_VENDOR_SONY && device->product_id == USB_PRODUCT_SONY_DS4_DONGLE);
263  if (ctx->is_dongle) {
264  ctx->is_bluetooth = SDL_FALSE;
265  } else if (device->vendor_id == USB_VENDOR_SONY) {
266  ctx->is_bluetooth = !CheckUSBConnected(device->dev);
267  } else {
268  /* Third party controllers appear to all be wired */
269  ctx->is_bluetooth = SDL_FALSE;
270  }
271 #ifdef DEBUG_PS4
272  SDL_Log("PS4 dongle = %s, bluetooth = %s\n", ctx->is_dongle ? "TRUE" : "FALSE", ctx->is_bluetooth ? "TRUE" : "FALSE");
273 #endif
274 
275  /* Check to see if audio is supported */
276  if (device->vendor_id == USB_VENDOR_SONY &&
277  (device->product_id == USB_PRODUCT_SONY_DS4_SLIM || device->product_id == USB_PRODUCT_SONY_DS4_DONGLE)) {
278  ctx->audio_supported = SDL_TRUE;
279  }
280 
281  if (HIDAPI_DriverPS4_CanRumble(device->vendor_id, device->product_id)) {
282  if (ctx->is_bluetooth) {
284  } else {
285  ctx->rumble_supported = SDL_TRUE;
286  }
287  }
288 
289  /* Initialize player index (needed for setting LEDs) */
290  ctx->player_index = SDL_JoystickGetPlayerIndex(joystick);
291 
292  /* Initialize LED and effect state */
293  HIDAPI_DriverPS4_RumbleJoystick(device, joystick, 0, 0);
294 
295  /* Initialize the joystick capabilities */
296  joystick->nbuttons = 16;
297  joystick->naxes = SDL_CONTROLLER_AXIS_MAX;
298  joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
299 
300  return SDL_TRUE;
301 }
302 
303 static int
304 HIDAPI_DriverPS4_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
305 {
306  SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context;
307  DS4EffectsState_t *effects;
308  Uint8 data[78];
309  int report_size, offset;
310 
311  if (!ctx->rumble_supported) {
312  return SDL_Unsupported();
313  }
314 
315  /* In order to send rumble, we have to send a complete effect packet */
316  SDL_memset(data, 0, sizeof(data));
317 
318  if (ctx->is_bluetooth) {
319  data[0] = k_EPS4ReportIdBluetoothEffects;
320  data[1] = 0xC0 | 0x04; /* Magic value HID + CRC, also sets interval to 4ms for samples */
321  data[3] = 0x03; /* 0x1 is rumble, 0x2 is lightbar, 0x4 is the blink interval */
322 
323  report_size = 78;
324  offset = 6;
325  } else {
326  data[0] = k_EPS4ReportIdUsbEffects;
327  data[1] = 0x07; /* Magic value */
328 
329  report_size = 32;
330  offset = 4;
331  }
332  effects = (DS4EffectsState_t *)&data[offset];
333 
334  effects->ucRumbleLeft = (low_frequency_rumble >> 8);
335  effects->ucRumbleRight = (high_frequency_rumble >> 8);
336 
337  /* Populate the LED state with the appropriate color from our lookup table */
338  SetLedsForPlayerIndex(effects, ctx->player_index);
339 
340  if (ctx->is_bluetooth) {
341  /* Bluetooth reports need a CRC at the end of the packet (at least on Linux) */
342  Uint8 ubHdr = 0xA2; /* hidp header is part of the CRC calculation */
343  Uint32 unCRC;
344  unCRC = crc32(0, &ubHdr, 1);
345  unCRC = crc32(unCRC, data, (Uint32)(report_size - sizeof(unCRC)));
346  SDL_memcpy(&data[report_size - sizeof(unCRC)], &unCRC, sizeof(unCRC));
347  }
348 
349  if (SDL_HIDAPI_SendRumble(device, data, report_size) != report_size) {
350  return SDL_SetError("Couldn't send rumble packet");
351  }
352  return 0;
353 }
354 
355 static void
356 HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, SDL_DriverPS4_Context *ctx, PS4StatePacket_t *packet)
357 {
358  Sint16 axis;
359 
360  if (ctx->last_state.rgucButtonsHatAndCounter[0] != packet->rgucButtonsHatAndCounter[0]) {
361  {
362  Uint8 data = (packet->rgucButtonsHatAndCounter[0] >> 4);
363 
368  }
369  {
370  Uint8 data = (packet->rgucButtonsHatAndCounter[0] & 0x0F);
371  SDL_bool dpad_up = SDL_FALSE;
372  SDL_bool dpad_down = SDL_FALSE;
373  SDL_bool dpad_left = SDL_FALSE;
374  SDL_bool dpad_right = SDL_FALSE;
375 
376  switch (data) {
377  case 0:
378  dpad_up = SDL_TRUE;
379  break;
380  case 1:
381  dpad_up = SDL_TRUE;
382  dpad_right = SDL_TRUE;
383  break;
384  case 2:
385  dpad_right = SDL_TRUE;
386  break;
387  case 3:
388  dpad_right = SDL_TRUE;
389  dpad_down = SDL_TRUE;
390  break;
391  case 4:
392  dpad_down = SDL_TRUE;
393  break;
394  case 5:
395  dpad_left = SDL_TRUE;
396  dpad_down = SDL_TRUE;
397  break;
398  case 6:
399  dpad_left = SDL_TRUE;
400  break;
401  case 7:
402  dpad_up = SDL_TRUE;
403  dpad_left = SDL_TRUE;
404  break;
405  default:
406  break;
407  }
412  }
413  }
414 
415  if (ctx->last_state.rgucButtonsHatAndCounter[1] != packet->rgucButtonsHatAndCounter[1]) {
416  Uint8 data = packet->rgucButtonsHatAndCounter[1];
417 
424  }
425 
426  if (ctx->last_state.rgucButtonsHatAndCounter[2] != packet->rgucButtonsHatAndCounter[2]) {
427  Uint8 data = (packet->rgucButtonsHatAndCounter[2] & 0x03);
428 
430  SDL_PrivateJoystickButton(joystick, 15, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
431  }
432 
433  axis = ((int)packet->ucTriggerLeft * 257) - 32768;
435  axis = ((int)packet->ucTriggerRight * 257) - 32768;
437  axis = ((int)packet->ucLeftJoystickX * 257) - 32768;
439  axis = ((int)packet->ucLeftJoystickY * 257) - 32768;
441  axis = ((int)packet->ucRightJoystickX * 257) - 32768;
443  axis = ((int)packet->ucRightJoystickY * 257) - 32768;
445 
446  if (packet->ucBatteryLevel & 0x10) {
447  joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
448  } else {
449  /* Battery level ranges from 0 to 10 */
450  int level = (packet->ucBatteryLevel & 0xF);
451  if (level == 0) {
452  joystick->epowerlevel = SDL_JOYSTICK_POWER_EMPTY;
453  } else if (level <= 2) {
454  joystick->epowerlevel = SDL_JOYSTICK_POWER_LOW;
455  } else if (level <= 7) {
456  joystick->epowerlevel = SDL_JOYSTICK_POWER_MEDIUM;
457  } else {
458  joystick->epowerlevel = SDL_JOYSTICK_POWER_FULL;
459  }
460  }
461 
462  SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state));
463 }
464 
465 static SDL_bool
466 HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device)
467 {
468  SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context;
469  SDL_Joystick *joystick = NULL;
471  int size;
472 
473  if (device->num_joysticks > 0) {
474  joystick = SDL_JoystickFromInstanceID(device->joysticks[0]);
475  }
476  if (!joystick) {
477  return SDL_FALSE;
478  }
479 
480  while ((size = hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) {
481  switch (data[0]) {
482  case k_EPS4ReportIdUsbState:
483  HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t *)&data[1]);
484  break;
485  case k_EPS4ReportIdBluetoothState:
486  /* Bluetooth state packets have two additional bytes at the beginning */
487  HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t *)&data[3]);
488  break;
489  default:
490 #ifdef DEBUG_JOYSTICK
491  SDL_Log("Unknown PS4 packet: 0x%.2x\n", data[0]);
492 #endif
493  break;
494  }
495  }
496 
497  if (size < 0) {
498  /* Read error, device is disconnected */
499  HIDAPI_JoystickDisconnected(device, joystick->instance_id);
500  }
501  return (size >= 0);
502 }
503 
504 static void
505 HIDAPI_DriverPS4_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
506 {
507  hid_close(device->dev);
508  device->dev = NULL;
509 
510  SDL_free(device->context);
511  device->context = NULL;
512 }
513 
514 static void
515 HIDAPI_DriverPS4_FreeDevice(SDL_HIDAPI_Device *device)
516 {
517 }
518 
519 SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4 =
520 {
522  SDL_TRUE,
523  HIDAPI_DriverPS4_IsSupportedDevice,
524  HIDAPI_DriverPS4_GetDeviceName,
525  HIDAPI_DriverPS4_InitDevice,
526  HIDAPI_DriverPS4_GetDevicePlayerIndex,
527  HIDAPI_DriverPS4_SetDevicePlayerIndex,
528  HIDAPI_DriverPS4_UpdateDevice,
529  HIDAPI_DriverPS4_OpenJoystick,
530  HIDAPI_DriverPS4_RumbleJoystick,
531  HIDAPI_DriverPS4_CloseJoystick,
532  HIDAPI_DriverPS4_FreeDevice
533 };
534 
535 #endif /* SDL_JOYSTICK_HIDAPI_PS4 */
536 
537 #endif /* SDL_JOYSTICK_HIDAPI */
538 
539 /* vi: set ts=4 sw=4 expandtab: */
SDL_HINT_JOYSTICK_HIDAPI_PS4
#define SDL_HINT_JOYSTICK_HIDAPI_PS4
A variable controlling whether the HIDAPI driver for PS4 controllers should be used.
Definition: SDL_hints.h:591
SDL_CONTROLLER_BUTTON_DPAD_LEFT
@ SDL_CONTROLLER_BUTTON_DPAD_LEFT
Definition: SDL_gamecontroller.h:362
SDL_memset
#define SDL_memset
Definition: SDL_dynapi_overrides.h:386
SDL_CONTROLLER_AXIS_RIGHTX
@ SDL_CONTROLLER_AXIS_RIGHTX
Definition: SDL_gamecontroller.h:307
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_HIDAPI_DriverPS4
SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4
USB_VENDOR_RAZER
#define USB_VENDOR_RAZER
Definition: usb_ids.h:34
SDL_events.h
offset
GLintptr offset
Definition: SDL_opengl_glext.h:541
if
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
Definition: pixman-arm-neon-asm.h:469
NULL
#define NULL
Definition: begin_code.h:167
SDL_timer.h
HIDAPI_JoystickConnected
SDL_bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoystickID)
SDL_joystick.h
hid_close
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device)
Close a HID device.
level
GLint level
Definition: SDL_opengl.h:1572
SDL_log.h
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_hidapi_rumble.h
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE
#define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE
A variable controlling whether extended input reports should be used for PS4 controllers when using t...
Definition: SDL_hints.h:606
SDL_CONTROLLER_BUTTON_RIGHTSTICK
@ SDL_CONTROLLER_BUTTON_RIGHTSTICK
Definition: SDL_gamecontroller.h:357
SDL_JOYSTICK_POWER_LOW
@ SDL_JOYSTICK_POWER_LOW
Definition: SDL_joystick.h:101
SDL_CONTROLLER_AXIS_LEFTX
@ SDL_CONTROLLER_AXIS_LEFTX
Definition: SDL_gamecontroller.h:305
SDL_RELEASED
#define SDL_RELEASED
Definition: SDL_events.h:49
SDL_JOYSTICK_POWER_EMPTY
@ SDL_JOYSTICK_POWER_EMPTY
Definition: SDL_joystick.h:100
ctx
EGLContext ctx
Definition: eglext.h:208
SDL_CONTROLLER_BUTTON_B
@ SDL_CONTROLLER_BUTTON_B
Definition: SDL_gamecontroller.h:350
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
USB_PRODUCT_SONY_DS4_DONGLE
#define USB_PRODUCT_SONY_DS4_DONGLE
Definition: usb_ids.h:41
SDL_JoystickGetPlayerIndex
#define SDL_JoystickGetPlayerIndex
Definition: SDL_dynapi_overrides.h:702
SDL_PrivateJoystickAxis
int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
Definition: SDL_joystick.c:1023
SDL_hidapijoystick_c.h
SDL_CONTROLLER_BUTTON_BACK
@ SDL_CONTROLLER_BUTTON_BACK
Definition: SDL_gamecontroller.h:353
SDL_CONTROLLER_BUTTON_LEFTSHOULDER
@ SDL_CONTROLLER_BUTTON_LEFTSHOULDER
Definition: SDL_gamecontroller.h:358
SDL_JoystickID
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:81
SDL_PRESSED
#define SDL_PRESSED
Definition: SDL_events.h:50
Sint16
int16_t Sint16
Definition: SDL_stdinc.h:185
SDL_memcpy
#define SDL_memcpy
Definition: SDL_dynapi_overrides.h:387
SDL_GetHintBoolean
#define SDL_GetHintBoolean
Definition: SDL_dynapi_overrides.h:608
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
SDL_JOYSTICK_POWER_MEDIUM
@ SDL_JOYSTICK_POWER_MEDIUM
Definition: SDL_joystick.h:102
SDL_CONTROLLER_TYPE_PS4
@ SDL_CONTROLLER_TYPE_PS4
Definition: SDL_gamecontroller.h:66
SDL_CONTROLLER_AXIS_TRIGGERLEFT
@ SDL_CONTROLLER_AXIS_TRIGGERLEFT
Definition: SDL_gamecontroller.h:309
SDL_Log
#define SDL_Log
Definition: SDL_dynapi_overrides.h:31
SDL_JoystickFromInstanceID
#define SDL_JoystickFromInstanceID
Definition: SDL_dynapi_overrides.h:595
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
USB_PRODUCT_RAZER_PANTHERA
#define USB_PRODUCT_RAZER_PANTHERA
Definition: usb_ids.h:38
USB_PRODUCT_RAZER_PANTHERA_EVO
#define USB_PRODUCT_RAZER_PANTHERA_EVO
Definition: usb_ids.h:39
hid_read_timeout
int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *device, unsigned char *data, size_t length, int milliseconds)
Read an Input report from a HID device with timeout.
name
GLuint const GLchar * name
Definition: SDL_opengl_glext.h:663
SDL_JOYSTICK_POWER_WIRED
@ SDL_JOYSTICK_POWER_WIRED
Definition: SDL_joystick.h:104
SDL_PrivateJoystickButton
int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
Definition: SDL_joystick.c:1162
SDL_CONTROLLER_AXIS_MAX
@ SDL_CONTROLLER_AXIS_MAX
Definition: SDL_gamecontroller.h:311
Uint16
uint16_t Uint16
Definition: SDL_stdinc.h:191
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
SDL_gamecontroller.h
SDL_CONTROLLER_BUTTON_START
@ SDL_CONTROLLER_BUTTON_START
Definition: SDL_gamecontroller.h:355
hid_open_path
HID_API_EXPORT hid_device *HID_API_CALL hid_open_path(const char *path, int bExclusive)
Open a HID device by its path name.
USB_VENDOR_SONY
#define USB_VENDOR_SONY
Definition: usb_ids.h:33
axis
SDL_Texture * axis
Definition: testgamecontroller.c:67
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:540
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
SDL_CONTROLLER_BUTTON_RIGHTSHOULDER
@ SDL_CONTROLLER_BUTTON_RIGHTSHOULDER
Definition: SDL_gamecontroller.h:359
SDL_CONTROLLER_BUTTON_Y
@ SDL_CONTROLLER_BUTTON_Y
Definition: SDL_gamecontroller.h:352
HIDAPI_JoystickDisconnected
void HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID)
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
hid_get_feature_report
int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length)
Get a feature report from a HID device.
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_GameControllerType
SDL_GameControllerType
Definition: SDL_gamecontroller.h:60
USB_PACKET_LENGTH
#define USB_PACKET_LENGTH
Definition: SDL_hidapijoystick_c.h:58
SDL_hints.h
SDL_JOYSTICK_POWER_FULL
@ SDL_JOYSTICK_POWER_FULL
Definition: SDL_joystick.h:103
SDL_CONTROLLER_AXIS_LEFTY
@ SDL_CONTROLLER_AXIS_LEFTY
Definition: SDL_gamecontroller.h:306
SDL_CONTROLLER_BUTTON_LEFTSTICK
@ SDL_CONTROLLER_BUTTON_LEFTSTICK
Definition: SDL_gamecontroller.h:356
SDL_CONTROLLER_BUTTON_DPAD_DOWN
@ SDL_CONTROLLER_BUTTON_DPAD_DOWN
Definition: SDL_gamecontroller.h:361
USB_PRODUCT_SONY_DS4_SLIM
#define USB_PRODUCT_SONY_DS4_SLIM
Definition: usb_ids.h:42
SDL_CONTROLLER_BUTTON_DPAD_UP
@ SDL_CONTROLLER_BUTTON_DPAD_UP
Definition: SDL_gamecontroller.h:360
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_CONTROLLER_AXIS_TRIGGERRIGHT
@ SDL_CONTROLLER_AXIS_TRIGGERRIGHT
Definition: SDL_gamecontroller.h:310
hid_device
struct hid_device_ hid_device
Definition: hidapi.h:54
SDL_CONTROLLER_AXIS_RIGHTY
@ SDL_CONTROLLER_AXIS_RIGHTY
Definition: SDL_gamecontroller.h:308
SDL_CONTROLLER_BUTTON_X
@ SDL_CONTROLLER_BUTTON_X
Definition: SDL_gamecontroller.h:351
device
static SDL_AudioDeviceID device
Definition: loopwave.c:37
SDL_CONTROLLER_BUTTON_A
@ SDL_CONTROLLER_BUTTON_A
Definition: SDL_gamecontroller.h:349
type
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_CONTROLLER_BUTTON_DPAD_RIGHT
@ SDL_CONTROLLER_BUTTON_DPAD_RIGHT
Definition: SDL_gamecontroller.h:363
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
SDL_CONTROLLER_BUTTON_GUIDE
@ SDL_CONTROLLER_BUTTON_GUIDE
Definition: SDL_gamecontroller.h:354
colors
static int colors[7]
Definition: testgesture.c:41
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179