Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -22315,6 +22315,7 @@ package android.view { field public static final int AXIS_RZ = 14; // 0xe field public static final int AXIS_SIZE = 3; // 0x3 field public static final int AXIS_THROTTLE = 19; // 0x13 field public static final int AXIS_TILT = 25; // 0x19 field public static final int AXIS_TOOL_MAJOR = 6; // 0x6 field public static final int AXIS_TOOL_MINOR = 7; // 0x7 field public static final int AXIS_TOUCH_MAJOR = 4; // 0x4 core/java/android/view/MotionEvent.java +26 −2 Original line number Diff line number Diff line Loading @@ -619,6 +619,11 @@ public final class MotionEvent extends InputEvent implements Parcelable { * indicates that the major axis of contact is oriented to the left. * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians * (finger pointing fully right). * <li>For a stylus, the orientation indicates the direction in which the stylus * is pointing in relation to the vertical axis of the current orientation of the screen. * The range is from -PI radians to PI radians, where 0 is pointing up, * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians * is pointing right. See also {@link #AXIS_TILT}. * </ul> * </p> * Loading Loading @@ -883,8 +888,8 @@ public final class MotionEvent extends InputEvent implements Parcelable { * <p> * <ul> * <li>For a stylus, reports the distance of the stylus from the screen. * The value is nominally measured in millimeters where 0.0 indicates direct contact * and larger values indicate increasing distance from the surface. * A value of 0.0 indicates direct contact and larger values indicate increasing * distance from the surface. * </ul> * </p> * Loading @@ -895,6 +900,24 @@ public final class MotionEvent extends InputEvent implements Parcelable { */ public static final int AXIS_DISTANCE = 24; /** * Axis constant: Tilt axis of a motion event. * <p> * <ul> * <li>For a stylus, reports the tilt angle of the stylus in radians where * 0 radians indicates that the stylus is being held perpendicular to the * surface, and PI/2 radians indicates that the stylus is being held flat * against the surface. * </ul> * </p> * * @see #getAxisValue(int, int) * @see #getHistoricalAxisValue(int, int, int) * @see MotionEvent.PointerCoords#getAxisValue(int, int) * @see InputDevice#getMotionRange */ public static final int AXIS_TILT = 25; /** * Axis constant: Generic 1 axis of a motion event. * The interpretation of a generic axis is device-specific. Loading Loading @@ -1104,6 +1127,7 @@ public final class MotionEvent extends InputEvent implements Parcelable { names.append(AXIS_GAS, "AXIS_GAS"); names.append(AXIS_BRAKE, "AXIS_BRAKE"); names.append(AXIS_DISTANCE, "AXIS_DISTANCE"); names.append(AXIS_TILT, "AXIS_TILT"); names.append(AXIS_GENERIC_1, "AXIS_GENERIC_1"); names.append(AXIS_GENERIC_2, "AXIS_GENERIC_2"); names.append(AXIS_GENERIC_3, "AXIS_GENERIC_3"); Loading core/java/com/android/internal/widget/PointerLocationView.java +70 −21 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class PointerLocationView extends View { // Most recent coordinates. private PointerCoords mCoords = new PointerCoords(); private int mToolType; // Most recent velocity. private float mXVelocity; Loading Loading @@ -88,7 +89,7 @@ public class PointerLocationView extends View { private int mMaxNumPointers; private int mActivePointerId; private final ArrayList<PointerState> mPointers = new ArrayList<PointerState>(); private final PointerCoords mHoverCoords = new PointerCoords(); private final PointerCoords mTempCoords = new PointerCoords(); private final VelocityTracker mVelocity; Loading Loading @@ -306,22 +307,66 @@ public class PointerLocationView extends View { ps.mCoords.toolMinor, ps.mCoords.orientation, mPaint); // Draw the orientation arrow. float arrowSize = ps.mCoords.toolMajor * 0.7f; if (arrowSize < 20) { arrowSize = 20; } mPaint.setARGB(255, pressureLevel, 255, 0); float orientationVectorX = (float) (Math.sin(-ps.mCoords.orientation) * ps.mCoords.toolMajor * 0.7); float orientationVectorY = (float) (Math.cos(-ps.mCoords.orientation) * ps.mCoords.toolMajor * 0.7); float orientationVectorX = (float) (Math.sin(ps.mCoords.orientation) * arrowSize); float orientationVectorY = (float) (-Math.cos(ps.mCoords.orientation) * arrowSize); if (ps.mToolType == MotionEvent.TOOL_TYPE_STYLUS || ps.mToolType == MotionEvent.TOOL_TYPE_ERASER) { // Show full circle orientation. canvas.drawLine(ps.mCoords.x, ps.mCoords.y, ps.mCoords.x + orientationVectorX, ps.mCoords.y + orientationVectorY, mPaint); } else { // Show half circle orientation. canvas.drawLine( ps.mCoords.x - orientationVectorX, ps.mCoords.y - orientationVectorY, ps.mCoords.x + orientationVectorX, ps.mCoords.y + orientationVectorY, ps.mCoords.x - orientationVectorX, ps.mCoords.y - orientationVectorY, ps.mCoords.x + orientationVectorX, ps.mCoords.y + orientationVectorY, mPaint); } // Draw the tilt point along the orientation arrow. float tiltScale = (float) Math.sin( ps.mCoords.getAxisValue(MotionEvent.AXIS_TILT)); canvas.drawCircle( ps.mCoords.x + orientationVectorX * tiltScale, ps.mCoords.y + orientationVectorY * tiltScale, 3.0f, mPaint); } } } } private void logPointerCoords(int action, int index, MotionEvent.PointerCoords coords, int id, int toolType, int buttonState) { private void logMotionEvent(String type, MotionEvent event) { final int action = event.getAction(); final int N = event.getHistorySize(); final int NI = event.getPointerCount(); for (int historyPos = 0; historyPos < N; historyPos++) { for (int i = 0; i < NI; i++) { final int id = event.getPointerId(i); event.getHistoricalPointerCoords(i, historyPos, mTempCoords); logCoords(type, action, i, mTempCoords, id, event.getToolType(i), event.getButtonState()); } } for (int i = 0; i < NI; i++) { final int id = event.getPointerId(i); event.getPointerCoords(i, mTempCoords); logCoords(type, action, i, mTempCoords, id, event.getToolType(i), event.getButtonState()); } } private void logCoords(String type, int action, int index, MotionEvent.PointerCoords coords, int id, int toolType, int buttonState) { final String prefix; switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: Loading Loading @@ -373,7 +418,7 @@ public class PointerLocationView extends View { } Log.i(TAG, mText.clear() .append("Pointer ").append(id + 1) .append(type).append(" id ").append(id + 1) .append(": ") .append(prefix) .append(" (").append(coords.x, 3).append(", ").append(coords.y, 3) Loading @@ -385,6 +430,9 @@ public class PointerLocationView extends View { .append(" ToolMinor=").append(coords.toolMinor, 3) .append(" Orientation=").append((float)(coords.orientation * 180 / Math.PI), 1) .append("deg") .append(" Tilt=").append((float)( coords.getAxisValue(MotionEvent.AXIS_TILT) * 180 / Math.PI), 1) .append("deg") .append(" Distance=").append(coords.getAxisValue(MotionEvent.AXIS_DISTANCE), 1) .append(" VScroll=").append(coords.getAxisValue(MotionEvent.AXIS_VSCROLL), 1) .append(" HScroll=").append(coords.getAxisValue(MotionEvent.AXIS_HSCROLL), 1) Loading Loading @@ -445,10 +493,10 @@ public class PointerLocationView extends View { for (int i = 0; i < NI; i++) { final int id = event.getPointerId(i); final PointerState ps = mCurDown ? mPointers.get(id) : null; final PointerCoords coords = ps != null ? ps.mCoords : mHoverCoords; final PointerCoords coords = ps != null ? ps.mCoords : mTempCoords; event.getHistoricalPointerCoords(i, historyPos, coords); if (mPrintCoords) { logPointerCoords(action, i, coords, id, logCoords("Pointer", action, i, coords, id, event.getToolType(i), event.getButtonState()); } if (ps != null) { Loading @@ -459,16 +507,17 @@ public class PointerLocationView extends View { for (int i = 0; i < NI; i++) { final int id = event.getPointerId(i); final PointerState ps = mCurDown ? mPointers.get(id) : null; final PointerCoords coords = ps != null ? ps.mCoords : mHoverCoords; final PointerCoords coords = ps != null ? ps.mCoords : mTempCoords; event.getPointerCoords(i, coords); if (mPrintCoords) { logPointerCoords(action, i, coords, id, logCoords("Pointer", action, i, coords, id, event.getToolType(i), event.getButtonState()); } if (ps != null) { ps.addTrace(coords.x, coords.y); ps.mXVelocity = mVelocity.getXVelocity(id); ps.mYVelocity = mVelocity.getYVelocity(id); ps.mToolType = event.getToolType(i); } } Loading Loading @@ -515,11 +564,11 @@ public class PointerLocationView extends View { if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) { addPointerEvent(event); } else if ((source & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { Log.i(TAG, "Joystick: " + event); logMotionEvent("Joystick", event); } else if ((source & InputDevice.SOURCE_CLASS_POSITION) != 0) { Log.i(TAG, "Position: " + event); logMotionEvent("Position", event); } else { Log.i(TAG, "Generic: " + event); logMotionEvent("Generic", event); } return true; } Loading Loading @@ -563,7 +612,7 @@ public class PointerLocationView extends View { @Override public boolean onTrackballEvent(MotionEvent event) { Log.i(TAG, "Trackball: " + event); logMotionEvent("Trackball", event); return true; } Loading include/ui/KeycodeLabels.h +2 −0 Original line number Diff line number Diff line Loading @@ -278,6 +278,8 @@ static const KeycodeLabel AXES[] = { { "WHEEL", 21 }, { "GAS", 22 }, { "BRAKE", 23 }, { "DISTANCE", 24 }, { "TILT", 25 }, { "GENERIC_1", 32 }, { "GENERIC_2", 33 }, { "GENERIC_3", 34 }, Loading native/include/android/input.h +1 −0 Original line number Diff line number Diff line Loading @@ -373,6 +373,7 @@ enum { AMOTION_EVENT_AXIS_GAS = 22, AMOTION_EVENT_AXIS_BRAKE = 23, AMOTION_EVENT_AXIS_DISTANCE = 24, AMOTION_EVENT_AXIS_TILT = 25, AMOTION_EVENT_AXIS_GENERIC_1 = 32, AMOTION_EVENT_AXIS_GENERIC_2 = 33, AMOTION_EVENT_AXIS_GENERIC_3 = 34, Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -22315,6 +22315,7 @@ package android.view { field public static final int AXIS_RZ = 14; // 0xe field public static final int AXIS_SIZE = 3; // 0x3 field public static final int AXIS_THROTTLE = 19; // 0x13 field public static final int AXIS_TILT = 25; // 0x19 field public static final int AXIS_TOOL_MAJOR = 6; // 0x6 field public static final int AXIS_TOOL_MINOR = 7; // 0x7 field public static final int AXIS_TOUCH_MAJOR = 4; // 0x4
core/java/android/view/MotionEvent.java +26 −2 Original line number Diff line number Diff line Loading @@ -619,6 +619,11 @@ public final class MotionEvent extends InputEvent implements Parcelable { * indicates that the major axis of contact is oriented to the left. * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians * (finger pointing fully right). * <li>For a stylus, the orientation indicates the direction in which the stylus * is pointing in relation to the vertical axis of the current orientation of the screen. * The range is from -PI radians to PI radians, where 0 is pointing up, * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians * is pointing right. See also {@link #AXIS_TILT}. * </ul> * </p> * Loading Loading @@ -883,8 +888,8 @@ public final class MotionEvent extends InputEvent implements Parcelable { * <p> * <ul> * <li>For a stylus, reports the distance of the stylus from the screen. * The value is nominally measured in millimeters where 0.0 indicates direct contact * and larger values indicate increasing distance from the surface. * A value of 0.0 indicates direct contact and larger values indicate increasing * distance from the surface. * </ul> * </p> * Loading @@ -895,6 +900,24 @@ public final class MotionEvent extends InputEvent implements Parcelable { */ public static final int AXIS_DISTANCE = 24; /** * Axis constant: Tilt axis of a motion event. * <p> * <ul> * <li>For a stylus, reports the tilt angle of the stylus in radians where * 0 radians indicates that the stylus is being held perpendicular to the * surface, and PI/2 radians indicates that the stylus is being held flat * against the surface. * </ul> * </p> * * @see #getAxisValue(int, int) * @see #getHistoricalAxisValue(int, int, int) * @see MotionEvent.PointerCoords#getAxisValue(int, int) * @see InputDevice#getMotionRange */ public static final int AXIS_TILT = 25; /** * Axis constant: Generic 1 axis of a motion event. * The interpretation of a generic axis is device-specific. Loading Loading @@ -1104,6 +1127,7 @@ public final class MotionEvent extends InputEvent implements Parcelable { names.append(AXIS_GAS, "AXIS_GAS"); names.append(AXIS_BRAKE, "AXIS_BRAKE"); names.append(AXIS_DISTANCE, "AXIS_DISTANCE"); names.append(AXIS_TILT, "AXIS_TILT"); names.append(AXIS_GENERIC_1, "AXIS_GENERIC_1"); names.append(AXIS_GENERIC_2, "AXIS_GENERIC_2"); names.append(AXIS_GENERIC_3, "AXIS_GENERIC_3"); Loading
core/java/com/android/internal/widget/PointerLocationView.java +70 −21 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class PointerLocationView extends View { // Most recent coordinates. private PointerCoords mCoords = new PointerCoords(); private int mToolType; // Most recent velocity. private float mXVelocity; Loading Loading @@ -88,7 +89,7 @@ public class PointerLocationView extends View { private int mMaxNumPointers; private int mActivePointerId; private final ArrayList<PointerState> mPointers = new ArrayList<PointerState>(); private final PointerCoords mHoverCoords = new PointerCoords(); private final PointerCoords mTempCoords = new PointerCoords(); private final VelocityTracker mVelocity; Loading Loading @@ -306,22 +307,66 @@ public class PointerLocationView extends View { ps.mCoords.toolMinor, ps.mCoords.orientation, mPaint); // Draw the orientation arrow. float arrowSize = ps.mCoords.toolMajor * 0.7f; if (arrowSize < 20) { arrowSize = 20; } mPaint.setARGB(255, pressureLevel, 255, 0); float orientationVectorX = (float) (Math.sin(-ps.mCoords.orientation) * ps.mCoords.toolMajor * 0.7); float orientationVectorY = (float) (Math.cos(-ps.mCoords.orientation) * ps.mCoords.toolMajor * 0.7); float orientationVectorX = (float) (Math.sin(ps.mCoords.orientation) * arrowSize); float orientationVectorY = (float) (-Math.cos(ps.mCoords.orientation) * arrowSize); if (ps.mToolType == MotionEvent.TOOL_TYPE_STYLUS || ps.mToolType == MotionEvent.TOOL_TYPE_ERASER) { // Show full circle orientation. canvas.drawLine(ps.mCoords.x, ps.mCoords.y, ps.mCoords.x + orientationVectorX, ps.mCoords.y + orientationVectorY, mPaint); } else { // Show half circle orientation. canvas.drawLine( ps.mCoords.x - orientationVectorX, ps.mCoords.y - orientationVectorY, ps.mCoords.x + orientationVectorX, ps.mCoords.y + orientationVectorY, ps.mCoords.x - orientationVectorX, ps.mCoords.y - orientationVectorY, ps.mCoords.x + orientationVectorX, ps.mCoords.y + orientationVectorY, mPaint); } // Draw the tilt point along the orientation arrow. float tiltScale = (float) Math.sin( ps.mCoords.getAxisValue(MotionEvent.AXIS_TILT)); canvas.drawCircle( ps.mCoords.x + orientationVectorX * tiltScale, ps.mCoords.y + orientationVectorY * tiltScale, 3.0f, mPaint); } } } } private void logPointerCoords(int action, int index, MotionEvent.PointerCoords coords, int id, int toolType, int buttonState) { private void logMotionEvent(String type, MotionEvent event) { final int action = event.getAction(); final int N = event.getHistorySize(); final int NI = event.getPointerCount(); for (int historyPos = 0; historyPos < N; historyPos++) { for (int i = 0; i < NI; i++) { final int id = event.getPointerId(i); event.getHistoricalPointerCoords(i, historyPos, mTempCoords); logCoords(type, action, i, mTempCoords, id, event.getToolType(i), event.getButtonState()); } } for (int i = 0; i < NI; i++) { final int id = event.getPointerId(i); event.getPointerCoords(i, mTempCoords); logCoords(type, action, i, mTempCoords, id, event.getToolType(i), event.getButtonState()); } } private void logCoords(String type, int action, int index, MotionEvent.PointerCoords coords, int id, int toolType, int buttonState) { final String prefix; switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: Loading Loading @@ -373,7 +418,7 @@ public class PointerLocationView extends View { } Log.i(TAG, mText.clear() .append("Pointer ").append(id + 1) .append(type).append(" id ").append(id + 1) .append(": ") .append(prefix) .append(" (").append(coords.x, 3).append(", ").append(coords.y, 3) Loading @@ -385,6 +430,9 @@ public class PointerLocationView extends View { .append(" ToolMinor=").append(coords.toolMinor, 3) .append(" Orientation=").append((float)(coords.orientation * 180 / Math.PI), 1) .append("deg") .append(" Tilt=").append((float)( coords.getAxisValue(MotionEvent.AXIS_TILT) * 180 / Math.PI), 1) .append("deg") .append(" Distance=").append(coords.getAxisValue(MotionEvent.AXIS_DISTANCE), 1) .append(" VScroll=").append(coords.getAxisValue(MotionEvent.AXIS_VSCROLL), 1) .append(" HScroll=").append(coords.getAxisValue(MotionEvent.AXIS_HSCROLL), 1) Loading Loading @@ -445,10 +493,10 @@ public class PointerLocationView extends View { for (int i = 0; i < NI; i++) { final int id = event.getPointerId(i); final PointerState ps = mCurDown ? mPointers.get(id) : null; final PointerCoords coords = ps != null ? ps.mCoords : mHoverCoords; final PointerCoords coords = ps != null ? ps.mCoords : mTempCoords; event.getHistoricalPointerCoords(i, historyPos, coords); if (mPrintCoords) { logPointerCoords(action, i, coords, id, logCoords("Pointer", action, i, coords, id, event.getToolType(i), event.getButtonState()); } if (ps != null) { Loading @@ -459,16 +507,17 @@ public class PointerLocationView extends View { for (int i = 0; i < NI; i++) { final int id = event.getPointerId(i); final PointerState ps = mCurDown ? mPointers.get(id) : null; final PointerCoords coords = ps != null ? ps.mCoords : mHoverCoords; final PointerCoords coords = ps != null ? ps.mCoords : mTempCoords; event.getPointerCoords(i, coords); if (mPrintCoords) { logPointerCoords(action, i, coords, id, logCoords("Pointer", action, i, coords, id, event.getToolType(i), event.getButtonState()); } if (ps != null) { ps.addTrace(coords.x, coords.y); ps.mXVelocity = mVelocity.getXVelocity(id); ps.mYVelocity = mVelocity.getYVelocity(id); ps.mToolType = event.getToolType(i); } } Loading Loading @@ -515,11 +564,11 @@ public class PointerLocationView extends View { if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) { addPointerEvent(event); } else if ((source & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { Log.i(TAG, "Joystick: " + event); logMotionEvent("Joystick", event); } else if ((source & InputDevice.SOURCE_CLASS_POSITION) != 0) { Log.i(TAG, "Position: " + event); logMotionEvent("Position", event); } else { Log.i(TAG, "Generic: " + event); logMotionEvent("Generic", event); } return true; } Loading Loading @@ -563,7 +612,7 @@ public class PointerLocationView extends View { @Override public boolean onTrackballEvent(MotionEvent event) { Log.i(TAG, "Trackball: " + event); logMotionEvent("Trackball", event); return true; } Loading
include/ui/KeycodeLabels.h +2 −0 Original line number Diff line number Diff line Loading @@ -278,6 +278,8 @@ static const KeycodeLabel AXES[] = { { "WHEEL", 21 }, { "GAS", 22 }, { "BRAKE", 23 }, { "DISTANCE", 24 }, { "TILT", 25 }, { "GENERIC_1", 32 }, { "GENERIC_2", 33 }, { "GENERIC_3", 34 }, Loading
native/include/android/input.h +1 −0 Original line number Diff line number Diff line Loading @@ -373,6 +373,7 @@ enum { AMOTION_EVENT_AXIS_GAS = 22, AMOTION_EVENT_AXIS_BRAKE = 23, AMOTION_EVENT_AXIS_DISTANCE = 24, AMOTION_EVENT_AXIS_TILT = 25, AMOTION_EVENT_AXIS_GENERIC_1 = 32, AMOTION_EVENT_AXIS_GENERIC_2 = 33, AMOTION_EVENT_AXIS_GENERIC_3 = 34, Loading