Skip to content

Commit

Permalink
Add extended buttons to support trackpad (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingri committed May 10, 2024
1 parent 471b047 commit d3fc873
Showing 1 changed file with 124 additions and 4 deletions.
128 changes: 124 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,12 @@ <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 [=Additional gamepad buttons=].
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 +882,15 @@ <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>Determine the |type| of the button from the provided {{GamepadButtonType}}
array, defaulting to null if not specified.
</li>
<li>[=list/Append=] a [=new=] {{GamepadButton}} to |buttons|
with the determined button type.
</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,107 @@ <h2>
Visual representation of a [=Standard Gamepad=] layout.
</figcaption>
</figure>
<section>
<h4>
<dfn>Additional gamepad buttons</dfn>
</h4>
<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>
<td>share/capture</td>
<td>Xbox Wireless Controller Model 1914<br>
Nintendo Switch controllers<br>
Stadia controller<br>
</td>
</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>
<tr>
</tbody>
</table>
<section>
<h3>
<dfn>GamepadButtonType</dfn> Enum
</h3>
<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 d3fc873

Please sign in to comment.