--- orphan: true --- # Controller tester one ControllerDevice per pad ```{raw} html ▶ Run in browser ``` **Tags:** `input` `controller` `touch` `polling` Every controller input a pad reports, drawn live: both sticks as a crosshair in a circle (`pad.stick`), the analogue triggers as fill bars (`pad.axis`), and all fifteen buttons as labelled dots that light while held (`pad.pressed`). The pads themselves come from `Input.controllers`, so plugging one in and unplugging it again are both visible while the demo runs. A `TouchController` is drawn along the bottom, and it is a pad like any other: it appears in `Input.controllers` under `ControllerSource.VIRTUAL`, so the readout above has something to show with no controller in the room. It leaves the screen the moment a real one is used, and the readout follows whichever pad is there. ## What it demonstrates - `Input.controllers`: the pads readable this frame, keyed by id. It empties the moment a pad is unplugged. - One `Controller` per pad, so a two-player game reads each pad separately: `pad.stick(Controller.LEFT_STICK)`, `pad.axis(Controller.LEFT_TRIGGER)`, `pad.pressed(Controller.A)`. - What a pad says about itself: `name`, `source` and `family`. - `TouchController` as a source of exactly that: an on-screen pad reads back through the same `Controller` object a controller does. - The engine's axis convention, identical on every backend: sticks -1..1 centred at 0, triggers 0..1 resting at 0. - The radial deadzone `stick()` applies (a small circle marks it). Controls: ControllerDevice - everything on it, mirrored on screen Drawn pad - the same, from two thumbs ESC - Quit Run: simvx examples run features_input_controller Headless self-check: simvx examples run features_input_controller --test ## Source ```{literalinclude} ../../examples/features/input/controller.py :language: python :linenos: ```