@@ -355,25 +355,24 @@ static bool HIDAPI_DriverSwitch2_InitUSB(SDL_HIDAPI_Device *device)
355
355
flash_read_command [12 ] = 0x80 ;
356
356
res = SendBulkData (ctx , flash_read_command , sizeof (flash_read_command ));
357
357
if (res < 0 ) {
358
- SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't request calibration data: %d" , res );
358
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't request factory calibration data: %d" , res );
359
359
} else {
360
360
res = RecvBulkData (ctx , calibration_data , sizeof (calibration_data ));
361
361
if (res < 0 ) {
362
- SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't read calibration data: %d" , res );
362
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't read factory calibration data: %d" , res );
363
363
} else {
364
364
ParseStickCalibration (& ctx -> left_stick , & calibration_data [0x38 ]);
365
365
}
366
366
}
367
367
368
-
369
368
flash_read_command [12 ] = 0xC0 ;
370
369
res = SendBulkData (ctx , flash_read_command , sizeof (flash_read_command ));
371
370
if (res < 0 ) {
372
- SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't request calibration data: %d" , res );
371
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't request factory calibration data: %d" , res );
373
372
} else {
374
373
res = RecvBulkData (ctx , calibration_data , sizeof (calibration_data ));
375
374
if (res < 0 ) {
376
- SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't read calibration data: %d" , res );
375
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't read factory calibration data: %d" , res );
377
376
} else {
378
377
ParseStickCalibration (& ctx -> right_stick , & calibration_data [0x38 ]);
379
378
}
@@ -384,18 +383,46 @@ static bool HIDAPI_DriverSwitch2_InitUSB(SDL_HIDAPI_Device *device)
384
383
flash_read_command [13 ] = 0x31 ;
385
384
res = SendBulkData (ctx , flash_read_command , sizeof (flash_read_command ));
386
385
if (res < 0 ) {
387
- SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't read calibration data: %d" , res );
386
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't request factory calibration data: %d" , res );
388
387
} else {
389
388
res = RecvBulkData (ctx , calibration_data , sizeof (calibration_data ));
390
389
if (res < 0 ) {
391
- SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't read calibration data: %d" , res );
390
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't read factory calibration data: %d" , res );
392
391
} else {
393
392
ctx -> left_trigger_max = calibration_data [0x10 ];
394
393
ctx -> right_trigger_max = calibration_data [0x11 ];
395
394
}
396
395
}
397
396
}
398
397
398
+ flash_read_command [12 ] = 0x40 ;
399
+ flash_read_command [13 ] = 0xC0 ;
400
+ flash_read_command [14 ] = 0x1F ;
401
+ res = SendBulkData (ctx , flash_read_command , sizeof (flash_read_command ));
402
+ if (res < 0 ) {
403
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't request user calibration data: %d" , res );
404
+ } else {
405
+ res = RecvBulkData (ctx , calibration_data , sizeof (calibration_data ));
406
+ if (res < 0 ) {
407
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't request user calibration data: %d" , res );
408
+ } else if (calibration_data [0x10 ] == 0xb2 && calibration_data [0x11 ] == 0xa1 ) {
409
+ ParseStickCalibration (& ctx -> left_stick , & calibration_data [0x12 ]);
410
+ }
411
+ }
412
+
413
+ flash_read_command [12 ] = 0x80 ;
414
+ res = SendBulkData (ctx , flash_read_command , sizeof (flash_read_command ));
415
+ if (res < 0 ) {
416
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't request user calibration data: %d" , res );
417
+ } else {
418
+ res = RecvBulkData (ctx , calibration_data , sizeof (calibration_data ));
419
+ if (res < 0 ) {
420
+ SDL_LogWarn (SDL_LOG_CATEGORY_INPUT , "Couldn't read user calibration data: %d" , res );
421
+ } else if (calibration_data [0x10 ] == 0xb2 && calibration_data [0x11 ] == 0xa1 ) {
422
+ ParseStickCalibration (& ctx -> right_stick , & calibration_data [0x12 ]);
423
+ }
424
+ }
425
+
399
426
return true;
400
427
}
401
428
0 commit comments