touch-handling

command
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 5 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL