| Linux-Input-Info documentation | Contained in the Linux-Input-Info distribution. |
Linux::Input::Info - get information about /dev/input/event* devices under Linux
use Linux::Input::Info qw(:all); # optionally export EV_* constants
for (0..32) {
my $i = Linux::Input::Info->new($_);
printf "/dev/input/event%d\n", $_;
printf "\tbustype : %s\n", $i->bustype;
printf "\tvendor : 0x%x\n", $i->vendor;
printf "\tproduct : 0x%x\n", $i->product;
printf "\tversion : %d\n", $i->version;
printf "\tname : %s\n", $i->name;
printf "\tuniq : %s\n", $i->uniq;
printf "\tphys : %s\n", $i->phys;
printf "\tbits ev :";
printf " %s", $i->ev_name($_) for $i->bits;
printf "\n";
}
Returns undef if the device does not exist.
get the bus type
get vendor id
get the product id
get driver version
get device name
get unique identifier
get physical location
get event bits
map event bit to event name
Make sure it doesn't leak memory.
Simon Wistow <simon@thegestalt.org>
Copyright 2005, Simon Wistow
Gerd Knorr's input utils - http://dl.bytesex.org/cvs-snapshots/
| Linux-Input-Info documentation | Contained in the Linux-Input-Info distribution. |
package Linux::Input::Info; use strict; require DynaLoader; require Exporter; our @ISA = qw(Exporter DynaLoader); our $VERSION = '0.2'; use constant EV_SYN => 0x00; use constant EV_KEY => 0x01; use constant EV_REL => 0x02; use constant EV_ABS => 0x03; use constant EV_MSC => 0x04; use constant EV_LED => 0x11; use constant EV_SND => 0x12; use constant EV_REP => 0x14; use constant EV_FF => 0x15; use constant EV_PWR => 0x16; use constant EV_FF_STATUS => 0x17; use constant EV_MAX => 0x1f; our %EV_NAME = ( EV_SYN , "EV_SYN", EV_KEY , "EV_KEY", EV_REL , "EV_REL", EV_ABS , "EV_ABS", EV_MSC , "EV_MSC", EV_LED , "EV_LED", EV_SND , "EV_SND", EV_REP , "EV_REP", EV_FF , "EV_FF", EV_PWR , "EV_PWR", EV_FF_STATUS , "EV_FF_STATUS", ); our @EXPORT_OK = qw(EV_SYN EV_KEY EV_REL EV_ABS EV_MSC EV_LED EV_SND EV_REP EV_FF EV_PWR EV_FF_STATUS); our %EXPORT_TAGS = ( all => [@EXPORT_OK] );
sub new { my $class = shift; my $num = shift; my $fd = device_open($num); return undef unless defined $fd; my $self = device_info($fd); return bless $self, $class; }
sub bustype { return $_[0]->{bustype}; }
sub vendor { return $_[0]->{vendor}; }
sub product { return $_[0]->{product}; }
sub version { return $_[0]->{version}; }
sub name { return $_[0]->{name}; }
sub uniq { return $_[0]->{uniq}; }
sub phys { return $_[0]->{phys}; }
sub bits { return @{$_[0]->{bits}}; }
sub ev_name { my ($self, $bit) = @_; return $EV_NAME{$bit}; }
bootstrap Linux::Input::Info $VERSION; 1; __END__