diff options
| author | Jeff Brown <jeffbrown@google.com> | 2011-03-04 13:07:49 -0800 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2011-03-04 18:53:32 -0800 |
| commit | 3a22fa057091cd6614f58ebc57a7ce4fe29462bb (patch) | |
| tree | 974dcf7edb5668a7cffd7aa629c4ccc95ed5a99f /core/java/android/view/MotionEvent.java | |
| parent | 06b0e5899525330119f27f0f7d9898db6f73e0e2 (diff) | |
Joystick tweaks.
Ensure that the joystick can always reach -1.0, 0.0 and 1.0 positions
even when noise filtering is applied. (Bug: 3514510)
Add support for a few more standard axes.
Add additional mapping modes for axes.
Some axes are inverted from standard interpretation
or are actually intended to be split into two distict axes
such as left/right trigger controls or accelerator/brake.
Add key layout file for a G25 racing wheel and XBox 360 controller
to tweak behavior. They work fine without them but the axis mappings
are not ideal.
Change-Id: Id4c86a0a272331c680039a9bde6815bb7eba44ab
Diffstat (limited to 'core/java/android/view/MotionEvent.java')
| -rw-r--r-- | core/java/android/view/MotionEvent.java | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index f70f1fb92a4b..a17db5d42a4b 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -675,6 +675,87 @@ public final class MotionEvent extends InputEvent implements Parcelable { public static final int AXIS_RTRIGGER = 18; /** + * Constant used to identify the Throttle axis of a motion event. + * <p> + * <ul> + * <li>For a joystick, reports the absolute position of the throttle control. + * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed). + * </ul> + * </p> + * + * @see #getAxisValue(int, int) + * @see #getHistoricalAxisValue(int, int, int) + * @see MotionEvent.PointerCoords#getAxisValue(int) + * @see InputDevice#getMotionRange + */ + public static final int AXIS_THROTTLE = 19; + + /** + * Constant used to identify the Rudder axis of a motion event. + * <p> + * <ul> + * <li>For a joystick, reports the absolute position of the rudder control. + * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). + * </ul> + * </p> + * + * @see #getAxisValue(int, int) + * @see #getHistoricalAxisValue(int, int, int) + * @see MotionEvent.PointerCoords#getAxisValue(int) + * @see InputDevice#getMotionRange + */ + public static final int AXIS_RUDDER = 20; + + /** + * Constant used to identify the Wheel axis of a motion event. + * <p> + * <ul> + * <li>For a joystick, reports the absolute position of the steering wheel control. + * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). + * </ul> + * </p> + * + * @see #getAxisValue(int, int) + * @see #getHistoricalAxisValue(int, int, int) + * @see MotionEvent.PointerCoords#getAxisValue(int) + * @see InputDevice#getMotionRange + */ + public static final int AXIS_WHEEL = 21; + + /** + * Constant used to identify the Gas axis of a motion event. + * <p> + * <ul> + * <li>For a joystick, reports the absolute position of the gas (accelerator) control. + * The value is normalized to a range from 0.0 (no acceleration) + * to 1.0 (maximum acceleration). + * </ul> + * </p> + * + * @see #getAxisValue(int, int) + * @see #getHistoricalAxisValue(int, int, int) + * @see MotionEvent.PointerCoords#getAxisValue(int) + * @see InputDevice#getMotionRange + */ + public static final int AXIS_GAS = 22; + + /** + * Constant used to identify the Brake axis of a motion event. + * <p> + * <ul> + * <li>For a joystick, reports the absolute position of the brake control. + * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking). + * </ul> + * </p> + * + * @see #getAxisValue(int, int) + * @see #getHistoricalAxisValue(int, int, int) + * @see MotionEvent.PointerCoords#getAxisValue(int) + * @see InputDevice#getMotionRange + */ + public static final int AXIS_BRAKE = 23; + + /** * Constant used to identify the Generic 1 axis of a motion event. * The interpretation of a generic axis is device-specific. * @@ -877,6 +958,11 @@ public final class MotionEvent extends InputEvent implements Parcelable { names.append(AXIS_HAT_Y, "AXIS_HAT_Y"); names.append(AXIS_LTRIGGER, "AXIS_LTRIGGER"); names.append(AXIS_RTRIGGER, "AXIS_RTRIGGER"); + names.append(AXIS_THROTTLE, "AXIS_THROTTLE"); + names.append(AXIS_RUDDER, "AXIS_RUDDER"); + names.append(AXIS_WHEEL, "AXIS_WHEEL"); + names.append(AXIS_GAS, "AXIS_GAS"); + names.append(AXIS_BRAKE, "AXIS_BRAKE"); names.append(AXIS_GENERIC_1, "AXIS_GENERIC_1"); names.append(AXIS_GENERIC_2, "AXIS_GENERIC_2"); names.append(AXIS_GENERIC_3, "AXIS_GENERIC_3"); |
