From 28c67f8ab4d68d0a2ebe642cf68f6a7971d16c4c 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 | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 126 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 8ca6304..74c8eaa 100644 --- a/index.html +++ b/index.html @@ -820,8 +820,11 @@

  • [=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 |type| be the result of determining if the button at index |rawInputIndex| + [=represents a Standard Gamepad button=] or represents a [=additional gamepad button=]. + If it's neither, use {{GamepadButtonType/"non-standard"}}. +
    3. +
    4. If |type| is not {{GamepadButtonType/"non-standard"}}:
      1. Let |canonicalIndex:long| be the [=canonical index=] for the button. @@ -878,8 +881,17 @@

      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|, + button.value initialized to 0, + button.pressed initialized to false, and + button.touched initialized to false. +
        2. +
        3. [=list/Append=] |button| to |buttons|. +
        4. +
      4. Return |buttons|.
      5. @@ -900,6 +912,7 @@

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

        @@ -1018,6 +1031,13 @@

      +
      + type attribute +
      +
      + An enumerated {{GamepadButtonType}} attribute that classifies the current button's type in relation to an + extended mapping. +
      @@ -2031,6 +2051,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