From 36d2213ea3f22f588d7160c3fa813bb53bfda386 Mon Sep 17 00:00:00 2001 From: Sun Shin Date: Tue, 5 Mar 2024 09:18:13 -0800 Subject: [PATCH] Add extended buttons to support trackpad (#191) --- index.html | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 125 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 8ca6304..0bd91d8 100644 --- a/index.html +++ b/index.html @@ -820,8 +820,13 @@

  • [=list/For each=] |rawInputIndex:long| of [=the range=] from 0 to |inputCount| − 1:
      -
    1. If the the gamepad button at index |rawInputIndex| - [=represents a Standard Gamepad button=]: +
    2. Let |button| be the button at index |rawInputIndex|. +
    3. +
    4. Let |type| be the result of determining if the |button| [=represents + a Standard Gamepad button=] or represents a [=additional gamepad button=]. + If it's neither, use {{GamepadButtonType/"non-standard"}}. +
    5. +
    6. If |type| is not {{GamepadButtonType/"non-standard"}}:
      1. Let |canonicalIndex:long| be the [=canonical index=] for the button. @@ -878,8 +883,14 @@

      2. Initialize |buttons| to be an empty [=list=].
      3. [=list/For each=] |buttonIndex:long| of [=the range=] from 0 to - |buttonsSize| − 1, [=list/append=] a [=new=] {{GamepadButton}} to - |buttons|. + |buttonsSize| − 1: +
          +
        1. Let |button:GamepadButton| be a [=new=] {{GamepadButton}} with its + {{GamepadButton/type}} attribute initialized to |type|. +
        2. +
        3. [=list/Append=] |button| to |buttons|. +
        4. +
      4. Return |buttons|.
      5. @@ -900,6 +911,7 @@

        readonly attribute boolean pressed; readonly attribute boolean touched; readonly attribute double value; + readonly attribute GamepadButtonType type; };

        @@ -1018,6 +1030,13 @@

      +
      + type attribute +
      +
      + An enumerated {{GamepadButtonType}} attribute that classifies the current button's type in relation to an + extended mapping. +
      @@ -2031,6 +2050,108 @@

      Visual representation of a [=Standard Gamepad=] layout. +
      +

      + Additional gamepad buttons +

      +

      + This section introduces an extended gamepad button mapping beyond the [=Standard Gamepad=] mapping. + These additional buttons are commonly found on certain gamepad models. + The following definition list represents the additional buttons used by some gamepad models. + It's important to note that this list is not exhaustive, and user agents may utilize different + or additional buttons for these or other gamepad models. + Consequently, the number of buttons on the {{Gamepad}} is not limited to the standard mapping of 17 buttons. +

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      ButtonsGamepad Models
      trackpad/touchpadSony DualSense, DualShock 4
      share/captureXbox Wireless Controller Model 1914
      + Nintendo Switch controllers
      + Stadia controller
      +
      voice assistantGoogle Stadia Controller
      + Amazon Luna Controller
      +
      homeNvidia Shield Gamepad
      squeeze_leftXbox Elite Wireless Controller
      + PlayStation DualSense Edge
      squeeze_left_lowerXbox Elite Wireless Controller
      squeeze_rightXbox Elite Wireless Controller
      + PlayStation DualSense Edge
      squeeze_right_lowerXbox Elite Wireless Controller
      +
      +

      + GamepadButtonType Enum +

      +

      + To accommodate additional gamepad buttons, we have defined an enumeration for the various button types termed + {{GamepadButtonType}}, and have expanded the {{GamepadButton}} interface to encompass this new + {{GamepadButtonType}} enumeration. +

      +

      + This enum defines the set of possible button types. +

      +
      +            enum GamepadButtonType {
      +              "standard",
      +              "non-standard",
      +              "trackpad",
      +            };
      +          
      +
      +
      + "standard" +
      +
      + Represent a button has a button type defined in the [=Standard Gamepad=] mapping. +
      +
      + "non-standard" +
      +
      + Represents a button that exists but doesn't have a standard name. +
      +
      + "trackpad" +
      +
      + Represent a trackpad input type. +
      +
      +
      +

      Fingerprinting mitigation