AndroidGamepad
| Kind | class |
| Package | android.platform |
| Full name | android.platform.AndroidGamepad |
| Source | source/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
| Name | Type | Static | Default | Notes |
|---|---|---|---|---|
onConnected | FlxTypedSignal<Int->Void> | yes | — | property (get, never) |
onDisconnected | FlxTypedSignal<Int->Void> | yes | — | property (get, never) |
onFlixelGamepadAdded | FlxTypedSignal<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.
getDevices
static function getDevices():Array<GamepadInfo>
All currently connected gamepad-like devices.
getDevice
static function getDevice(id:Int):Null<GamepadInfo>
Information for a single device id (null when unavailable).
| Parameter | Type | Default |
|---|---|---|
id | Int | — |
vibrate
static function vibrate(deviceId:Int, durationMs:Int = 200):Bool
Vibrates a controller that has a built-in vibrator, returns success.
| Parameter | Type | Default |
|---|---|---|
deviceId | Int | — |
durationMs (optional) | Int | 200 |
anyConnected
static function anyConnected():Bool
Whether any gamepad is currently connected.
Internals
Private / internal members
| Field | Type | Static |
|---|---|---|
initialized | Bool | yes |
_registerGamepadListener | Dynamic | yes |
_getGamepads | Dynamic | yes |
_getDeviceInfo | Dynamic | yes |
_vibrateGamepad | Dynamic | yes |
| 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 |