Make GameCube controllers only rumble if both USB cables are connected The Nintendo USB GameCube Adapter has two USB connectors. Black for data and grey for additional power for rumble. The Wii U and other software require both cables to use rumble. The rumble is weaker without the second USB cable. Other than that I don't know if there is any negative side affects from using rumble with only one cable.
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
diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c
index 40314f2..d5f5132 100644
--- a/src/joystick/hidapi/SDL_hidapi_gamecube.c
+++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c
@@ -37,6 +37,7 @@
typedef struct {
SDL_JoystickID joysticks[4];
+ Uint8 rumbleAllowed[4];
Uint8 rumble[5];
Uint32 rumbleExpiration[4];
/* Without this variable, hid_write starts to lag a TON */
@@ -99,6 +100,9 @@ HIDAPI_DriverGameCube_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_i
/* Go through all 4 slots */
curSlot = packet + 1;
for (i = 0; i < 4; i += 1, curSlot += 9) {
+ /* Only allow rumble if the adapter's second USB cable is connected */
+ ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0;
+
if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */
if (ctx->joysticks[i] == -1) {
ctx->joysticks[i] = SDL_GetNextJoystickInstanceID();
@@ -168,6 +172,9 @@ HIDAPI_DriverGameCube_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joys
/* Go through all 4 slots */
curSlot = packet + 1;
for (i = 0; i < 4; i += 1, curSlot += 9) {
+ /* Only allow rumble if the adapter's second USB cable is connected */
+ ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0;
+
if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */
if (ctx->joysticks[i] == -1) {
ctx->joysticks[i] = SDL_GetNextJoystickInstanceID();
@@ -238,7 +245,7 @@ HIDAPI_DriverGameCube_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joys
now = SDL_GetTicks();
for (i = 0; i < 4; i += 1) {
if (ctx->rumbleExpiration[i] > 0) {
- if (SDL_TICKS_PASSED(now, ctx->rumbleExpiration[i])) {
+ if (SDL_TICKS_PASSED(now, ctx->rumbleExpiration[i]) || !ctx->rumbleAllowed[i]) {
ctx->rumble[i + 1] = 0;
ctx->rumbleExpiration[i] = 0;
ctx->rumbleUpdate = 1;
@@ -325,6 +332,9 @@ HIDAPI_DriverGameCube_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joyst
Uint8 i, val;
for (i = 0; i < 4; i += 1) {
if (instance == ctx->joysticks[i]) {
+ if (!ctx->rumbleAllowed[i]) {
+ return SDL_SetError("Second USB cable for WUP-028 not connected");
+ }
val = (low_frequency_rumble > 0 || high_frequency_rumble > 0);
if (val != ctx->rumble[i + 1]) {
ctx->rumble[i + 1] = val;
@@ -338,7 +348,7 @@ HIDAPI_DriverGameCube_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joyst
return 0;
}
}
- return -1;
+ return -1; /* Should never get here! */
}
SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube =