From 36936cbf37600e79e97f1a4e3d95bcd2367188ff Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 28 May 2025 12:18:07 -0700
Subject: [PATCH] Set the serial number to the Bluetooth MAC address for 8BitDo
controllers
---
src/joystick/hidapi/SDL_hidapi_8bitdo.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/joystick/hidapi/SDL_hidapi_8bitdo.c b/src/joystick/hidapi/SDL_hidapi_8bitdo.c
index 6ad96a178a962..bcbdb6c56a182 100644
--- a/src/joystick/hidapi/SDL_hidapi_8bitdo.c
+++ b/src/joystick/hidapi/SDL_hidapi_8bitdo.c
@@ -179,6 +179,14 @@ static bool HIDAPI_Driver8BitDo_InitDevice(SDL_HIDAPI_Device *device)
ctx->sensors_supported = true;
ctx->rumble_supported = true;
ctx->powerstate_supported = true;
+
+ // Set the serial number to the Bluetooth MAC address
+ if (size >= 12 && data[10] != 0) {
+ char serial[18];
+ (void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ data[10], data[9], data[8], data[7], data[6], data[5]);
+ HIDAPI_SetDeviceSerial(device, serial);
+ }
break;
}