hxn

Gamepad

A connection-scoped controller handle; reconnecting invalidates the old handle.

Static methods

function hxnAdopt(hxnRaw:Handle):Gamepad

An object for a value the library returned.

function available():Bool

Whether the platform backend initialized, including when no controllers are connected.

function error():String

Why the backend is unavailable, or an empty string.

function count():Int
function at(index:Int):Gamepad

A connected controller in enumeration order, or an invalid handle.

function fromId(deviceId:Int):Gamepad
function poll():GamepadEvent
function drain(output:Bytes):Int

Drain whole 32-byte records into reused storage without constructing event objects. u32 kind, i32 device, u32 control, u32 pressed, f64 value, u64 dropped. Kinds match GamepadEvent variants. Returns count; a short buffer consumes nothing.

Properties

var hxnRaw:Handle

Methods

function valid():Bool
function deviceId():Int
function name():String
function hasButton(button:GamepadButton):Bool
function hasAxis(axis:GamepadAxis):Bool
function button(button:GamepadButton):Float
function pressed(button:GamepadButton):Bool
function axis(axis:GamepadAxis):Float
function snapshot(output:Bytes):Bool

Atomically copy into a reused 176-byte buffer: 17 little-endian f64 button values, 4 f64 axes, a u32 pressed mask and a u32 change sequence. False for an invalid handle or short buffer; no bytes are written then.

function rumbleSupported():Bool
function rumble(strong:Float, weak:Float, seconds:Float):Bool

Start or replace finite dual-motor rumble; zero duration stops it. Magnitudes are [0,1], seconds [0,5]. Reports backend acceptance.

function close():Void

Releases the native value now. The collector does it otherwise. Using this object afterwards throws.