-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extended buttons to support trackpad (#191) #196
base: gh-pages
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -820,8 +820,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. | ||
|
@@ -878,8 +881,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> | ||
|
@@ -900,6 +912,7 @@ <h2> | |
readonly attribute boolean pressed; | ||
readonly attribute boolean touched; | ||
readonly attribute double value; | ||
readonly attribute GamepadButtonType type; | ||
}; | ||
</pre> | ||
<p> | ||
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we're still missing getter definitions, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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="GamepadMappingType"> | ||
|
@@ -2035,6 +2055,60 @@ <h2> | |
Visual representation of a [=Standard Gamepad=] layout. | ||
</figcaption> | ||
</figure> | ||
<section> | ||
xingri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<h3> | ||
<dfn data-lt="additional gamepad button">Additional gamepad buttons</dfn> | ||
marcoscaceres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</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 | ||
marcoscaceres marked this conversation as resolved.
Show resolved
Hide 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 { | ||
"standard", | ||
"non-standard", | ||
"trackpad", | ||
marcoscaceres marked this conversation as resolved.
Show resolved
Hide resolved
marcoscaceres marked this conversation as resolved.
Show resolved
Hide 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 | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.