Skip to content

Add gamepad support to simulator#262

Merged
dli7319 merged 11 commits intogoogle:mainfrom
salmanmkc:demo/gamepad-support
May 9, 2026
Merged

Add gamepad support to simulator#262
dli7319 merged 11 commits intogoogle:mainfrom
salmanmkc:demo/gamepad-support

Conversation

@salmanmkc
Copy link
Copy Markdown
Contributor

@salmanmkc salmanmkc commented May 8, 2026

Adds gamepad support to the simulator so people on PC who don't want to switch to keyboard/mouse can use an Xbox/PS controller instead. WebXR already supports controllers, but the desktop simulator preview didn't.

Sticks move and look, triggers go up/down, RB toggles the UI, Start opens a settings panel for rebinding buttons, D-pad cycles hand poses. In Controller mode the stick also moves the active hand. Bindings are stored in localStorage so they persist.

When the settings panel is open it grabs gamepad input so the camera doesn't fly around while you're picking menu items.

Tested manually with an Xbox controller. New unit tests cover the bindings store and rising-edge button timing.

Demo: https://youtu.be/RgJJfYdkvJM

salmanmkc added 9 commits May 8, 2026 12:46
Lets you drive the simulator with an Xbox/PS controller: left stick to move, right stick to look, LT/RT for up/down, A to select, RB toggles UI, Start opens a settings panel where you can rebind buttons. D-pad cycles hand poses (auto-switches out of User mode so the change is visible). In Controller mode the left stick / triggers also move the active hand. Settings panel itself is navigable with the stick, D-pad or LT/RT — A activates, B closes — and grabs gamepad input while open so you don't move the camera at the same time.
The small Back button is awkward; Y is closer to thumb position.
Track button-down state locally in the panel's nav loop instead of
relying on GamepadController's rising-edge cache, which the main render
loop's gp.update() clobbers each frame. Also sync the panel's prev
buttons after a capture completes so the just-bound press isn't seen
as a fresh rising edge (which previously caused B to close the menu
right after binding it).
Always keep openSettings bound — refuse rebind/unbind, refuse to assign
its button to other actions, and hide it from the settings list. Also
let the settings button close the panel when it's open.
Split out moveDown/moveUp gamepad actions (default LT/RT) so users can
remap them in the settings panel like everything else, instead of the
triggers being hardcoded for vertical hand/camera movement.
@ruofeidu
Copy link
Copy Markdown
Collaborator

ruofeidu commented May 8, 2026

Thank you Salman for the valuable contribution! This is indeed very useful!

David: would you give it a review pass?

In the long run, we need to design a settings menu for simulator to debug controller, hands, depth, accessibility etc.
For now, the mapping of the controller to the simulator works.

For hands, another direction is to add webcam-based simulation of hands.

@ruofeidu ruofeidu requested a review from dli7319 May 8, 2026 16:11
@ruofeidu ruofeidu added the enhancement New feature or request label May 8, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Simulator May 8, 2026
@dli7319
Copy link
Copy Markdown
Collaborator

dli7319 commented May 8, 2026

Will test this after work since I don't have a gamepad handy in the office.

@salmanmkc
Copy link
Copy Markdown
Contributor Author

Thank you Salman for the valuable contribution! This is indeed very useful!

David: would you give it a review pass?

In the long run, we need to design a settings menu for simulator to debug controller, hands, depth, accessibility etc. For now, the mapping of the controller to the simulator works.

For hands, another direction is to add webcam-based simulation of hands.

That's a cool idea!

Will test this after work since I don't have a gamepad handy in the office.

Awesome thanks!

@dli7319
Copy link
Copy Markdown
Collaborator

dli7319 commented May 9, 2026

Just tested and it's working well. Great job!
The UI is a nice touch.
image

@dli7319 dli7319 merged commit b512e1c into google:main May 9, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Simulator May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants