script/evtest.pl untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 32 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl -w
2  
3 use strict;
4 use Linux::Input::Joystick;
5 use Getopt::Long;
6  
7 die (qq{Usage: $0 <device_file>...
8  
9 Example:
10 sudo $0 /dev/input/event*
11 }) if (!@ARGV);
12  
13 my @dev = map { Linux::Input->new($_) } @ARGV;
14 my $selector = IO::Select->new( map { $_->fh } @dev );
15 my %dev_for_fh = map { $_->fh => $_ } @dev;
16  
17 print "Press Ctrl-C to exit.\n";
18 my $i = 0;
19  
20 while (1) {
21 while (my @fh = $selector->can_read()) {
22 foreach (@fh) {
23 my $input_device = $dev_for_fh{$_};
24 my @event = $input_device->poll(0.01);
25 foreach my $ev (@event) {
26 printf(
27 '%5d, %7d.%-7d, '.
28 'type => %4s, code => %4d, value => %d,'."\n",
29 $i++,
30 $ev->{tv_sec},
31 $ev->{tv_usec},
32 $ev->{type},
33 $ev->{code},
34 $ev->{value},
35 );
36 }
37 }
38 }
39 }
40  
41 exit 0;
42  
43 =head1 NAME
44  
45 evtest.pl - Linux::Input event testing utility
46  
47 =head1 SYNOPSIS
48  
49 sudo evtest.pl /dev/input/event*
50  
51 =head1 DESCRIPTION
52  
53 This utility will observe all the input devices that are passed on to the
54 command line, and print the event data as it comes in.
55  
56 =head1 AUTHOR
57  
58 John Beppu (beppu@cpan.org)
59  
60 =cut
61  
62 # vim:sw=2 sts=2