Checks if controller button currently pressed (held down).
Takes controller (controller handle from inpCreateController, positive integer), button (button ID constant, integer).
Returns 1 if button currently pressed, 0 if released or error.
Input
Parameters & Returns
Parameters
controllerInt
buttonInt
Returns
Int
Quick Summary
Checks if controller button currently pressed (held down).
Takes controller (controller handle from inpCreateController, positive integer), button (button ID constant, integer).
Returns 1 if button currently pressed, 0 if released or error.
Technical Exegesis...
Checks if controller button currently pressed (held down). Takes controller (controller handle from inpCreateController, positive integer), button (button ID constant, integer). Returns 1 if button currently pressed, 0 if released or error. Queries current frame button state, returns true every frame while button held.
Checks if controller button currently pressed (held down). Takes controller (controller handle from inpCreateController, positive integer), button (button ID constant, integer). Returns 1 if button currently pressed, 0 if released or error. Queries current frame button state, returns true every frame while button held.
Button state: 1=button pressed this frame (held down), 0=button not pressed (released or never pressed), continuous detection (returns 1 every frame while held), different from inpControllerButtonHit (which returns 1 only on first press frame).
Button IDs: use predefined button constants (A, B, X, Y, LB, RB, LT, RT, Start, Back, LS, RS, etc.), button values map to XInput/DirectInput standards (Xbox controller layout), consult input constants for available button IDs.
Use cases: (1) Continuous actions (hold button to run, accelerate, fire continuously), (2) Analog button behavior (check pressure with repeated queries), (3) Multi-button combos (If inpControllerButtonDown(ctrl, BTN_A) AND inpControllerButtonDown(ctrl, BTN_B) Then combo), (4) Hold-to-charge mechanics (accumulate charge while button held), (5) Movement controls (hold direction buttons for continuous movement).
Common patterns: continuous action = If inpControllerButtonDown(controller%, BUTTON_A) Then player accelerating; hold duration = If inpControllerButtonDown(controller%, BUTTON_B) Then holdTime#=holdTime#+deltaTime#; combo check = If inpControllerButtonDown(controller%, BTN_LB) AND inpControllerButtonDown(controller%, BTN_RB) Then special move; toggle vs hold = If inpControllerButtonHit(controller%, BTN) Then toggle Else If inpControllerButtonDown(controller%, BTN) Then hold action.
Button vs Hit: inpControllerButtonDown returns 1 every frame while held (continuous detection for sustained actions), inpControllerButtonHit returns 1 only on first press frame (single-shot detection for discrete actions like jumps), use ButtonDown for auto-fire/running/charging (hold mechanics), use ButtonHit for jumps/menu navigation/toggles (press-once mechanics).
Performance: fast query (~0.001ms, simple state lookup), safe for per-frame calls (intended usage pattern), no controller update required (reads cached state from last inpUpdateController).
Controller state: requires inpUpdateController called each frame (updates button states from hardware), reads from cached controller state (no direct hardware access), button state from previous update (call inpUpdateController before querying buttons).
Return values: 1 if button pressed (held down this frame), 0 if button released (not pressed), 0 on error (invalid controller handle or button ID).
Validation: returns 0 for invalid controller handle (prints error if handle out of range), returns 0 for invalid button ID (button index beyond available buttons), check inpIsControllerConnected before use (avoid querying disconnected controllers).
Related: inpControllerButtonHit detects single press (first frame only), inpUpdateController updates controller state from hardware, inpCreateController creates controller handle, inpIsControllerConnected checks connection status.