diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-06-18 18:09:33 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2010-06-22 11:21:50 -0700 |
commit | a95e4cb62f3642cb190d032dbf7dc40d9ecc6973 (patch) | |
tree | ae4437444a3d3ebeff48dabfd1e9c11fc14620ac /native/include | |
parent | ef730e6ececa96a3e0576140eea707f7c48cd66c (diff) | |
download | frameworks_base-a95e4cb62f3642cb190d032dbf7dc40d9ecc6973.zip frameworks_base-a95e4cb62f3642cb190d032dbf7dc40d9ecc6973.tar.gz frameworks_base-a95e4cb62f3642cb190d032dbf7dc40d9ecc6973.tar.bz2 |
First stab at attaching native event dispatching.
Provides the basic infrastructure for a
NativeActivity's native code to get an object representing
its event stream that can be used to read input events.
Still work to do, probably some API changes, and reasonable
default key handling (so that for example back will still
work).
Change-Id: I6db891bc35dc9683181d7708eaed552b955a077e
Diffstat (limited to 'native/include')
-rw-r--r-- | native/include/android/input.h | 36 | ||||
-rw-r--r-- | native/include/android/native_activity.h | 15 |
2 files changed, 51 insertions, 0 deletions
diff --git a/native/include/android/input.h b/native/include/android/input.h index 193cbf3..2441af0 100644 --- a/native/include/android/input.h +++ b/native/include/android/input.h @@ -523,6 +523,42 @@ float motion_event_get_historical_pressure(input_event_t* motion_event, size_t p float motion_event_get_historical_size(input_event_t* motion_event, size_t pointer_index, size_t history_index); +/* + * Input queue + * + * An input queue is the facility through which you retrieve input + * events. + */ +struct input_queue_t; +typedef struct input_queue_t input_queue_t; + +/* + * Return a file descriptor for the queue, which you + * can use to determine if there are events available. This + * is typically used with select() or poll() to multiplex + * with other kinds of events. + */ +int input_queue_get_fd(input_queue_t* queue); + +/* + * Returns true if there are one or more events available in the + * input queue. Returns 1 if the queue has events; 0 if + * it does not have events; and a negative value if there is an error. + */ +int input_queue_has_events(input_queue_t* queue); + +/* + * Returns the next available event from the queue. Returns a negative + * value if no events are available or an error has occurred. + */ +int32_t input_queue_get_event(input_queue_t* queue, input_event_t** outEvent); + +/* + * Report that dispatching has finished with the given event. + * This must be called after receiving an event with input_queue_get_event(). + */ +void input_queue_finish_event(input_queue_t* queue, input_event_t* event, int handled); + #ifdef __cplusplus } #endif diff --git a/native/include/android/native_activity.h b/native/include/android/native_activity.h index 328a4b5..a58a7d2 100644 --- a/native/include/android/native_activity.h +++ b/native/include/android/native_activity.h @@ -23,6 +23,8 @@ #include <jni.h> +#include <android/input.h> + #ifdef __cplusplus extern "C" { #endif @@ -144,6 +146,19 @@ typedef struct android_activity_callbacks_t { * returning from here. */ void (*onSurfaceDestroyed)(android_activity_t* activity, android_surface_t* surface); + + /** + * The input queue for this native activity's window has been created. + * You can use the given input queue to start retrieving input events. + */ + void (*onInputQueueCreated)(android_activity_t* activity, input_queue_t* queue); + + /** + * The input queue for this native activity's window is being destroyed. + * You should no longer try to reference this object upon returning from this + * function. + */ + void (*onInputQueueDestroyed)(android_activity_t* activity, input_queue_t* queue); /** * The system is running low on memory. Use this callback to release |