From d635a064aa20343a4bf5fe659dde515dbf5fcef9 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 17 Oct 2025 18:56:57 -0700 Subject: [PATCH] switch2: Read out serial number --- src/joystick/hidapi/SDL_hidapi_switch2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/joystick/hidapi/SDL_hidapi_switch2.c b/src/joystick/hidapi/SDL_hidapi_switch2.c index cd7b22c42a..c21510fcab 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch2.c +++ b/src/joystick/hidapi/SDL_hidapi_switch2.c @@ -425,6 +425,15 @@ static bool HIDAPI_DriverSwitch2_InitUSB(SDL_HIDAPI_Device *device) unsigned char calibration_data[0x40] = {0}; + res = ReadFlashBlock(ctx, 0x13000, calibration_data); + if (res < 0) { + SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Couldn't read serial number: %d", res); + } else { + char serial[0x11] = {0}; + SDL_strlcpy(serial, (char*)&calibration_data[2], sizeof(serial)); + HIDAPI_SetDeviceSerial(device, serial); + } + res = ReadFlashBlock(ctx, 0x13080, calibration_data); if (res < 0) { SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Couldn't read factory calibration data: %d", res);