Re: [w3c/gamepad] Spec gamepad input events (PR #234)

@gabrielsanbrito commented on this pull request.



> 

I think there is also a small spec bug here. I believe that `axisIndex` should actually be `mappedIndex`. I will fix it .
```suggestion
<li>Set |gamepad|.{{Gamepad/[[axes]]}}[|mappedIndex|] to be
|normalizedValue|.
```

> @@ -839,6 +842,27 @@ <h3>
               </li>
             </ol>
           </li>
+          <li>If |navigator|.{{Navigator/[[hasGamepadGesture]]}} is `true` and
+          |navigator|.{{Navigator/[[gamepads]]}}[|gamepad|.{{Gamepad/index}}]
+          is not `null`:
+            <ol>
+              <li>Let |hasInputChanged:boolean| be the result of running the
+              steps to [=detect gamepad input changes=] between
+              |navigator|.{{Navigator/[[gamepads]]}}[|gamepad|.{{Gamepad/index}}]

Understood. Switched it to start using `oldGamepad` instead.

> @@ -1006,6 +1030,100 @@ <h3>
             </ol>
           </li>
         </ol>
+        <p>
+          To <dfn>detect gamepad input changes</dfn> between |gamepad1:Gamepad|
+          and |gamepad2:Gamepad|, run the following steps:
+        </p>
+        <ol class="algorithm">
+          <li>Assert: |gamepad1| and |gamepad2| are not `null`.
+          </li>
+          <li>Let |maxAxisIndex:long| be the [=list/size=] of
+          |gamepad1|.{{Gamepad/[[axes]]}} - 1.
+          </li>
+          <li>[=list/For each=] |axisIndex:long| of [=the range=] from 0 to
+          |maxAxisIndex|:

Done. Also did the same for buttons to maintain consistency.

> @@ -1006,6 +1030,100 @@ <h3>
             </ol>
           </li>
         </ol>
+        <p>
+          To <dfn>detect gamepad input changes</dfn> between |gamepad1:Gamepad|
+          and |gamepad2:Gamepad|, run the following steps:
+        </p>
+        <ol class="algorithm">
+          <li>Assert: |gamepad1| and |gamepad2| are not `null`.
+          </li>
+          <li>Let |maxAxisIndex:long| be the [=list/size=] of
+          |gamepad1|.{{Gamepad/[[axes]]}} - 1.
+          </li>
+          <li>[=list/For each=] |axisIndex:long| of [=the range=] from 0 to
+          |maxAxisIndex|:
+            <ol>
+              <li>If |gamepad1|.{{Gamepad/[[axes]]}}[|axisIndex|] is different

Done for both

> +                  <li>|touch1|.{{GamepadTouch/touchId}} is different from
+                  |touch2|.{{GamepadTouch/touchId}}
+                  </li>
+                  <li>|touch1|.{{GamepadTouch/surfaceId}} is different from
+                  |touch2|.{{GamepadTouch/surfaceId}}
+                  </li>
+                  <li>|touch1|.{{GamepadTouch/position}}.{{DOMPointReadOnly/x}}
+                  is different from
+                  |touch2|.{{GamepadTouch/position}}.{{DOMPointReadOnly/x}}
+                  </li>
+                  <li>|touch1|.{{GamepadTouch/position}}.{{DOMPointReadOnly/y}}
+                  is different from
+                  |touch2|.{{GamepadTouch/position}}.{{DOMPointReadOnly/y}}
+                  </li>
+                  <li>
+                  |touch1|.{{GamepadTouch/surfaceDimensions}}.{{DOMRectReadOnly/width}}

Done

> +          </li>
+          <li>Let |maxButtonIndex:long| be the [=list/size=] of
+          |gamepad1|.{{Gamepad/[[buttons]]}} - 1.
+          </li>
+          <li>[=list/For each=] |buttonIndex:long| of [=the range=] from 0 to
+          |maxButtonIndex|:
+            <ol>
+              <li>Let |button1:GamepadButton| be equal to
+              |gamepad1|.{{Gamepad/[[buttons]]}}[|buttonIndex|].
+              </li>
+              <li>Let |button2:GamepadButton| be equal to
+              |gamepad2|.{{Gamepad/[[buttons]]}}[|buttonIndex|].
+              </li>
+              <li>If any of the following are true, then return `true`:
+                <ul>
+                  <li>|button1|.{{GamepadButton/[[value]]}} is different from

Done

> @@ -839,6 +842,27 @@ <h3>
               </li>
             </ol>
           </li>
+          <li>If |navigator|.{{Navigator/[[hasGamepadGesture]]}} is `true` and
+          |navigator|.{{Navigator/[[gamepads]]}}[|gamepad|.{{Gamepad/index}}]
+          is not `null`:
+            <ol>
+              <li>Let |hasInputChanged:boolean| be the result of running the
+              steps to [=detect gamepad input changes=] between
+              |navigator|.{{Navigator/[[gamepads]]}}[|gamepad|.{{Gamepad/index}}]
+              and |gamepad|.
+              </li>
+              <li>If |hasInputChanged| is `true`:
+                <ol>
+                  <li>[=queue a global task=] on the [=gamepad task source=] to

Done. I also thought that there was something off about the `gamepadconnected` bit but wasn't sure. Thanks for

> @@ -787,6 +787,17 @@ <h3>
           following steps:
         </p>
         <ol>
+          <li>Let |navigator:Navigator| be |gamepad|'s [=relevant global
+          object=]'s {{Navigator}} object.
+          </li>
+          <li>Let |document:Document?| be |gamepad|'s [=relevant global
+          object=]'s [=associated `Document`=]; otherwise `null`.
+          </li>
+          <li>If |document| is `null`, abort these steps.
+          </li>
+          <li>If |document| is not [=allowed to use=] the `"gamepad"`

I copied this text from the `gamepadconnected` section. I also noticed that it is used the same way in the [getGamepads](https://w3c.github.io/gamepad/#getgamepads-method) algorithm. I also updated these other places.

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

Message ID: <w3c/gamepad/pull/234/review/5322843831@github.com>

Received on Saturday, 26 September 2026 01:09:58 UTC