Skip to content

Commit

Permalink
Fixed GameCube rumble
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 20, 2019
1 parent 202c966 commit 25bd507
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/joystick/hidapi/SDL_hidapi_gamecube.c
Expand Up @@ -147,7 +147,6 @@ HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device)
SDL_Joystick *joystick;
Uint8 packet[37];
Uint8 *curSlot;
Uint32 now;
Uint8 i;
int size;

Expand Down Expand Up @@ -225,9 +224,9 @@ HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device)
}

/* Write rumble packet */
now = SDL_GetTicks();
for (i = 0; i < 4; i += 1) {
if (ctx->rumbleExpiration[i] > 0) {
if (ctx->rumbleExpiration[i] || (ctx->rumble[1 + i] && !ctx->rumbleAllowed[i])) {
Uint32 now = SDL_GetTicks();
if (SDL_TICKS_PASSED(now, ctx->rumbleExpiration[i]) || !ctx->rumbleAllowed[i]) {
ctx->rumble[1 + i] = 0;
ctx->rumbleExpiration[i] = 0;
Expand Down Expand Up @@ -279,8 +278,8 @@ HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *jo
ctx->rumble[i + 1] = val;
ctx->rumbleUpdate = SDL_TRUE;
}
if (val && duration_ms < SDL_HAPTIC_INFINITY) {
ctx->rumbleExpiration[i] = SDL_GetTicks() + duration_ms;
if (val && duration_ms) {
ctx->rumbleExpiration[i] = SDL_GetTicks() + SDL_min(duration_ms, SDL_MAX_RUMBLE_DURATION_MS);
} else {
ctx->rumbleExpiration[i] = 0;
}
Expand Down

0 comments on commit 25bd507

Please sign in to comment.