# InputDevice.MotionRange

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# MotionRange

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/view/InputDevice.MotionRange "View this page in Java")  

```
class MotionRange
```

|---|------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                               ||
| ↳ | [android.view.InputDevice.MotionRange](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#) |

Provides information about the range of values for a particular [MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent) axis.

## Summary

|                                                                                                                                                                          Public methods                                                                                                                                                                           ||
|------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getAxis](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#getAxis())`()` Gets the axis id.                                                                                                                                                |
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)     | [getFlat](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#getFlat())`()` Gets the extent of the center flat position with respect to this axis.                                                                                           |
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)     | [getFuzz](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#getFuzz())`()` Gets the error tolerance for input device measurements with respect to this axis.                                                                                |
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)     | [getMax](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#getMax())`()` Gets the inclusive maximum value for the axis.                                                                                                                     |
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)     | [getMin](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#getMin())`()` Gets the inclusive minimum value for the axis.                                                                                                                     |
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)     | [getRange](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#getRange())`()` Gets the range of the axis (difference between maximum and minimum).                                                                                           |
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)     | [getResolution](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#getResolution())`()` Gets the resolution for input device measurements with respect to this axis.                                                                         |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)         | [getSource](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#getSource())`()` Gets the source for which the axis is defined.                                                                                                               |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isFromSource](https://developer.android.com/reference/kotlin/android/view/InputDevice.MotionRange#isFromSource(kotlin.Int))`(`source:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Determines whether the event is from the given source. |

## Public methods

### getAxis

Added in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAxis(): Int
```

Gets the axis id.

|                                          Return                                          ||
|----------------------------------------------------------------------------|--------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The axis id. |

### getFlat

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getFlat(): Float
```

Gets the extent of the center flat position with respect to this axis.

For example, a flat value of 8 means that the center position is between -8 and +8. This value is mainly useful for calibrating self-centering devices.

|                                                         Return                                                          ||
|--------------------------------------------------------------------------------|-----------------------------------------|
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html) | The extent of the center flat position. |

### getFuzz

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getFuzz(): Float
```

Gets the error tolerance for input device measurements with respect to this axis.

For example, a value of 2 indicates that the measured value may be up to +/- 2 units away from the actual value due to noise and device sensitivity limitations.

|                                                Return                                                ||
|--------------------------------------------------------------------------------|----------------------|
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html) | The error tolerance. |

### getMax

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getMax(): Float
```

Gets the inclusive maximum value for the axis.

|                                                    Return                                                    ||
|--------------------------------------------------------------------------------|------------------------------|
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html) | The inclusive maximum value. |

### getMin

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getMin(): Float
```

Gets the inclusive minimum value for the axis.

|                                                    Return                                                    ||
|--------------------------------------------------------------------------------|------------------------------|
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html) | The inclusive minimum value. |

### getRange

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getRange(): Float
```

Gets the range of the axis (difference between maximum and minimum).

|                                                Return                                                ||
|--------------------------------------------------------------------------------|----------------------|
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html) | The range of values. |

### getResolution

Added in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getResolution(): Float
```

Gets the resolution for input device measurements with respect to this axis.

|                                                                              Return                                                                              ||
|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html) | The resolution in units per millimeter, or units per radian for rotational axes. |

### getSource

Added in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getSource(): Int
```

Gets the source for which the axis is defined.

|                                         Return                                          ||
|----------------------------------------------------------------------------|-------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The source. |

### isFromSource

Added in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun isFromSource(source: Int): Boolean
```

Determines whether the event is from the given source.

|                                                                                                                                                                                                                                                  Parameters                                                                                                                                                                                                                                                  ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The input source to check against. This can be a specific device type, such as [InputDevice.SOURCE_TOUCH_NAVIGATION](https://developer.android.com/reference/kotlin/android/view/InputDevice#SOURCE_TOUCH_NAVIGATION:kotlin.Int), or a more generic device class, such as [InputDevice.SOURCE_CLASS_POINTER](https://developer.android.com/reference/kotlin/android/view/InputDevice#SOURCE_CLASS_POINTER:kotlin.Int). |

|                                                             Return                                                              ||
|------------------------------------------------------------------------------------|---------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | Whether the event is from the given source. |