Re: [w3c/gamepad] Add extended buttons to support trackpad (#191) (PR #196)

@nondebug commented on this pull request.



> @@ -649,6 +649,168 @@ <h2>
         </p>
       </dd>
     </section>
+    <section>

Let's define extended buttons in the main spec document (index.html). The extensions document is not officially part of the spec and we want to eventually remove it.

The spec PR should extend [GamepadButton](https://www.w3.org/TR/gamepad/#gamepadbutton-interface) to add a new attribute (perhaps called `GamepadButton.name`) and an algorithm for the getter. The type of the new attribute will be a new enum (perhaps called `GamepadButtonName`). The enum type should be defined in the spec along with all its values.

Add steps to initialize the new attribute when [initializing buttons](https://www.w3.org/TR/gamepad/#dfn-initializing-buttons). The steps should define what to do if a gamepad is missing a button defined in the Standard Gamepad. I think it makes sense to use a special value for these buttons so applications can identify which buttons are not actually mapped. (Ideally we'd set the button to null, but this would break existing apps which don't check for null.)

Also, initialization steps should define what to do if a gamepad has a button that doesn't have a predefined Standard Gamepad index or enum value. Do we enumerate it? If so, what should the new attribute's value be? Perhaps we can add a special "unrecognized" value for this.

> @@ -649,6 +649,168 @@ <h2>
         </p>
       </dd>
     </section>
+    <section>
+      <h2>
+        "extended" Gamepad Buttons Mapping
+      </h2>
+      <p>
+        This section defines extended gamepad buttons mapping beyonds the Standard Gamepads layout,
+        but are commonly found on some gamepad models .The <code>_ext</code> suffix is used to indicate

The `_ext` suffix comes from OpenXR's input subpaths specification:

https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#_adding_input_sources_via_extensions

We should decide whether this attribute uses OpenXR input subpaths or something new that we want to define for ourselves. If we're using OpenXR subpaths then we should explicitly link to the OpenXR spec which explains how to extend it. If we're only using it for inspiration then I think we should drop the `_ext` suffix.

> +            <td>buttons[14]</td>
+            <td>dpad_left</td>
+            <td>Standard: Left button in left cluster</td>
+          </tr>
+          <tr>
+            <td>buttons[15]</td>
+            <td>dpad_right</td>
+            <td>Standard: Right button in left cluster</td>
+          </tr>
+          <tr>
+            <td>buttons[16]</td>
+            <td>system</td>
+            <td>Standard: Center button in center cluster</td>
+          </tr>
+          <tr>
+            <td>buttons[17]</td>

This suggests the "trackpad" button can only appear at `buttons[17]`. My thinking is that we should not continue the current pattern of assigning meaning to button indices, otherwise the `buttons` array will be very sparse since most gamepads do not share the same extra buttons. Instead of using button indices to identify buttons, apps can check the new enum attribute.

For this non-normative section, I think it will be clearer if we provide a separate table for each gamepad instead of trying to combine them all into a single table.

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

Message ID: <w3c/gamepad/pull/196/review/1918599015@github.com>

Received on Wednesday, 6 March 2024 02:33:02 UTC