Index: Slim/Hardware/IR.pm =================================================================== RCS file: /home/cvs/cvsroot/slim/server/Slim/Hardware/IR.pm,v retrieving revision 1.23 diff -u -p -B -r1.23 IR.pm --- Slim/Hardware/IR.pm 27 Aug 2004 21:53:56 -0000 1.23 +++ Slim/Hardware/IR.pm 2 Sep 2004 06:24:16 -0000 @@ -119,10 +119,10 @@ sub mapfiles { $::d_ir && msg(" key mapping file entry: $mapfile\n"); my $path = catdir($irfiledir,$mapfile); if ($1 eq defaultMap()) { - $maplist{$path} = Slim::Utils::Strings::string('DEFAULT_MAP'); - $defaultMapFile = $path + $maplist{$mapfile} = Slim::Utils::Strings::string('DEFAULT_MAP'); + $defaultMapFile = $mapfile } else { - $maplist{$path} = $1; + $maplist{$mapfile} = $1; } } } @@ -145,39 +145,49 @@ sub addModeDefaultMapping { my @buttonPressStyles = ( '','.single','.double','.repeat','.hold','.hold_release'); +sub mapPath { + my $mapfile = shift; + my $path; + foreach my $irfiledir (IRFileDirs()) { + $path = catdir($irfiledir,$mapfile); + last if -r $path; + } + return $path; +} + sub loadMapFile { my $mapfile = shift; my $mode; - $::d_ir && msg("opening map file $mapfile\n"); - - if (-r $mapfile) { - delete $irMap{$mapfile}; - open(MAP, $mapfile); - while () { - if (/\[(.+)\]/) { - $mode = $1; - next; - } - chomp; # no newline - s/^\s+//; # no leading white - s/\s+$//; # no trailing white - s/\s*#.*$//; # trim comments (note, no #'s or ='s allowed in button names) - next unless length; #anything left? - my ($buttonName, $function) = split(/\s*=\s*/, $_, 2); - unless ($buttonName =~ /(.+)\.\*/) { - $irMap{$mapfile}{$mode}{$buttonName} = $function; - } else { - foreach my $style (@buttonPressStyles) { - $irMap{$mapfile}{$mode}{$1 . $style} = $function unless exists($irMap{$mapfile}{$mode}{$1 . $style}) ; + $::d_ir && msg(" key mapping file entry: $mapfile\n"); + my $path = -r $mapfile ? $mapfile : mapPath($mapfile); + $::d_ir && msg("opening map file $path\n"); + if (-r $path) { + delete $irMap{$path}; + open(MAP, $path); + while () { + if (/\[(.+)\]/) { + $mode = $1; + next; + } + chomp; # no newline + s/^\s+//; # no leading white + s/\s+$//; # no trailing white + s/\s*#.*$//; # trim comments (note, no #'s or ='s allowed in button names) + next unless length; #anything left? + my ($buttonName, $function) = split(/\s*=\s*/, $_, 2); + unless ($buttonName =~ /(.+)\.\*/) { + $irMap{$path}{$mode}{$buttonName} = $function; + } else { + foreach my $style (@buttonPressStyles) { + $irMap{$path}{$mode}{$1 . $style} = $function unless exists($irMap{$path}{$mode}{$1 . $style}) ; + } } } + close(MAP); + } else { + $::d_ir && msg("failed to open $path\n"); } - close(MAP); - - } else { - $::d_ir && msg("failed to open $mapfile\n"); - } } sub loadIRFile { @@ -246,6 +256,7 @@ sub lookupFunction { $mode = Slim::Buttons::Common::mode($client) unless defined($mode); my $map = Slim::Utils::Prefs::clientGet($client,'irmap'); + $map = -r $map ? $map : mapPath($map); assert($client); assert($map); assert($mode);