Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8576dd70 authored by Vaibhav's avatar Vaibhav
Browse files

Add new NDK function definitions in input.h

This CL adds 2 new functions to get ActionButton and Classification from
a MotionEvent.

Test: atest android.view.cts.MotionEventTest

Bug: 213266814

Change-Id: Id264a5d110c6c65a7daae89194ab234f64832e13
parent 9df93aa6
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -807,6 +807,33 @@ enum {
    AMOTION_EVENT_TOOL_TYPE_PALM = 5,
};

/**
 * Constants that identify different gesture classification types.
 */
enum {
    /**
     * Classification constant: None.
     *
     * No additional information is available about the current motion event stream.
     */
    AMOTION_EVENT_CLASSIFICATION_NONE = 0,
    /**
     * Classification constant: Ambiguous gesture.
     *
     * The user's intent with respect to the current event stream is not yet determined.
     * Gestural actions, such as scrolling, should be inhibited until the classification resolves
     * to another value or the event stream ends.
     */
    AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE = 1,
    /**
     * Classification constant: Deep press.
     *
     * The current event stream represents the user intentionally pressing harder on the screen.
     * This classification type should be used to accelerate the long press behaviour.
     */
    AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS = 2,
};

/**
 * Input source masks.
 *
@@ -1326,6 +1353,23 @@ float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, siz
float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
        int32_t axis, size_t pointer_index, size_t history_index);

/**
 * Get the action button for the motion event. Returns a valid action button when the
 * event is associated with a button press or button release action. For other actions
 * the return value is undefined.
 */
int32_t AMotionEvent_getActionButton(const AInputEvent* motion_event);

/**
 * Returns the classification for the current gesture.
 * The classification may change as more events become available for the same gesture.
 *
 * @see #AMOTION_EVENT_CLASSIFICATION_NONE
 * @see #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE
 * @see #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS
*/
int32_t AMotionEvent_getClassification(const AInputEvent* motion_event);

/**
 * Creates a native AInputEvent* object that is a copy of the specified Java
 * android.view.MotionEvent. The result may be used with generic and MotionEvent-specific
+3 −5
Original line number Diff line number Diff line
@@ -275,23 +275,21 @@ enum {

/**
 * Classifications of the current gesture, if available.
 *
 * The following values must be kept in sync with MotionEvent.java
 */
enum class MotionClassification : uint8_t {
    /**
     * No classification is available.
     */
    NONE = 0,
    NONE = AMOTION_EVENT_CLASSIFICATION_NONE,
    /**
     * Too early to classify the current gesture. Need more events. Look for changes in the
     * upcoming motion events.
     */
    AMBIGUOUS_GESTURE = 1,
    AMBIGUOUS_GESTURE = AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE,
    /**
     * The current gesture likely represents a user intentionally exerting force on the touchscreen.
     */
    DEEP_PRESS = 2,
    DEEP_PRESS = AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS,
};

/**