From c5ed5910c9ef066cec6a13bbb404ec57b1e92637 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Wed, 14 Jul 2010 18:48:53 -0700 Subject: Add support for new input sources. Added several new coordinate values to MotionEvents to capture touch major/minor area, tool major/minor area and orientation. Renamed NDK input constants per convention. Added InputDevice class in Java which will eventually provide useful information about available input devices. Added APIs for manufacturing new MotionEvent objects with multiple pointers and all necessary coordinate data. Fixed a bug in the input dispatcher where it could get stuck with a pointer down forever. Fixed a bug in the WindowManager where the input window list could end up containing stale removed windows. Fixed a bug in the WindowManager where the input channel was being removed only after the final animation transition had taken place which caused spurious WINDOW DIED log messages to be printed. Change-Id: Ie55084da319b20aad29b28a0499b8dd98bb5da68 --- core/java/android/view/InputQueue.java | 41 ++++++++++++---------------------- 1 file changed, 14 insertions(+), 27 deletions(-) (limited to 'core/java/android/view/InputQueue.java') diff --git a/core/java/android/view/InputQueue.java b/core/java/android/view/InputQueue.java index 7feee38..997246f 100644 --- a/core/java/android/view/InputQueue.java +++ b/core/java/android/view/InputQueue.java @@ -26,6 +26,8 @@ import android.util.Slog; public final class InputQueue { private static final String TAG = "InputQueue"; + private static final boolean DEBUG = false; + public static interface Callback { void onInputQueueCreated(InputQueue queue); void onInputQueueDestroyed(InputQueue queue); @@ -33,15 +35,6 @@ public final class InputQueue { final InputChannel mChannel; - // Describes the interpretation of an event. - // XXX This concept is tentative. See comments in android/input.h. - /** @hide */ - public static final int INPUT_EVENT_NATURE_KEY = 1; - /** @hide */ - public static final int INPUT_EVENT_NATURE_TOUCH = 2; - /** @hide */ - public static final int INPUT_EVENT_NATURE_TRACKBALL = 3; - private static Object sLock = new Object(); private static native void nativeRegisterInputChannel(InputChannel inputChannel, @@ -79,7 +72,10 @@ public final class InputQueue { } synchronized (sLock) { - Slog.d(TAG, "Registering input channel '" + inputChannel + "'"); + if (DEBUG) { + Slog.d(TAG, "Registering input channel '" + inputChannel + "'"); + } + nativeRegisterInputChannel(inputChannel, inputHandler, messageQueue); } } @@ -96,35 +92,26 @@ public final class InputQueue { } synchronized (sLock) { - Slog.d(TAG, "Unregistering input channel '" + inputChannel + "'"); + if (DEBUG) { + Slog.d(TAG, "Unregistering input channel '" + inputChannel + "'"); + } + nativeUnregisterInputChannel(inputChannel); } } @SuppressWarnings("unused") private static void dispatchKeyEvent(InputHandler inputHandler, - KeyEvent event, int nature, long finishedToken) { + KeyEvent event, long finishedToken) { Runnable finishedCallback = new FinishedCallback(finishedToken); - - if (nature == INPUT_EVENT_NATURE_KEY) { - inputHandler.handleKey(event, finishedCallback); - } else { - Slog.d(TAG, "Unsupported nature for key event: " + nature); - } + inputHandler.handleKey(event, finishedCallback); } @SuppressWarnings("unused") private static void dispatchMotionEvent(InputHandler inputHandler, - MotionEvent event, int nature, long finishedToken) { + MotionEvent event, long finishedToken) { Runnable finishedCallback = new FinishedCallback(finishedToken); - - if (nature == INPUT_EVENT_NATURE_TOUCH) { - inputHandler.handleTouch(event, finishedCallback); - } else if (nature == INPUT_EVENT_NATURE_TRACKBALL) { - inputHandler.handleTrackball(event, finishedCallback); - } else { - Slog.d(TAG, "Unsupported nature for motion event: " + nature); - } + inputHandler.handleMotion(event, finishedCallback); } // TODO consider recycling finished callbacks when done -- cgit v1.1