MotionEventCompat

Added in 1.1.0

public final class MotionEventCompat


Helper for accessing features in MotionEvent.

Summary

Constants

static final int

This field is deprecated.

Use ACTION_HOVER_ENTER directly.

static final int

This field is deprecated.

Use ACTION_HOVER_EXIT directly.

static final int

This field is deprecated.

Use ACTION_HOVER_MOVE directly.

static final int

This field is deprecated.

Use ACTION_MASK directly.

static final int

This field is deprecated.

Use ACTION_POINTER_DOWN directly.

static final int

This field is deprecated.

Use ACTION_POINTER_INDEX_MASK directly.

static final int

This field is deprecated.

Use ACTION_POINTER_INDEX_SHIFT directly.

static final int

This field is deprecated.

Use ACTION_POINTER_UP directly.

static final int

This field is deprecated.

Use ACTION_SCROLL directly.

static final int

This field is deprecated.

Use AXIS_BRAKE directly.

static final int

This field is deprecated.

Use AXIS_DISTANCE directly.

static final int

This field is deprecated.

Use AXIS_GAS directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_1 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_10 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_11 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_12 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_13 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_14 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_15 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_16 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_2 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_3 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_4 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_5 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_6 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_7 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_8 directly.

static final int

This field is deprecated.

Use AXIS_GENERIC_9 directly.

static final int

This field is deprecated.

Use AXIS_HAT_X directly.

static final int

This field is deprecated.

Use AXIS_HAT_Y directly.

static final int

This field is deprecated.

Use AXIS_HSCROLL directly.

static final int

This field is deprecated.

Use AXIS_LTRIGGER directly.

static final int

This field is deprecated.

Use AXIS_ORIENTATION directly.

static final int

This field is deprecated.

Use AXIS_PRESSURE directly.

static final int

Synonym for AXIS_RELATIVE_X.

static final int

Synonym for AXIS_RELATIVE_Y.

static final int

This field is deprecated.

Use AXIS_RTRIGGER directly.

static final int

This field is deprecated.

Use AXIS_RUDDER directly.

static final int
AXIS_RX = 12

This field is deprecated.

Use AXIS_RX directly.

static final int
AXIS_RY = 13

This field is deprecated.

Use AXIS_RY directly.

static final int
AXIS_RZ = 14

This field is deprecated.

Use AXIS_RZ directly.

static final int

Synonym for AXIS_SCROLL.

static final int

This field is deprecated.

Use AXIS_SIZE directly.

static final int

This field is deprecated.

Use AXIS_THROTTLE directly.

static final int

This field is deprecated.

Use AXIS_TILT directly.

static final int

This field is deprecated.

Use AXIS_TOOL_MAJOR directly.

static final int

This field is deprecated.

Use AXIS_TOOL_MINOR directly.

static final int

This field is deprecated.

Use AXIS_TOUCH_MAJOR directly.

static final int

This field is deprecated.

Use AXIS_TOUCH_MINOR directly.

static final int

This field is deprecated.

Use AXIS_VSCROLL directly.

static final int

This field is deprecated.

Use AXIS_WHEEL directly.

static final int
AXIS_X = 0

This field is deprecated.

Use AXIS_X directly.

static final int
AXIS_Y = 1

This field is deprecated.

Use AXIS_Y directly.

static final int
AXIS_Z = 11

This field is deprecated.

Use AXIS_Z directly.

static final int

This field is deprecated.

Use BUTTON_PRIMARY directly.

Public methods

static int
findPointerIndex(MotionEvent event, int pointerId)

This method is deprecated.

Call findPointerIndex directly.

static int

This method is deprecated.

Call getActionIndex directly.

static int

This method is deprecated.

Call getAction directly.

static float
getAxisValue(MotionEvent event, int axis)

This method is deprecated.

Call getAxisValue directly.

static float
getAxisValue(MotionEvent event, int axis, int pointerIndex)

This method is deprecated.

Call getAxisValue directly.

static int

This method is deprecated.

Call getButtonState directly.

static int

This method is deprecated.

Call getPointerCount directly.

static int
getPointerId(MotionEvent event, int pointerIndex)

This method is deprecated.

Call getPointerId directly.

static int

This method is deprecated.

Call getSource directly.

static float
getX(MotionEvent event, int pointerIndex)

This method is deprecated.

Call getX directly.

static float
getY(MotionEvent event, int pointerIndex)

This method is deprecated.

Call getY directly.

static boolean
isFromSource(@NonNull MotionEvent event, int source)

Determines whether the event is from the given source.

Constants

ACTION_HOVER_ENTER

Added in 1.1.0
Deprecated in 1.1.0
public static final int ACTION_HOVER_ENTER = 9

Synonym for ACTION_HOVER_ENTER.

ACTION_HOVER_EXIT

Added in 1.1.0
Deprecated in 1.1.0
public static final int ACTION_HOVER_EXIT = 10

Synonym for ACTION_HOVER_EXIT.

ACTION_HOVER_MOVE

Added in 1.1.0
Deprecated in 1.1.0
public static final int ACTION_HOVER_MOVE = 7

Synonym for ACTION_HOVER_MOVE.

ACTION_MASK

Added in 1.1.0
Deprecated in 1.1.0
public static final int ACTION_MASK = 255

Synonym for ACTION_MASK.

ACTION_POINTER_DOWN

Added in 1.1.0
Deprecated in 1.1.0
public static final int ACTION_POINTER_DOWN = 5

Synonym for ACTION_POINTER_DOWN.

ACTION_POINTER_INDEX_MASK

Added in 1.1.0
Deprecated in 1.1.0
public static final int ACTION_POINTER_INDEX_MASK = 65280

Synonym for ACTION_POINTER_INDEX_MASK.

ACTION_POINTER_INDEX_SHIFT

Added in 1.1.0
Deprecated in 1.1.0
public static final int ACTION_POINTER_INDEX_SHIFT = 8

Synonym for ACTION_POINTER_INDEX_SHIFT.

ACTION_POINTER_UP

Added in 1.1.0
Deprecated in 1.1.0
public static final int ACTION_POINTER_UP = 6

Synonym for ACTION_POINTER_UP.

ACTION_SCROLL

Added in 1.1.0
Deprecated in 1.1.0
public static final int ACTION_SCROLL = 8

Synonym for ACTION_SCROLL.

AXIS_BRAKE

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_BRAKE = 23

Synonym for AXIS_BRAKE.

AXIS_DISTANCE

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_DISTANCE = 24

Synonym for AXIS_DISTANCE.

AXIS_GAS

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GAS = 22

Synonym for AXIS_GAS.

AXIS_GENERIC_1

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_1 = 32

Synonym for AXIS_GENERIC_1.

AXIS_GENERIC_10

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_10 = 41

Synonym for AXIS_GENERIC_10.

AXIS_GENERIC_11

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_11 = 42

Synonym for AXIS_GENERIC_11.

AXIS_GENERIC_12

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_12 = 43

Synonym for AXIS_GENERIC_12.

AXIS_GENERIC_13

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_13 = 44

Synonym for AXIS_GENERIC_13.

AXIS_GENERIC_14

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_14 = 45

Synonym for AXIS_GENERIC_14.

AXIS_GENERIC_15

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_15 = 46

Synonym for AXIS_GENERIC_15.

AXIS_GENERIC_16

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_16 = 47

Synonym for AXIS_GENERIC_16.

AXIS_GENERIC_2

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_2 = 33

Synonym for AXIS_GENERIC_2.

AXIS_GENERIC_3

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_3 = 34

Synonym for AXIS_GENERIC_3.

AXIS_GENERIC_4

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_4 = 35

Synonym for AXIS_GENERIC_4.

AXIS_GENERIC_5

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_5 = 36

Synonym for AXIS_GENERIC_5.

AXIS_GENERIC_6

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_6 = 37

Synonym for AXIS_GENERIC_6.

AXIS_GENERIC_7

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_7 = 38

Synonym for AXIS_GENERIC_7.

AXIS_GENERIC_8

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_8 = 39

Synonym for AXIS_GENERIC_8.

AXIS_GENERIC_9

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_GENERIC_9 = 40

Synonym for AXIS_GENERIC_9.

AXIS_HAT_X

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_HAT_X = 15

Synonym for AXIS_HAT_X.

AXIS_HAT_Y

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_HAT_Y = 16

Synonym for AXIS_HAT_Y.

AXIS_HSCROLL

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_HSCROLL = 10

Synonym for AXIS_HSCROLL.

AXIS_LTRIGGER

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_LTRIGGER = 17

Synonym for AXIS_LTRIGGER.

AXIS_ORIENTATION

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_ORIENTATION = 8

Synonym for AXIS_ORIENTATION.

AXIS_PRESSURE

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_PRESSURE = 2

Synonym for AXIS_PRESSURE.

AXIS_RELATIVE_X

Added in 1.1.0
public static final int AXIS_RELATIVE_X = 27

Synonym for AXIS_RELATIVE_X.

AXIS_RELATIVE_Y

Added in 1.1.0
public static final int AXIS_RELATIVE_Y = 28

Synonym for AXIS_RELATIVE_Y.

AXIS_RTRIGGER

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_RTRIGGER = 18

Synonym for AXIS_RTRIGGER.

AXIS_RUDDER

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_RUDDER = 20

Synonym for AXIS_RUDDER.

AXIS_RX

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_RX = 12

Synonym for AXIS_RX.

AXIS_RY

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_RY = 13

Synonym for AXIS_RY.

AXIS_RZ

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_RZ = 14

Synonym for AXIS_RZ.

AXIS_SCROLL

Added in 1.1.0
public static final int AXIS_SCROLL = 26

Synonym for AXIS_SCROLL.

AXIS_SIZE

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_SIZE = 3

Synonym for AXIS_SIZE.

AXIS_THROTTLE

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_THROTTLE = 19

Synonym for AXIS_THROTTLE.

AXIS_TILT

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_TILT = 25

Synonym for AXIS_TILT.

AXIS_TOOL_MAJOR

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_TOOL_MAJOR = 6

Synonym for AXIS_TOOL_MAJOR.

AXIS_TOOL_MINOR

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_TOOL_MINOR = 7

Synonym for AXIS_TOOL_MINOR.

AXIS_TOUCH_MAJOR

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_TOUCH_MAJOR = 4

Synonym for AXIS_TOUCH_MAJOR.

AXIS_TOUCH_MINOR

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_TOUCH_MINOR = 5

Synonym for AXIS_TOUCH_MINOR.

AXIS_VSCROLL

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_VSCROLL = 9

Synonym for AXIS_VSCROLL.

AXIS_WHEEL

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_WHEEL = 21

Synonym for AXIS_WHEEL.

AXIS_X

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_X = 0

Synonym for AXIS_X.

AXIS_Y

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_Y = 1

Synonym for AXIS_Y.

AXIS_Z

Added in 1.1.0
Deprecated in 1.1.0
public static final int AXIS_Z = 11

Synonym for AXIS_Z.

BUTTON_PRIMARY

Added in 1.1.0
Deprecated in 1.1.0
public static final int BUTTON_PRIMARY = 1

Synonym for BUTTON_PRIMARY.

Public methods

findPointerIndex

Added in 1.1.0
Deprecated in 1.1.0
public static int findPointerIndex(MotionEvent event, int pointerId)

Call findPointerIndex.

getActionIndex

Added in 1.1.0
Deprecated in 1.1.0
public static int getActionIndex(MotionEvent event)

Call getAction, returning only the pointer index portion.

getActionMasked

Added in 1.1.0
Deprecated in 1.1.0
public static int getActionMasked(MotionEvent event)

Call getAction, returning only the ACTION_MASK portion.

getAxisValue

Added in 1.1.0
Deprecated in 1.1.0
public static float getAxisValue(MotionEvent event, int axis)

Get axis value for the first pointer index (may be an arbitrary pointer identifier).

Parameters
MotionEvent event

motion event for which to get the value.

int axis

The axis identifier for the axis value to retrieve.

See also
AXIS_X
AXIS_Y

getAxisValue

Added in 1.1.0
Deprecated in 1.1.0
public static float getAxisValue(MotionEvent event, int axis, int pointerIndex)

Returns the value of the requested axis for the given pointer index (use getPointerId to find the pointer identifier for this index).

Parameters
MotionEvent event

motion event for which to get the value.

int axis

The axis identifier for the axis value to retrieve.

int pointerIndex

Raw index of pointer to retrieve. Value may be from 0 (the first pointer that is down) to getPointerCount-1.

Returns
float

The value of the axis, or 0 if the axis is not available.

See also
AXIS_X
AXIS_Y

getButtonState

Added in 1.1.0
Deprecated in 1.1.0
public static int getButtonState(MotionEvent event)

getPointerCount

Added in 1.1.0
Deprecated in 1.1.0
public static int getPointerCount(MotionEvent event)

The number of pointers of data contained in this event. Always

getPointerId

Added in 1.1.0
Deprecated in 1.1.0
public static int getPointerId(MotionEvent event, int pointerIndex)

Call getPointerId.

getSource

Added in 1.1.0
Deprecated in 1.1.0
public static int getSource(MotionEvent event)

Gets the source of the event.

Returns
int

The event source or SOURCE_UNKNOWN if unknown.

getX

Added in 1.1.0
Deprecated in 1.1.0
public static float getX(MotionEvent event, int pointerIndex)

Call getX.

getY

Added in 1.1.0
Deprecated in 1.1.0
public static float getY(MotionEvent event, int pointerIndex)

Call getY.

isFromSource

Added in 1.1.0
public static boolean isFromSource(@NonNull MotionEvent event, int source)

Determines whether the event is from the given source.

Parameters
@NonNull MotionEvent event

motion event for which to check the source.

int source

The input source to check against.

Returns
boolean

Whether the event is from the given source.