let gilrs = Gilrs::new()
while true {
match gilrs.next_event() {
None => break
Some(ev) => println(ev)
}
}let gilrs =
GilrsBuilder::new()
.with_mock_gamepad_count(1)
.with_default_filters(true)
.build()
let id = GamepadId::new(0)
gilrs.insert_event(Event::at(id, EventType::ButtonPressed(Button::South, BTN_SOUTH), 0L))
match gilrs.next_event() {
None => ()
Some(ev) => println(ev.id().value())
}type ParserErrorpub(all) enum Axis {
LeftStickX
LeftStickY
LeftZ
RightStickX
RightStickY
RightZ
DPadX
DPadY
Unknown
}pub struct AxisData {
last_event_ts : Int64
last_event_c : Int64
value : Double
}pub struct AxisInfo {
min : Int
max : Int
deadzone : Int?
}pub(all) enum Button {
South
East
C
North
West
Z
LeftTrigger
RightTrigger
LeftTrigger2
RightTrigger2
Select
Start
Mode
LeftThumb
RightThumb
DPadUp
DPadDown
DPadLeft
DPadRight
Unknown
}pub struct ButtonData {
last_event_ts : Int64
counter : Int64
value : Double
is_pressed : Bool
is_repeating : Bool
}pub enum DistanceModel {
None
Linear(Double, Double, Double)
LinearClamped(Double, Double, Double)
Inverse(Double, Double)
InverseClamped(Double, Double, Double)
Exponential(Double, Double)
ExponentialClamped(Double, Double, Double)
}pub struct Effect {
gilrs : Gilrs
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
}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
}fn EffectBuilder::position(self : EffectBuilder, position : (Double, Double, Double)) -> EffectBuilderpub struct Envelope {
attack_length : Int
attack_level : Double
fade_length : Int
fade_level : Double
}pub struct GamepadData {
state : GamepadState
connected : Bool
mapping : Mapping
name : String
uuid : Uuid
vendor_id : Int?
product_id : Int?
ff_supported : Bool
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]
}pub struct GamepadId {
value : Int
}pub struct Gilrs {
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
backend : NativeBackend?
}fn Gilrs::set_axis_to_btn(self : Gilrs, pressed : Double, released : Double) -> Unit raise GilrsErrorfn Gilrs::set_mapping_data(self : Gilrs, id : GamepadId, mapping_data : MappingData, name? : String?) -> String raise MappingErrorfn Gilrs::set_mapping_data_strict(self : Gilrs, id : GamepadId, mapping_data : MappingData, name? : String?) -> String raise MappingErrorpub struct GilrsBuilder {
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]
}fn GilrsBuilder::add_included_mappings(self : GilrsBuilder, included_mappings : Bool) -> GilrsBuilderfn GilrsBuilder::set_axis_to_btn(self : GilrsBuilder, pressed : Double, released : Double) -> GilrsBuilderpub struct Jitter {
threshold : Double
}fn Mapping::from_data(data : MappingData, buttons : Array[Int], axes : Array[Int], name : String, uuid : Uuid) -> (Mapping, String) raise MappingErrorfn Mapping::parse_sdl_mapping(line : String, buttons : Array[Int], axes : Array[Int]) -> Mapping raise ParseSdlMappingErrorfn NativeBackend::set_rumble(self : NativeBackend, id : Int, strong : Double, weak : Double, duration_ms : Int) -> Boolpub(all) enum NativeEventTag {
Connected
Disconnected
ButtonPressed
ButtonReleased
AxisChanged
ButtonChanged
}pub(all) enum ParserErrorKind {
InvalidGuid
InvalidKeyValPair
InvalidValue
EmptyValue
UnknownAxis
UnknownButton
InvalidParserState
UnexpectedEnd
}pub struct Repeat {
after_ms : Int64
every_ms : Int64
}pub struct Replay {
after : Int
play_for : Int
with_delay : Int
}pub struct Ticks {
ms : Int64
}pub struct Uuid {
simple : String
}