public final class InputEvent


Defines input events for XRCore.

Summary

Nested types

public final class InputEvent.HitInfo

Information about the hit result of the ray.

Constants

static final int

While the primary action button or gesture was held, the pointer was disabled.

static final int

The primary action button or gesture was just pressed / started.

static final int

The primary action button or gesture is not pressed, and the pointer ray started to hit a new node.

static final int

The primary action button or gesture is not pressed, and the pointer ray stopped hitting the node that it was previously hitting.

static final int

The primary action button or gesture is not pressed, and the pointer ray continued to hit the same node.

static final int

The primary action button or gesture was pressed/active in the previous event, and is still pressed/active.

static final int

The primary action button or gesture was just released / stopped.

static final int

Default pointer type for the source (no handedness).

static final int

Left hand / controller pointer.

static final int

Right hand / controller pointer.

static final int

Event is based on (one of) the user's controller(s).

static final int

Event is based on a mix of the head, eyes, and hands.

static final int

Event is based on one of the user's hands.

static final int

Event is based on the user's head.

static final int

Event is based on a 2D mouse pointing device.

static final int

Unknown source.

Public constructors

InputEvent(
    int source,
    int pointerType,
    long timestamp,
    @NonNull Vector3 origin,
    @NonNull Vector3 direction,
    int action,
    InputEvent.HitInfo hitInfo,
    InputEvent.HitInfo secondaryHitInfo
)

Public methods

boolean
equals(Object other)
final int

Actions similar to Android's MotionEvent for keeping track of a sequence of events on the same target, e.g., * HOVER_ENTER -> HOVER_MOVE -> HOVER_EXIT * DOWN -> MOVE -> UP

final @NonNull Vector3

A point indicating the direction the ray is pointing, in the receiver's activity space.

final InputEvent.HitInfo

Info about the first scene entity (closest to the ray origin) that was hit by the input ray, if any.

final @NonNull Vector3

The origin of the ray in the receiver's activity space.

final int

Type of the individual pointer.

final InputEvent.HitInfo

Info about the second scene entity from the same task that was hit, if any.

final int

Type of device that generated this event.

final long

Timestamp from android.os.SystemClock#uptimeMillis time base.

int

Constants

ACTION_CANCEL

public static final int ACTION_CANCEL = 3

While the primary action button or gesture was held, the pointer was disabled. This happens if you are using controllers and the battery runs out, or if you are using a source that transitions to a new pointer type, eg SOURCE_GAZE_AND_GESTURE.

ACTION_DOWN

public static final int ACTION_DOWN = 0

The primary action button or gesture was just pressed / started.

ACTION_HOVER_ENTER

public static final int ACTION_HOVER_ENTER = 5

The primary action button or gesture is not pressed, and the pointer ray started to hit a new node. The hit info represents the node that is being hit (may be null if pointer capture is enabled).

Hover input events are never provided for sensitive source types.

ACTION_HOVER_EXIT

public static final int ACTION_HOVER_EXIT = 6

The primary action button or gesture is not pressed, and the pointer ray stopped hitting the node that it was previously hitting. The hit info represents the node that was being hit (may be null if pointer capture is enabled).

Hover input events are never provided for sensitive source types.

ACTION_HOVER_MOVE

public static final int ACTION_HOVER_MOVE = 4

The primary action button or gesture is not pressed, and the pointer ray continued to hit the same node. The hit info represents the node that was hit (may be null if pointer capture is enabled).

Hover input events are never provided for sensitive source types.

ACTION_MOVE

public static final int ACTION_MOVE = 2

The primary action button or gesture was pressed/active in the previous event, and is still pressed/active. The hit info represents the node that was originally hit (ie, as provided in the ACTION_DOWN event). The hit position may be null if the pointer is no longer hitting that node.

ACTION_UP

public static final int ACTION_UP = 1

The primary action button or gesture was just released / stopped. The hit info represents the node that was originally hit (ie, as provided in the ACTION_DOWN event).

POINTER_TYPE_DEFAULT

public static final int POINTER_TYPE_DEFAULT = 0

Default pointer type for the source (no handedness). Occurs for SOURCE_UNKNOWN, SOURCE_HEAD, SOURCE_MOUSE, and SOURCE_GAZE_AND_GESTURE.

POINTER_TYPE_LEFT

public static final int POINTER_TYPE_LEFT = 1

Left hand / controller pointer. Occurs for SOURCE_CONTROLLER, SOURCE_HANDS, and SOURCE_GAZE_AND_GESTURE.

POINTER_TYPE_RIGHT

public static final int POINTER_TYPE_RIGHT = 2

Right hand / controller pointer. Occurs for SOURCE_CONTROLLER, SOURCE_HANDS, and SOURCE_GAZE_AND_GESTURE.

SOURCE_CONTROLLER

public static final int SOURCE_CONTROLLER = 2

Event is based on (one of) the user's controller(s). Ray origin and direction are for a controller aim pose as defined by OpenXR. Action state is based on the primary button on the controller, usually the bottom-most face button.

SOURCE_GAZE_AND_GESTURE

public static final int SOURCE_GAZE_AND_GESTURE = 5

Event is based on a mix of the head, eyes, and hands. Ray origin is at average between eyes and points in direction based on a mix of eye gaze direction and hand motion. During a two-handed zoom/rotate gesture, left/right pointer events will be issued; otherwise, default events are issued based on the gaze ray. Action state is based on if the user has done a pinch gesture or not.

Events from this source are considered sensitive and hover events are never sent.

SOURCE_HANDS

public static final int SOURCE_HANDS = 3

Event is based on one of the user's hands. Ray is a hand aim pose, with origin between thumb and forefinger and points in direction based on hand orientation. Action state is based on a pinch gesture.

SOURCE_HEAD

public static final int SOURCE_HEAD = 1

Event is based on the user's head. Ray origin is at average between eyes, pushed out to the near clipping plane for both eyes and points in direction head is facing. Action state is based on volume up button being depressed.

Events from this source are considered sensitive and hover events are never sent.

SOURCE_MOUSE

public static final int SOURCE_MOUSE = 4

Event is based on a 2D mouse pointing device. Ray origin behaves the same as for SOURCE_HEAD and points in direction based on mouse movement. During a drag, the ray origin moves approximating hand motion. The scrollwheel moves the ray away from / towards the user. Action state is based on the primary mouse button.

SOURCE_UNKNOWN

public static final int SOURCE_UNKNOWN = 0

Unknown source.

Public constructors

InputEvent

Added in 1.0.0-alpha01
public InputEvent(
    int source,
    int pointerType,
    long timestamp,
    @NonNull Vector3 origin,
    @NonNull Vector3 direction,
    int action,
    InputEvent.HitInfo hitInfo,
    InputEvent.HitInfo secondaryHitInfo
)
Parameters
int source

Type of device that generated this event.

int pointerType

Type of the individual pointer.

long timestamp

Timestamp from android.os.SystemClock#uptimeMillis time base.

@NonNull Vector3 origin

The origin of the ray in the receiver's activity space.

@NonNull Vector3 direction

A point indicating the direction the ray is pointing, in the receiver's activity space.

int action

Actions similar to Android's MotionEvent for keeping track of a sequence of events on the same target, e.g., * HOVER_ENTER -> HOVER_MOVE -> HOVER_EXIT * DOWN -> MOVE -> UP

InputEvent.HitInfo hitInfo

Info about the first scene entity (closest to the ray origin) that was hit by the input ray, if any. This will be null if no entity was hit. Note that the hit entity remains the same during an ongoing DOWN -> MOVE -> UP action, even if the pointer stops hitting the entity during the action.

InputEvent.HitInfo secondaryHitInfo

Info about the second scene entity from the same task that was hit, if any.

Public methods

equals

public boolean equals(Object other)

getAction

Added in 1.0.0-alpha01
public final int getAction()

Actions similar to Android's MotionEvent for keeping track of a sequence of events on the same target, e.g., * HOVER_ENTER -> HOVER_MOVE -> HOVER_EXIT * DOWN -> MOVE -> UP

getDirection

Added in 1.0.0-alpha01
public final @NonNull Vector3 getDirection()

A point indicating the direction the ray is pointing, in the receiver's activity space.

getHitInfo

Added in 1.0.0-alpha01
public final InputEvent.HitInfo getHitInfo()

Info about the first scene entity (closest to the ray origin) that was hit by the input ray, if any. This will be null if no entity was hit. Note that the hit entity remains the same during an ongoing DOWN -> MOVE -> UP action, even if the pointer stops hitting the entity during the action.

getOrigin

Added in 1.0.0-alpha01
public final @NonNull Vector3 getOrigin()

The origin of the ray in the receiver's activity space.

getPointerType

Added in 1.0.0-alpha01
public final int getPointerType()

Type of the individual pointer.

getSecondaryHitInfo

Added in 1.0.0-alpha01
public final InputEvent.HitInfo getSecondaryHitInfo()

Info about the second scene entity from the same task that was hit, if any.

getSource

Added in 1.0.0-alpha01
public final int getSource()

Type of device that generated this event.

getTimestamp

Added in 1.0.0-alpha01
public final long getTimestamp()

Timestamp from android.os.SystemClock#uptimeMillis time base.

hashCode

public int hashCode()