From 4e7489d0e4291487aa09f4129eeee226d9c9d508 Mon Sep 17 00:00:00 2001 From: Nadia Holmquist Pedersen Date: Tue, 19 May 2026 23:26:36 +0200 Subject: [PATCH] Add support for the 8BitDo Ultimate 2 Bluetooth in DInput mode --- src/joystick/SDL_gamepad.c | 5 +++-- src/joystick/hidapi/SDL_hidapi_8bitdo.c | 5 ++++- src/joystick/usb_ids.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index 6dab310b80..1172a5b5f6 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -714,7 +714,7 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_GUID guid) int button_mask; int axis_mask; Uint16 vendor, product; - + SDL_strlcpy(mapping_string, "none,", sizeof(mapping_string)); SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); @@ -1223,11 +1223,12 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid) product == USB_PRODUCT_8BITDO_SN30_PRO_BT || product == USB_PRODUCT_8BITDO_PRO_2 || product == USB_PRODUCT_8BITDO_PRO_2_BT || + product == USB_PRODUCT_8BITDO_ULTIMATE2_BT || product == USB_PRODUCT_8BITDO_PRO_3)) { SDL_strlcat(mapping_string, "a:b1,b:b0,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", sizeof(mapping_string)); if (product == USB_PRODUCT_8BITDO_PRO_2 || product == USB_PRODUCT_8BITDO_PRO_2_BT) { SDL_strlcat(mapping_string, "paddle1:b14,paddle2:b13,", sizeof(mapping_string)); - } else if (product == USB_PRODUCT_8BITDO_PRO_3) { + } else if (product == USB_PRODUCT_8BITDO_PRO_3 || product == USB_PRODUCT_8BITDO_ULTIMATE2_BT) { SDL_strlcat(mapping_string, "paddle1:b12,paddle2:b11,paddle3:b14,paddle4:b13,", sizeof(mapping_string)); } } else if (vendor == USB_VENDOR_8BITDO && diff --git a/src/joystick/hidapi/SDL_hidapi_8bitdo.c b/src/joystick/hidapi/SDL_hidapi_8bitdo.c index 8d70f4aaab..bac8c9f776 100644 --- a/src/joystick/hidapi/SDL_hidapi_8bitdo.c +++ b/src/joystick/hidapi/SDL_hidapi_8bitdo.c @@ -146,6 +146,7 @@ static bool HIDAPI_Driver8BitDo_IsSupportedDevice(SDL_HIDAPI_Device *device, con case USB_PRODUCT_8BITDO_PRO_2: case USB_PRODUCT_8BITDO_PRO_2_BT: case USB_PRODUCT_8BITDO_PRO_3: + case USB_PRODUCT_8BITDO_ULTIMATE2_BT: case USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS: return true; default: @@ -163,7 +164,7 @@ static bool HIDAPI_Driver8BitDo_InitDevice(SDL_HIDAPI_Device *device) } device->context = ctx; - if (device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS) { + if (device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS || device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2_BT) { // The Ultimate 2 Wireless v1.02 firmware has 12 byte reports, v1.03 firmware has 34 byte reports const int ULTIMATE2_WIRELESS_V103_REPORT_SIZE = 34; const int MAX_ATTEMPTS = 3; @@ -269,6 +270,7 @@ static Uint64 HIDAPI_Driver8BitDo_GetIMURateForProductID(SDL_HIDAPI_Device *devi // This firmware appears to update at 100 Hz over USB return 100; } + case USB_PRODUCT_8BITDO_ULTIMATE2_BT: case USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS: if (device->is_bluetooth) { // Note, This is estimated by observation of Bluetooth packets received in the testcontroller tool @@ -298,6 +300,7 @@ static bool HIDAPI_Driver8BitDo_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joys if (device->product_id == USB_PRODUCT_8BITDO_PRO_2 || device->product_id == USB_PRODUCT_8BITDO_PRO_2_BT || device->product_id == USB_PRODUCT_8BITDO_PRO_3 || + device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2_BT || device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS) { // This controller has additional buttons joystick->nbuttons = SDL_GAMEPAD_NUM_8BITDO_BUTTONS; diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index 6095f1eb66..f7f5959b10 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -74,6 +74,7 @@ #define USB_PRODUCT_8BITDO_PRO_2 0x6003 // mode switch to D #define USB_PRODUCT_8BITDO_PRO_2_BT 0x6006 // mode switch to D #define USB_PRODUCT_8BITDO_PRO_3 0x6009 // mode switch to D +#define USB_PRODUCT_8BITDO_ULTIMATE2_BT 0x6011 // mode switch to D #define USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS 0x6012 // mode switch to BT #define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419 #define USB_PRODUCT_ASTRO_C40_XBOX360 0x0024