The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Linux::Input::Joystick - joystick-specific interface for Linux 2.2+

SYNOPSIS

Usage

  use YAML;
  my $js = Linux::Input::Joystick->new('/dev/input/js0');
  while (1) {
    my @event = $js->poll(0.01);
    print Dump($_) foreach (@event);
  }

DESCRIPTION

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:

Class Methods

new

This method takes a $filename and returns a Linux::Input::Joystick object on success.

Example:

  my $js = Linux::Input::Joystick->new('/dev/input/js1');

event_bytes

This method returns the size of the joystick event structure (which is always 8) no matter what platform you run this on.

Object Methods

poll

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.

time

This is the time in microseconds that this event happened.

type

This is the type of event.

number

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).

value

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.

AUTHOR

John Beppu (beppu@cpan.org)

SEE ALSO

Perl Modules:

Linux::Input,

C Headers:

/usr/include/linux/joystick.h

Other Documentation:

/usr/src/linux/Documentation/input/joystick.txt