Skip to content

Commit

Permalink
Fixed bug 4600 - Dualshock 4 touchpad press is not detectable with SD…
Browse files Browse the repository at this point in the history
…L_JoystickGetButton

Dexter Friedman

When using a Dualshock 4 controller (model numbers CUH-ZCT1U and CUH-ZCT2U), pressing anywhere on the center touchpad does not send an SDL_JOYBUTTONDOWN event. I have verified this with testjoystick:

Repro steps:
1. Plug in a DS4 over USB
2. Compile testjoystick and run: testjoystick.exe 0
3. Press and hold the touchpad. Observe that no lime green box appears

Expected behavior:
A lime green box appears while the touchpad is pressed.

Notes:
I've attached a patch here that works on my PC and produces the expected behavior in testjoystick, for both DS4 model numbers I listed earlier.

If I understand correctly, by exposing this as a joystick button, the gamecontroller API mapping can be modified with a change to gamecontrollerdb.txt in the future.
  • Loading branch information
slouken committed Jun 8, 2019
1 parent 30a5e90 commit d97387c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/joystick/hidapi/SDL_hidapi_ps4.c
Expand Up @@ -360,7 +360,7 @@ HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *joys
HIDAPI_DriverPS4_Rumble(context, joystick, 0, 0, 0);

/* Initialize the joystick capabilities */
joystick->nbuttons = SDL_CONTROLLER_BUTTON_MAX;
joystick->nbuttons = 16;
joystick->naxes = SDL_CONTROLLER_AXIS_MAX;
joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;

Expand Down Expand Up @@ -515,6 +515,7 @@ HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, SDL_
Uint8 data = (packet->rgucButtonsHatAndCounter[2] & 0x03);

SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED);
SDL_PrivateJoystickButton(joystick, 15, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED);
}

axis = ((int)packet->ucTriggerLeft * 257) - 32768;
Expand Down

0 comments on commit d97387c

Please sign in to comment.