Skip to content

Commit

Permalink
Add extended buttons to support trackpad (w3c#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingri committed May 11, 2024
1 parent 471b047 commit 36d2213
Showing 1 changed file with 125 additions and 4 deletions.
129 changes: 125 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,13 @@ <h3>
<li>[=list/For each=] |rawInputIndex:long| of [=the range=] from 0 to
|inputCount| − 1:
<ol>
<li>If the the gamepad button at index |rawInputIndex|
[=represents a Standard Gamepad button=]:
<li>Let |button| be the button at index |rawInputIndex|.
</li>
<li>Let |type| be the result of determining if the |button| [=represents
a Standard Gamepad button=] or represents a [=additional gamepad button=].
If it's neither, use {{GamepadButtonType/"non-standard"}}.
</li>
<li>If |type| is not {{GamepadButtonType/"non-standard"}}:
<ol>
<li>Let |canonicalIndex:long| be the [=canonical index=] for
the button.
Expand Down Expand Up @@ -878,8 +883,14 @@ <h3>
<li>Initialize |buttons| to be an empty [=list=].
</li>
<li>[=list/For each=] |buttonIndex:long| of [=the range=] from 0 to
|buttonsSize| − 1, [=list/append=] a [=new=] {{GamepadButton}} to
|buttons|.
|buttonsSize| − 1:
<ol>
<li>Let |button:GamepadButton| be a [=new=] {{GamepadButton}} with its
{{GamepadButton/type}} attribute initialized to |type|.
</li>
<li>[=list/Append=] |button| to |buttons|.
</li>
</ol>
</li>
<li>Return |buttons|.
</li>
Expand All @@ -900,6 +911,7 @@ <h2>
readonly attribute boolean pressed;
readonly attribute boolean touched;
readonly attribute double value;
readonly attribute GamepadButtonType type;
};
</pre>
<p>
Expand Down Expand Up @@ -1018,6 +1030,13 @@ <h2>
</li>
</ol>
</dd>
<dt>
<dfn>type</dfn> attribute
</dt>
<dd>
An enumerated {{GamepadButtonType}} attribute that classifies the current button's type in relation to an
extended mapping.
</dd>
</dl>
</section>
<section data-dfn-for="GamepadMappingType">
Expand Down Expand Up @@ -2031,6 +2050,108 @@ <h2>
Visual representation of a [=Standard Gamepad=] layout.
</figcaption>
</figure>
<section>
<h3>
<dfn data-lt="additional gamepad button">Additional gamepad buttons</dfn>
</h3>
<p>
This section introduces an extended gamepad button mapping beyond the [=Standard Gamepad=] mapping.
These additional buttons are commonly found on certain gamepad models.
The following definition list represents the additional buttons used by some gamepad models.
It's important to note that this list is not exhaustive, and user agents may utilize different
or additional buttons for these or other gamepad models.
Consequently, the number of buttons on the {{Gamepad}} is not limited to the standard mapping of 17 buttons.
</p>
<table class="tg">
<thead>
<tr>
<th scope="col">Buttons</th>
<th scope="col">Gamepad Models</th>
</tr>
</thead>
<tbody>
<tr>
<td>trackpad/touchpad</td>
<td>Sony DualSense, DualShock 4</td>
</tr>
<tr>
<td>share/capture</td>
<td>Xbox Wireless Controller Model 1914<br>
Nintendo Switch controllers<br>
Stadia controller<br>
</td>
</tr>
<tr>
<td>voice assistant</td>
<td>Google Stadia Controller<br>
Amazon Luna Controller<br>
</td>
</tr>
<tr>
<td>home</td>
<td>Nvidia Shield Gamepad</td>
</tr>
<tr>
<td>squeeze_left</td>
<td>Xbox Elite Wireless Controller<br>
PlayStation DualSense Edge</td>
</tr>
<tr>
<td>squeeze_left_lower</td>
<td>Xbox Elite Wireless Controller</td>
</tr>
<tr>
<td>squeeze_right</td>
<td>Xbox Elite Wireless Controller<br>
PlayStation DualSense Edge</td>
</tr>
<tr>
<td>squeeze_right_lower</td>
<td>Xbox Elite Wireless Controller</td>
</tr>
</tbody>
</table>
<section>
<h4>
<dfn>GamepadButtonType</dfn> Enum
</h4>
<p>
To accommodate additional gamepad buttons, we have defined an enumeration for the various button types termed
{{GamepadButtonType}}, and have expanded the {{GamepadButton}} interface to encompass this new
{{GamepadButtonType}} enumeration.
</p>
<p>
This enum defines the set of possible button types.
</p>
<pre class="idl">
enum GamepadButtonType {
"standard",
"non-standard",
"trackpad",
};
</pre>
<dl data-dfn-for="GamepadButtonType">
<dt>
"<dfn>standard</dfn>"
</dt>
<dd>
Represent a button has a button type defined in the [=Standard Gamepad=] mapping.
</dd>
<dt>
"<dfn>non-standard</dfn>"
</dt>
<dd>
Represents a button that exists but doesn't have a standard name.
</dd>
<dt>
"<dfn>trackpad</dfn>"
</dt>
<dd>
Represent a trackpad input type.
</dd>
</dl>
</section>
</section>
<section>
<h3>
Fingerprinting mitigation
Expand Down

0 comments on commit 36d2213

Please sign in to comment.