Skip to main content

AndroidHardwareInput

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

Non-standard Android hardware triggers (currently the volume buttons) exposed as bindable game input.

While enabled, KEYCODE_VOLUME_UP/DOWN no longer change the system volume; they fire onKey instead, letting the engine map them to gameplay actions. Only enable this in contexts where the user opted in (e.g. a keybind screen chose volume triggers), and disable it everywhere else so normal volume control keeps working.

Public fields​

NameTypeStaticDefaultNotes
KEYCODE_VOLUME_UPIntyes24final · android.view.KeyEvent keycodes for the volume rocker.
KEYCODE_VOLUME_DOWNIntyes25final
onKeyFlxTypedSignal<Int->Bool->Void>yes—property (get, never) · Fired for every intercepted hardware key: keyCode, isDown.

Public methods​

enableVolumeKeys​

static function enableVolumeKeys():Void

Starts intercepting the volume keys as game input.

View source

disableVolumeKeys​

static function disableVolumeKeys():Void

Restores normal system volume key behavior.

View source

areVolumeKeysEnabled​

static function areVolumeKeysEnabled():Bool

View source

Internals​

Private / internal members
FieldTypeStatic
interceptingBoolyes
_setVolumeKeysInterceptedDynamicyes
Method
static inline function get_onKey():FlxTypedSignal<Int->Bool->Void>
static function setVolumeKeysIntercepted_jni(intercept:Bool):Void