AccessoryMenu/Mouse.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 48 CC 6 SCAR 32.6
CC
6
Cov
0%
handle
42.0
on_enter
2.0
on_exit
2.0
CRAP 26.0
1 use strict;
2 package Device::Ericsson::AccessoryMenu::Mouse;
3 use base 'Device::Ericsson::AccessoryMenu::State';
4 __PACKAGE__->mk_accessors( qw( callback title upup ) );
5  
6 sub on_enter {
7 my $self = shift;
8  
9 my $title = $self->title;
10  
11 # show the user a dialog they can quit from
12 $self->send( qq{AT*EAID=13,2,"$title"} );
13 $self->expect( 'OK' );
14 # and put them into Event Reporting mode.
15 $self->send( qq{AT+CMER=3,2,0,0,0} );
16 $self->expect( 'OK' );
17 }
18  
19 sub on_exit {
20 my $self = shift;
21  
22 # reset spy mode
23 $self->send( qq{AT+CMER=0,0,0,0,0} );
24 $self->expect( 'OK' );
25 }
26  
27 sub handle {
28 my $self = shift;
29 my $got = shift;
30  
31 if ($got =~ /\+CKEV: (?:(.),(.))?/) {
32 my ($key, $updown) = ($1, $2);
33 unless (defined $key) {
34 # this seems glitchy on my phone. oh well - hack it
35 $key = "^";
36 $updown = $self->upup;
37 $updown ^= 1;
38 $self->upup( $updown );
39 }
40 $self->callback->($key, $updown) if $self->callback;
41 }
42 if ($got =~ /\*EAII/) { # backup
43 $self->exit_state;
44 return;
45 }
46  
47 warn "Mouse got unexpected 'line'\n" if $self->debug;
48 }
49  
50 1;