Input

Input user drivers provide an interface for apps to inject events into Android's
input pipeline. With
this API, apps can emulate a Human Interface Device (HID) or connect external
hardware to the input system using Peripheral I/O.

Adding the required permission

Add the required permission for the user driver to your app's manifest file:

Key events

Key events indicate a momentary press and release of an input switch. They are
generally used for generic button input (e.g. volume keys, media playback keys)
and the keys of a keyboard. Android represents each event as a
KeyEvent instance.

Motion events

Input drivers can also emit motion events to connect a pointing device to the
framework, such as a touchpad or mouse. These devices report an absolute
position value as an x/y coordinate. Each event includes an optional pressed
state to indicate if the event represents a "tap" or "click" event at that
location.