InputDevice
  public
  
  final
  
  class
  InputDevice
  
    extends Object
  
  
  
  
  
      implements
      
        Parcelable
      
  
  
| java.lang.Object | |
| ↳ | android.view.InputDevice | 
Describes the capabilities of a particular input device.
Each input device may support multiple classes of input. For example, a multi-function keyboard may compose the capabilities of a standard keyboard together with a track pad mouse or other pointing device.
Some input devices present multiple distinguishable sources of input. Applications can query the framework about the characteristics of each distinct source.
As a further wrinkle, different kinds of input sources uses different coordinate systems to describe motion events. Refer to the comments on the input source constants for the appropriate interpretation.
Summary
| Nested classes | ||
|---|---|---|
| 
        
        
        
        
        class | InputDevice.MotionRangeProvides information about the range of values for a particular  | |
| 
        
        
        
        
        class | InputDevice.ViewBehaviorProvides information on how views processing  | |
| Constants | |
|---|---|
| int | KEYBOARD_TYPE_ALPHABETICThe keyboard supports a complement of alphabetic keys. | 
| int | KEYBOARD_TYPE_NONEThere is no keyboard. | 
| int | KEYBOARD_TYPE_NON_ALPHABETICThe keyboard is not fully alphabetic. | 
| int | MOTION_RANGE_ORIENTATION
      This constant was deprecated
      in API level 15.
    Use  | 
| int | MOTION_RANGE_PRESSURE
      This constant was deprecated
      in API level 15.
    Use  | 
| int | MOTION_RANGE_SIZE
      This constant was deprecated
      in API level 15.
    Use  | 
| int | MOTION_RANGE_TOOL_MAJOR
      This constant was deprecated
      in API level 15.
    Use  | 
| int | MOTION_RANGE_TOOL_MINOR
      This constant was deprecated
      in API level 15.
    Use  | 
| int | MOTION_RANGE_TOUCH_MAJOR
      This constant was deprecated
      in API level 15.
    Use  | 
| int | MOTION_RANGE_TOUCH_MINOR
      This constant was deprecated
      in API level 15.
    Use  | 
| int | MOTION_RANGE_X
      This constant was deprecated
      in API level 15.
    Use  | 
| int | MOTION_RANGE_Y
      This constant was deprecated
      in API level 15.
    Use  | 
| int | SOURCE_ANYA special input source constant that is used when filtering input devices to match devices that provide any type of input source. | 
| int | SOURCE_BLUETOOTH_STYLUSThe input device is a Bluetooth stylus. | 
| int | SOURCE_CLASS_BUTTONThe input source has buttons or keys. | 
| int | SOURCE_CLASS_JOYSTICKThe input source is a joystick. | 
| int | SOURCE_CLASS_MASKA mask for input source classes. | 
| int | SOURCE_CLASS_NONEThe input source has no class. | 
| int | SOURCE_CLASS_POINTERThe input source is a pointing device associated with a display. | 
| int | SOURCE_CLASS_POSITIONThe input source is an absolute positioning device not associated with a display
 (unlike  | 
| int | SOURCE_CLASS_TRACKBALLThe input source is a trackball navigation device. | 
| int | SOURCE_DPADThe input source is a DPad. | 
| int | SOURCE_GAMEPADThe input source is a game pad. | 
| int | SOURCE_HDMIThe input source is a device connected through HDMI-based bus. | 
| int | SOURCE_JOYSTICKThe input source is a joystick. | 
| int | SOURCE_KEYBOARDThe input source is a keyboard. | 
| int | SOURCE_MOUSEThe input source is a mouse pointing device. | 
| int | SOURCE_MOUSE_RELATIVEThe input source is a mouse device whose relative motions should be interpreted as navigation events. | 
| int | SOURCE_ROTARY_ENCODERThe input source is a rotating encoder device whose motions should be interpreted as akin to those of a scroll wheel. | 
| int | SOURCE_SENSORThe input source is a sensor associated with the input device. | 
| int | SOURCE_STYLUSThe input source is a stylus pointing device. | 
| int | SOURCE_TOUCHPADThe input source is a touchpad (also known as a trackpad). | 
| int | SOURCE_TOUCHSCREENThe input source is a touch screen pointing device. | 
| int | SOURCE_TOUCH_NAVIGATIONThe input source is a touch device whose motions should be interpreted as navigation events. | 
| int | SOURCE_TRACKBALLThe input source is a trackball. | 
| int | SOURCE_UNKNOWNThe input source is unknown. | 
| Inherited constants | 
|---|
| Fields | |
|---|---|
| 
    public
    static
    final
    Creator<InputDevice> | CREATOR
 | 
| Public methods | |
|---|---|
| 
        
        
        
        
        
        int | 
      describeContents()
      Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | 
| 
        
        
        
        
        
        BatteryState | 
      getBatteryState()
      Gets the battery state object associated with the device, if there is one. | 
| 
        
        
        
        
        
        int | 
      getControllerNumber()
      The controller number for a given input device. | 
| 
        
        
        
        
        
        String | 
      getDescriptor()
      Gets the input device descriptor, which is a stable identifier for an input device. | 
| 
        
        
        static
        
        
        InputDevice | 
      getDevice(int id)
      Gets information about the input device with the specified id. | 
| 
        
        
        static
        
        
        int[] | 
      getDeviceIds()
      Gets the ids of all input devices in the system. | 
| 
        
        
        
        
        
        int | 
      getId()
      Gets the input device id. | 
| 
        
        
        
        
        
        KeyCharacterMap | 
      getKeyCharacterMap()
      Gets the key character map associated with this input device. | 
| 
        
        
        
        
        
        int | 
      getKeyCodeForKeyLocation(int locationKeyCode)
      Gets the  | 
| 
        
        
        
        
        
        int | 
      getKeyboardType()
      Gets the keyboard type. | 
| 
        
        
        
        
        
        LightsManager | 
      getLightsManager()
      Gets the lights manager associated with the device, if there is one. | 
| 
        
        
        
        
        
        InputDevice.MotionRange | 
      getMotionRange(int axis)
      Gets information about the range of values for a particular  | 
| 
        
        
        
        
        
        InputDevice.MotionRange | 
      getMotionRange(int axis, int source)
      Gets information about the range of values for a particular  | 
| 
        
        
        
        
        
        List<InputDevice.MotionRange> | 
      getMotionRanges()
      Gets the ranges for all axes supported by the device. | 
| 
        
        
        
        
        
        String | 
      getName()
      Gets the name of this input device. | 
| 
        
        
        
        
        
        int | 
      getProductId()
      Gets the product id for the given device, if available. | 
| 
        
        
        
        
        
        SensorManager | 
      getSensorManager()
      Gets the sensor manager service associated with the input device. | 
| 
        
        
        
        
        
        int | 
      getSources()
      Gets the input sources supported by this input device as a combined bitfield. | 
| 
        
        
        
        
        
        int | 
      getVendorId()
      Gets the vendor id for the given device, if available. | 
| 
        
        
        
        
        
        Vibrator | 
      getVibrator()
      
      This method was deprecated
      in API level 31.
    Use  | 
| 
        
        
        
        
        
        VibratorManager | 
      getVibratorManager()
      Gets the vibrator manager associated with the device. | 
| 
        
        
        
        
        
        boolean[] | 
      hasKeys(int... keys)
      Gets whether the device is capable of producing the list of keycodes. | 
| 
        
        
        
        
        
        boolean | 
      hasMicrophone()
      Reports whether the device has a built-in microphone. | 
| 
        
        
        
        
        
        boolean | 
      isEnabled()
      Returns true if input device is enabled. | 
| 
        
        
        
        
        
        boolean | 
      isExternal()
      Returns true if the device is external (connected to USB or Bluetooth or some other peripheral bus), otherwise it is built-in. | 
| 
        
        
        
        
        
        boolean | 
      isVirtual()
      Returns true if the device is a virtual input device rather than a real one,
 such as the virtual keyboard (see  | 
| 
        
        
        
        
        
        boolean | 
      supportsSource(int source)
      Determines whether the input device supports the given source or sources. | 
| 
        
        
        
        
        
        String | 
      toString()
      Returns a string representation of the object. | 
| 
        
        
        
        
        
        void | 
      writeToParcel(Parcel out, int flags)
      Flatten this object in to a Parcel. | 
| Inherited methods | |
|---|---|
Constants
KEYBOARD_TYPE_ALPHABETIC
public static final int KEYBOARD_TYPE_ALPHABETIC
The keyboard supports a complement of alphabetic keys.
Constant Value: 2 (0x00000002)
KEYBOARD_TYPE_NONE
public static final int KEYBOARD_TYPE_NONE
There is no keyboard.
Constant Value: 0 (0x00000000)
KEYBOARD_TYPE_NON_ALPHABETIC
public static final int KEYBOARD_TYPE_NON_ALPHABETIC
The keyboard is not fully alphabetic. It may be a numeric keypad or an assortment of buttons that are not mapped as alphabetic keys suitable for text input.
Constant Value: 1 (0x00000001)
MOTION_RANGE_ORIENTATION
public static final int MOTION_RANGE_ORIENTATION
      This constant was deprecated
      in API level 15.
    Use MotionEvent.AXIS_ORIENTATION instead.
  
Constant for retrieving the range of values for MotionEvent.AXIS_ORIENTATION.
See also:
Constant Value: 8 (0x00000008)
MOTION_RANGE_PRESSURE
public static final int MOTION_RANGE_PRESSURE
      This constant was deprecated
      in API level 15.
    Use MotionEvent.AXIS_PRESSURE instead.
  
Constant for retrieving the range of values for MotionEvent.AXIS_PRESSURE.
See also:
Constant Value: 2 (0x00000002)
MOTION_RANGE_SIZE
public static final int MOTION_RANGE_SIZE
      This constant was deprecated
      in API level 15.
    Use MotionEvent.AXIS_SIZE instead.
  
Constant for retrieving the range of values for MotionEvent.AXIS_SIZE.
See also:
Constant Value: 3 (0x00000003)
MOTION_RANGE_TOOL_MAJOR
public static final int MOTION_RANGE_TOOL_MAJOR
      This constant was deprecated
      in API level 15.
    Use MotionEvent.AXIS_TOOL_MAJOR instead.
  
Constant for retrieving the range of values for MotionEvent.AXIS_TOOL_MAJOR.
See also:
Constant Value: 6 (0x00000006)
MOTION_RANGE_TOOL_MINOR
public static final int MOTION_RANGE_TOOL_MINOR
      This constant was deprecated
      in API level 15.
    Use MotionEvent.AXIS_TOOL_MINOR instead.
  
Constant for retrieving the range of values for MotionEvent.AXIS_TOOL_MINOR.
See also:
Constant Value: 7 (0x00000007)
MOTION_RANGE_TOUCH_MAJOR
public static final int MOTION_RANGE_TOUCH_MAJOR
      This constant was deprecated
      in API level 15.
    Use MotionEvent.AXIS_TOUCH_MAJOR instead.
  
Constant for retrieving the range of values for MotionEvent.AXIS_TOUCH_MAJOR.
See also:
Constant Value: 4 (0x00000004)
MOTION_RANGE_TOUCH_MINOR
public static final int MOTION_RANGE_TOUCH_MINOR
      This constant was deprecated
      in API level 15.
    Use MotionEvent.AXIS_TOUCH_MINOR instead.
  
Constant for retrieving the range of values for MotionEvent.AXIS_TOUCH_MINOR.
See also:
Constant Value: 5 (0x00000005)
MOTION_RANGE_X
public static final int MOTION_RANGE_X
      This constant was deprecated
      in API level 15.
    Use MotionEvent.AXIS_X instead.
  
Constant for retrieving the range of values for MotionEvent.AXIS_X.
See also:
Constant Value: 0 (0x00000000)
MOTION_RANGE_Y
public static final int MOTION_RANGE_Y
      This constant was deprecated
      in API level 15.
    Use MotionEvent.AXIS_Y instead.
  
Constant for retrieving the range of values for MotionEvent.AXIS_Y.
See also:
Constant Value: 1 (0x00000001)
SOURCE_ANY
public static final int SOURCE_ANY
A special input source constant that is used when filtering input devices to match devices that provide any type of input source.
Constant Value: -256 (0xffffff00)
SOURCE_BLUETOOTH_STYLUS
public static final int SOURCE_BLUETOOTH_STYLUS
The input device is a Bluetooth stylus.
 Note that this bit merely indicates that an input device is capable of
 obtaining input from a Bluetooth stylus.  To determine whether a given
 touch event was produced by a stylus, examine the tool type returned by
 MotionEvent.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
 MotionEvent.TOOL_TYPE_FINGER and another pointer with tool type
 MotionEvent.TOOL_TYPE_STYLUS.  So it is important to examine
 the tool type of each pointer, regardless of the source reported
 by MotionEvent.getSource().
 
A bluetooth stylus generally receives its pressure and button state information from the stylus itself, and derives the rest from another source. For example, a Bluetooth stylus used in conjunction with a touchscreen would derive its contact position and pointer size from the touchscreen and may not be any more accurate than other tools such as fingers.
See also:
Constant Value: 49154 (0x0000c002)
SOURCE_CLASS_BUTTON
public static final int SOURCE_CLASS_BUTTON
The input source has buttons or keys.
 Examples: SOURCE_KEYBOARD, SOURCE_DPAD.
 A KeyEvent should be interpreted as a button or key press.
 Use getKeyCharacterMap() to query the device's button and key mappings.
Constant Value: 1 (0x00000001)
SOURCE_CLASS_JOYSTICK
public static final int SOURCE_CLASS_JOYSTICK
The input source is a joystick.
 A MotionEvent should be interpreted as absolute joystick movements.
 Use getMotionRange(int) to query the range of positions.
Constant Value: 16 (0x00000010)
SOURCE_CLASS_MASK
public static final int SOURCE_CLASS_MASK
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.
Constant Value: 255 (0x000000ff)
SOURCE_CLASS_NONE
public static final int SOURCE_CLASS_NONE
The input source has no class. It is up to the application to determine how to handle the device based on the device type.
Constant Value: 0 (0x00000000)
SOURCE_CLASS_POINTER
public static final int SOURCE_CLASS_POINTER
The input source is a pointing device associated with a display.
 Examples: SOURCE_TOUCHSCREEN, SOURCE_MOUSE.
 A MotionEvent should be interpreted as absolute coordinates in
 display units according to the View hierarchy.  Pointer down/up indicated when
 the finger touches the display or when the selection button is pressed/released.
 Use 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.
Constant Value: 2 (0x00000002)
SOURCE_CLASS_POSITION
public static final int SOURCE_CLASS_POSITION
The input source is an absolute positioning device not associated with a display
 (unlike SOURCE_CLASS_POINTER).
 A MotionEvent should be interpreted as absolute coordinates in
 device-specific surface units.
 Use getMotionRange(int) to query the range of positions.
Constant Value: 8 (0x00000008)
SOURCE_CLASS_TRACKBALL
public static final int SOURCE_CLASS_TRACKBALL
The input source is a trackball navigation device.
 Examples: SOURCE_TRACKBALL.
 A MotionEvent 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 getMotionRange(int) to query the range of motion.
Constant Value: 4 (0x00000004)
SOURCE_DPAD
public static final int SOURCE_DPAD
The input source is a DPad.
See also:
Constant Value: 513 (0x00000201)
SOURCE_GAMEPAD
public static final int SOURCE_GAMEPAD
The input source is a game pad.
 (It may also be a SOURCE_JOYSTICK).
See also:
Constant Value: 1025 (0x00000401)
SOURCE_HDMI
public static final int SOURCE_HDMI
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.
Constant Value: 33554433 (0x02000001)
SOURCE_JOYSTICK
public static final int SOURCE_JOYSTICK
The input source is a joystick.
 (It may also be a SOURCE_GAMEPAD).
See also:
Constant Value: 16777232 (0x01000010)
SOURCE_KEYBOARD
public static final int SOURCE_KEYBOARD
The input source is a keyboard.
 This source indicates pretty much anything that has buttons.  Use
 getKeyboardType() to determine whether the keyboard has alphabetic keys
 and can be used to enter text.
See also:
Constant Value: 257 (0x00000101)
SOURCE_MOUSE
public static final int SOURCE_MOUSE
The input source is a mouse pointing device.
 This value is also used for other mouse-like pointing devices such as touchpads and pointing
 sticks. When used in combination with SOURCE_STYLUS, it denotes an external drawing
 tablet.
See also:
Constant Value: 8194 (0x00002002)
SOURCE_MOUSE_RELATIVE
public static final int SOURCE_MOUSE_RELATIVE
The input source is a mouse device whose relative motions should be interpreted as navigation events.
See also:
Constant Value: 131076 (0x00020004)
SOURCE_ROTARY_ENCODER
public static final int SOURCE_ROTARY_ENCODER
The input source is a rotating encoder device whose motions should be interpreted as akin to those of a scroll wheel.
See also:
Constant Value: 4194304 (0x00400000)
SOURCE_SENSOR
public static final int SOURCE_SENSOR
The input source is a sensor associated with the input device.
See also:
Constant Value: 67108864 (0x04000000)
SOURCE_STYLUS
public static final int SOURCE_STYLUS
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 MotionEvent.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
 MotionEvent.TOOL_TYPE_FINGER and another pointer with tool type
 MotionEvent.TOOL_TYPE_STYLUS.  So it is important to examine
 the tool type of each pointer, regardless of the source reported
 by MotionEvent.getSource().
 
See also:
Constant Value: 16386 (0x00004002)
SOURCE_TOUCHPAD
public static final int SOURCE_TOUCHPAD
The input source is a touchpad (also known as a trackpad). Touchpads that are used to move
 the mouse cursor will also have SOURCE_MOUSE.
See also:
Constant Value: 1048584 (0x00100008)
SOURCE_TOUCHSCREEN
public static final int SOURCE_TOUCHSCREEN
The input source is a touch screen pointing device.
See also:
Constant Value: 4098 (0x00001002)
SOURCE_TOUCH_NAVIGATION
public static final int SOURCE_TOUCH_NAVIGATION
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:
Constant Value: 2097152 (0x00200000)
SOURCE_TRACKBALL
public static final int SOURCE_TRACKBALL
The input source is a trackball.
See also:
Constant Value: 65540 (0x00010004)
SOURCE_UNKNOWN
public static final int SOURCE_UNKNOWN
The input source is unknown.
Constant Value: 0 (0x00000000)
Fields
Public methods
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
 instance's marshaled representation. For example, if the object will
 include a file descriptor in the output of writeToParcel(android.os.Parcel, int),
 the return value of this method must include the
 CONTENTS_FILE_DESCRIPTOR bit.
| Returns | |
|---|---|
| int | a bitmask indicating the set of special object types marshaled
 by this Parcelable object instance.
 Value is either 0orCONTENTS_FILE_DESCRIPTOR | 
getBatteryState
public BatteryState getBatteryState ()
Gets the battery state object associated with the device, if there is one.
 Even if the device does not have a battery, the result is never null.
 Use BatteryState.isPresent to determine whether a battery is
 present.
| Returns | |
|---|---|
| BatteryState | The battery object associated with the device, never null. | 
getControllerNumber
public int getControllerNumber ()
The controller number for a given input device.
 Each gamepad or joystick is given a unique, positive controller number when initially
 configured by the system. This number may change due to events such as device disconnects /
 reconnects or user initiated reassignment. Any change in number will trigger an event that
 can be observed by registering an
 InputManager.InputDeviceListener.
 
All input devices which are not gamepads or joysticks will be assigned a controller number of 0.
| Returns | |
|---|---|
| int | The controller number of the device. | 
getDescriptor
public String getDescriptor ()
Gets the input device descriptor, which is a stable identifier for an input device.
An input device descriptor uniquely identifies an input device. Its value is intended to be persistent across system restarts, and should not change even if the input device is disconnected, reconnected or reconfigured at any time.
 It is possible for there to be multiple InputDevice instances that have the
 same input device descriptor.  This might happen in situations where a single
 human input device registers multiple InputDevice instances (HID collections)
 that describe separate features of the device, such as a keyboard that also
 has a touchpad.  Alternately, it may be that the input devices are simply
 indistinguishable, such as two keyboards made by the same manufacturer.
 
 The input device descriptor returned by getDescriptor() should only be
 used when an application needs to remember settings associated with a particular
 input device.  For all other purposes when referring to a logical
 InputDevice instance at runtime use the id returned by getId().
 
| Returns | |
|---|---|
| String | The input device descriptor. | 
getDevice
public static InputDevice getDevice (int id)
Gets information about the input device with the specified id.
| Parameters | |
|---|---|
| id | int: The device id. | 
| Returns | |
|---|---|
| InputDevice | The input device or null if not found. | 
getDeviceIds
public static int[] getDeviceIds ()
Gets the ids of all input devices in the system.
| Returns | |
|---|---|
| int[] | The input device ids. | 
getId
public int getId ()
Gets the input device id.
 Each input device receives a unique id when it is first configured
 by the system.  The input device id may change when the system is restarted or if the
 input device is disconnected, reconnected or reconfigured at any time.
 If you require a stable identifier for a device that persists across
 boots and reconfigurations, use getDescriptor().
 
| Returns | |
|---|---|
| int | The input device id. | 
getKeyCharacterMap
public KeyCharacterMap getKeyCharacterMap ()
Gets the key character map associated with this input device.
| Returns | |
|---|---|
| KeyCharacterMap | The key character map. | 
getKeyCodeForKeyLocation
public int getKeyCodeForKeyLocation (int locationKeyCode)
Gets the key code produced by the given location on a reference
 QWERTY keyboard layout.
 
This API is useful for querying the physical location of keys that change the character produced based on the current locale and keyboard layout.
The following table provides a non-exhaustive list of examples:
| Active Keyboard Layout | Input Parameter | Return Value | 
|---|---|---|
| French AZERTY |  |  | 
| German QWERTZ |  |  | 
| US QWERTY |  |  | 
| Parameters | |
|---|---|
| locationKeyCode | int: The location of a key specified as a key code on the QWERTY layout.
 This provides a consistent way of referring to the physical location of a key independently
 of the current keyboard layout. Also see the
 
 hypothetical keyboard provided by the W3C, which may be helpful for identifying the
 physical location of a key. | 
| Returns | |
|---|---|
| int | The key code produced by the key at the specified location, given the current
 keyboard layout. Returns KeyEvent.KEYCODE_UNKNOWNif the device does not specifyInputDevice.SOURCE_KEYBOARDor the requested mapping cannot be determined. | 
getKeyboardType
public int getKeyboardType ()
Gets the keyboard type.
| Returns | |
|---|---|
| int | The keyboard type. | 
getLightsManager
public LightsManager getLightsManager ()
Gets the lights manager associated with the device, if there is one.
 Even if the device does not have lights, the result is never null.
 Use LightsManager.getLights to determine whether any lights is
 present.
| Returns | |
|---|---|
| LightsManager | The lights manager associated with the device, never null. | 
getMotionRange
public InputDevice.MotionRange getMotionRange (int axis)
Gets information about the range of values for a particular MotionEvent axis.
 If the device supports multiple sources, the same axis may have different meanings
 for each source.  Returns information about the first axis found for any source.
 To obtain information about the axis for a specific source, use
 getMotionRange(int, int).
| Parameters | |
|---|---|
| axis | int: The axis constant. | 
| Returns | |
|---|---|
| InputDevice.MotionRange | The range of values, or null if the requested axis is not supported by the device. | 
See also:
getMotionRange
public InputDevice.MotionRange getMotionRange (int axis, int source)
Gets information about the range of values for a particular MotionEvent axis
 used by a particular source on the device.
 If the device supports multiple sources, the same axis may have different meanings
 for each source.
| Parameters | |
|---|---|
| axis | int: The axis constant. | 
| source | int: The source for which to return information. | 
| Returns | |
|---|---|
| InputDevice.MotionRange | The range of values, or null if the requested axis is not supported by the device. | 
See also:
getMotionRanges
public List<InputDevice.MotionRange> getMotionRanges ()
Gets the ranges for all axes supported by the device.
| Returns | |
|---|---|
| List<InputDevice.MotionRange> | The motion ranges for the device. | 
See also:
getName
public String getName ()
Gets the name of this input device.
| Returns | |
|---|---|
| String | The input device name. | 
getProductId
public int getProductId ()
Gets the product id for the given device, if available.
A product id uniquely identifies which product within the address space of a given vendor, identified by the device's vendor id. A value of 0 will be assigned where a product id is not available.
| Returns | |
|---|---|
| int | The product id of a given device | 
getSensorManager
public SensorManager getSensorManager ()
Gets the sensor manager service associated with the input device.
 Even if the device does not have a sensor, the result is never null.
 Use SensorManager.getSensorList to get a full list of all supported sensors.
 Note that the sensors associated with the device may be different from
 the system sensors, as typically they are builtin sensors physically attached to
 input devices.
| Returns | |
|---|---|
| SensorManager | The sensor manager service associated with the device, never null. | 
getSources
public int getSources ()
Gets the input sources supported by this input device as a combined bitfield.
| Returns | |
|---|---|
| int | The supported input sources. | 
getVendorId
public int getVendorId ()
Gets the vendor id for the given device, if available.
A vendor id uniquely identifies the company who manufactured the device. A value of 0 will be assigned where a vendor id is not available.
| Returns | |
|---|---|
| int | The vendor id of a given device | 
getVibrator
public Vibrator getVibrator ()
      This method was deprecated
      in API level 31.
    Use getVibratorManager() to retrieve the default device vibrator.
  
Gets the vibrator service associated with the device, if there is one.
 Even if the device does not have a vibrator, the result is never null.
 Use Vibrator.hasVibrator to determine whether a vibrator is
 present.
 Note that the vibrator associated with the device may be different from
 the system vibrator.  To obtain an instance of the system vibrator instead, call
 Context.getSystemService with Context.VIBRATOR_SERVICE as argument.
| Returns | |
|---|---|
| Vibrator | The vibrator service associated with the device, never null. | 
getVibratorManager
public VibratorManager getVibratorManager ()
Gets the vibrator manager associated with the device.
 Even if the device does not have a vibrator manager, the result is never null.
 Use VibratorManager.getVibratorIds to determine whether any vibrator is
 present.
| Returns | |
|---|---|
| VibratorManager | The vibrator manager associated with the device, never null. | 
hasKeys
public boolean[] hasKeys (int... keys)
Gets whether the device is capable of producing the list of keycodes.
| Parameters | |
|---|---|
| keys | int: The list of android keycodes to check for. | 
| Returns | |
|---|---|
| boolean[] | An array of booleans where each member specifies whether the device is capable of generating the keycode given by the corresponding value at the same index in the keys array. | 
hasMicrophone
public boolean hasMicrophone ()
Reports whether the device has a built-in microphone.
| Returns | |
|---|---|
| boolean | Whether the device has a built-in microphone. | 
isEnabled
public boolean isEnabled ()
Returns true if input device is enabled.
| Returns | |
|---|---|
| boolean | Whether the input device is enabled. | 
isExternal
public boolean isExternal ()
Returns true if the device is external (connected to USB or Bluetooth or some other peripheral bus), otherwise it is built-in.
| Returns | |
|---|---|
| boolean | True if the device is external. | 
isVirtual
public boolean isVirtual ()
Returns true if the device is a virtual input device rather than a real one,
 such as the virtual keyboard (see KeyCharacterMap.VIRTUAL_KEYBOARD).
 
Virtual input devices are provided to implement system-level functionality and should not be seen or configured by users.
| Returns | |
|---|---|
| boolean | True if the device is virtual. | 
See also:
supportsSource
public boolean supportsSource (int source)
Determines whether the input device supports the given source or sources.
| Parameters | |
|---|---|
| source | int: The input source or sources to check against. This can be a generic device
 type such asInputDevice.SOURCE_MOUSE, a more generic device class, such asInputDevice.SOURCE_CLASS_POINTER, or a combination of sources bitwise ORed together. | 
| Returns | |
|---|---|
| boolean | Whether the device can produce all of the given sources. | 
toString
public String toString ()
Returns a string representation of the object.
| Returns | |
|---|---|
| String | a string representation of the object. | 
writeToParcel
public void writeToParcel (Parcel out, int flags)
Flatten this object in to a Parcel.
| Parameters | |
|---|---|
| out | Parcel: The Parcel in which the object should be written.
 This value cannot benull. | 
| flags | int: Additional flags about how the object should be written.
 May be 0 orParcelable.PARCELABLE_WRITE_RETURN_VALUE.
 Value is either0or a combination ofParcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
