Added support for the Razer Raiju Tournament Edition controller in Bluetooth mode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index b2df90e..52326a9 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -374,6 +374,11 @@ HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
/* The Razer Raiju doesn't respond to the detection protocol, but has a touchpad and vibration */
ctx->vibration_supported = SDL_TRUE;
ctx->touchpad_supported = SDL_TRUE;
+
+ if (device->product_id == USB_PRODUCT_RAZER_TOURNAMENT_EDITION_BLUETOOTH ||
+ device->product_id == USB_PRODUCT_RAZER_ULTIMATE_EDITION_BLUETOOTH) {
+ device->is_bluetooth = SDL_TRUE;
+ }
}
ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported);
@@ -679,7 +684,14 @@ HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
/* Initialize the joystick capabilities */
joystick->nbuttons = ctx->touchpad_supported ? 16 : 15;
joystick->naxes = SDL_CONTROLLER_AXIS_MAX;
- joystick->epowerlevel = device->is_bluetooth ? SDL_JOYSTICK_POWER_UNKNOWN : SDL_JOYSTICK_POWER_WIRED;
+ if (device->is_bluetooth && ctx->official_controller) {
+ joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
+ } else if (device->is_bluetooth) {
+ /* We can't get the power status, assume it's full */
+ joystick->epowerlevel = SDL_JOYSTICK_POWER_FULL;
+ } else {
+ joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
+ }
if (ctx->enhanced_mode) {
/* Force initialization when opening the joystick */
@@ -765,7 +777,7 @@ HIDAPI_DriverPS4_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joy
SDL_zeroa(data);
- if (device->is_bluetooth) {
+ if (device->is_bluetooth && ctx->official_controller) {
data[0] = k_EPS4ReportIdBluetoothEffects;
data[1] = 0xC0 | 0x04; /* Magic value HID + CRC, also sets interval to 4ms for samples */
data[3] = 0x03; /* 0x1 is rumble, 0x2 is lightbar, 0x4 is the blink interval */
@@ -919,7 +931,7 @@ HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_device *dev,
axis = ((int)packet->ucRightJoystickY * 257) - 32768;
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis);
- if (ctx->device->is_bluetooth) {
+ if (ctx->device->is_bluetooth && ctx->official_controller) {
if (packet->ucBatteryLevel & 0x10) {
SDL_PrivateJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
} else {
diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h
index d06ceca..dd390f1 100644
--- a/src/joystick/usb_ids.h
+++ b/src/joystick/usb_ids.h
@@ -88,6 +88,10 @@
#define USB_PRODUCT_RAZER_PANTHERA 0x0401
#define USB_PRODUCT_RAZER_PANTHERA_EVO 0x1008
#define USB_PRODUCT_RAZER_RAIJU 0x1000
+#define USB_PRODUCT_RAZER_TOURNAMENT_EDITION_USB 0x1007
+#define USB_PRODUCT_RAZER_TOURNAMENT_EDITION_BLUETOOTH 0x100a
+#define USB_PRODUCT_RAZER_ULTIMATE_EDITION_USB 0x1004
+#define USB_PRODUCT_RAZER_ULTIMATE_EDITION_BLUETOOTH 0x1009
#define USB_PRODUCT_SHANWAN_DS3 0x0523
#define USB_PRODUCT_SONY_DS3 0x0268
#define USB_PRODUCT_SONY_DS4 0x05c4