summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-07-15 17:44:53 -0700
committerDianne Hackborn <hackbod@google.com>2010-07-15 22:05:33 -0700
commit2c6081ce3593712f30dacd990a97209c791d6ced (patch)
tree4808bc521c207ea11ec0daceb98f77a6b47b00a0 /native
parentc5ed5910c9ef066cec6a13bbb404ec57b1e92637 (diff)
downloadframeworks_base-2c6081ce3593712f30dacd990a97209c791d6ced.zip
frameworks_base-2c6081ce3593712f30dacd990a97209c791d6ced.tar.gz
frameworks_base-2c6081ce3593712f30dacd990a97209c791d6ced.tar.bz2
Implement native key pre-dispatching to IMEs.
This significantly re-works the native key dispatching code to allow events to be pre-dispatched to the current IME before being processed by native code. It introduces one new public API, which must be called after retrieving an event if the app wishes for it to be pre-dispatched. Currently the native code will only do pre-dispatching of system keys, to avoid significant overhead for gaming input. This should be improved to be smarted, filtering for only keys that the IME is interested in. Unfortunately IMEs don't currently provide this information. :p Change-Id: Ic1c7aeec8b348164957f2cd88119eb5bd85c2a9f
Diffstat (limited to 'native')
-rw-r--r--native/android/input.cpp6
-rw-r--r--native/include/android/input.h12
2 files changed, 16 insertions, 2 deletions
diff --git a/native/android/input.cpp b/native/android/input.cpp
index 4e1b6dc..59bf711 100644
--- a/native/android/input.cpp
+++ b/native/android/input.cpp
@@ -248,7 +248,7 @@ void AInputQueue_detachLooper(AInputQueue* queue) {
queue->detachLooper();
}
-int AInputQueue_hasEvents(AInputQueue* queue) {
+int32_t AInputQueue_hasEvents(AInputQueue* queue) {
return queue->hasEvents();
}
@@ -256,6 +256,10 @@ int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent) {
return queue->getEvent(outEvent);
}
+int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event) {
+ return queue->preDispatchEvent(event) ? 1 : 0;
+}
+
void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled) {
queue->finishEvent(event, handled != 0);
}
diff --git a/native/include/android/input.h b/native/include/android/input.h
index ce79cd4..0b8c7e4 100644
--- a/native/include/android/input.h
+++ b/native/include/android/input.h
@@ -607,7 +607,7 @@ void AInputQueue_detachLooper(AInputQueue* queue);
* 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 AInputQueue_hasEvents(AInputQueue* queue);
+int32_t AInputQueue_hasEvents(AInputQueue* queue);
/*
* Returns the next available event from the queue. Returns a negative
@@ -616,6 +616,16 @@ int AInputQueue_hasEvents(AInputQueue* queue);
int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
/*
+ * Sends the key for standard pre-dispatching -- that is, possibly deliver
+ * it to the current IME to be consumed before the app. Returns 0 if it
+ * was not pre-dispatched, meaning you can process it right now. If non-zero
+ * is returned, you must abandon the current event processing and allow the
+ * event to appear again in the event queue (if it does not get consumed during
+ * pre-dispatching).
+ */
+int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
+
+/*
* Report that dispatching has finished with the given event.
* This must be called after receiving an event with AInputQueue_get_event().
*/