Linux::Input::Joystick - joystick-specific interface for Linux 2.2+
Usage
use YAML; my $js = Linux::Input::Joystick->new('/dev/input/js0'); while (1) { my @event = $js->poll(0.01); print Dump($_) foreach (@event); }
This is a subclass of Linux::Input that implements the joystick event interface that versions of Linux from 2.2 onward support. It differs from the normal event interface in that it uses a slightly different C struct to return event information.
This subclass inherits all of Linux::Input's methods, but differs from it in the following ways:
This method takes a $filename
and returns a Linux::Input::Joystick object on success.
Example:
my $js = Linux::Input::Joystick->new('/dev/input/js1');
This method returns the size of the joystick event structure (which is always 8) no matter what platform you run this on.
This method takes a $timeout
as a parameter and returns an list of @events
after that timeout has elapsed. The hashrefs inside @events
have the following key/value pairs.
This is the time in microseconds that this event happened.
This is the type of event.
This number represents a more specific instance of type. For example, if type is 1 (meaning button event), then number might be 5 (meaning button 5 moved).
This number specifies what happened. Keeping the previous example in mind, if the value received is 1, that means the button was pressed. However, if it's 0, that means the button was released.
For more information on what values to expect in this hashref, go look at /usr/include/linux/joystick.h.
John Beppu (beppu@cpan.org)
Perl Modules:
C Headers:
/usr/include/linux/joystick.h
Other Documentation:
/usr/src/linux/Documentation/input/joystick.txt