<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>266293</bug_id>
          
          <creation_ts>2023-12-12 10:29:34 -0800</creation_ts>
          <short_desc>Gamepad: Map DualShock/DualSense Trackpad Button</short_desc>
          <delta_ts>2024-05-10 16:07:14 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>Safari Technology Preview</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="James Howard">jameshoward</reporter>
          <assigned_to name="Byungseon(Sun) Shin">sun.shin</assigned_to>
          <cc>beidson</cc>
    
    <cc>jameshoward</cc>
    
    <cc>karlcow</cc>
    
    <cc>marcosc</cc>
    
    <cc>sun.shin</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1999025</commentid>
    <comment_count>0</comment_count>
    <who name="James Howard">jameshoward</who>
    <bug_when>2023-12-12 10:29:34 -0800</bug_when>
    <thetext>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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1999777</commentid>
    <comment_count>1</comment_count>
    <who name="Marcos Caceres">marcosc</who>
    <bug_when>2023-12-14 17:57:07 -0800</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2000600</commentid>
    <comment_count>2</comment_count>
    <who name="Marcos Caceres">marcosc</who>
    <bug_when>2023-12-18 18:35:22 -0800</bug_when>
    <thetext>Filed spec issue https://github.com/w3c/gamepad/issues/191</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2000603</commentid>
    <comment_count>3</comment_count>
    <who name="James Howard">jameshoward</who>
    <bug_when>2023-12-18 18:54:13 -0800</bug_when>
    <thetext>Thanks for doing that for me, Marcos :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2000766</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-12-19 10:30:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/119876782&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2034651</commentid>
    <comment_count>5</comment_count>
    <who name="Byungseon(Sun) Shin">sun.shin</who>
    <bug_when>2024-05-10 16:07:14 -0700</bug_when>
    <thetext>Will work on by the W3C working group proposal.
- https://github.com/w3c/gamepad/pull/196</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>