summaryrefslogtreecommitdiff
path: root/src/irdumptable
diff options
context:
space:
mode:
Diffstat (limited to 'src/irdumptable')
-rwxr-xr-xsrc/irdumptable165
1 files changed, 165 insertions, 0 deletions
diff --git a/src/irdumptable b/src/irdumptable
new file mode 100755
index 0000000..94554e0
--- /dev/null
+++ b/src/irdumptable
@@ -0,0 +1,165 @@
+#!/usr/bin/perl -w
+#
+# IRBOX, an Ivy driver for infra-red remote controls
+#
+# Copyright 1998-1999
+# Centre d'Etudes de la Navigation Aerienne
+#
+# Authors: Johnny Accot <accot@cenatoulouse.dgac.fr>
+# Stephane Chatty <chatty@cenatoulouse.dgac.fr>
+#
+# A utility for creating code tables from an RCA programmable remote
+#
+# $Id$
+#
+# Please refer to file version.h for the
+# copyright notice regarding this software
+#
+
+$SIG{HUP} = $SIG{INT} = $SIG{KILL} = 'Quit';
+
+use strict;
+use Ivy;
+use File::Basename;
+
+$| = 1;
+
+my @vcrkeys = ('power', 'channel up', 'channel down', 'rew', 'play', 'ff', 'rec', 'stop', 'pause');
+my @tvkeys = ('mute', 'power', 'volume up', 'volume down', 'channel up', 'channel down');
+my @cablekeys = ('power', 'channel up', 'channel down');
+
+my %typekeys = ('VCR', \@vcrkeys, 'TV', \@tvkeys, 'CABLE', \@cablekeys);
+
+my $me = basename ($0);
+die ("Usage: $me [<brand:class:id>] [RCA mode number]\n") unless @ARGV < 3;
+
+
+# retrieve various IR control identification items
+
+my ($id, $mode) = @ARGV;
+
+if (!defined $id) {
+ print "ID of the IR remote control (eg: Sony:VCR:1)? ";
+ chop ($id = <>);
+}
+
+my ($brand, $type, $num) = split (':', $id, 3);
+
+if (!defined ($brand) || !defined ($type)) {
+ die "Brand and type must be defined";
+}
+
+
+my $comment;
+$comment = "# obtained on an RCA SystemLink 3 in $type mode $mode" if (defined $mode);
+
+# we only handle types we know
+
+if (!defined ($typekeys{$type})) {
+ die "Type $type unknown\n";
+}
+
+#
+# OK, let's go
+#
+
+# first, prepare to receive key presses from Ivy bus
+
+my $host = 'nebul';
+Ivy::bindRegexp ("$host\.IRBOX unknown code ([0-9]+ [0-9]+ [0-9]+ [0-9]+ [0-9]+ [0-9]+)", [\&ReceiveCode]);
+Ivy::bindRegexp ("$host\.IRBOX Down (.*)", [\&PrintCode]);
+
+
+Ivy::start (-loopMode => 'LOCAL',
+ -appName => 'IR Remote Control Map dumper',
+ -broadcastPort => 2019);
+
+
+# then create list of keys the user will have to press,
+# and ask for the first one
+
+my @keylist = @{$typekeys{$type}};
+my %table;
+
+my $key = shift @keylist;
+print "Please press on '$key'...";
+
+# then loop
+
+Ivy::mainLoop ();
+
+&Dump();
+exit 1;
+
+
+
+
+sub ReceiveCode {
+ my $code = $_[1];
+ print "ok, code = $code\n";
+ $table{$key} = $code;
+ $key = shift @keylist;
+ if (defined $key) {
+ print "Please press on '$key'...";
+ } else {
+ print "Done, thank you\n";
+
+ # should exit loop, but Ivy does not allow that
+ # Ivy::stop ();
+ # So, let's be brutal!
+ Dump ();
+ exit 1;
+ }
+}
+
+sub PrintCode {
+ my $name = $_[1];
+ print "$name\n";
+}
+
+sub Quit {
+ Ivy::stop ();
+ exit 1;
+}
+
+sub Dump {
+ my $lowbrand = $brand;
+ $lowbrand =~ tr/[A-Z]/[a-z]/;
+ my $brandnum;
+ if (defined ($num)) {
+ $brandnum = "$brand $num";
+ } else {
+ $brandnum = $brand;
+ $num = "";
+ }
+ my $filename = "$lowbrand$type$num.ir";
+ print "Saving table $filename\n";
+
+ if (-s "$filename") {
+ my $choice;
+ print "File $filename exists... Overwrite? (y/[n]) ";
+ chop ($choice = <>);
+ until ($choice eq 'y' or $choice eq 'n') {
+ print "Please answer by 'y' or 'n': ";
+ chop ($choice = <>);
+ }
+ die ("Aborting.\n") if $choice eq 'n';
+ }
+
+ open Table, ">$filename";
+ print Table "name $brand$type$num\n";
+ print Table "type: $type\n";
+ print Table "\n";
+ print Table "brand: $brandnum\n";
+ print Table "brand: RCA SystemLink 3 [mode $mode]\n" if defined $mode;
+ print Table "\n$comment\n" if defined $comment;
+ print Table "\n";
+
+ foreach my $key (@{$typekeys{$type}}) {
+ print Table "$key:\t$table{$key}\n";
+ }
+ close Table;
+
+ exit;
+
+}