# InputDeviceCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/InputDeviceCompat.java+class:androidx.core.view.InputDeviceCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

<br />

```
public final class InputDeviceCompat
```

<br />

*** ** * ** ***

Helper class for accessing values in `https://developer.android.com/reference/android/view/InputDevice.html`.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_ANY() = -256` A special input source constant that is used when filtering input devices to match devices that provide any type of input source. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_BUTTON() = 1` The input source has buttons or keys. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_JOYSTICK() = 16` The input source is a joystick. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_MASK() = 255` A mask for input source classes. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_NONE() = 0` The input source has no class. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_POINTER() = 2` The input source is a pointing device associated with a display. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_POSITION() = 8` The input source is an absolute positioning device not associated with a display (unlike `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_POINTER()`). |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_TRACKBALL() = 4` The input source is a trackball navigation device. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_DPAD() = 513` The input source is a DPad. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_GAMEPAD() = 1025` The input source is a game pad. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_HDMI() = 33554433` The input source is a device connected through HDMI-based bus. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_JOYSTICK() = 16777232` The input source is a joystick. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_KEYBOARD() = 257` The input source is a keyboard. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_MOUSE() = 8194` The input source is a mouse pointing device. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_ROTARY_ENCODER() = 4194304` The input source is a rotating encoder device whose motions should be interpreted as akin to those of a scroll wheel. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_STYLUS() = 16386` The input source is a stylus pointing device. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_TOUCHPAD() = 1048584` The input source is a touch pad or digitizer tablet that is not associated with a display (unlike `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_TOUCHSCREEN()`). |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_TOUCHSCREEN() = 4098` The input source is a touch screen pointing device. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_TOUCH_NAVIGATION() = 2097152` The input source is a touch device whose motions should be interpreted as navigation events. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_TRACKBALL() = 65540` The input source is a trackball. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_UNKNOWN() = 0` The input source is unknown. |

## Constants

### SOURCE_ANY

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_ANY = -256
```

A special input source constant that is used when filtering input devices to match devices that provide any type of input source.

### SOURCE_CLASS_BUTTON

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_CLASS_BUTTON = 1
```

The input source has buttons or keys. Examples: `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_KEYBOARD()`, `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_DPAD()`. A `https://developer.android.com/reference/android/view/KeyEvent.html` should be interpreted as a button or key press.

### SOURCE_CLASS_JOYSTICK

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_CLASS_JOYSTICK = 16
```

The input source is a joystick. A `https://developer.android.com/reference/android/view/MotionEvent.html` should be interpreted as absolute joystick movements. Use `https://developer.android.com/reference/android/view/InputDevice.html#getMotionRange(int)` to query the range of positions.

### SOURCE_CLASS_MASK

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_CLASS_MASK = 255
```

A mask for input source classes. Each distinct input source constant has one or more input source class bits set to specify the desired interpretation for its input events.

### SOURCE_CLASS_NONE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_CLASS_NONE = 0
```

The input source has no class. It is up to the application to determine how to handle the device based on the device type.

### SOURCE_CLASS_POINTER

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_CLASS_POINTER = 2
```

The input source is a pointing device associated with a display. Examples: `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_TOUCHSCREEN()`, `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_MOUSE()`. A `https://developer.android.com/reference/android/view/MotionEvent.html` should be interpreted as absolute coordinates in display units according to the `https://developer.android.com/reference/android/view/View.html` hierarchy. Pointer down/up indicated when the finger touches the display or when the selection button is pressed/released. Use `https://developer.android.com/reference/android/view/InputDevice.html#getMotionRange(int)` to query the range of the pointing device. Some devices permit touches outside the display area so the effective range may be somewhat smaller or larger than the actual display size.

### SOURCE_CLASS_POSITION

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_CLASS_POSITION = 8
```

The input source is an absolute positioning device not associated with a display (unlike `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_POINTER()`). A `https://developer.android.com/reference/android/view/MotionEvent.html` should be interpreted as absolute coordinates in device-specific surface units. Use `https://developer.android.com/reference/android/view/InputDevice.html#getMotionRange(int)` to query the range of positions.

### SOURCE_CLASS_TRACKBALL

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_CLASS_TRACKBALL = 4
```

The input source is a trackball navigation device. Examples: `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_TRACKBALL()`. A `https://developer.android.com/reference/android/view/MotionEvent.html` should be interpreted as relative movements in device-specific units used for navigation purposes. Pointer down/up indicates when the selection button is pressed/released. Use `https://developer.android.com/reference/android/view/InputDevice.html#getMotionRange(int)` to query the range of motion.

### SOURCE_DPAD

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_DPAD = 513
```

The input source is a DPad.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_BUTTON()` |   |

### SOURCE_GAMEPAD

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_GAMEPAD = 1025
```

The input source is a game pad. (It may also be a `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_JOYSTICK()`).

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_BUTTON()` |   |

### SOURCE_HDMI

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_HDMI = 33554433
```

The input source is a device connected through HDMI-based bus. The key comes in through HDMI-CEC or MHL signal line, and is treated as if it were generated by a locally connected DPAD or keyboard.

### SOURCE_JOYSTICK

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_JOYSTICK = 16777232
```

The input source is a joystick. (It may also be a `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_GAMEPAD()`).

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_JOYSTICK()` |   |

### SOURCE_KEYBOARD

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_KEYBOARD = 257
```

The input source is a keyboard. This source indicates pretty much anything that has buttons. Use `https://developer.android.com/reference/android/view/InputDevice.html#getKeyboardType()` to determine whether the keyboard has alphabetic keys and can be used to enter text.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_BUTTON()` |   |

### SOURCE_MOUSE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_MOUSE = 8194
```

The input source is a mouse pointing device. This code is also used for other mouse-like pointing devices such as trackpads and trackpoints.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_POINTER()` |   |

### SOURCE_ROTARY_ENCODER

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_ROTARY_ENCODER = 4194304
```

The input source is a rotating encoder device whose motions should be interpreted as akin to those of a scroll wheel.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_NONE()` |   |

### SOURCE_STYLUS

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_STYLUS = 16386
```

The input source is a stylus pointing device.

Note that this bit merely indicates that an input device is capable of obtaining input from a stylus. To determine whether a given touch event was produced by a stylus, examine the tool type returned by `https://developer.android.com/reference/android/view/MotionEvent.html#getToolType(int)` for each individual pointer.

A single touch event may multiple pointers with different tool types, such as an event that has one pointer with tool type `https://developer.android.com/reference/android/view/MotionEvent.html#TOOL_TYPE_FINGER` and another pointer with tool type `https://developer.android.com/reference/android/view/MotionEvent.html#TOOL_TYPE_STYLUS`. So it is important to examine the tool type of each pointer, regardless of the source reported by `https://developer.android.com/reference/android/view/MotionEvent.html#getSource()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_POINTER()` |   |

### SOURCE_TOUCHPAD

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_TOUCHPAD = 1048584
```

The input source is a touch pad or digitizer tablet that is not associated with a display (unlike `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_TOUCHSCREEN()`).

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_POSITION()` |   |

### SOURCE_TOUCHSCREEN

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_TOUCHSCREEN = 4098
```

The input source is a touch screen pointing device.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_POINTER()` |   |

### SOURCE_TOUCH_NAVIGATION

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_TOUCH_NAVIGATION = 2097152
```

The input source is a touch device whose motions should be interpreted as navigation events. For example, an upward swipe should be as an upward focus traversal in the same manner as pressing up on a D-Pad would be. Swipes to the left, right and down should be treated in a similar manner.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_NONE()` |   |

### SOURCE_TRACKBALL

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_TRACKBALL = 65540
```

The input source is a trackball.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/InputDeviceCompat#SOURCE_CLASS_TRACKBALL()` |   |

### SOURCE_UNKNOWN

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int SOURCE_UNKNOWN = 0
```

The input source is unknown.