Skip to main content

AndroidGamepad

Kindclass
Packageandroid.platform
Full nameandroid.platform.AndroidGamepad
Sourcesource/android/platform/AndroidGamepad.hx

Native Android gamepad/controller support: connected device information, connection/disconnection events, controller identification and rumble.

Actual button/axis input is handled by Flixel's gamepad system (fed by SDL on Android); this module provides the device-level information the engine's keybind/input system needs on top of that.

Public fields​

NameTypeStaticDefaultNotes
onConnectedFlxTypedSignal<Int->Void>yes—property (get, never)
onDisconnectedFlxTypedSignal<Int->Void>yes—property (get, never)
onFlixelGamepadAddedFlxTypedSignal<Int->Void> = new FlxTypedSignal<Int->Void>()yes—Fired when Flixel sees a new gamepad (after init() wired things up).

Public methods​

init​

static function init():Void

Starts watching for controller connection changes and keeps Flixel's keybind system (Controls.addDefaultGamepad) in sync with newly connected pads.

View source

getDevices​

static function getDevices():Array<GamepadInfo>

All currently connected gamepad-like devices.

View source

getDevice​

static function getDevice(id:Int):Null<GamepadInfo>

Information for a single device id (null when unavailable).

ParameterTypeDefault
idInt—

View source

vibrate​

static function vibrate(deviceId:Int, durationMs:Int = 200):Bool

Vibrates a controller that has a built-in vibrator, returns success.

ParameterTypeDefault
deviceIdInt—
durationMs (optional)Int200

View source

anyConnected​

static function anyConnected():Bool

Whether any gamepad is currently connected.

View source

Internals​

Private / internal members
FieldTypeStatic
initializedBoolyes
_registerGamepadListenerDynamicyes
_getGamepadsDynamicyes
_getDeviceInfoDynamicyes
_vibrateGamepadDynamicyes
Method
static inline function get_onConnected():FlxTypedSignal<Int->Void>
static inline function get_onDisconnected():FlxTypedSignal<Int->Void>
static function parseDeviceList(raw:String):Array<GamepadInfo>
static function parseDevice(raw:String):Null<GamepadInfo>
static function parseDeviceEntry(entry:Dynamic):Null<GamepadInfo>
static function registerGamepadListener_jni():Void
static function getGamepads_jni():String
static function getDeviceInfo_jni(id:Int):String
static function vibrateGamepad_jni(id:Int, durationMs:Int):Bool