Handle GameCube WaveBird controller differences
authorZack Middleton <zack@cloemail.com>
Wed, 19 Jun 2019 06:43:54 -0700
changeset 12895ae044ecb144f
parent 12894 e0980413763c
child 12896 b91647e1a977
Handle GameCube WaveBird controller differences
Make wireless GameCube controllers use unknown power level instead of
wired and don't allow rumble (it doesn't have hardware for it).
src/joystick/hidapi/SDL_hidapi_gamecube.c
     1.1 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c	Wed Jun 19 06:43:36 2019 -0700
     1.2 +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c	Wed Jun 19 06:43:54 2019 -0700
     1.3 @@ -37,6 +37,7 @@
     1.4  
     1.5  typedef struct {
     1.6      SDL_JoystickID joysticks[4];
     1.7 +    Uint8 wireless[4];
     1.8      Uint8 rumbleAllowed[4];
     1.9      Uint8 rumble[5];
    1.10      Uint32 rumbleExpiration[4];
    1.11 @@ -100,8 +101,10 @@
    1.12          /* Go through all 4 slots */
    1.13          curSlot = packet + 1;
    1.14          for (i = 0; i < 4; i += 1, curSlot += 9) {
    1.15 +            ctx->wireless[i] = (curSlot[0] & 0x20) != 0;
    1.16 +
    1.17              /* Only allow rumble if the adapter's second USB cable is connected */
    1.18 -            ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0;
    1.19 +            ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i];
    1.20  
    1.21              if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */
    1.22                  if (ctx->joysticks[i] == -1) {
    1.23 @@ -172,8 +175,10 @@
    1.24          /* Go through all 4 slots */
    1.25          curSlot = packet + 1;
    1.26          for (i = 0; i < 4; i += 1, curSlot += 9) {
    1.27 +            ctx->wireless[i] = (curSlot[0] & 0x20) != 0;
    1.28 +
    1.29              /* Only allow rumble if the adapter's second USB cable is connected */
    1.30 -            ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0;
    1.31 +            ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i];
    1.32  
    1.33              if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */
    1.34                  if (ctx->joysticks[i] == -1) {
    1.35 @@ -316,7 +321,7 @@
    1.36          if (instance == ctx->joysticks[i]) {
    1.37              joystick->nbuttons = 12;
    1.38              joystick->naxes = 6;
    1.39 -            joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
    1.40 +            joystick->epowerlevel = ctx->wireless[i] ? SDL_JOYSTICK_POWER_UNKNOWN : SDL_JOYSTICK_POWER_WIRED;
    1.41              joystick->player_index = i;
    1.42              return SDL_TRUE;
    1.43          }
    1.44 @@ -332,6 +337,9 @@
    1.45      Uint8 i, val;
    1.46      for (i = 0; i < 4; i += 1) {
    1.47          if (instance == ctx->joysticks[i]) {
    1.48 +            if (ctx->wireless[i]) {
    1.49 +                return SDL_SetError("Ninteno GameCube WaveBird controllers do not support rumble");
    1.50 +            }
    1.51              if (!ctx->rumbleAllowed[i]) {
    1.52                  return SDL_SetError("Second USB cable for WUP-028 not connected");
    1.53              }