Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Libraries

    Linux::Joystick 0.0.1

    Download button

    No screenshots available
    Downloads: 467  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    B. Watson | More programs
    Perl Artistic License / FREE
    January 6th, 2007, 06:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Linux::Joystick description

    Linux::Joystick is an object-oriented, pure Perl API for accessing joystick devices under Linux-based operating systems.

    Linux::Joystick is an object-oriented, pure Perl API for accessing joystick devices under Linux-based operating systems. Linux::Joystick module is capable of using either blocking or non-blocking I/O, and represents each axis change or button press as a Linux::Joystick::Event object.

    USAGE

    If you want your application to be driven by joystick events, use blocking I/O and an event loop:

    use Linux::Joystick;

    my $js = new Linux::Joystick;
    my $event;

    print "Joystick has " . $js->buttonCount() . " buttons ".
    "and " . $js->axisCount() . " axes.n";

    # blocking reads:
    while( $event = $js->nextEvent ) {

    print "Event type: " . $event->type . ", ";
    if($event->isButton) {
    print "Button " . $event->button;
    if($event->buttonDown) {
    print " pressed";
    } else {
    print " released";
    }
    } elsif($event->isAxis) {
    print "Axis " . $event->axis . ", value " . $event->axisValue . ", ";
    print "UP" if $event->stickUp;
    print "DOWN" if $event->stickDown;
    print "LEFT" if $event->stickLeft;
    print "RIGHT" if $event->stickRight;
    } else { # should never happen
    print "Unknown event " . $event->hexDump;
    }

    print "n";
    }

    # if the while loop terminates, we got a false (undefined) event:
    die "Error reading joystick: " . $js->errorString;

    You can also use non-blocking I/O, in which case nextEvent() returning undef just means there was no event to read:

    my $js = Linux::Joystick->new(nonblocking => 1);
    # use this to open 2nd joystick in nonblocking mode instead:
    # my $js = Linux::Joystick->new(device => 1, nonblocking => 1);

    while(1) {
    my $event = $js->nextEvent;

    if($event) {
    print "Got a joystick eventn";
    # process the event here
    }

    # Do other processing here (graphics, sound, I/O, calculation)

    }

    It is possible to switch between blocking and non-blocking I/O without reopening the device (see the setNonblocking() method, below).

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Perl API | joystick devices | Perl module | Linux::Joystick | object-oriented | Perl

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM