--- slim/Slim/Hardware/IR.pm 2004-08-27 23:53:00.000000000 -0700 +++ slimnew/Slim/Hardware/IR.pm 2004-09-01 13:23:01.000000000 -0700 @@ -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 = 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 { @@ -245,7 +255,7 @@ sub lookupFunction { my $mode = shift; $mode = Slim::Buttons::Common::mode($client) unless defined($mode); - my $map = Slim::Utils::Prefs::clientGet($client,'irmap'); + my $map = mapPath(Slim::Utils::Prefs::clientGet($client,'irmap')); assert($client); assert($map); assert($mode);