@@ -76,6 +76,37 @@ extern "C" {
76
76
struct SDL_hid_device_ ;
77
77
typedef struct SDL_hid_device_ SDL_hid_device ; /**< opaque hidapi structure */
78
78
79
+ /**
80
+ * \brief HID underlying bus types.
81
+ */
82
+ typedef enum {
83
+ /** Unknown bus type */
84
+ SDL_HID_API_BUS_UNKNOWN = 0x00 ,
85
+
86
+ /** USB bus
87
+ Specifications:
88
+ https://usb.org/hid */
89
+ SDL_HID_API_BUS_USB = 0x01 ,
90
+
91
+ /** Bluetooth or Bluetooth LE bus
92
+ Specifications:
93
+ https://www.bluetooth.com/specifications/specs/human-interface-device-profile-1-1-1/
94
+ https://www.bluetooth.com/specifications/specs/hid-service-1-0/
95
+ https://www.bluetooth.com/specifications/specs/hid-over-gatt-profile-1-0/ */
96
+ SDL_HID_API_BUS_BLUETOOTH = 0x02 ,
97
+
98
+ /** I2C bus
99
+ Specifications:
100
+ https://docs.microsoft.com/previous-versions/windows/hardware/design/dn642101(v=vs.85) */
101
+ SDL_HID_API_BUS_I2C = 0x03 ,
102
+
103
+ /** SPI bus
104
+ Specifications:
105
+ https://www.microsoft.com/download/details.aspx?id=103325 */
106
+ SDL_HID_API_BUS_SPI = 0x04 ,
107
+
108
+ } SDL_hid_bus_type ;
109
+
79
110
/** hidapi info structure */
80
111
/**
81
112
* \brief Information about a connected HID device
@@ -98,17 +129,17 @@ typedef struct SDL_hid_device_info
98
129
/** Product string */
99
130
wchar_t * product_string ;
100
131
/** Usage Page for this Device/Interface
101
- (Windows/Mac only). */
132
+ (Windows/Mac/hidraw only) */
102
133
unsigned short usage_page ;
103
134
/** Usage for this Device/Interface
104
- (Windows/Mac only). */
135
+ (Windows/Mac/hidraw only) */
105
136
unsigned short usage ;
106
137
/** The USB interface which this logical device
107
138
represents.
108
139
109
- * Valid on both Linux implementations in all cases .
110
- * Valid on the Windows implementation only if the device
111
- contains more than one interface. */
140
+ Valid only if the device is a USB HID device .
141
+ Set to -1 in all other cases.
142
+ */
112
143
int interface_number ;
113
144
114
145
/** Additional information about the USB interface.
@@ -117,8 +148,12 @@ typedef struct SDL_hid_device_info
117
148
int interface_subclass ;
118
149
int interface_protocol ;
119
150
151
+ /** Underlying bus type */
152
+ SDL_hid_bus_type bus_type ;
153
+
120
154
/** Pointer to the next device */
121
155
struct SDL_hid_device_info * next ;
156
+
122
157
} SDL_hid_device_info ;
123
158
124
159
@@ -187,8 +222,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_hid_device_change_count(void);
187
222
* matches. If `vendor_id` and `product_id` are both set to 0, then all HID
188
223
* devices will be returned.
189
224
*
190
- * \param vendor_id The Vendor ID (VID) of the types of device to open.
191
- * \param product_id The Product ID (PID) of the types of device to open.
225
+ * \param vendor_id The Vendor ID (VID) of the types of device to open, or 0 to match any vendor .
226
+ * \param product_id The Product ID (PID) of the types of device to open, or 0 to match any product .
192
227
* \returns a pointer to a linked list of type SDL_hid_device_info, containing
193
228
* information about the HID devices attached to the system, or NULL
194
229
* in the case of failure. Free this linked list by calling
@@ -237,13 +272,12 @@ extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_id,
237
272
* platform-specific path name can be used (eg: /dev/hidraw0 on Linux).
238
273
*
239
274
* \param path The path name of the device to open
240
- * \param bExclusive Open device in exclusive mode (Windows only)
241
275
* \returns a pointer to a SDL_hid_device object on success or NULL on
242
276
* failure.
243
277
*
244
278
* \since This function is available since SDL 3.0.0.
245
279
*/
246
- extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path (const char * path , int bExclusive /* = false */ );
280
+ extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path (const char * path );
247
281
248
282
/**
249
283
* Write an Output report to a HID device.
@@ -377,6 +411,28 @@ extern DECLSPEC int SDLCALL SDL_hid_send_feature_report(SDL_hid_device *dev, con
377
411
*/
378
412
extern DECLSPEC int SDLCALL SDL_hid_get_feature_report (SDL_hid_device * dev , unsigned char * data , size_t length );
379
413
414
+ /**
415
+ * Get an input report from a HID device.
416
+ *
417
+ * Set the first byte of `data` to the Report ID of the report to be read.
418
+ * Make sure to allow space for this extra byte in `data`. Upon return, the
419
+ * first byte will still contain the Report ID, and the report data will start
420
+ * in data[1].
421
+ *
422
+ * \param dev A device handle returned from SDL_hid_open().
423
+ * \param data A buffer to put the read data into, including the Report ID.
424
+ * Set the first byte of `data` to the Report ID of the report to
425
+ * be read, or set it to zero if your device does not use numbered
426
+ * reports.
427
+ * \param length The number of bytes to read, including an extra byte for the
428
+ * report ID. The buffer can be longer than the actual report.
429
+ * \returns the number of bytes read plus one for the report ID (which is
430
+ * still in the first byte), or -1 on error.
431
+ *
432
+ * \since This function is available since SDL 3.0.0.
433
+ */
434
+ extern DECLSPEC int SDLCALL SDL_hid_get_input_report (SDL_hid_device * dev , unsigned char * data , size_t length );
435
+
380
436
/**
381
437
* Close a HID device.
382
438
*
@@ -441,6 +497,26 @@ extern DECLSPEC int SDLCALL SDL_hid_get_serial_number_string(SDL_hid_device *dev
441
497
*/
442
498
extern DECLSPEC int SDLCALL SDL_hid_get_indexed_string (SDL_hid_device * dev , int string_index , wchar_t * string , size_t maxlen );
443
499
500
+ /**
501
+ * Get the device info from a HID device.
502
+ *
503
+ * \param dev A device handle returned from SDL_hid_open().
504
+ * \returns a pointer to the SDL_hid_device_info for this hid_device, or NULL in the case of failure; call SDL_GetError() for more information. This struct is valid until the device is closed with SDL_hid_close().
505
+ */
506
+ extern DECLSPEC SDL_hid_device_info * SDLCALL SDL_hid_get_device_info (SDL_hid_device * dev );
507
+
508
+ /**
509
+ * Get a report descriptor from a HID device.
510
+ *
511
+ * User has to provide a preallocated buffer where descriptor will be copied to. The recommended size for a preallocated buffer is 4096 bytes.
512
+ *
513
+ * \param dev A device handle returned from SDL_hid_open().
514
+ * \param buf The buffer to copy descriptor into.
515
+ * \param buf_size The size of the buffer in bytes.
516
+ * \returns the number of bytes actually copied, or -1 on error; call SDL_GetError() for more information.
517
+ */
518
+ extern DECLSPEC int SDLCALL SDL_hid_get_report_descriptor (SDL_hid_device * dev , unsigned char * buf , size_t buf_size );
519
+
444
520
/**
445
521
* Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers
446
522
*
0 commit comments