mirror of https://github.com/libsdl-org/SDL
Fixed analog triggers on the DualSense controller
(cherry picked from commit a67d410501
)
(cherry picked from commit 866f7c7f7c496343ad21d32f8edc76390e11101d)
This commit is contained in:
parent
d94b944f91
commit
4fb81fdff9
|
@ -1083,9 +1083,17 @@ HIDAPI_DriverPS5_HandleSimpleStatePacket(SDL_Joystick *joystick, SDL_hid_device
|
||||||
SDL_PrivateJoystickButton(joystick, 15, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
SDL_PrivateJoystickButton(joystick, 15, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||||
}
|
}
|
||||||
|
|
||||||
axis = ((int)packet->ucTriggerLeft * 257) - 32768;
|
if (packet->ucTriggerLeft == 0 && (packet->rgucButtonsHatAndCounter[1] & 0x04)) {
|
||||||
|
axis = SDL_JOYSTICK_AXIS_MAX;
|
||||||
|
} else {
|
||||||
|
axis = ((int)packet->ucTriggerLeft * 257) - 32768;
|
||||||
|
}
|
||||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
|
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
|
||||||
axis = ((int)packet->ucTriggerRight * 257) - 32768;
|
if (packet->ucTriggerRight == 0 && (packet->rgucButtonsHatAndCounter[1] & 0x08)) {
|
||||||
|
axis = SDL_JOYSTICK_AXIS_MAX;
|
||||||
|
} else {
|
||||||
|
axis = ((int)packet->ucTriggerRight * 257) - 32768;
|
||||||
|
}
|
||||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
|
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis);
|
||||||
axis = ((int)packet->ucLeftJoystickX * 257) - 32768;
|
axis = ((int)packet->ucLeftJoystickX * 257) - 32768;
|
||||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
|
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis);
|
||||||
|
@ -1178,13 +1186,13 @@ HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL_hid_device
|
||||||
SDL_PrivateJoystickButton(joystick, 16, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
SDL_PrivateJoystickButton(joystick, 16, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet->rgucButtonsAndHat[1] & 0x04) {
|
if (packet->ucTriggerLeft == 0 && (packet->rgucButtonsAndHat[1] & 0x04)) {
|
||||||
axis = SDL_JOYSTICK_AXIS_MAX;
|
axis = SDL_JOYSTICK_AXIS_MAX;
|
||||||
} else {
|
} else {
|
||||||
axis = ((int)packet->ucTriggerLeft * 257) - 32768;
|
axis = ((int)packet->ucTriggerLeft * 257) - 32768;
|
||||||
}
|
}
|
||||||
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
|
SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis);
|
||||||
if (packet->rgucButtonsAndHat[1] & 0x08) {
|
if (packet->ucTriggerRight == 0 && (packet->rgucButtonsAndHat[1] & 0x08)) {
|
||||||
axis = SDL_JOYSTICK_AXIS_MAX;
|
axis = SDL_JOYSTICK_AXIS_MAX;
|
||||||
} else {
|
} else {
|
||||||
axis = ((int)packet->ucTriggerRight * 257) - 32768;
|
axis = ((int)packet->ucTriggerRight * 257) - 32768;
|
||||||
|
|
Loading…
Reference in New Issue