File Coverage

blib/lib/Linux/Input/Joystick.pm
Criterion Covered Total %
statement 9 20 45.0
branch n/a
condition 0 3 0.0
subroutine 3 4 75.0
pod 1 1 100.0
total 13 28 46.4


line stmt bran cond sub pod time code
1             package Linux::Input::Joystick;
2              
3 1     1   4026 use base 'Linux::Input';
  1         2  
  1         91  
4 1     1   5 use strict;
  1         2  
  1         28  
5 1     1   5 use warnings;
  1         2  
  1         179  
6              
7             # class data
8             Linux::Input::Joystick->event_bytes(8);
9              
10             # return all pending events
11             sub poll {
12 0     0 1   my $self = shift;
13 0   0       my $timeout = shift || ref($self)->timeout();
14 0           my $selector = $self->selector();
15 0           my @ev;
16 0           while (my ($fh) = $selector->can_read($timeout)) {
17 0           my $buffer;
18 0           my $len = sysread($fh, $buffer, Linux::Input::Joystick->event_bytes);
19 0           my ($time, $value, $type, $number) =
20             unpack('LsCC', $buffer);
21 0           my $event = {
22             time => $time,
23             type => $type,
24             number => $number,
25             value => $value,
26             };
27 0           push @ev, $event;
28             }
29 0           return @ev;
30             }
31              
32             1;
33              
34             __END__