Support for control bindings with user-defined values (eg, for Keyboard "test" button)
This commit is contained in:
parent
a7f9985785
commit
4ab2c21043
32 changed files with 2374 additions and 2253 deletions
|
|
@ -994,15 +994,16 @@ ChipSet.FPU = { // TODO: Define a variable for this?
|
|||
};
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {ChipSet}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "sw1")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
ChipSet.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
ChipSet.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
switch (sBinding) {
|
||||
case ChipSet.CONTROLS.SW1:
|
||||
|
|
|
|||
|
|
@ -1002,15 +1002,16 @@ Computer.prototype.stop = function(ms, nCycles)
|
|||
};
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {Computer}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
Computer.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
Computer.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
var computer = this;
|
||||
|
||||
|
|
|
|||
|
|
@ -517,15 +517,16 @@ CPU.prototype.setFocus = function()
|
|||
};
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {CPU}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "run")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
CPU.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
CPU.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
var cpu = this;
|
||||
var fBound = false;
|
||||
|
|
|
|||
|
|
@ -2084,15 +2084,16 @@ if (DEBUGGER) {
|
|||
}
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {Debugger}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "debugInput")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
Debugger.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
Debugger.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
var dbg = this;
|
||||
switch (sBinding) {
|
||||
|
|
|
|||
|
|
@ -401,15 +401,16 @@ FDC.aCmdInfo = {
|
|||
};
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {FDC}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "listDisks")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
FDC.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
FDC.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
var fdc = this;
|
||||
|
||||
|
|
|
|||
|
|
@ -553,15 +553,16 @@ if (DEBUG) {
|
|||
}
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {HDC}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "listDisks")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
HDC.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
HDC.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
/*
|
||||
* This is reserved for future use; for now, hard disk images can be specified during initialization only (no "hot-swapping")
|
||||
|
|
|
|||
|
|
@ -970,15 +970,16 @@ Keyboard.LIMIT = {
|
|||
};
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {Keyboard}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "esc")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
/*
|
||||
* There's a special binding that the Video component uses ("kbd") to effectively bind its
|
||||
|
|
@ -1047,6 +1048,14 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control)
|
|||
};
|
||||
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"
|
||||
|
|
@ -1562,17 +1571,19 @@ Keyboard.prototype.addScanCode = function(bScan)
|
|||
};
|
||||
|
||||
/**
|
||||
* injectKeys(sKeyCodes, msDelay)
|
||||
* injectKeys(sKeys, msDelay)
|
||||
*
|
||||
* @this {Keyboard}
|
||||
* @param {string} sKeyCodes
|
||||
* @param {number|undefined} [msDelay] is an optional injection delay (default is msInjectDelay)
|
||||
* @param {string|undefined} sKeys
|
||||
* @param {number} [msDelay] is an optional injection delay (default is msInjectDelay)
|
||||
*/
|
||||
Keyboard.prototype.injectKeys = function(sKeyCodes, msDelay)
|
||||
Keyboard.prototype.injectKeys = function(sKeys, msDelay)
|
||||
{
|
||||
this.sInjectBuffer = sKeyCodes;
|
||||
if (!COMPILED) this.log("injectKeys(" + this.sInjectBuffer.split("\n").join("\\n") + ")");
|
||||
this.injectKeysFromBuffer(msDelay || this.msInjectDelay);
|
||||
if (sKeys && !this.sInjectBuffer) {
|
||||
this.sInjectBuffer = sKeys;
|
||||
if (!COMPILED) this.log("injectKeys(" + this.sInjectBuffer.split("\n").join("\\n") + ")");
|
||||
this.injectKeysFromBuffer(msDelay || this.msInjectDelay);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ Rectangle.prototype.drawWith = function(context, color)
|
|||
};
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* Most panel layouts don't have bindings of their own, so we pass along all binding requests to the
|
||||
* Computer, CPU, Keyboard and Debugger components first. The order shouldn't matter, since any component
|
||||
|
|
@ -245,14 +245,15 @@ Rectangle.prototype.drawWith = function(context, color)
|
|||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
Panel.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
Panel.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
if (this.cmp && this.cmp.setBinding(sHTMLType, sBinding, control)) return true;
|
||||
if (this.cpu && this.cpu.setBinding(sHTMLType, sBinding, control)) return true;
|
||||
if (this.kbd && this.kbd.setBinding(sHTMLType, sBinding, control)) return true;
|
||||
if (DEBUGGER && this.dbg && this.dbg.setBinding(sHTMLType, sBinding, control)) return true;
|
||||
if (this.cmp && this.cmp.setBinding(sHTMLType, sBinding, control, sValue)) return true;
|
||||
if (this.cpu && this.cpu.setBinding(sHTMLType, sBinding, control, sValue)) return true;
|
||||
if (this.kbd && this.kbd.setBinding(sHTMLType, sBinding, control, sValue)) return true;
|
||||
if (DEBUGGER && this.dbg && this.dbg.setBinding(sHTMLType, sBinding, control, sValue)) return true;
|
||||
|
||||
if (!this.canvas && sHTMLType == "canvas") {
|
||||
|
||||
|
|
@ -330,7 +331,7 @@ Panel.prototype.setBinding = function(sHTMLType, sBinding, control)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return this.parent.setBinding.call(this, sHTMLType, sBinding, control);
|
||||
return this.parent.setBinding.call(this, sHTMLType, sBinding, control, sValue);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -342,15 +342,16 @@ SerialPort.prototype.syncMouse = function()
|
|||
*/
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {SerialPort}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "buffer")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
SerialPort.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
SerialPort.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
var serial = this;
|
||||
|
||||
|
|
|
|||
|
|
@ -2909,15 +2909,16 @@ Video.prototype.initBus = function(cmp, bus, cpu, dbg)
|
|||
};
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {Video}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "refresh")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
Video.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
Video.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
var video = this;
|
||||
|
||||
|
|
|
|||
|
|
@ -2947,15 +2947,16 @@ X86CPU.prototype.checkIOPM = function(port, nPorts, fInput)
|
|||
};
|
||||
|
||||
/**
|
||||
* setBinding(sHTMLType, sBinding, control)
|
||||
* setBinding(sHTMLType, sBinding, control, sValue)
|
||||
*
|
||||
* @this {X86CPU}
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "AX")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string} [sValue] optional data value
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
X86CPU.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
X86CPU.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
var fBound = false;
|
||||
switch (sBinding) {
|
||||
|
|
|
|||
|
|
@ -266,6 +266,9 @@
|
|||
<xsl:variable name="binding">
|
||||
<xsl:text>binding:'</xsl:text><xsl:value-of select="@binding"/><xsl:text>'</xsl:text>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="value">
|
||||
<xsl:text>value:'</xsl:text><xsl:value-of select="@value"/><xsl:text>'</xsl:text>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="border">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@border = '1'">border:1px solid black;</xsl:when>
|
||||
|
|
@ -363,7 +366,7 @@
|
|||
<canvas class="{$APPCLASS}-binding {$APPCLASS}-canvas" width="{@width}" height="{@height}" style="-webkit-user-select:none;{$border}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}"><xsl:apply-templates/></canvas>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'button'">
|
||||
<button class="{$APPCLASS}-binding" style="-webkit-user-select:none;{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}"><xsl:apply-templates/></button>
|
||||
<button class="{$APPCLASS}-binding" style="-webkit-user-select:none;{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding},{$value}}}"><xsl:apply-templates/></button>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'list'">
|
||||
<select class="{$APPCLASS}-binding" style="{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}">
|
||||
|
|
@ -531,7 +534,7 @@
|
|||
<xsl:variable name="stepping">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@stepping"><xsl:value-of select="@stepping"/></xsl:when>
|
||||
<xsl:otherwise></xsl:otherwise>
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="fpu">
|
||||
|
|
@ -600,7 +603,7 @@
|
|||
<xsl:variable name="stepping">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@stepping"><xsl:value-of select="@stepping"/></xsl:when>
|
||||
<xsl:otherwise></xsl:otherwise>
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:call-template name="component">
|
||||
|
|
@ -956,7 +959,7 @@
|
|||
<xsl:variable name="touchScreen">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@touchscreen"><xsl:value-of select="@touchscreen"/></xsl:when>
|
||||
<xsl:otherwise></xsl:otherwise>
|
||||
<xsl:otherwise/>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="autoLock">
|
||||
|
|
|
|||
Loading…
Reference in a new issue