Support for unlimited test controls

This commit is contained in:
Jeff Parsons 2016-02-02 10:31:11 -08:00
commit 38c1632511
2 changed files with 17 additions and 10 deletions

View file

@ -7,5 +7,6 @@
<control type="button" binding="up">&#x2191;</control>
<control type="button" binding="down">&#x2193;</control>
<control type="button" binding="right">&#x2192;</control>
<control type="button" binding="test" value="Hello World!">TEST</control>
<control type="button" binding="test1" value="Hello World!">HELLO</control>
<control type="button" binding="test2" value="GoodBye!">GOODBYE</control>
</keyboard>

View file

@ -1048,14 +1048,6 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
};
return true;
case "test":
this.bindings[id] = control;
control.onclick = function onClickTest(event) {
if (kbd.cpu) kbd.cpu.setFocus();
return kbd.injectKeys(sValue);
};
return true;
default:
/*
* Maintain support for older button codes; eg, map button code "ctrl-c" to CLICKCODE "CTRL_C"
@ -1072,7 +1064,8 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
};
}(this, sCode, Keyboard.CLICKCODES[sCode]);
return true;
} else if (Keyboard.SOFTCODES[sBinding] !== undefined) {
}
else if (Keyboard.SOFTCODES[sBinding] !== undefined) {
this.cSoftCodes++;
this.bindings[id] = control;
var fnDown = function(kbd, sKey, simCode) {
@ -1094,6 +1087,19 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
}
return true;
}
else if (sValue) {
/*
* Instead of just having a dedicated "test" control, we now treat any unrecognized control with
* a data value as a test control. The only caveat is that such controls must have binding IDs that
* do not conflict with predefined controls (which, of course, is the only way you can get here).
*/
this.bindings[id] = control;
control.onclick = function onClickTest(event) {
if (kbd.cpu) kbd.cpu.setFocus();
return kbd.injectKeys(sValue);
};
return true;
}
break;
}
}