Skip to content

Commit e2f597d

Browse files
committed
Added support for the Saitek Cyborg V.3 Rumble Pad in PS3 mode
(cherry picked from commit b6ca360)
1 parent 70faef8 commit e2f597d

File tree

2 files changed

+53
-42
lines changed

2 files changed

+53
-42
lines changed

src/joystick/hidapi/SDL_hidapi_ps3.c

+51-42
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,8 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *
584584
Uint8 data[USB_PACKET_LENGTH];
585585
int size;
586586

587-
if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) {
587+
if ((type == SDL_CONTROLLER_TYPE_PS3 && vendor_id != USB_VENDOR_SONY) ||
588+
HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) {
588589
if (device && device->dev) {
589590
size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data));
590591
if (size == 8 && data[2] == 0x26) {
@@ -813,48 +814,56 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic
813814
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
814815
}
815816

816-
if (ctx->last_state[2] != data[2]) {
817-
SDL_bool dpad_up = SDL_FALSE;
818-
SDL_bool dpad_down = SDL_FALSE;
819-
SDL_bool dpad_left = SDL_FALSE;
820-
SDL_bool dpad_right = SDL_FALSE;
821-
822-
switch (data[2] & 0x0f) {
823-
case 0:
824-
dpad_up = SDL_TRUE;
825-
break;
826-
case 1:
827-
dpad_up = SDL_TRUE;
828-
dpad_right = SDL_TRUE;
829-
break;
830-
case 2:
831-
dpad_right = SDL_TRUE;
832-
break;
833-
case 3:
834-
dpad_right = SDL_TRUE;
835-
dpad_down = SDL_TRUE;
836-
break;
837-
case 4:
838-
dpad_down = SDL_TRUE;
839-
break;
840-
case 5:
841-
dpad_left = SDL_TRUE;
842-
dpad_down = SDL_TRUE;
843-
break;
844-
case 6:
845-
dpad_left = SDL_TRUE;
846-
break;
847-
case 7:
848-
dpad_up = SDL_TRUE;
849-
dpad_left = SDL_TRUE;
850-
break;
851-
default:
852-
break;
817+
if (ctx->device->vendor_id == USB_VENDOR_SAITEK && ctx->device->product_id == USB_PRODUCT_SAITEK_CYBORG_V3) {
818+
/* Cyborg V.3 Rumble Pad doesn't set the dpad bits as expected, so use the axes instead */
819+
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, data[10] ? SDL_PRESSED : SDL_RELEASED);
820+
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, data[9] ? SDL_PRESSED : SDL_RELEASED);
821+
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, data[7] ? SDL_PRESSED : SDL_RELEASED);
822+
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, data[8] ? SDL_PRESSED : SDL_RELEASED);
823+
} else {
824+
if (ctx->last_state[2] != data[2]) {
825+
SDL_bool dpad_up = SDL_FALSE;
826+
SDL_bool dpad_down = SDL_FALSE;
827+
SDL_bool dpad_left = SDL_FALSE;
828+
SDL_bool dpad_right = SDL_FALSE;
829+
830+
switch (data[2] & 0x0f) {
831+
case 0:
832+
dpad_up = SDL_TRUE;
833+
break;
834+
case 1:
835+
dpad_up = SDL_TRUE;
836+
dpad_right = SDL_TRUE;
837+
break;
838+
case 2:
839+
dpad_right = SDL_TRUE;
840+
break;
841+
case 3:
842+
dpad_right = SDL_TRUE;
843+
dpad_down = SDL_TRUE;
844+
break;
845+
case 4:
846+
dpad_down = SDL_TRUE;
847+
break;
848+
case 5:
849+
dpad_left = SDL_TRUE;
850+
dpad_down = SDL_TRUE;
851+
break;
852+
case 6:
853+
dpad_left = SDL_TRUE;
854+
break;
855+
case 7:
856+
dpad_up = SDL_TRUE;
857+
dpad_left = SDL_TRUE;
858+
break;
859+
default:
860+
break;
861+
}
862+
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_down);
863+
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_up);
864+
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, dpad_right);
865+
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left);
853866
}
854-
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_down);
855-
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_up);
856-
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, dpad_right);
857-
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left);
858867
}
859868

860869
axis = ((int)data[17] * 257) - 32768;

src/joystick/usb_ids.h

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#define USB_VENDOR_POWERA_ALT 0x20d6
4848
#define USB_VENDOR_QANBA 0x2c22
4949
#define USB_VENDOR_RAZER 0x1532
50+
#define USB_VENDOR_SAITEK 0x06a3
5051
#define USB_VENDOR_SHANWAN 0x2563
5152
#define USB_VENDOR_SHANWAN_ALT 0x20bc
5253
#define USB_VENDOR_SONY 0x054c
@@ -104,6 +105,7 @@
104105
#define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRELESS 0x100c
105106
#define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRED 0x1010
106107
#define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRELESS 0x1011
108+
#define USB_PRODUCT_SAITEK_CYBORG_V3 0xf622
107109
#define USB_PRODUCT_SHANWAN_DS3 0x0523
108110
#define USB_PRODUCT_SONY_DS3 0x0268
109111
#define USB_PRODUCT_SONY_DS4 0x05c4

0 commit comments

Comments
 (0)