From 3c80a4a044865bdf1289c7896baffa1c082d835c Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 29 Jun 2010 19:20:40 -0700 Subject: Implement default key handling for native code. The native code now maintains a list of all keys that may use default handling. If the app finishes one of these keys without handling it, the key will be passed back off to Java for default treatment. Change-Id: I6a842a0d728eeafa4de7142fae573f8c11099e18 --- native/android/input.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'native/android/input.cpp') diff --git a/native/android/input.cpp b/native/android/input.cpp index e0544a1..8498840 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -225,6 +225,15 @@ int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent) { void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled) { + if (!handled && ((InputEvent*)event)->getType() == INPUT_EVENT_TYPE_KEY + && ((KeyEvent*)event)->hasDefaultAction()) { + // The app didn't handle this, but it may have a default action + // associated with it. We need to hand this back to Java to be + // executed. + queue->doDefaultKey((KeyEvent*)event); + return; + } + int32_t res = queue->getConsumer().sendFinishedSignal(); if (res != android::OK) { LOGW("Failed to send finished signal on channel '%s'. status=%d", -- cgit v1.1