AAC-Pvoice
view release on metacpan or search on metacpan
lib/AAC/Pvoice/Input.pm view on Meta::CPAN
{
# BEWARE: $self is the wxWindow subclass the timer
# belongs to!
my ($self, $event) = @_;
# do nothing if the device is not adremo or
# if we're already running
return if ($self->{monitorrun} ||
(not $self->{input}->{next}) ||
(not $self->{input}->{select}) ||
$self->{pause});
# set the flag that we're checking the port
$self->{monitorrun} = 1;
$self->{pp} = Device::ParallelPort->new() if not $self->{pp};
my $curvalue = $self->{pp}->get_status();
if (not defined $curvalue)
{
# clear the flag that we're checking the port and return
$self->{monitorrun} = 0;
return
}
$self->{lastvalue} = 0 if not exists $self->{lastvalue};
# if we detect a change...
if ($curvalue != $self->{lastvalue})
{
unless ($curvalue & 0x40)
{
# if bit 6 is off it's a headmove to the right
lib/AAC/Pvoice/Input.pm view on Meta::CPAN
if ($curvalue & 0x80)
{
# if bit 7 is on (this bit is inverted), it's a headmove to the left
# which will indicate a Select() event.
$self->{input}->{select}->();
}
}
# the current value becomes the last value
$self->{lastvalue} = $curvalue if $curvalue;
# clear the flag that we're checking the port
$self->{monitorrun} = 0;
}
1;
__END__
=head1 NAME
( run in 2.903 seconds using v1.01-cache-2.11-cpan-94b05bcf43c )