class
Eagle::Input::Gamepad
- Eagle::Input::Gamepad
- Reference
- Object
Overview
A connected game controller. Get one with Input.gamepad or iterate Input.gamepads.
Stick values have a deadzone applied, so a resting stick reads exactly 0. Most games use actions instead, but direct access is handy for twin-stick controls.
if pad = Input.gamepad
aim = pad.right_stick
pad.rumble(0.3, 0.6, 150) if pad.pressed?(GamepadButton::RightShoulder)
end
Defined in:
eagle/input/input.crInstance Method Summary
-
#axis(a : GamepadAxis) : Float32
An axis value after the deadzone: -1 to 1 for sticks, 0 to 1 for triggers.
-
#deadzone : Float32
Stick values smaller than this read as 0.
-
#deadzone=(deadzone : Float32)
Stick values smaller than this read as 0.
-
#down?(b : GamepadButton) : Bool
True while b is held.
-
#id : Int32
The controller's id, as reported in gamepad events.
-
#left_stick : Vec2
The left stick as a vector.
-
#name : String
The controller's product name, such as "Xbox Wireless Controller".
-
#pressed?(b : GamepadButton) : Bool
True on the frame b went down.
-
#raw_axis(a : GamepadAxis) : Float32
An axis value without the deadzone.
-
#released?(b : GamepadButton) : Bool
True on the frame b went up.
-
#right_stick : Vec2
The right stick as a vector.
-
#rumble(low : Number = 0.5, high : Number = 0.5, ms : Int = 200) : Nil
Vibrates the controller.
Instance Method Detail
An axis value after the deadzone: -1 to 1 for sticks, 0 to 1 for triggers.
Stick values smaller than this read as 0. Raise it for worn sticks that drift.
Stick values smaller than this read as 0. Raise it for worn sticks that drift.