--- RCU/DevLirc/DevLirc.pm 2005/11/06 17:24:32 1.1 +++ RCU/DevLirc/DevLirc.pm 2005/11/06 18:27:31 1.2 @@ -1,10 +1,10 @@ =head1 NAME -RCU::Lirc - RCU interface to linux-infrared-remote-control +RCU::DevLirc - RCU interface to the /dev/lirc device. =head1 SYNOPSIS - use RCU::Lirc; + use RCU::DevLirc; =head1 DESCRIPTION @@ -14,7 +14,7 @@ =cut -package RCU::Lirc; +package RCU::DevLirc; use DynaLoader; use Carp; @@ -29,50 +29,26 @@ BEGIN { $VERSION = 0.01; - bootstrap RCU::Lirc $VERSION; + bootstrap RCU::DevLirc $VERSION; } -=item new progname +=item new -Create an interface to lircd using the configuration for program "progname". +Create an interface to /dev/lirc. =cut sub new { my $class = shift; - my $prog = shift || "perl"; my $self = $class->SUPER::new(); my $fh = local *LIRC_FH; $self->{fh} = $fh; - $self->{pid} = open $fh, "-|"; - if ($self->{pid} == 0) { - select STDOUT; $|=1; - eval { - $SIG{HUP} = sub { _exit }; - lirc_init($prog) >= 0 or croak "unable to connect to lircd: $!"; - lirc_readconfig();# == 0 or croak "unable to read lirc configuration for <$prog>: $!\n"; - print "I\x00"; - for(;;) { - my ($raw, $cooked) = _get_code; - print "=".Time::HiRes::time."\x01$raw\x01$cooked\x00"; - } - }; - if ($@) { - $@ =~ s/\x00/\x01/g; - print "E$@\x00"; - } - #lirc_freeconfig; - #lirc_deinit; - POSIX::_exit(0); - } elsif (!defined $self->{pid}) { - die; - } - - $self->get; # wait for I packet + open $fh, "+<", "/dev/lirc" + or die "/dev/lirc: $!"; - $self; + $self } sub fd {