Add joystick support to framework.
Change-Id: I95374436708752e1a9cff3f85c5b9bc3e0987961
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index f05ef8c..57520d1 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4493,6 +4493,16 @@
}
/**
+ * Pass a generic motion event down to the focused view.
+ *
+ * @param event The motion event to be dispatched.
+ * @return True if the event was handled by the view, false otherwise.
+ */
+ public boolean dispatchGenericMotionEvent(MotionEvent event) {
+ return onGenericMotionEvent(event);
+ }
+
+ /**
* Called when the window containing this view gains or loses window focus.
* ViewGroups should override to route to their children.
*
@@ -4994,6 +5004,37 @@
}
/**
+ * Implement this method to handle generic motion events.
+ * <p>
+ * Generic motion events are dispatched to the focused view to describe
+ * the motions of input devices such as joysticks. The
+ * {@link MotionEvent#getSource() source} of the motion event specifies
+ * the class of input that was received. Implementations of this method
+ * must examine the bits in the source before processing the event.
+ * The following code example shows how this is done.
+ * </p>
+ * <code>
+ * public boolean onGenericMotionEvent(MotionEvent event) {
+ * if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
+ * float x = event.getX();
+ * float y = event.getY();
+ * // process the joystick motion
+ * return true;
+ * }
+ * return super.onGenericMotionEvent(event);
+ * }
+ * </code>
+ *
+ * @param event The generic motion event being processed.
+ *
+ * @return Return true if you have consumed the event, false if you haven't.
+ * The default implementation always returns false.
+ */
+ public boolean onGenericMotionEvent(MotionEvent event) {
+ return false;
+ }
+
+ /**
* Implement this method to handle touch screen motion events.
*
* @param event The motion event.