Skip to content

Spec gamepad input events - #234

Open
gabrielsanbrito wants to merge 3 commits into
w3c:gh-pagesfrom
gabrielsanbrito:gamepad-raw-events
Open

gabrielsanbrito wants to merge 3 commits into
w3c:gh-pagesfrom
gabrielsanbrito:gamepad-raw-events

Conversation

@gabrielsanbrito

@gabrielsanbrito gabrielsanbrito commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

This PR specifies the API changes proposed in the explainer with some changes.

Origin trial feedback in Chromium said that the extra *Changed fields - e.g. axesChanged - are not being used i their production code. Therefore, this PR makes the proposal a little simpler by removing the GamepadRawInputChangeEvent making the gamepadrawinputchanged be a regular GamepadEvent

Closes #4


Preview | Diff

@gabrielsanbrito

Copy link
Copy Markdown
Collaborator Author

@nondebug @marcoscaceres this is the first draft for the gamepad input events specification. PTAL when you have some time.

Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html
</li>
</ol>
</li>
<li>Let |oldGamepad:Gamepad| be the state of the device represented

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Before the current input changes were applied" is ambigious, please add steps to copy the state from |gamepad| to |oldGamepad| before running the steps to map and normalize buttons and axes.

Comment thread index.html
</li>
<li>If |document| is not [=allowed to use=] the [=policy-controlled
feature=] named "gamepad", then abort these steps.
</li>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the steps to update gamepad state don't check if the document is fully active before firing an event. We should update the steps to abort on not-fully-active documents so that input and connection events only fire when the document is fully active.

Comment thread index.html
<ol class="algorithm">
<li>Assert: |gamepad1| and |gamepad2| are not `null`.
</li>
<li>If [=list/size=] of |gamepad1|.{{Gamepad/[[axes]]}} is not equal

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer the possessive form:

If |gamepad1|.{{Gamepad/[[axes]]}}'s [=list/size=] is not equal to |gamepad2|.{{Gamepad/[[axes]]}}'s [=list/size=], return true.

Comment thread index.html
to the [=list/size=] of |gamepad2|.{{Gamepad/[[axes]]}}, return
`true`.
</li>
<li>[=list/For each=] |axisIndex:long| of

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

[=list/For each=] [=list/index=] |axisIndex| of |gamepad1|.{{Gamepad/[[axes]]}}:

Comment thread index.html
<li>[=list/For each=] |buttonIndex:long| of
|gamepad1|.{{Gamepad/[[buttons]]}}'s [=list/indices=]:
<ol>
<li>Let |button1:GamepadButton| be equal to

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Omit "equal to" in let statements

  • Let |button1:GamepadButton| be |gamepad1|.{{Gamepad/[[buttons]]}}[|buttonIndex|].
  • Comment thread index.html
    <li>|touch1|.{{GamepadTouch/surfaceDimensions}} and
    |touch2|.{{GamepadTouch/surfaceDimensions}} are both not
    `null`, and any of the following are true:
    <ol>

    Copy link
    Copy Markdown
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Use an unordered list

      for "any of the following"

    Comment thread index.html
    The <dfn class="event">gamepadrawinputchanged</dfn> event
    </h2>
    <p>
    This event should be fired whenever the system [=receives new button or

    Copy link
    Copy Markdown
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    SHOULD should be capitalized since it's an RFC 2119 keyword in a normative statement.

    Alternatively, we can remove "should be" and say "This event is fired" to avoid the keyword. I think there are enough cases where the event is not fired that we don't want to use "should" here.

    Comment thread index.html
    are detected=] for a gamepad device.
    </p>
    <p>
    [=User agents=] implementing this specification must provide a new DOM

    Copy link
    Copy Markdown
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Capitalize MUST

    This branch has not been deployed

    No deployments
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    Should fire events instead of using passive model

    2 participants