@@ -187,13 +187,17 @@ static bool HIDAPI_Driver8BitDo_InitDevice(SDL_HIDAPI_Device *device)
187
187
for (int attempt = 0 ; attempt < MAX_ATTEMPTS ; ++ attempt ) {
188
188
int size = ReadFeatureReport (device -> dev , SDL_8BITDO_FEATURE_REPORTID_ENABLE_SDL_REPORTID , data , sizeof (data ));
189
189
if (size > 0 ) {
190
+ #ifdef DEBUG_8BITDO_PROTOCOL
191
+ HIDAPI_DumpPacket ("8BitDo features packet: size = %d" , data , size );
192
+ #endif
190
193
ctx -> sensors_supported = true;
191
194
ctx -> rumble_supported = true;
192
195
ctx -> powerstate_supported = true;
193
196
194
- if (data [13 ] == SDL_8BITDO_SENSOR_TIMESTAMP_ENABLE ) {
197
+ if (size >= 14 && data [13 ] == SDL_8BITDO_SENSOR_TIMESTAMP_ENABLE ) {
195
198
ctx -> sensor_timestamp_supported = true;
196
199
}
200
+
197
201
// Set the serial number to the Bluetooth MAC address
198
202
if (size >= 12 && data [10 ] != 0 ) {
199
203
char serial [18 ];
@@ -231,18 +235,36 @@ static void HIDAPI_Driver8BitDo_SetDevicePlayerIndex(SDL_HIDAPI_Device *device,
231
235
232
236
static Uint64 HIDAPI_Driver8BitDo_GetIMURateForProductID (SDL_HIDAPI_Device * device )
233
237
{
238
+ SDL_Driver8BitDo_Context * ctx = (SDL_Driver8BitDo_Context * )device -> context ;
239
+
234
240
// TODO: If sensor time stamp is sent, these fixed settings from observation can be replaced
235
241
switch (device -> product_id ) {
236
- // Note, This is estimated by observation of Bluetooth packets received in the testcontroller tool
237
- case USB_PRODUCT_8BITDO_SN30_PRO_BT :
238
- case USB_PRODUCT_8BITDO_SF30_PRO_BT :
239
- return 90 ; // Observed to be anywhere between 60-90 hz. Possibly lossy in current state
240
242
case USB_PRODUCT_8BITDO_SF30_PRO :
243
+ case USB_PRODUCT_8BITDO_SF30_PRO_BT :
241
244
case USB_PRODUCT_8BITDO_SN30_PRO :
242
- return 100 ;
245
+ case USB_PRODUCT_8BITDO_SN30_PRO_BT :
246
+ if (device -> is_bluetooth ) {
247
+ // Note, This is estimated by observation of Bluetooth packets received in the testcontroller tool
248
+ return 70 ; // Observed to be anywhere between 60-90 hz. Possibly lossy in current state
249
+ } else if (ctx -> sensor_timestamp_supported ) {
250
+ // This firmware appears to update at 200 Hz over USB
251
+ return 200 ;
252
+ } else {
253
+ // This firmware appears to update at 100 Hz over USB
254
+ return 100 ;
255
+ }
243
256
case USB_PRODUCT_8BITDO_PRO_2 :
244
- case USB_PRODUCT_8BITDO_PRO_2_BT :// Note, labelled as "BT" but appears this way when wired. Observed bluetooth packet rate seems to be 80-90hz
245
- return (device -> is_bluetooth ? 85 : 100 );
257
+ case USB_PRODUCT_8BITDO_PRO_2_BT : // Note, labeled as "BT" but appears this way when wired.
258
+ if (device -> is_bluetooth ) {
259
+ // Note, This is estimated by observation of Bluetooth packets received in the testcontroller tool
260
+ return 85 ; // Observed Bluetooth packet rate seems to be 80-90hz
261
+ } else if (ctx -> sensor_timestamp_supported ) {
262
+ // This firmware appears to update at 200 Hz over USB
263
+ return 200 ;
264
+ } else {
265
+ // This firmware appears to update at 100 Hz over USB
266
+ return 100 ;
267
+ }
246
268
case USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS :
247
269
default :
248
270
return 120 ;
0 commit comments