Updates controller input state from hardware.
Takes controller (controller handle from inpCreateController, positive integer).
Returns nothing.
Input
Parameters & Returns
Parameters
controllerInt
Returns
Void
Quick Summary
Updates controller input state from hardware.
Takes controller (controller handle from inpCreateController, positive integer).
Returns nothing.
Technical Exegesis...
Updates controller input state from hardware. Takes controller (controller handle from inpCreateController, positive integer). Returns nothing. Polls XInput system for current controller state, updates internal button/stick history for input queries. Must be called each frame before querying controller input.
Updates controller input state from hardware. Takes controller (controller handle from inpCreateController, positive integer). Returns nothing. Polls XInput system for current controller state, updates internal button/stick history for input queries. Must be called each frame before querying controller input.
Update process: queries XInput for current button states (reads all buttons: A, B, X, Y, triggers, bumpers, D-pad, stick clicks), reads analog stick positions (left/right stick X/Y axes with deadzone filtering), updates internal state history (stores previous frame state for Hit detection), processes rumble commands (if any pending rumble effects).
Timing requirements: call once per frame (typically at start of game loop, before input queries), call before any controller input queries (button/stick functions read cached state from last update), calling multiple times per frame wastes CPU (no benefit, same state returned), skipping frames causes missed input (buttons pressed between updates not detected).
Use cases: (1) Game loop integration (call at loop start before processing input), (2) Enable controller input (required for all controller functions to work), (3) Hotplug support (detects controller connect/disconnect during update), (4) Input synchronization (ensures all input queries see same frame state).
Common patterns: game loop = While running: inpUpdateController(controller%): process input: update game: render: Wend; multiple controllers = For i=0 To 3: inpUpdateController(controllers%(i)): Next: process all player input; conditional update = If inpIsControllerConnected(controller%) Then inpUpdateController(controller%).
Button Hit detection: inpUpdateController enables Hit functions (ButtonHit, DPadHit detect edge transitions), compares current frame to previous frame (Hit returns true only on transition from released to pressed), requires previous frame state stored by inpUpdateController (no update = no Hit detection works).
Input lag: call inpUpdateController as late as possible before input processing (minimizes input lag, reads most recent hardware state), avoid calling too early in frame (increases delay between hardware input and game response), typically call at start of game loop (before AI/physics/rendering).
Performance: fast operation (~0.1-0.5ms, XInput polling overhead), safe for per-frame calls (intended usage pattern, necessary for input), minimal CPU cost (simple hardware query and state copy), no blocking I/O (returns immediately with current state).
Disconnected controllers: safe to call inpUpdateController on disconnected controllers (no error, just returns without updating), queries return neutral/zero values when controller disconnected (buttons=0, sticks=0), check inpIsControllerConnected before update (optional optimization, skip update if disconnected).
State caching: inpUpdateController caches controller state in memory (all subsequent queries read cached state, not hardware), one update services all queries for that frame (multiple button queries don't re-poll hardware), efficient pattern (poll once, query many times per frame).
Rumble: inpUpdateController processes rumble effects (if rumble commands pending from previous frame), sends rumble values to hardware (vibration motors), rumble state persists between updates (set rumble intensity, update applies it).
Error handling: prints error if invalid controller handle (check stderr for messages), silently succeeds if controller disconnected (no error, just neutral state), safe to call with any handle (won't crash, validates handle internally).
Related: inpCreateController creates controller handle (required before update), inpIsControllerConnected checks connection status (before update), inpControllerButtonDown/Hit query button states (require update first), inpLeftStickHitX/Y query stick axes (require update first).