rcade/inputs

Types

A button press event from the classic controls.

pub type ButtonPress {
  PlayerButton(player: player.Player, button: String)
  SystemButton(String)
}

Constructors

  • PlayerButton(player: player.Player, button: String)
  • SystemButton(String)

Combined input state for a player.

pub type Player1Inputs {
  Player1Inputs(
    controls: controls.Controls,
    spinner: spinner.Spinner,
  )
}

Constructors

Combined input state for a player.

pub type Player2Inputs {
  Player2Inputs(
    controls: controls.Controls,
    spinner: spinner.Spinner,
  )
}

Constructors

Values

pub fn on_press(
  with to_msg: fn(ButtonPress) -> msg,
) -> effect.Effect(msg)

Subscribe to “classic” control press events.

Each press dispatches a ButtonPress with the provided msg constructor.

pub fn poll(
  every interval: Int,
  with to_msg: fn(
    Player1Inputs,
    Player2Inputs,
    controls.SystemButtons,
  ) -> msg,
) -> effect.Effect(msg)

Poll all input states at a given interval (in milliseconds).

Returns an effect that builds a msg from the states of both players’ controls and spinners, as well as the state of the system buttons.

Search Document