Skip to content

Commit d635a06

Browse files
endriftslouken
authored andcommitted
switch2: Read out serial number
1 parent e4b763f commit d635a06

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/joystick/hidapi/SDL_hidapi_switch2.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,15 @@ static bool HIDAPI_DriverSwitch2_InitUSB(SDL_HIDAPI_Device *device)
425425

426426
unsigned char calibration_data[0x40] = {0};
427427

428+
res = ReadFlashBlock(ctx, 0x13000, calibration_data);
429+
if (res < 0) {
430+
SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Couldn't read serial number: %d", res);
431+
} else {
432+
char serial[0x11] = {0};
433+
SDL_strlcpy(serial, (char*)&calibration_data[2], sizeof(serial));
434+
HIDAPI_SetDeviceSerial(device, serial);
435+
}
436+
428437
res = ReadFlashBlock(ctx, 0x13080, calibration_data);
429438
if (res < 0) {
430439
SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Couldn't read factory calibration data: %d", res);

0 commit comments

Comments
 (0)