Documentation
¶
Overview ¶
Touch and key input event handling example.
Demonstrates the complete input event processing pipeline using the ndk/input package. On Android, input events (touches, key presses) are delivered through an AInputQueue that the framework attaches to the Activity. This example shows:
- How to wrap a raw AInputQueue pointer into an input.Queue.
- The full event polling loop: HasEvents -> GetEvent -> PreDispatchEvent -> handle -> FinishEvent.
- Dispatching key events (action, keycode, repeat count).
- Dispatching motion/touch events (action, pointer count, per-pointer x/y coordinates and pressure).
- How to integrate the input queue with an ALooper for continuous event-driven processing (documented in comments).
The event loop runs against a nil queue pointer in this example, so HasEvents returns an error immediately and no events are delivered. In a real NativeActivity the queue pointer comes from the framework via the onInputQueueCreated callback.
This program must run on an Android device.
Click to show internal directories.
Click to hide internal directories.