Joystick (joystick v0.2.2) View Source
Simple wrapper to get Linux Joystick events.
Usage
iex()> {:ok, js} = Joystick.start_link(0, self())
iex()> flush()
{:joystick, %Joystick.Event{number: 1, timestamp: 1441087318, type: :axis, value: -60}}
{:joystick, %Joystick.Event{number: 4, timestamp: 1441087318, type: :axis, value: -5}}
iex()> Joystick.info(js)
%{axes: 8, buttons: 11, name: 'Microsoft X-Box One pad', version: 131328}
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Get information about a joystick
Start listening to joystick events.
Stop a running joystick instance.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Get information about a joystick
Start listening to joystick events.
device
- a number pointing to the js file.- for example 0 would evaluate to "/dev/input/js0"
listener
- pid to receive eventscallback
- a message will be sent tolistener
with the form{callback, joystick}
, wherejoystick
is be the pid of the Joystick GenServer. Default value ofcallback
isnil
, which means theJoystick
pid will be returned immediately, but the GenServer will crash if a joystick connection cannot be opened.
Stop a running joystick instance.