Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 78 additions & 4 deletions index.html
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add steps to the "initialize buttons" steps to initialize the button type.

https://w3c.github.io/gamepad/#dfn-initializing-buttons

Currently we initialize buttons in two phases. First, determine how many buttons are needed. Then, create all the buttons.

We'll need to remember the button type from the first phase so we can initialize the GamepadButton in the second phase. We also need to handle some special cases:

A GamepadButton may be created without a corresponding button input on the gamepad. (For instance, a gamepad may not have all the Standard Gamepad buttons; the button array entry for a missing button will still have a GamepadButton object but its value should never change.) We can initialize GamepadButton.type to null to represent this case.

A gamepad may have buttons that don't have a canonical button type. We should create a special GamepadButtonType enum value to signal that the button exists but doesn't have a canonical name yet.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nondebug Thanks for the feedback. Added steps for considering the button types.

Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,11 @@ <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 |type| be the result of determining if the button at index |rawInputIndex|
[=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 @@ -1235,8 +1238,17 @@ <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
|button|.{{GamepadButton/pressed}} initialized to `false`,
|button|.{{GamepadButton/touched}} initialized to `false`,
|button|.{{GamepadButton/type}} initialized to |type|, and
|button|.{{GamepadButton/value}} initialized to 0.
</li>
<li>[=list/Append=] |button| to |buttons|.
</li>
</ol>
</li>
<li>Return |buttons|.
</li>
Expand All @@ -1257,6 +1269,7 @@ <h2>
readonly attribute boolean pressed;
readonly attribute boolean touched;
readonly attribute double value;
readonly attribute GamepadButtonType type;
};
</pre>
<p>
Expand Down Expand Up @@ -1375,6 +1388,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>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're still missing getter definitions, no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, though it's implied... but yeah, if the others have the getter steps (what it was initialized to) then so should this.

</dl>
</section>
<section data-dfn-for="GamepadTouch">
Expand Down Expand Up @@ -2447,6 +2467,60 @@ <h2>
Visual representation of a [=Standard Gamepad=] layout.
</figcaption>
</figure>
<section>
Comment thread
xingri marked this conversation as resolved.
<h3>
<dfn>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.
Some examples of these additional buttons include trackpads or touchpads, share or capture buttons,
voice assistant buttons, home buttons, and various squeeze buttons.
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>
<section>
<h4>
<dfn>GamepadButtonType</dfn> Enum
Comment thread
marcoscaceres marked this conversation as resolved.
</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 {
"non-standard",
"standard",
"trackpad",
Comment thread
marcoscaceres marked this conversation as resolved.
};
</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