SDL: plumb previously unused digital trigger bits for PS4 controllers. Victrix fight stick only sets these bits and doesn't send the analog values
authorSam Lantinga
Mon, 30 Mar 2020 14:26:21 -0700
changeset 13682bd45c7649f7b
parent 13681 e078c7e21285
child 13683 60f1e9fb5957
SDL: plumb previously unused digital trigger bits for PS4 controllers. Victrix fight stick only sets these bits and doesn't send the analog values

CR: SamL
src/joystick/hidapi/SDL_hidapi_ps4.c
     1.1 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c	Mon Mar 30 14:26:15 2020 -0700
     1.2 +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c	Mon Mar 30 14:26:21 2020 -0700
     1.3 @@ -423,6 +423,15 @@
     1.4          SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data & 0x80) ? SDL_PRESSED : SDL_RELEASED);
     1.5      }
     1.6  
     1.7 +	/* Some fightsticks, ex: Victrix FS Pro will only this these digital trigger bits and not the analog values so this needs to run whenever the
     1.8 +	   trigger is evaluated
     1.9 +	*/
    1.10 +	if ((packet->rgucButtonsHatAndCounter[1] & 0x0C) != 0) {
    1.11 +		Uint8 data = packet->rgucButtonsHatAndCounter[1];
    1.12 +		packet->ucTriggerLeft = (data & 0x04) ? 255 : packet->ucTriggerLeft;
    1.13 +		packet->ucTriggerRight = (data & 0x08) ? 255 : packet->ucTriggerRight;
    1.14 +	}
    1.15 +
    1.16      if (ctx->last_state.rgucButtonsHatAndCounter[2] != packet->rgucButtonsHatAndCounter[2]) {
    1.17          Uint8 data = (packet->rgucButtonsHatAndCounter[2] & 0x03);
    1.18