Add pinch classification and scale factor axis
Bug: 251196347
Test: check events received by a custom tester app, and touches shown by
pointer location overlay
Test: atest inputflinger_tests
Change-Id: I0cb7ade63139ab35025ff1e12609e2b411b1f5f8
This commit is contained in:
@@ -50482,6 +50482,7 @@ package android.view {
|
||||
field public static final int AXIS_GENERIC_7 = 38; // 0x26
|
||||
field public static final int AXIS_GENERIC_8 = 39; // 0x27
|
||||
field public static final int AXIS_GENERIC_9 = 40; // 0x28
|
||||
field public static final int AXIS_GESTURE_PINCH_SCALE_FACTOR = 52; // 0x34
|
||||
field public static final int AXIS_GESTURE_SCROLL_X_DISTANCE = 50; // 0x32
|
||||
field public static final int AXIS_GESTURE_SCROLL_Y_DISTANCE = 51; // 0x33
|
||||
field public static final int AXIS_GESTURE_X_OFFSET = 48; // 0x30
|
||||
@@ -50522,6 +50523,7 @@ package android.view {
|
||||
field public static final int CLASSIFICATION_AMBIGUOUS_GESTURE = 1; // 0x1
|
||||
field public static final int CLASSIFICATION_DEEP_PRESS = 2; // 0x2
|
||||
field public static final int CLASSIFICATION_NONE = 0; // 0x0
|
||||
field public static final int CLASSIFICATION_PINCH = 5; // 0x5
|
||||
field public static final int CLASSIFICATION_TWO_FINGER_SWIPE = 3; // 0x3
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.view.MotionEvent> CREATOR;
|
||||
field public static final int EDGE_BOTTOM = 2; // 0x2
|
||||
|
||||
@@ -1283,6 +1283,8 @@ public final class MotionEvent extends InputEvent implements Parcelable {
|
||||
* swipe gesture starts at X = 500 then moves to X = 400, this axis would have a value of
|
||||
* -0.1.
|
||||
* </ul>
|
||||
* These values are relative to the state from the last event, not accumulated, so developers
|
||||
* should make sure to process this axis value for all batched historical events.
|
||||
*/
|
||||
public static final int AXIS_GESTURE_X_OFFSET = 48;
|
||||
|
||||
@@ -1300,6 +1302,8 @@ public final class MotionEvent extends InputEvent implements Parcelable {
|
||||
* <li>For a touch pad, reports the distance that should be scrolled in the X axis as a result
|
||||
* of the user's two-finger scroll gesture, in display pixels.
|
||||
* </ul>
|
||||
* These values are relative to the state from the last event, not accumulated, so developers
|
||||
* should make sure to process this axis value for all batched historical events.
|
||||
*/
|
||||
public static final int AXIS_GESTURE_SCROLL_X_DISTANCE = 50;
|
||||
|
||||
@@ -1310,6 +1314,19 @@ public final class MotionEvent extends InputEvent implements Parcelable {
|
||||
*/
|
||||
public static final int AXIS_GESTURE_SCROLL_Y_DISTANCE = 51;
|
||||
|
||||
/**
|
||||
* Axis constant: pinch scale factor of a motion event.
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>For a touch pad, reports the change in distance between the fingers when the user is
|
||||
* making a pinch gesture, as a proportion of the previous distance. For example, if the fingers
|
||||
* were 50 units apart and are now 52 units apart, the scale factor would be 1.04.
|
||||
* </ul>
|
||||
* These values are relative to the state from the last event, not accumulated, so developers
|
||||
* should make sure to process this axis value for all batched historical events.
|
||||
*/
|
||||
public static final int AXIS_GESTURE_PINCH_SCALE_FACTOR = 52;
|
||||
|
||||
// NOTE: If you add a new axis here you must also add it to:
|
||||
// frameworks/native/include/android/input.h
|
||||
// frameworks/native/libs/input/InputEventLabels.cpp
|
||||
@@ -1369,6 +1386,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
|
||||
names.append(AXIS_GESTURE_Y_OFFSET, "AXIS_GESTURE_Y_OFFSET");
|
||||
names.append(AXIS_GESTURE_SCROLL_X_DISTANCE, "AXIS_GESTURE_SCROLL_X_DISTANCE");
|
||||
names.append(AXIS_GESTURE_SCROLL_Y_DISTANCE, "AXIS_GESTURE_SCROLL_Y_DISTANCE");
|
||||
names.append(AXIS_GESTURE_PINCH_SCALE_FACTOR, "AXIS_GESTURE_PINCH_SCALE_FACTOR");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1522,11 +1540,22 @@ public final class MotionEvent extends InputEvent implements Parcelable {
|
||||
*/
|
||||
public static final int CLASSIFICATION_MULTI_FINGER_SWIPE = 4;
|
||||
|
||||
/**
|
||||
* Classification constant: touchpad pinch.
|
||||
*
|
||||
* The current event stream represents the user pinching with two fingers on a touchpad. The
|
||||
* gesture is centered around the current cursor position.
|
||||
*
|
||||
* @see #getClassification
|
||||
*/
|
||||
public static final int CLASSIFICATION_PINCH = 5;
|
||||
|
||||
/** @hide */
|
||||
@Retention(SOURCE)
|
||||
@IntDef(prefix = { "CLASSIFICATION" }, value = {
|
||||
CLASSIFICATION_NONE, CLASSIFICATION_AMBIGUOUS_GESTURE, CLASSIFICATION_DEEP_PRESS,
|
||||
CLASSIFICATION_TWO_FINGER_SWIPE, CLASSIFICATION_MULTI_FINGER_SWIPE})
|
||||
CLASSIFICATION_TWO_FINGER_SWIPE, CLASSIFICATION_MULTI_FINGER_SWIPE,
|
||||
CLASSIFICATION_PINCH})
|
||||
public @interface Classification {};
|
||||
|
||||
/**
|
||||
|
||||
@@ -299,6 +299,8 @@ int32_t AMotionEvent_getClassification(const AInputEvent* motion_event) {
|
||||
return AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE;
|
||||
case android::MotionClassification::MULTI_FINGER_SWIPE:
|
||||
return AMOTION_EVENT_CLASSIFICATION_MULTI_FINGER_SWIPE;
|
||||
case android::MotionClassification::PINCH:
|
||||
return AMOTION_EVENT_CLASSIFICATION_PINCH;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user