Bug 266293

Summary: Gamepad: Map DualShock/DualSense Trackpad Button
Product: WebKit Reporter: James Howard <jameshoward>
Component: WebCore Misc.Assignee: Byungseon(Sun) Shin <sun.shin>
Status: NEW ---    
Severity: Normal CC: beidson, jameshoward, karlcow, marcosc, sun.shin, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: All   
OS: All   

Description James Howard 2023-12-12 10:29:34 PST
On Sony gamepads, the trackpad is itself a clickable button. This is independent of the multitouch behavior of the trackpad[^1]. Chromium maps this trackpad click as button 17 in the standard gamepad mapping.

In WebKit, the trackpad button is unmapped[^2].

I notice that the Gamepad spec[^3] now says that user agents can choose to map exactly the 16 buttons regardless of what the controller supports as a fingerprinting mitigation, so maybe it makes sense to get button 17 added to the spec as part of the standard mapping, or else always make the buttons array be 17 elements long for all controller types.

Steps to reproduce:
1. Connect a Sony DualShock 4 or Sony DualSense controller via USB or BT.
2. Navigate to https://gamepad-tester.com
3. Press any button on controller to get page to recognize it.
4. Press the trackpad button.

Results:
Safari Technology Preview 184, macOS 14.1.1: Nothing happens.
Chrome 120.0.6099.71, macOS 14.1.1: Button 17 value toggles between 0.0 and 1.0 when pressed. 

Why do we want this:
Some games make use of the trackpad button.

[^1]: https://knyg.github.io/gamepad/extensions.html#gamepadtouch-interface
[^2]: https://github.com/WebKit/WebKit/blob/ed54b0254b83b2ea15aa23354e1e0c91f1d8dfaf/Source/WebCore/platform/gamepad/cocoa/GameControllerGamepad.mm#L57
[^3]: https://w3c.github.io/gamepad/#fingerprinting-mitigation
Comment 1 Marcos Caceres 2023-12-14 17:57:07 PST
James, would you mind filing a bug on the spec? 
https://github.com/w3c/gamepad/issues

Sounds like we need to update the spec in parallel.
Comment 2 Marcos Caceres 2023-12-18 18:35:22 PST
Filed spec issue https://github.com/w3c/gamepad/issues/191
Comment 3 James Howard 2023-12-18 18:54:13 PST
Thanks for doing that for me, Marcos :)
Comment 4 Radar WebKit Bug Importer 2023-12-19 10:30:14 PST
<rdar://problem/119876782>
Comment 5 Byungseon(Sun) Shin 2024-05-10 16:07:14 PDT
Will work on by the W3C working group proposal.
- https://github.com/w3c/gamepad/pull/196