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 Apr 22, 2024
1 parent 471b047 commit 2a9ecc2
Showing 1 changed file with 80 additions and 4 deletions.
84 changes: 80 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>Determine the type of the button at index |rawInputIndex|
[=represents a Standard Gamepad button=] or Extended button
types as described in the {{ExtendedMapping}} using the provided
buttonTypes array. If the button does not have a canonical type,
use GamePadButtonType.non_canonical.
</li>
<li>If the button type is not GamepadButtonType.non_canonical:
<ol>
<li>Let |canonicalIndex:long| be the [=canonical index=] for
the button.
Expand Down Expand Up @@ -878,8 +883,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 buttonTypes
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 +912,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 +1031,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 +2051,62 @@ <h2>
Visual representation of a [=Standard Gamepad=] layout.
</figcaption>
</figure>
<section data-dfn-for="ExtendedMapping" data-link-for="ExtendedMapping">
<h3>
<dfn>ExtendedMapping</dfn>
</h3>
<p>
This section introduces an extended gamepad button mapping beyond the Standard Gamepad layout.
These additional buttons are commonly found on certain gamepad models.
The following table defines the extended 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>
<p>
To accommodate extended gamepads, we have incorporated an "extended" mapping enumeration
into the {{GamepadMappingType}}. Additionally, we have defined an enumeration for the various
button types termed {{GamepadButtonType}}, and have expanded the {{GamepadButton}}
interface to encompass this new button type enumeration.
</p>
<section>
<h3>
<dfn>GamepadButtonType</dfn> Enum
</h3>
<p>
This enum defines the set of possible button types.
</p>
<pre class="idl">
enum GamepadButtonType {
"standard",
"non-canonical",
"trackpad",
// ... More enum types to be defined by the separate W3C wiki page.
};
</pre>
<dl data-dfn-for="GamepadButtonType">
<dt>
<dfn>standard</dfn>
</dt>
<dd>
Represent a button has a button type defined in the standard mapping.
</dd>
<dt>
<dfn>non-canonical</dfn>
</dt>
<dd>
Represents a button that exists but doesn't have a canonical name.
</dd>
<dt>
<dfn>trackpad</dfn>
</dt>
<dd>
Represent a trackpad input type which beyonds the scope of the standard mapping.
<p>More enum types to be defined by the separate W3C wiki page.
</dd>
</dl>
</section>
</section>
<section>
<h3>
Fingerprinting mitigation
Expand Down

0 comments on commit 2a9ecc2

Please sign in to comment.