Skip to main content

compute_pressed_buttons

Function compute_pressed_buttons 

Source
pub fn compute_pressed_buttons(
    previous_held: &GamepadButtonSet,
    values: &[f64],
) -> GamepadButtonSet
Expand description

Folds one frame of raw gamepad readings into the per-pad edge sets.

This is the DOM-free half of a poll: it takes the previous frame’s held set and this frame’s raw button pressures, and recomputes pressed / held / released exactly the way InputState::press_key and InputState::release_key do for keys. A button counts as down when its pressure is at least half, which makes digital buttons (0.0 / 1.0) and analog triggers agree.

§Arguments

  • &GamepadButtonSet - The previous frame’s held button indices.
  • &[f64] - This frame’s raw button pressure per button index.

§Returns

  • GamepadButtonSet - The buttons newly pressed on this frame.