View Source InputEvent (input_event v1.4.2)
Elixir interface to Linux input event devices
Summary
Types
Event code
Event structure
Message that is sent to the caller when input event received
Options for the InputEvent Genserver
Event type
The type of event
An unknown event type
Event value
Functions
Returns a specification to start this module under a supervisor.
Scan the system for input devices and return information on each one.
Return information about this input event device
Start a GenServer that reports events from the specified input event device
Stop the InputEvent GenServer.
Types
@type code() :: atom() | code_number()
Event code
Usually these are translated to an atom that corresponds with the Linux event code. Event codes depend on the event type.
@type code_number() :: 0..65535
Event structure
Message that is sent to the caller when input event received
@type options() :: [ path: String.t(), grab: boolean(), receiver: pid() | atom(), repeat_delay: pos_integer(), repeat_period: pos_integer() ]
Options for the InputEvent Genserver
@type type() :: type_name() | type_number()
Event type
Usually these are translated to an atom that corresponds with the Linux event type.
@type type_name() ::
:ev_syn
| :ev_key
| :ev_rel
| :ev_abs
| :ev_msc
| :ev_sw
| :ev_led
| :ev_snd
| :ev_rep
| :ev_ff
| :ev_pwr
| :ev_ff_status
The type of event
@type type_number() :: 0..65535
An unknown event type
@type value() :: integer()
Event value
See the event type and code for how to interpret the value. For example, it could be a 0 or 1 signifying a key press or release, or it could be an x or y coordinate or delta.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec enumerate() :: [{String.t(), InputEvent.Info.t()}]
Scan the system for input devices and return information on each one.
@spec info(GenServer.server()) :: InputEvent.Info.t()
Return information about this input event device
@spec start_link(String.t() | options()) :: GenServer.on_start()
Start a GenServer that reports events from the specified input event device
Options:
:path
- the path to the input event device (e.g.,"/dev/input/event0"
):grab
- set to true to prevent events from being passed to other applications (defaults tofalse
):repeat_delay
- delay in milliseconds before a key press repeats:repeat_period
- period in milliseconds in which a key press will repeat:receiver
- the pid or name of the process that receives events (defaults to the process that callsstart_link/1
Note that passing the device path rather than a keyword list to
start_link/1
is deprecated.
When adjusting the key repeat rate, you must set BOTH :repeat_delay
and
:repeat_period
for input_event
to make the change. Be careful setting
repeat timing in multiple places on the same device path! You might override
your own settings!
@spec stop(GenServer.server()) :: :ok
Stop the InputEvent GenServer.