diff --git a/index.html b/index.html index 0368aa4..3c7401e 100644 --- a/index.html +++ b/index.html @@ -63,10 +63,9 @@ implementationReportURI: "https://wpt.fyi/results/gamepad", caniuse: "gamepad", - xref: ["HTML", "DOM"], + xref: ["HTML", "DOM", "PERMISSIONS-POLICY", "HR-TIME", "Infra"], }; -
- Some user agents have connected gamepad devices. These devices - are desirable and suited to input for gaming applications, and for "10 + Some [=user agent=]s have connected gamepad devices. These devices are + desirable and suited to input for gaming applications, and for "10 foot" user interfaces (presentations, media viewers).
Currently, the only way for a gamepad to be used as input would be to emulate mouse or keyboard events, however this would lose information - and require additional software outside of the user agent to + and require additional software outside of the [=user agent=] to accomplish emulation.
@@ -104,22 +103,6 @@
- This specification references interfaces from a number of other - specifications: -
-+ The algorithms used to communicate with the system typically complete + asynchronously, queuing work on the gamepad task source. +
++ Instances of {{Gamepad}} are created with the internal slots described + in the following table: +
++ Internal slot + | ++ Initial value + | ++ Description (non-normative) + | +
---|---|---|
+ [[\connected]] + | ++ `false` + | ++ A flag indicating that the device is connected to the system + | +
+ [[\timestamp]] + | ++ undefined + | ++ The last time data for this {{Gamepad}} was updated + | +
+ [[\axes]] + | ++ An empty [=sequence=] + | ++ A [=sequence=] of {{double}} values representing the current state + of axes exposed by this device + | +
+ [[\buttons]] + | ++ An empty [=sequence=] + | ++ A [=sequence=] of {{GamepadButton}} objects representing the + current state of buttons exposed by this device + | +
+ [[\exposed]] + | ++ `false` + | ++ A flag indicating that the {{Gamepad}} object has been exposed to + script + | +
+ [[\axisMapping]] + | ++ An empty [=ordered map=] + | ++ Mapping from unmapped axis index to an index in the + {{Gamepad/axes}} array + | +
+ [[\axisMinimums]] + | ++ An empty [=list=] + | ++ A [=list=] containing the minimum logical value for each axis + | +
+ [[\axisMaximums]] + | ++ An empty [=list=] + | ++ A [=list=] containing the maximum logical value for each axis + | +
+ [[\buttonMapping]] + | ++ An empty [=ordered map=] + | ++ Mapping from unmapped button index to an index in the + {{Gamepad/buttons}} array + | +
+ [[\buttonMinimums]] + | ++ An empty [=list=] + | ++ A [=list=] containing the minimum logical value for each button. + | +
+ [[\buttonMaximums]] + | ++ An empty [=list=] + | ++ A [=list=] containing the maximum logical value for each button + | +
+ An identification string for the gamepad. This string identifies + the brand or style of connected gamepad device. +
++ The exact format of the {{Gamepad/id}} string is left unspecified. + It is RECOMMENDED that the [=user agent=] select a string that + identifies the product without uniquely identifying the device. For + example, a USB gamepad may be identified by its `idVendor` and + `idProduct` values. Unique identifiers like serial numbers or + Bluetooth device addresses MUST NOT be included in the + {{Gamepad/id}} string. +
+ Indicates whether the physical device represented by this object is + still connected to the system. When a gamepad becomes unavailable, + whether by being physically disconnected, powered off or otherwise + unusable, the {{Gamepad/connected}} attribute MUST be set to + `false`. +
++ The {{Gamepad/connected}} getter steps are: +
+navigationStart
attribute of the
- PerformanceTiming interface. Since values are monotonically
- increasing they can be compared to determine the ordering of updates,
- as newer values will always be greater than or equal to older values.
- If no data has been received from the hardware, the value of the
- timestamp
attribute should be the time relative to
- navigationStart
when the Gamepad object was first
- made available to script.
+ + The {{Gamepad/timestamp}} allows the author to determine the last + time the {{Gamepad/axes}} or {{Gamepad/buttons}} attribute for this + gamepad was updated. The value MUST be set to the [=current high + resolution time=] each time the system [=receives new button or + axis input values=] from the device. If no data has been received + from the hardware, {{Gamepad/timestamp}} MUST be the [=current high + resolution time=] at the time when the {{Gamepad}} was first made + available to script. +
++ [=User agent=]s SHOULD set a minimum resolution of |gamepad|'s + {{Gamepad/timestamp}} attribute to 5 microseconds, following + [[HR-TIME]]'s clock resolution recommendation. +
++ The {{Gamepad/timestamp}} getter steps are: +
++ The mapping in use for this device. If the user agent has knowledge + of the layout of the device, then it SHOULD indicate that a mapping + is in use by setting {{Gamepad/mapping}} to the corresponding + {{GamepadMappingType}} value. +
++ To select a mapping for a + gamepad device, run the following steps: +
++ Array of values for all axes of the gamepad. All axis values MUST + be linearly normalized to the range [-1.0 .. 1.0]. If the + controller is perpendicular to the ground with the directional + stick pointing up, -1.0 SHOULD correspond to "forward" or "left", + and 1.0 SHOULD correspond to "backward" or "right". Axes that are + drawn from a 2D input device SHOULD appear next to each other in + the axes array, X then Y. It is RECOMMENDED that axes appear in + decreasing order of importance, such that element 0 and 1 typically + represent the X and Y axis of a directional stick. The same object + MUST be returned until the [=user agent=] needs to return different + values (or values in a different order). +
++ The {{Gamepad/axes}} getter steps are: +
++ Array of button states for all buttons of the gamepad. It is + RECOMMENDED that buttons appear in decreasing importance such that + the primary button, secondary button, tertiary button, and so on + appear as elements 0, 1, 2, ... in the buttons array. The same + object MUST be returned until the [=user agent=] needs to return + different values (or values in a different order). +
++ The {{Gamepad/buttons}} getter steps are: +
++ When the system receives new button or axis input values, + run the following steps: +
++ To update gamepad state for |gamepad:Gamepad|, run the + following steps: +
++ To map and normalize axes for |gamepad:Gamepad|, run the + following steps: +
++ To map and normalize buttons for |gamepad:Gamepad|, run + the following steps: +
++ If the button has a digital switch to indicate a pure pressed + or released state, set |button|.{{GamepadButton/[[pressed]]}} + to `true` if the button is pressed or `false` if it is not + pressed. +
++ Otherwise, set |button|.{{GamepadButton/[[pressed]]}} to + `true` if the value is above the [=button press threshold=] + or `false` if it is not above the threshold. +
++ If the button is capable of detecting touch, set + |button|.{{GamepadButton/[[touched]]}} to `true` if the + button is currently being touched. +
++ Otherwise, set |button|.{{GamepadButton/[[touched]]}} to + |button|.{{GamepadButton/[[pressed]]}}. +
++ A new `Gamepad` representing a connected gamepad device is + constructed by performing the following steps: +
++ To select an unused + gamepad index for |gamepad:Gamepad|, run the following steps: +
++ To initialize axes for + |gamepad:Gamepad|, run the following steps: +
++ Otherwise: +
++ Otherwise, [=list/append=] |rawInputIndex| to + |unmappedInputList|. +
++ To initialize buttons for a + gamepad, run the following steps: +
++ Otherwise: +
++ Otherwise, [=list/append=] |rawInputIndex| to + |unmappedInputList|. +
++ Instances of {{GamepadButton}} are created with the internal slots + described in the following table: +
++ Internal slot + | ++ Initial value + | ++ Description (non-normative) + | +
---|---|---|
+ [[\pressed]] + | ++ `false` + | ++ A flag indicating that the button is pressed + | +
+ [[\touched]] + | ++ `false` + | ++ A flag indicating that the button is touched + | +
+ [[\value]] + | ++ 0.0 + | ++ A {{double}} representing the button value scaled to the range [0.0 + .. 1.0] + | +
+ The pressed state of the button. This property MUST be `true` if + the button is currently pressed, and `false` if it is not pressed. + For buttons which do not have a digital switch to indicate a pure + pressed or released state, the [=user agent=] MUST choose a + button press threshold to indicate the button as pressed + when its value is above a certain amount. If the platform API gives + a recommended value, the user agent SHOULD use that. In other + cases, the user agent SHOULD choose some other reasonable value. +
++ The {{GamepadButton/pressed}} getter steps are: +
++ The touched state of the button. If the button is capable of + detecting touch, this property MUST be `true` if the button is + currently being touched, and `false` otherwise. If the button is + not capable of detecting touch and is capable of reporting an + analog value, this property MUST be `true` if the value property is + greater than 0, and `false` if the value is 0. If the button is not + capable of detecting touch and can only report a digital value, + this property MUST mirror the {{GamepadButton/pressed}} attribute. +
++ The {{GamepadButton/touched}} getter steps are: +
++ For buttons that have an analog sensor, this property MUST + represent the amount which the button has been pressed. All button + values MUST be linearly normalized to the range [0.0 .. 1.0]. 0.0 + MUST mean fully unpressed, and 1.0 MUST mean fully pressed. For + buttons without an analog sensor, only the values 0.0 and 1.0 for + fully unpressed and fully pressed respectively, MUST be provided. +
++ The {{GamepadButton/value}} getter steps are: +
+- This partial interface defines an extension to the Navigator interface. -
[Exposed=Window] partial interface Navigator { sequence<Gamepad?> getGamepads(); };-
- The gamepad state returned from {{Navigator/getGamepads()}} does - not reflect disconnection or connection until after the - gamepaddisconnected or gamepadconnected events have - fired. -
-- If the current settings object's [=environment settings - object / responsible document=] is not allowed to use the - "`gamepad`" permission, then [=exception/throw=] a - {{"SecurityError"}} {{DOMException}}. -
-- The gamepad state returned from getGamepads() does not reflect - disconnection or connection until after the - gamepaddisconnected or gamepadconnected events have - fired. -
-- As an example, if there is one connected gamepad with an index of - 1, then the following code snippet describes the expected behavior: -
-++ Instances of {{Navigator}} are created with the internal slots + described in the following table: +
+
+ Internal slot + | ++ Initial value + | ++ Description (non-normative) + | +
---|---|---|
+ [[\hasGamepadGesture]] + | ++ `false` + | ++ A flag indicating that a [=gamepad user gesture=] has been observed + | +
+ [[\gamepads]] + | ++ `[]` + | ++ A `sequence<Gamepad?>` with each {{Gamepad}} present at the + index specified by its {{Gamepad/index}} attribute, or `null` for + unassigned indices. + | +
+ The gamepad state returned from {{Navigator/getGamepads()}} does not + reflect disconnection or connection until after the + {{gamepaddisconnected}} or {{gamepadconnected}} events have fired. +
++ To mitigate fingerprinting, {{Navigator/getGamepads()}} returns an + empty [=list=] before a [=gamepad user gesture=] has been seen. + [[FINGERPRINTING-GUIDANCE]] +
++ The {{Navigator/getGamepads()}} method steps are: +
++ A |gamepad:Gamepad| contains a + gamepad user gesture if the current input state indicates that + the user is currently interacting with the gamepad. The [=user + agent=] MUST provide an algorithm to check if the input state + contains a gamepad user gesture. For buttons that support a neutral + default value and have reported a {{GamepadButton/pressed}} value of + `false` at least once, a {{GamepadButton/pressed}} value of `true` + SHOULD be considered interaction. If a button does not support a + neutral default value (for example, a toggle switch), then a + {{GamepadButton/pressed}} value of `true` SHOULD NOT be considered + interaction. If a button has never reported a + {{GamepadButton/pressed}} value of `false` then it SHOULD NOT be + considered interaction. Axis movements SHOULD be considered + interaction if the axis supports a neutral default value, the current + displacement from neutral is greater than a threshold chosen by the + [=user agent=], and the axis has reported a value below the threshold + at least once. If an axis does not support a neutral default value + (for example, an axis for a joystick that does not self-center), or + an axis has never reported a value below the axis gesture threshold, + then the axis SHOULD NOT be considered when checking for interaction. + The axis gesture threshold SHOULD be large enough that random jitter + is not considered interaction. +
+Each device manufacturer creates many different products and each has unique styles and layouts of buttons and axes. It is intended that the - user agent support as many of these as possible. + [=user agent=] support as many of these as possible.
Additionally there are de facto standard layouts that have - been made popular by game consoles. When the user agent - recognizes the attached device, it is RECOMMENDED that it be remapped - to a canonical ordering when possible. Devices that are not recognized + been made popular by game consoles. When the [=user agent=] recognizes + the attached device, it is RECOMMENDED that it be remapped to a + canonical ordering when possible. Devices that are not recognized should still be exposed in their raw form.
- There is currently one canonical device, the "Standard Gamepad". The - standard gamepad has 4 axes, and up to 17 buttons. When remapping, the - indices in axes[] and buttons[] should correspond as - closely as possible to the physical locations in the diagram below. - Additionally, the mapping property of the Gamepad SHOULD be set - to the string {{GamepadMappingType["standard"]}}. -
-- The "Standard Gamepad" physical button locations are layed out in a - left cluster of four buttons, a right cluster of four buttons, a center - cluster of three buttons, and a pair of front facing buttons on the - left and right side of the gamepad. The four axes of the "Standard - Gamepad" are associated with a pair of analog sticks, one on the left - and one on the right. The following table describes the buttons/axes - and their physical locations. + There is currently one canonical layout, the Standard + Gamepad. When remapping, the indices in {{Gamepad/axes}} and + {{Gamepad/buttons}} should correspond as closely as possible to the + physical locations in the diagram below. Additionally, + {{Gamepad/mapping}} SHOULD be set to {{GamepadMappingType/"standard"}}. +
++ The [=Standard Gamepad=] buttons are laid out in a left cluster of four + buttons, a right cluster of four buttons, a center cluster of three + buttons, and a pair of front facing buttons on the left and right side + of the gamepad. The four axes of the "Standard Gamepad" are associated + with a pair of analog sticks, one on the left and one on the right. The + following table describes the buttons/axes and their physical + locations. +
++ An axis input represents a Standard Gamepad axis if it + reports the input value for a thumbstick axis, the thumbstick is + located in approximately the same location as the corresponding + [=Standard Gamepad=] thumbstick, and the orientation of the axis + (up-down or left-right) matches the orientation of the [=Standard + Gamepad=] axis. If there are multiple axes that represent the same + [=Standard Gamepad=] axis, then the [=user agent=] SHOULD select one to + be the [=Standard Gamepad=] axis and assign a different index to the + other axis. +
++ A button input represents a Standard Gamepad button if it + reports the input value for a button or trigger, and the button or + trigger is located in approximately the same location as the + corresponding [=Standard Gamepad=] button. +
++ If an axis or button input represents a [=Standard Gamepad=] axis or + button, then its canonical index is the index of the + corresponding [=Standard Gamepad=] axis or button.