Commit 55515a8c25006eca9e7c993bd915e837608cef61

Sam Lantinga 2020-04-08T08:42:15

SDL: ps4 controller trigger bits on other controllers just mean that there's some activity, not saturation - only force it on if the analog value is 0.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index a95c6e9..722e04b 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -427,8 +427,8 @@ HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, SDL_
 	*/
 	if ((packet->rgucButtonsHatAndCounter[1] & 0x0C) != 0) {
 		Uint8 data = packet->rgucButtonsHatAndCounter[1];
-		packet->ucTriggerLeft = (data & 0x04) ? 255 : packet->ucTriggerLeft;
-		packet->ucTriggerRight = (data & 0x08) ? 255 : packet->ucTriggerRight;
+		packet->ucTriggerLeft = (data & 0x04) && packet->ucTriggerLeft == 0 ? 255 : packet->ucTriggerLeft;
+		packet->ucTriggerRight = (data & 0x08) && packet->ucTriggerRight == 0 ? 255 : packet->ucTriggerRight;
 	}
 
     if (ctx->last_state.rgucButtonsHatAndCounter[2] != packet->rgucButtonsHatAndCounter[2]) {