Re: [w3c/gamepad] spec `gamepadbuttondown` and `gamepadbuttonup` events (issue #4) (#15)

nondebug commented on this pull request.



> @@ -441,6 +441,171 @@ <h2><dfn>GamepadEvent</dfn> Interface</h2>
       </dl>
     </section>
 
+    <section>
+      <h2><dfn>GamepadButtonEvent</dfn> Interface</h2>
+      <dl title='[Constructor(GamepadButtonEventInit eventInitDict)] interface GamepadButtonEvent : Event'
+          class='idl'>
+        <dt>readonly attribute Gamepad gamepad</dt>
+
+        <dd>
+
+            The single gamepad attribute provides access to the associated
+            gamepad data for this event.
+
+        </dd>
+
+        <dt>readonly attribute GamepadButton button</dt>

Firefox's implementation uses a button index instead of a GamepadButton:

gamepadbuttondown { target: Window → /, isTrusted: true, **button: 1**, gamepad: Gamepad, currentTarget: Window → /, eventPhase: 2, bubbles: false, cancelable: false, defaultPrevented: false, composed: false, timeStamp: 1530125797442210 }

I think it would be better to include the button index to make it easier for listeners to know which button was pressed. The GamepadButton can be accessed through the gamepad attribute once we know the index, but it's difficult to determine a button's index from a GamepadButton.

> +      <dl title='[Constructor(GamepadButtonEventInit eventInitDict)] interface GamepadButtonEvent : Event'
+          class='idl'>
+        <dt>readonly attribute Gamepad gamepad</dt>
+
+        <dd>
+
+            The single gamepad attribute provides access to the associated
+            gamepad data for this event.
+
+        </dd>
+
+        <dt>readonly attribute GamepadButton button</dt>
+
+        <dd>
+
+            The single button attribute provides access to the associated

The event is asynchronous, but gamepad data is polled synchronously. This means that the button state in GamepadButton may not match the state as described by the event. For instance, for a gamepadbuttondown event, e.button.pressed may no longer be true if the button was released between the time the event was fired and when it was handled.

This proposal should be modified to indicate if the state in e.button is intended to preserve the button's state when the event was generated or if it should report the current button state.

> +          <a href="#event-gamepadbuttondown"><code>gamepadbuttondown</code></a>
+          event associated with the same key.
+        </p>
+
+    </section>
+
+    <section>
+
+        <h3>Other events</h3>
+
+        <p>
+
+          <i>More discussion is needed on whether to include events for axis
+          changes (e.g., <code>gamepadaxismove</code> for whenever the value of
+          an axis changes, or <code>gamepadaxischange</code> for whenever the
+          active axis changes), etc.</i>

What is an active axis?

> +          event for that gamepad to a window, a
+          <a><code>gamepaddisconnected</code></a> event MUST be dispatched to
+          that same window.
+        </p>
+
+    </section>
+
+    <section>
+
+        <h3 id="event-gamepadbuttondown">The <dfn class="event">gamepadbuttondown</dfn> event</h3>
+
+        <p>
+          User agents implementing this specification must provide a new DOM
+          event, named <a><code>gamepadbuttondown</code></a>. The
+          corresponding event MUST be of type
+          <a href="#gamepadevent-interface"><code>GamepadEvent</code></a>

GamepadButtonEvent

-- 
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/15#pullrequestreview-132568550

Received on Wednesday, 27 June 2018 19:17:41 UTC