From 519153ea33732a3fc3fe5387b28774f2450f491b Mon Sep 17 00:00:00 2001 From: Matt Reynolds Date: Thu, 4 Jun 2020 15:29:42 -0700 Subject: [PATCH] Rewrite gamepad spec using algorithms --- index.html | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/index.html b/index.html index 2048375..c21f958 100644 --- a/index.html +++ b/index.html @@ -204,6 +204,132 @@

sensing, depth sensing, video analysis, gesture recognition, and so on.

+ +
+

+ Model +

+

+ A gamepad is a physical or virtual input + device that provides button and/or axis inputs. The + host is the operating system environment + hosting the user agent. The host MUST provide an algorithm for + enumerating connected gamepads. A + gamepad is considered connected when the + host is capable of reading new inputs. A gamepad that is not connected + is disconnected. +

+

+ The host MUST provide an algorithm for synchronously + reading input data from the + gamepad. If the host does not provide such an algorithm, the user agent + MAY implement an algorithm that caches the most recent input data and + synchronously returns the cached value. +

+

+ When a gamepad transitions from disconnected to connected, it + becomes connected. Likewise, + when a gamepad transitions from connected to disconnected, it + becomes disconnected. The + host MUST provide algorithms to register listeners for these + transitions. If these events are not available, the user agent MAY + implement an algorithm that synthesizes the events by periodically + enumerating connected gamepads. +

+

+ The user agent MUST define a + gamepad user gesture. A + gamepad user gesture is a class of gamepad input state transitions that + signify that the user is interacting with the gamepad. At a minimum, the + gamepad user gesture MUST include state changes where any button + transitions from unpressed to pressed. Other transitions MAY be included + as user gestures. A transition MUST NOT be included if the transition + could occur without user interaction. +

+

+ The user agent MUST NOT expose information about connected gamepads + until a gamepad user gesture has been received from any connected + gamepad. The user gesture MUST be tracked independently for each gamepad + context. A gamepad context MUST be + created when a page first requests the current gamepad state or + registers for gamepad connection events. The gamepad context MUST be + destroyed when the tab is closed or navigates away from the current + page. Reloading the current page MUST NOT destroy the gamepad context. +

+

+ To register a user gesture, a gamepad context MUST be active. A gamepad + context is active if the page associated with the context is visible and + the page is capable of executing script. If the page is not visible or + the page cannot execute script, the context is inactive. When a context + is first created or when it transitions from inactive to active, it + becomes active. Likewise, when + it transitions from active to inactive, it + becomes inactive. +

+
+ + +
+

+ Steps to execute when a gamepad context is created +

+

+ The steps to register a new gamepad context. +

+
    +
  1. + Let |context| be a new gamepad context object. +
  2. +
  3. + Set context["seenGamepadGesture"] to false. +
  4. +
  5. + Run "Steps to execute when a gamepad context becomes active". +
  6. +
+
+ +
+

+ Steps to execute when a gamepad context becomes active +

+

+ The steps to transition a gamepad context to an active state. +

+
    +
  1. + Let |context| be the gamepad context object. +
  2. +
  3. + Set context["active"] to true. +
  4. +
  5. If context["seenGamepadGesture"] is false: +
      +
    1. + Register a gamepad user gesture listener. When a gamepad user gesture + is received, run "Steps to execute when a gamepad user gesture is received". +
    2. +
    +
  6. +
+
+ +
+

+ Steps to execute when a gamepad user gesture is received +

+

+
    +
  1. + Let |context| be the gamepad context object. +
  2. +
  3. + Set context["seenGamepadGesture"] to true. +
  4. +
+
+ +

Gamepad interface