Skip to content

Commit 36936cb

Browse files
committed
Set the serial number to the Bluetooth MAC address for 8BitDo controllers
1 parent f80e819 commit 36936cb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/joystick/hidapi/SDL_hidapi_8bitdo.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ static bool HIDAPI_Driver8BitDo_InitDevice(SDL_HIDAPI_Device *device)
179179
ctx->sensors_supported = true;
180180
ctx->rumble_supported = true;
181181
ctx->powerstate_supported = true;
182+
183+
// Set the serial number to the Bluetooth MAC address
184+
if (size >= 12 && data[10] != 0) {
185+
char serial[18];
186+
(void)SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
187+
data[10], data[9], data[8], data[7], data[6], data[5]);
188+
HIDAPI_SetDeviceSerial(device, serial);
189+
}
182190
break;
183191
}
184192

0 commit comments

Comments
 (0)