Re: [w3c/gamepad] Add buttondown, buttonup, buttonchange, axischange events (#152)

@reillyeon requested changes on this pull request.



> +              {{GamepadAxisEvent/gamepadIndex}} attribute initialized to
+              |gamepad|.{{Gamepad/index}}, its {{GamepadAxisEvent/axisIndex}}
+              attribute initialized to |axisIndex|, its
+              {{GamepadAxisEvent/axisSnapshot}} attribute initialized to
+              |newValue|, and its {{GamepadAxisEvent/gamepadTimestamp}}
+              attribute initialized to |now|.
+              </li>
+            </ol>
+          </li>
+          <li>[=list/For each=] |buttonIndex:long| of [=the range=] from 0 to
+          the [=list/size=] of |gamepad|.{{Gamepad/buttons}} − 1:
+            <ol>
+              <li>Let |button:GamepadButton| be
+              |gamepad|.{{Gamepad/[[buttons]]}}[|buttonIndex|].
+              </li>
+              <li>If |oldButtonValue|[|buttonIndex|] is not equal to

```suggestion
              <li>If |oldButtonValues|[|buttonIndex|] is not equal to
```

> +              <li>Let |button:GamepadButton| be
+              |gamepad|.{{Gamepad/[[buttons]]}}[|buttonIndex|].
+              </li>
+              <li>If |oldButtonValue|[|buttonIndex|] is not equal to
+              |button|.{{GamepadButton/value}}:
+                <ol>
+                  <li>Let |buttonCopy| be a [=new=] {{GamepadButton}} instance
+                  with its {{GamepadButton/value}} attribute initialized to
+                  |button|.{{GamepadButton/value}}, its
+                  {{GamepadButton/pressed}} attribute initialized to
+                  |button|.{{GamepadButton/pressed}}, and its
+                  {{GamepadButton/touched}} attribute initialized to
+                  |button|.{{GamepadButton/touched}}.
+                  </li>
+                  <li>[=Queue a task=] on the [=gamepad task source=] to [=fire
+                  an event=] named {{buttonchange}} at |gamepad| using

Should `buttonchange` also fire when a button is touched but its value has not changed or do we want to save that for separate `buttontouchdown` and `buttontouchup` events?

> +              {{GamepadAxisEvent/axisSnapshot}} attribute initialized to
+              |newValue|, and its {{GamepadAxisEvent/gamepadTimestamp}}
+              attribute initialized to |now|.
+              </li>
+            </ol>
+          </li>
+          <li>[=list/For each=] |buttonIndex:long| of [=the range=] from 0 to
+          the [=list/size=] of |gamepad|.{{Gamepad/buttons}} − 1:
+            <ol>
+              <li>Let |button:GamepadButton| be
+              |gamepad|.{{Gamepad/[[buttons]]}}[|buttonIndex|].
+              </li>
+              <li>If |oldButtonValue|[|buttonIndex|] is not equal to
+              |button|.{{GamepadButton/value}}:
+                <ol>
+                  <li>Let |buttonCopy| be a [=new=] {{GamepadButton}} instance

Define a "create a button snapshot" algorithm to capture this logic in one place?

> @@ -1207,6 +1354,173 @@ <h3>
         </dl>
       </section>
     </section>
+    <section data-dfn-for="GamepadAxisEvent">
+      <h2>
+        <dfn>GamepadAxisEvent</dfn> Interface
+      </h2>
+      <pre class="idl" data-cite="DOM">
+        [Exposed=Window, SecureContext]
+
+        interface GamepadAxisEvent: Event {

```suggestion
        interface GamepadAxisEvent : Event {
```

> @@ -1207,6 +1354,173 @@ <h3>
         </dl>
       </section>
     </section>
+    <section data-dfn-for="GamepadAxisEvent">
+      <h2>
+        <dfn>GamepadAxisEvent</dfn> Interface
+      </h2>
+      <pre class="idl" data-cite="DOM">
+        [Exposed=Window, SecureContext]
+

```suggestion
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/gamepad/pull/152#pullrequestreview-712276250

Received on Wednesday, 21 July 2021 23:59:36 UTC