Enclosed is a fix that makes the "Auto assign" feature slightly more creative (more things match). Patch against current SVN, i.e. revision 1675.
Code: Select all
Index: com/hifiremote/jp1/DeviceUpgrade.java
===================================================================
--- com/hifiremote/jp1/DeviceUpgrade.java (revision 1675)
+++ com/hifiremote/jp1/DeviceUpgrade.java (working copy)
@@ -3894,8 +3894,7 @@
Button b = buttons[ i ];
if ( assignments.getAssignment( b ) == null )
{
- if ( b.getName().equalsIgnoreCase( func.getName() )
- || b.getStandardName().equalsIgnoreCase( func.getName() ) )
+ if ( func.matchingName(b) )
{
assignments.assign( b, func );
break;
Index: com/hifiremote/jp1/Function.java
===================================================================
--- com/hifiremote/jp1/Function.java (revision 1675)
+++ com/hifiremote/jp1/Function.java (working copy)
@@ -386,4 +386,41 @@
/** Default value used in upgrade when index==null */
public static final int defaultGID = 0;
+ boolean matchingName(Button b) {
+ return matchingName(b.getName()) || matchingName(b.getStandardName());
+ }
+
+ private boolean matchingName(String candidate) {
+ String nameLower = name.toLowerCase();
+ String candidateLower = candidate.toLowerCase();
+ return name.equals(candidateLower) || canonicalize(nameLower).equals(canonicalize(candidateLower));
+ }
+
+ private static String[][] substitutes = {
+ {"key_", ""}, // Lirc
+ {"cursor", ""},
+ {"arrow", ""},
+ {"toggle", ""},
+ {"return", "exit"},
+ {"-", "down"},
+ {"\\+", "up"},
+ {">", "play"},
+ {"<", "reverse"},
+ {"\\|\\|", "pause"},
+ {"fwd", "forward"},
+ {"volume", "vol"},
+ {"channel", "ch"},
+ {"\\s+", ""}
+ };
+
+ private String canonicalize(String str) {
+ String work = str;
+ for (String[] substitute : substitutes) {
+ String from = substitute[0];
+ String to = substitute[1];
+ work = work.replaceAll(from, to);
+ }
+
+ return work;
+ }
}