gamepad

moon add Milky2018/gamepad@0.4.7
Download zip
Author
Version
0.4.7
License
Apache-2.0
Last updated
13 days ago
Downloads
6K
README

#Milky2018/gamepad

Milky2018/gamepad is a MoonBit gamepad input library for native targets. It provides gil-style events, state tracking, SDL controller mappings, input filters, force-feedback APIs, and a mock backend for tests.

#Install

moon add Milky2018/gamepad

Use the native target for real device input:

moon test --target native moon run --target native

#Platform Support

Best support today is on macOS. Linux and Windows are available on native targets as well.

#Features

  • Native gamepad discovery and hotplug events
  • Gil event polling and blocking waits
  • Per-device state tracking through Gamepad and GamepadState
  • SDL controller mapping database support, including bundled mappings
  • Input filters: jitter, deadzone, axis_dpad_to_button, Repeat
  • Force-feedback APIs with platform-specific backend support
  • Mock backend for deterministic tests

#API Notes

  • Errors: Gil::new() does not raise. GilBuilder::build() may raise GilError.
  • Event time: Event::time() is a millisecond timestamp. On native backends this comes from the OS clock; on the mock backend it is whatever you set in Event::at(...).
  • Mappings (gil naming): Rust gil re-exports MappingData as Mapping. In this MoonBit port, the user-editable type is MappingData; Mapping is the parsed SDL mapping used by Gil.
  • Filters: Compose filters with filter_ev. If you write a custom filter, it must not turn Some(event) into None; to drop an event return Some(event.drop()).

#Force Feedback

  • macOS: not supported (will report is_ff_supported = false).
  • Linux/Windows: supported when the backend/device supports rumble.

#Quick Start

///|
test "quick start" {
let gil = Gil::new()

while true {
match gil.next_event() {
None => break
Some(ev) => ...
}
}
}

#Mock Example

///|
test "mock button press" {
let gil = GilBuilder::new()
.with_mock_gamepad_count(1)
.with_default_filters(false)
.build()

let id = @gamepad.GamepadId(0)
gil.insert_event(Event::at(id, ButtonPressed(South, BTN_SOUTH), 0L))

assert_true(gil.next_event() is Some(_))
}

#Notes

  • Code values are backend-specific raw input codes.
  • On macOS, some raw HID axes such as Rx and Ry may need SDL mappings before they resolve to semantic Axis values.
  • On macOS, PowerInfo currently reports Unknown.
  • On non-native targets, the package builds with a stub backend and does not provide real device events.
  • Force-feedback repeat mode is exposed as FfRepeat.

#License

Apache-2.0.

#
Code

type Code = Int

#
DistanceModelError

type DistanceModelError

#
FfError

type FfError

#
GilError

type GilError

#
GilError::is_invalid_axis_to_btn

fn GilError::is_invalid_axis_to_btn(self : GilError) -> Bool

#
MappingError

type MappingError

#
MappingError::invalid_code

fn MappingError::invalid_code(self : MappingError) -> Int?

#
ParseSdlMappingError

type ParseSdlMappingError

#
ParserError

type ParserError

#
ParserError::kind

#
ParserError::position

fn ParserError::position(self : ParserError) -> Int

#
UuidError

type UuidError

#
Axis

pub(all) enum Axis {
LeftStickX
LeftStickY
LeftZ
RightStickX
RightStickY
RightZ
DPadX
DPadY
Unknown
}

#
Axis::is_stick

fn Axis::is_stick(self : Axis) -> Bool

#
Axis::second_axis

fn Axis::second_axis(self : Axis) -> Axis?

#
Axis::to_index

fn Axis::to_index(self : Axis) -> Int

#
AxisData

pub struct AxisData {
last_event_ts : Int64
last_event_c : Int64
value : Double
}

#
AxisData::counter

fn AxisData::counter(self : AxisData) -> Int64

#
AxisData::timestamp

fn AxisData::timestamp(self : AxisData) -> Int64

#
AxisData::value

fn AxisData::value(self : AxisData) -> Double

#
AxisInfo

pub struct AxisInfo {
min : Int
max : Int
deadzone : Int?
}

#
AxisInfo::new

fn AxisInfo::new(min : Int, max : Int, deadzone : Int?) -> AxisInfo

#
AxisOrBtn

pub(all) enum AxisOrBtn {
Axis(Axis)
Btn(Button)
}

#
AxisOrBtn::is_button

fn AxisOrBtn::is_button(self : AxisOrBtn) -> Bool

#
AxisRange

pub(all) enum AxisRange {
LowerHalf
UpperHalf
Full
}

#
BackendOwner

type BackendOwner

#
BaseEffect

pub struct BaseEffect {
kind : BaseEffectType
scheduling : Replay
envelope : Envelope
}

#
BaseEffect::default

fn BaseEffect::default() -> BaseEffect

#
BaseEffectType

pub(all) enum BaseEffectType {
Weak(Int)
Strong(Int)
}

#
Button

pub(all) enum Button {
South
East
C
North
West
Z
LeftTrigger
RightTrigger
LeftTrigger2
RightTrigger2
Select
Start
Mode
LeftThumb
RightThumb
DPadUp
DPadDown
DPadLeft
DPadRight
Unknown
}

#
Button::is_action

fn Button::is_action(self : Button) -> Bool

#
Button::is_dpad

fn Button::is_dpad(self : Button) -> Bool

#
Button::is_menu

fn Button::is_menu(self : Button) -> Bool

#
Button::is_stick

fn Button::is_stick(self : Button) -> Bool

#
Button::is_trigger

fn Button::is_trigger(self : Button) -> Bool

#
Button::to_index

fn Button::to_index(self : Button) -> Int

#
ButtonData

pub struct ButtonData {
last_event_ts : Int64
counter : Int64
value : Double
is_pressed : Bool
is_repeating : Bool
}

#
ButtonData::counter

fn ButtonData::counter(self : ButtonData) -> Int64

#
ButtonData::is_pressed

fn ButtonData::is_pressed(self : ButtonData) -> Bool

#
ButtonData::is_repeating

fn ButtonData::is_repeating(self : ButtonData) -> Bool

#
ButtonData::timestamp

fn ButtonData::timestamp(self : ButtonData) -> Int64

#
ButtonData::value

fn ButtonData::value(self : ButtonData) -> Double

#
DistanceModel

pub enum DistanceModel {
None
Linear(ref_distance~ : Double, rolloff_factor~ : Double, max_distance~ : Double)
LinearClamped(ref_distance~ : Double, rolloff_factor~ : Double, max_distance~ : Double)
Inverse(ref_distance~ : Double, rolloff_factor~ : Double)
InverseClamped(ref_distance~ : Double, rolloff_factor~ : Double, max_distance~ : Double)
Exponential(ref_distance~ : Double, rolloff_factor~ : Double)
ExponentialClamped(ref_distance~ : Double, rolloff_factor~ : Double, max_distance~ : Double)
}

#
DistanceModel::validate

fn DistanceModel::validate(self : DistanceModel) -> Unit raise DistanceModelError

#
Effect

pub struct Effect {
gil : Gil
effect_token : Int
gamepads : Array[GamepadId]
strong : Double
weak : Double
duration_ms : Int64
base_effects : Array[BaseEffect]
repeat_mode : FfRepeat
distance_model : DistanceModel
position : (Double, Double, Double)
gain : Double
playing_since_ms : Int64?
}

#
Effect::add_gamepad

fn Effect::add_gamepad(self : Effect, gamepad : Gamepad) -> Unit raise FfError

#
Effect::play

fn Effect::play(self : Effect) -> Unit raise FfError

#
Effect::set_distance_model

fn Effect::set_distance_model(self : Effect, model : DistanceModel) -> Unit raise FfError

#
Effect::set_gain

fn Effect::set_gain(self : Effect, gain : Double) -> Unit

#
Effect::set_gamepads

fn Effect::set_gamepads(self : Effect, ids : Array[GamepadId], gil : Gil) -> Unit raise FfError

#
Effect::set_position

fn Effect::set_position(self : Effect, position : (Double, Double, Double)) -> Unit

#
Effect::set_repeat

fn Effect::set_repeat(self : Effect, repeat_mode : FfRepeat) -> Unit

#
Effect::stop

fn Effect::stop(self : Effect) -> Unit raise FfError

#
EffectBuilder

pub struct EffectBuilder {
gamepads : Array[GamepadId]
base_effects : Array[BaseEffect]
repeat_mode : FfRepeat
distance_model : DistanceModel
position : (Double, Double, Double)
gain : Double
strong : Double
weak : Double
duration_ms : Int64
}

#
EffectBuilder::add_effect

fn EffectBuilder::add_effect(self : EffectBuilder, effect : BaseEffect) -> EffectBuilder

#
EffectBuilder::add_gamepad

fn EffectBuilder::add_gamepad(self : EffectBuilder, gamepad : Gamepad) -> EffectBuilder

#
EffectBuilder::add_gamepad_id

fn EffectBuilder::add_gamepad_id(self : EffectBuilder, id : GamepadId) -> EffectBuilder

#
EffectBuilder::distance_model

fn EffectBuilder::distance_model(self : EffectBuilder, model : DistanceModel) -> EffectBuilder

#
EffectBuilder::duration

fn EffectBuilder::duration(self : EffectBuilder, duration_ms : Int64) -> EffectBuilder

#
EffectBuilder::finish

fn EffectBuilder::finish(self : EffectBuilder, gil : Gil) -> Effect raise FfError

#
EffectBuilder::gain

fn EffectBuilder::gain(self : EffectBuilder, gain : Double) -> EffectBuilder

#
EffectBuilder::gamepads

fn EffectBuilder::gamepads(self : EffectBuilder, ids : Array[GamepadId]) -> EffectBuilder

#
EffectBuilder::new

#
EffectBuilder::position

fn EffectBuilder::position(self : EffectBuilder, position : (Double, Double, Double)) -> EffectBuilder

#
EffectBuilder::repeat

fn EffectBuilder::repeat(self : EffectBuilder, repeat_mode : FfRepeat) -> EffectBuilder

#
EffectBuilder::rumble

fn EffectBuilder::rumble(self : EffectBuilder, strong : Double, weak : Double) -> EffectBuilder

#
Envelope

pub struct Envelope {
attack_length : Int
attack_level : Double
fade_length : Int
fade_level : Double
}

#
Envelope::at

fn Envelope::at(self : Envelope, ticks : Int, dur : Int) -> Double

#
Envelope::default

fn Envelope::default() -> Envelope

#
Event

pub struct Event {
id : GamepadId
event : EventType
time : Int64
}

#
Event::at

fn Event::at(id : GamepadId, event : EventType, time : Int64) -> Event

#
Event::drop

fn Event::drop(self : Event) -> Event

#
Event::event

fn Event::event(self : Event) -> EventType

#
Event::id

fn Event::id(self : Event) -> GamepadId

#
Event::is_dropped

fn Event::is_dropped(self : Event) -> Bool

#
Event::new

fn Event::new(id : GamepadId, event : EventType) -> Event

#
Event::time

fn Event::time(self : Event) -> Int64

#
EventType

pub(all) enum EventType {
ButtonPressed(Button, Int)
ButtonRepeated(Button, Int)
ButtonReleased(Button, Int)
ButtonChanged(Button, Double, Int)
AxisChanged(Axis, Double, Int)
Connected
Disconnected
Dropped
ForceFeedbackEffectCompleted
}

#
FfEffectSource

type FfEffectSource

#
FfRepeat

pub enum FfRepeat {
Infinitely
For(Int64)
}

#
Gamepad

pub struct Gamepad {
gil : Gil
id : GamepadId
}

#
Gamepad::axes

fn Gamepad::axes(self : Gamepad) -> Array[Int]

#
Gamepad::axis_code

fn Gamepad::axis_code(self : Gamepad, axis : Axis) -> Int?

#
Gamepad::axis_data

fn Gamepad::axis_data(self : Gamepad, axis : Axis) -> AxisData?

#
Gamepad::axis_info

fn Gamepad::axis_info(self : Gamepad, code : Int) -> AxisInfo?

#
Gamepad::axis_or_btn_name

fn Gamepad::axis_or_btn_name(self : Gamepad, code : Int) -> AxisOrBtn?

#
Gamepad::button_code

fn Gamepad::button_code(self : Gamepad, btn : Button) -> Int?

#
Gamepad::button_data

fn Gamepad::button_data(self : Gamepad, btn : Button) -> ButtonData?

#
Gamepad::buttons

fn Gamepad::buttons(self : Gamepad) -> Array[Int]

#
Gamepad::deadzone

fn Gamepad::deadzone(self : Gamepad, code : Int) -> Double?

#
Gamepad::id

fn Gamepad::id(self : Gamepad) -> GamepadId

#
Gamepad::is_connected

fn Gamepad::is_connected(self : Gamepad) -> Bool

#
Gamepad::is_ff_supported

fn Gamepad::is_ff_supported(self : Gamepad) -> Bool

#
Gamepad::is_pressed

fn Gamepad::is_pressed(self : Gamepad, btn : Button) -> Bool

#
Gamepad::map_name

fn Gamepad::map_name(self : Gamepad) -> String?

#
Gamepad::mapping

fn Gamepad::mapping(self : Gamepad) -> Mapping?

#
Gamepad::mapping_source

fn Gamepad::mapping_source(self : Gamepad) -> MappingSource

#
Gamepad::name

fn Gamepad::name(self : Gamepad) -> String

#
Gamepad::os_name

fn Gamepad::os_name(self : Gamepad) -> String

#
Gamepad::power_info

fn Gamepad::power_info(self : Gamepad) -> PowerInfo

#
Gamepad::product_id

fn Gamepad::product_id(self : Gamepad) -> Int?

#
Gamepad::set_listener_position

fn Gamepad::set_listener_position(self : Gamepad, position : (Double, Double, Double)) -> Unit raise FfError

#
Gamepad::state

fn Gamepad::state(self : Gamepad) -> GamepadState

#
Gamepad::uuid

fn Gamepad::uuid(self : Gamepad) -> Uuid

#
Gamepad::value

fn Gamepad::value(self : Gamepad, axis : Axis) -> Double

#
Gamepad::vendor_id

fn Gamepad::vendor_id(self : Gamepad) -> Int?

#
GamepadData

pub struct GamepadData {
state : GamepadState
connected : Bool
mapping : Mapping
name : String
uuid : Uuid
vendor_id : Int?
product_id : Int?
ff_supported : Bool
listener_position : (Double, Double, Double)
power_info : PowerInfo
axes : Array[Int]
buttons : Array[Int]
axis_info : Array[(Int, AxisInfo)]
deadzones : Array[(Int, Double)]
have_sent_nonzero_for_axis : Array[Bool]
}

#
GamepadId

pub struct GamepadId {
value : Int
}

#
GamepadId::GamepadId

fn GamepadId::GamepadId(value : Int) -> GamepadId

#
GamepadId::new

fn GamepadId::new(value : Int) -> GamepadId

#
GamepadId::value

fn GamepadId::value(self : GamepadId) -> Int

#
GamepadState

pub struct GamepadState {
buttons : Array[(Int, ButtonData)]
axes : Array[(Int, AxisData)]
}

#
GamepadState::axes_entries

fn GamepadState::axes_entries(self : GamepadState) -> Array[(Int, AxisData)]

#
GamepadState::axis_data

fn GamepadState::axis_data(self : GamepadState, axis : Int) -> AxisData?

#
GamepadState::button_data

fn GamepadState::button_data(self : GamepadState, btn : Int) -> ButtonData?

#
GamepadState::buttons_entries

fn GamepadState::buttons_entries(self : GamepadState) -> Array[(Int, ButtonData)]

#
GamepadState::is_pressed

fn GamepadState::is_pressed(self : GamepadState, btn : Int) -> Bool

#
GamepadState::new

#
GamepadState::value

fn GamepadState::value(self : GamepadState, el : Int) -> Double

#
Gil

pub struct Gil {
counter : Int64
update_state : Bool
default_filters : Bool
axis_to_btn_pressed : Double
axis_to_btn_released : Double
events : Array[Event]
events_head : Int
gamepads_data : Array[GamepadData]
mappings : MappingDb
now_ms : Int64
next_effect_token : Int
ff_tick_base_ms : Int64
ff_tick : Int
ff_dirty : Bool
ff_effects : Array[FfEffectSource]
ff_events : Array[Event]
ff_events_head : Int
backend : NativeBackend?
}

#
Gil::axis_code

fn Gil::axis_code(self : Gil, id : GamepadId, axis : Axis) -> Int?

#
Gil::axis_or_btn_name

fn Gil::axis_or_btn_name(self : Gil, id : GamepadId, code : Int) -> AxisOrBtn?

#
Gil::button_code

fn Gil::button_code(self : Gil, id : GamepadId, btn : Button) -> Int?

#
Gil::connected_gamepad

fn Gil::connected_gamepad(self : Gil, id : GamepadId) -> Gamepad?

#
Gil::counter

fn Gil::counter(self : Gil) -> Int64

#
Gil::deadzone

fn Gil::deadzone(self : Gil, id : GamepadId, code : Int) -> Double?

#
Gil::default_filters_enabled

fn Gil::default_filters_enabled(self : Gil) -> Bool

#
Gil::gamepad

fn Gil::gamepad(self : Gil, id : GamepadId) -> Gamepad?

#
Gil::gamepads

fn Gil::gamepads(self : Gil) -> Array[(GamepadId, Gamepad)]

#
Gil::inc

fn Gil::inc(self : Gil) -> Unit

#
Gil::insert_event

fn Gil::insert_event(self : Gil, ev : Event) -> Unit

#
Gil::is_connected

fn Gil::is_connected(self : Gil, id : GamepadId) -> Bool

#
Gil::load_mappings

fn Gil::load_mappings(self : Gil, s : String) -> Unit

#
Gil::mapping

fn Gil::mapping(self : Gil, id : GamepadId) -> Mapping?

#
Gil::new

fn Gil::new() -> Gil

#
Gil::new_mock

fn Gil::new_mock(gamepad_count : Int, update_state? : Bool, default_filters? : Bool) -> Gil

#
Gil::new_native

fn Gil::new_native(update_state? : Bool, default_filters? : Bool) -> Gil

#
Gil::next_event

fn Gil::next_event(self : Gil) -> Event?

#
Gil::next_event_blocking

fn Gil::next_event_blocking(self : Gil, timeout_ms : Int64?) -> Event?

#
Gil::poll

fn Gil::poll(self : Gil) -> Unit

#
Gil::reset_counter

fn Gil::reset_counter(self : Gil) -> Unit

#
Gil::set_axis_to_btn

fn Gil::set_axis_to_btn(self : Gil, pressed : Double, released : Double) -> Unit raise GilError

#
Gil::set_deadzone

fn Gil::set_deadzone(self : Gil, id : GamepadId, code : Int, threshold : Double) -> Unit

#
Gil::set_mapping

fn Gil::set_mapping(self : Gil, id : GamepadId, mapping : Mapping) -> Unit

#
Gil::set_mapping_data

fn Gil::set_mapping_data(self : Gil, id : GamepadId, mapping_data : MappingData, name? : String?) -> String raise MappingError

#
Gil::set_mapping_data_strict

fn Gil::set_mapping_data_strict(self : Gil, id : GamepadId, mapping_data : MappingData, name? : String?) -> String raise MappingError

#
Gil::set_time

fn Gil::set_time(self : Gil, now_ms : Int64) -> Unit

#
Gil::state

fn Gil::state(self : Gil, id : GamepadId) -> GamepadState?

#
Gil::time

fn Gil::time(self : Gil) -> Int64

#
Gil::update

fn Gil::update(self : Gil, event : Event) -> Unit

#
Gil::update_state_enabled

fn Gil::update_state_enabled(self : Gil) -> Bool

#
Gil::with_default_filters

fn Gil::with_default_filters(self : Gil, enabled : Bool) -> Gil

#
GilBuilder

pub struct GilBuilder {
update_state : Bool
default_filters : Bool
axis_to_btn_pressed : Double
axis_to_btn_released : Double
env_mappings : Bool
included_mappings : Bool
mock_gamepad_count : Int
use_native_backend : Bool
mapping_inputs : Array[String]
}

#
GilBuilder::add_env_mappings

fn GilBuilder::add_env_mappings(self : GilBuilder, env_mappings : Bool) -> GilBuilder

#
GilBuilder::add_included_mappings

fn GilBuilder::add_included_mappings(self : GilBuilder, included_mappings : Bool) -> GilBuilder

#
GilBuilder::add_mappings

fn GilBuilder::add_mappings(self : GilBuilder, mappings : String) -> GilBuilder

#
GilBuilder::build

fn GilBuilder::build(self : GilBuilder) -> Gil raise GilError

#
GilBuilder::new

fn GilBuilder::new() -> GilBuilder

#
GilBuilder::set_axis_to_btn

fn GilBuilder::set_axis_to_btn(self : GilBuilder, pressed : Double, released : Double) -> GilBuilder

#
GilBuilder::set_update_state

fn GilBuilder::set_update_state(self : GilBuilder, v : Bool) -> GilBuilder

#
GilBuilder::with_default_filters

fn GilBuilder::with_default_filters(self : GilBuilder, v : Bool) -> GilBuilder

#
GilBuilder::with_mock_gamepad_count

fn GilBuilder::with_mock_gamepad_count(self : GilBuilder, n : Int) -> GilBuilder

#
GilBuilder::with_native_backend

fn GilBuilder::with_native_backend(self : GilBuilder, v : Bool) -> GilBuilder

#
Jitter

pub struct Jitter {
threshold : Double
}

#
Jitter::filter

fn Jitter::filter(self : Jitter, ev : Event?, gil : Gil) -> Event?

#
Jitter::new

fn Jitter::new() -> Jitter

#
Mapping

pub struct Mapping {
mappings : Array[(Int, AxisOrBtn)]
name : String
default : Bool
hats_mapped : Int
}

#
Mapping::entries

fn Mapping::entries(self : Mapping) -> Array[(Int, AxisOrBtn)]

#
Mapping::from_data

fn Mapping::from_data(data : MappingData, buttons : Array[Int], axes : Array[Int], name : String, uuid : Uuid) -> (Mapping, String) raise MappingError

#
Mapping::hats_mapped

fn Mapping::hats_mapped(self : Mapping) -> Int

#
Mapping::insert

fn Mapping::insert(self : Mapping, code : Int, el : AxisOrBtn) -> Unit

#
Mapping::is_default

fn Mapping::is_default(self : Mapping) -> Bool

#
Mapping::map

fn Mapping::map(self : Mapping, code : Int) -> AxisOrBtn?

#
Mapping::map_rev

fn Mapping::map_rev(self : Mapping, el : AxisOrBtn) -> Int?

#
Mapping::name

fn Mapping::name(self : Mapping) -> String

#
Mapping::new

fn Mapping::new() -> Mapping

#
Mapping::new_default

fn Mapping::new_default() -> Mapping

#
Mapping::parse_sdl_mapping

fn Mapping::parse_sdl_mapping(line : String, buttons : Array[Int], axes : Array[Int]) -> Mapping raise ParseSdlMappingError

#
Mapping::set_hats_mapped

fn Mapping::set_hats_mapped(self : Mapping, hats : Int) -> Unit

#
MappingData

pub struct MappingData {
buttons : Array[Int?]
axes : Array[Int?]
}

#
MappingData::axis

fn MappingData::axis(self : MappingData, idx : Axis) -> Int?

#
MappingData::button

fn MappingData::button(self : MappingData, idx : Button) -> Int?

#
MappingData::insert_axis

fn MappingData::insert_axis(self : MappingData, from : Int, to : Axis) -> Int?

#
MappingData::insert_btn

fn MappingData::insert_btn(self : MappingData, from : Int, to : Button) -> Int?

#
MappingData::new

#
MappingData::remove_axis

fn MappingData::remove_axis(self : MappingData, idx : Axis) -> Int?

#
MappingData::remove_button

fn MappingData::remove_button(self : MappingData, idx : Button) -> Int?

#
MappingDb

pub struct MappingDb {
mappings : Array[(Uuid, String)]
}

#
MappingDb::add_env_mappings

fn MappingDb::add_env_mappings(self : MappingDb) -> Unit

#
MappingDb::add_included_mappings

fn MappingDb::add_included_mappings(self : MappingDb) -> Unit

#
MappingDb::get

fn MappingDb::get(self : MappingDb, uuid : Uuid) -> String?

#
MappingDb::insert

fn MappingDb::insert(self : MappingDb, s : String) -> Unit

#
MappingDb::len

fn MappingDb::len(self : MappingDb) -> Int

#
MappingDb::new

fn MappingDb::new() -> MappingDb

#
MappingSource

pub enum MappingSource {
SdlMappings
Driver
None
}

#
NativeBackend

pub struct NativeBackend {
owner : BackendOwner
}

#
NativeBackend::axes

fn NativeBackend::axes(self : NativeBackend, id : Int) -> Array[Int]

#
NativeBackend::axis_info

fn NativeBackend::axis_info(self : NativeBackend, id : Int, code : Int) -> AxisInfo?

#
NativeBackend::buttons

fn NativeBackend::buttons(self : NativeBackend, id : Int) -> Array[Int]

#
NativeBackend::gamepad_count

fn NativeBackend::gamepad_count(self : NativeBackend) -> Int

#
NativeBackend::is_connected

fn NativeBackend::is_connected(self : NativeBackend, id : Int) -> Bool

#
NativeBackend::is_ff_supported

fn NativeBackend::is_ff_supported(self : NativeBackend, id : Int) -> Bool

#
NativeBackend::last_gamepad_hint

fn NativeBackend::last_gamepad_hint(self : NativeBackend) -> Int

#
NativeBackend::name

fn NativeBackend::name(self : NativeBackend, id : Int) -> String

#
NativeBackend::new

#
NativeBackend::next_event

fn NativeBackend::next_event(self : NativeBackend) -> NativeEvent?

#
NativeBackend::poll

fn NativeBackend::poll(self : NativeBackend) -> Unit

#
NativeBackend::poll_timeout

fn NativeBackend::poll_timeout(self : NativeBackend, timeout_ms : Int) -> Unit

#
NativeBackend::power_info

fn NativeBackend::power_info(self : NativeBackend, id : Int) -> PowerInfo

#
NativeBackend::product_id

fn NativeBackend::product_id(self : NativeBackend, id : Int) -> Int?

#
NativeBackend::set_rumble

fn NativeBackend::set_rumble(self : NativeBackend, id : Int, strong : Double, weak : Double, duration_ms : Int) -> Bool

#
NativeBackend::uuid_simple

fn NativeBackend::uuid_simple(self : NativeBackend, id : Int) -> String

#
NativeBackend::vendor_id

fn NativeBackend::vendor_id(self : NativeBackend, id : Int) -> Int?

#
NativeEvent

pub struct NativeEvent {
tag : NativeEventTag
id : Int
code : Int
value : Double
time_ms : Int64
}

#
NativeEventTag

pub(all) enum NativeEventTag {
Connected
Disconnected
ButtonPressed
ButtonReleased
AxisChanged
ButtonChanged
}

#
ParserErrorKind

pub(all) enum ParserErrorKind {
InvalidGuid
InvalidKeyValPair
InvalidValue
EmptyValue
UnknownAxis
UnknownButton
InvalidParserState
UnexpectedEnd
}

#
PowerInfo

pub enum PowerInfo {
Unknown
Wired
Discharging(Int)
Charging(Int)
Charged
}

#
Repeat

pub struct Repeat {
after_ms : Int64
every_ms : Int64
}

#
Repeat::filter

fn Repeat::filter(self : Repeat, ev : Event?, gil : Gil) -> Event?

#
Repeat::new

fn Repeat::new() -> Repeat

#
Replay

pub struct Replay {
after : Int
play_for : Int
with_delay : Int
}

#
Replay::at

fn Replay::at(self : Replay, ticks : Int) -> Double

#
Replay::default

fn Replay::default() -> Replay

#
Replay::dur

fn Replay::dur(self : Replay) -> Int

#
Ticks

pub struct Ticks {
ms : Int64
}

#
Ticks::as_ms

fn Ticks::as_ms(self : Ticks) -> Int64

#
Ticks::from_ms

fn Ticks::from_ms(ms : Int64) -> Ticks

#
Token

pub(all) enum Token {
Uuid(Uuid)
Platform(String)
Name(String)
AxisMapping(Int, AxisOrBtn, AxisRange, AxisRange, Bool)
ButtonMapping(Int, AxisOrBtn, AxisRange)
HatMapping(Int, Int, AxisOrBtn, AxisRange)
}

#
Uuid

pub struct Uuid {
simple : String
}

#
Uuid::nil

fn Uuid::nil() -> Uuid

#
Uuid::parse

fn Uuid::parse(s : String) -> Uuid raise UuidError

#
Uuid::simple

fn Uuid::simple(self : Uuid) -> String

#
AXIS_COUNT

let AXIS_COUNT : Int

#
AXIS_DPADX

let AXIS_DPADX : Int

#
AXIS_DPADY

let AXIS_DPADY : Int

#
AXIS_LEFTZ

let AXIS_LEFTZ : Int

#
AXIS_LSTICKX

let AXIS_LSTICKX : Int

#
AXIS_LSTICKY

let AXIS_LSTICKY : Int

#
AXIS_LT

let AXIS_LT : Int

#
AXIS_LT2

let AXIS_LT2 : Int

#
AXIS_RIGHTZ

let AXIS_RIGHTZ : Int

#
AXIS_RSTICKX

let AXIS_RSTICKX : Int

#
AXIS_RSTICKY

let AXIS_RSTICKY : Int

#
AXIS_RT

let AXIS_RT : Int

#
AXIS_RT2

let AXIS_RT2 : Int

#
BTN_C

let BTN_C : Int

#
BTN_DPAD_DOWN

let BTN_DPAD_DOWN : Int

#
BTN_DPAD_LEFT

let BTN_DPAD_LEFT : Int

#
BTN_DPAD_RIGHT

let BTN_DPAD_RIGHT : Int

#
BTN_DPAD_UP

let BTN_DPAD_UP : Int

#
BTN_EAST

let BTN_EAST : Int

#
BTN_LT

let BTN_LT : Int

#
BTN_LT2

let BTN_LT2 : Int

#
BTN_LTHUMB

let BTN_LTHUMB : Int

#
BTN_MODE

let BTN_MODE : Int

#
BTN_NORTH

let BTN_NORTH : Int

#
BTN_RT

let BTN_RT : Int

#
BTN_RT2

let BTN_RT2 : Int

#
BTN_RTHUMB

let BTN_RTHUMB : Int

#
BTN_SELECT

let BTN_SELECT : Int

#
BTN_SOUTH

let BTN_SOUTH : Int

#
BTN_START

let BTN_START : Int

#
BTN_WEST

let BTN_WEST : Int

#
BTN_Z

let BTN_Z : Int

#
BUTTON_COUNT

let BUTTON_COUNT : Int

#
LEGACY_AXIS_DPADX

let LEGACY_AXIS_DPADX : Int

#
LEGACY_AXIS_DPADY

let LEGACY_AXIS_DPADY : Int

#
LEGACY_AXIS_LEFTZ

let LEGACY_AXIS_LEFTZ : Int

#
LEGACY_AXIS_LSTICKX

let LEGACY_AXIS_LSTICKX : Int

#
LEGACY_AXIS_LSTICKY

let LEGACY_AXIS_LSTICKY : Int

#
LEGACY_AXIS_LT

let LEGACY_AXIS_LT : Int

#
LEGACY_AXIS_LT2

let LEGACY_AXIS_LT2 : Int

#
LEGACY_AXIS_RIGHTZ

let LEGACY_AXIS_RIGHTZ : Int

#
LEGACY_AXIS_RSTICKX

let LEGACY_AXIS_RSTICKX : Int

#
LEGACY_AXIS_RSTICKY

let LEGACY_AXIS_RSTICKY : Int

#
LEGACY_AXIS_RT

let LEGACY_AXIS_RT : Int

#
LEGACY_AXIS_RT2

let LEGACY_AXIS_RT2 : Int

#
LEGACY_BTN_C

let LEGACY_BTN_C : Int

#
LEGACY_BTN_DPAD_DOWN

let LEGACY_BTN_DPAD_DOWN : Int

#
LEGACY_BTN_DPAD_LEFT

let LEGACY_BTN_DPAD_LEFT : Int

#
LEGACY_BTN_DPAD_RIGHT

let LEGACY_BTN_DPAD_RIGHT : Int

#
LEGACY_BTN_DPAD_UP

let LEGACY_BTN_DPAD_UP : Int

#
LEGACY_BTN_EAST

let LEGACY_BTN_EAST : Int

#
LEGACY_BTN_LT

let LEGACY_BTN_LT : Int

#
LEGACY_BTN_LT2

let LEGACY_BTN_LT2 : Int

#
LEGACY_BTN_LTHUMB

let LEGACY_BTN_LTHUMB : Int

#
LEGACY_BTN_MODE

let LEGACY_BTN_MODE : Int

#
LEGACY_BTN_NORTH

let LEGACY_BTN_NORTH : Int

#
LEGACY_BTN_RT

let LEGACY_BTN_RT : Int

#
LEGACY_BTN_RT2

let LEGACY_BTN_RT2 : Int

#
LEGACY_BTN_RTHUMB

let LEGACY_BTN_RTHUMB : Int

#
LEGACY_BTN_SELECT

let LEGACY_BTN_SELECT : Int

#
LEGACY_BTN_SOUTH

let LEGACY_BTN_SOUTH : Int

#
LEGACY_BTN_START

let LEGACY_BTN_START : Int

#
LEGACY_BTN_WEST

let LEGACY_BTN_WEST : Int

#
LEGACY_BTN_Z

let LEGACY_BTN_Z : Int

#
PAGE_BUTTON

let PAGE_BUTTON : Int

#
PAGE_GENERIC_DESKTOP

let PAGE_GENERIC_DESKTOP : Int

#
PAGE_SIMULATION

let PAGE_SIMULATION : Int

#
axis_dpad_to_button

fn axis_dpad_to_button(ev : Event?, gil : Gil) -> Event?

#
axis_from_code

fn axis_from_code(code : Int) -> Axis?

#
axis_or_btn_from_code

fn axis_or_btn_from_code(code : Int) -> AxisOrBtn?

#
axis_value

fn axis_value(info : AxisInfo, val : Int, axis : Axis) -> Double

#
btn_value

fn btn_value(info : AxisInfo, val : Int) -> Double

#
button_from_code

fn button_from_code(code : Int) -> Button?

#
ceil_div

fn ceil_div(a : UInt, b : UInt) -> UInt

#
clamp

fn clamp(x : Double, min : Double, max : Double) -> Double

#
deadzone

fn deadzone(ev : Event?, gil : Gil) -> Event?

#
decode_native_event

fn decode_native_event(b : Bytes) -> NativeEvent?

#
default_axis_code

fn default_axis_code(axis : Axis) -> Int?

#
default_button_code

fn default_button_code(btn : Button) -> Int?

#
filter_ev

fn filter_ev(ev : Event?, filter : (Event?, Gil) -> Event?, gil : Gil) -> Event?

#
hid_code

fn hid_code(page : Int, usage : Int) -> Int

#
hid_page

fn hid_page(code : Int) -> Int

#
hid_usage

fn hid_usage(code : Int) -> Int

#
jitter

fn jitter(ev : Event?, gil : Gil, threshold : Double) -> Event?

#
runtime_env_sdl_gamecontrollerconfig

fn runtime_env_sdl_gamecontrollerconfig() -> String

#
runtime_now_ms

fn runtime_now_ms() -> Int64

#
runtime_sdl_platform_name

fn runtime_sdl_platform_name() -> String