Add gamepad support to simulator#262
Conversation
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.
|
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 hands, another direction is to add webcam-based simulation of hands. |
|
Will test this after work since I don't have a gamepad handy in the office. |
That's a cool idea!
Awesome thanks! |

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