import rcade/player /// State of a player's joystick and buttons. pub type Controls { Controls(up: Bool, down: Bool, left: Bool, right: Bool, a: Bool, b: Bool) } /// State of the system buttons. pub type SystemButtons { SystemButtons(one_player: Bool, two_player: Bool) } /// Read the current state of a player's "classic" controls. pub fn read_player(player: player.Player) -> Controls { do_read_player(player.to_int(player)) } @external(javascript, "./controls_ffi.mjs", "read_player") fn do_read_player(player: Int) -> Controls /// Read the current state of the system buttons (one player, two players). @external(javascript, "./controls_ffi.mjs", "read_system") pub fn read_system() -> SystemButtons /// Whether the classic controls hardware is connected. @external(javascript, "./controls_ffi.mjs", "connected") pub fn connected() -> Bool @external(javascript, "./controls_ffi.mjs", "subscribe") pub fn subscribe(callback: fn(Int, String, Bool) -> Nil) -> fn() -> Nil