Added round LEDs to the UI (initially just for the VT100)
This commit is contained in:
parent
843d24c627
commit
b25a9268a1
21 changed files with 865 additions and 738 deletions
|
|
@ -245,6 +245,16 @@ Keyboard.ALTCODES[Keyboard.ASCII.A] = Keyboard.KEYCODE.LEFT;
|
|||
Keyboard.ALTCODES[Keyboard.ASCII.D] = Keyboard.KEYCODE.RIGHT;
|
||||
Keyboard.ALTCODES[Keyboard.ASCII.L] = Keyboard.KEYCODE.SPACE;
|
||||
|
||||
Keyboard.LEDSTATES = {
|
||||
'l1': 0x01,
|
||||
'l2': 0x02,
|
||||
'l3': 0x04,
|
||||
'l4': 0x08,
|
||||
'locked': 0x10,
|
||||
'local': 0x20,
|
||||
'online': 0x40
|
||||
};
|
||||
|
||||
/**
|
||||
* getSoftCode(keyCode)
|
||||
*
|
||||
|
|
@ -310,6 +320,12 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
|||
var id = sHTMLType + '-' + sBinding;
|
||||
|
||||
if (this.bindings[id] === undefined) {
|
||||
|
||||
if (sHTMLType == "led" && Keyboard.LEDSTATES[sBinding]) {
|
||||
this.bindings[id] = control;
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (sBinding) {
|
||||
case "kbd":
|
||||
/*
|
||||
|
|
@ -356,6 +372,39 @@ Keyboard.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
|||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* setLED(control, f)
|
||||
*
|
||||
* @this {Keyboard}
|
||||
* @param {Object} control is an HTML control DOM object
|
||||
* @param {boolean} f is true if the LED represented by control should be "on", false if "off"
|
||||
*/
|
||||
Keyboard.prototype.setLED = function(control, f)
|
||||
{
|
||||
/*
|
||||
* TODO: Add support for user-definable LED colors
|
||||
*/
|
||||
control.style.backgroundColor = (f? "#ff0000" : "#000000");
|
||||
};
|
||||
|
||||
/**
|
||||
* updateLEDs(bitState)
|
||||
*
|
||||
* @this {Keyboard}
|
||||
* @param {number} [bitState] is the bit in bitsStateSim that may have changed, if known; undefined if not
|
||||
*/
|
||||
Keyboard.prototype.updateLEDs = function(bitState)
|
||||
{
|
||||
var control;
|
||||
for (var sBinding in Keyboard.LEDSTATES) {
|
||||
var id = "led-" + sBinding;
|
||||
var bitLED = Keyboard.LEDSTATES[sBinding];
|
||||
if ((!bitState || bitState == bitLED) && (control = this.bindings[id])) {
|
||||
this.setLED(control, !!bitLED); // !!(this.bKeyboardState & bitLED)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* initBus(cmp, bus, cpu, dbg)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -242,6 +242,8 @@ function Video(parmsVideo, canvas, context, textarea, container)
|
|||
});
|
||||
}
|
||||
|
||||
this.ledBindings = {};
|
||||
|
||||
if (DEBUG) this.nCyclesPrev = 0;
|
||||
}
|
||||
|
||||
|
|
@ -404,12 +406,17 @@ Video.prototype.initBus = function(cmp, bus, cpu, dbg)
|
|||
this.initBuffers();
|
||||
|
||||
/*
|
||||
* If we have an associated keyboard, then ensure that the keyboard will be notified whenever the canvas
|
||||
* gets focus and receives input.
|
||||
* If we have an associated keyboard, then ensure that the keyboard will be notified
|
||||
* whenever the canvas gets focus and receives input.
|
||||
*/
|
||||
this.kbd = cmp.getMachineComponent("Keyboard");
|
||||
if (this.kbd && this.canvasScreen) {
|
||||
this.kbd.setBinding(this.textareaScreen? "textarea" : "canvas", "kbd", this.inputScreen);
|
||||
if (this.kbd) {
|
||||
for (var s in this.ledBindings) {
|
||||
this.kbd.setBinding("led", s, this.ledBindings[s]);
|
||||
}
|
||||
if (this.canvasScreen) {
|
||||
this.kbd.setBinding(this.textareaScreen? "textarea" : "canvas", "kbd", this.inputScreen);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.sFontROM) this.setReady();
|
||||
|
|
@ -666,6 +673,14 @@ Video.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
|
|||
{
|
||||
var video = this;
|
||||
|
||||
/*
|
||||
* TODO: A more general-purpose binding mechanism would be nice someday....
|
||||
*/
|
||||
if (sHTMLType == "led" || sHTMLType == "rled") {
|
||||
this.ledBindings[sBinding] = control;
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (sBinding) {
|
||||
case "fullScreen":
|
||||
this.bindings[sBinding] = control;
|
||||
|
|
|
|||
Loading…
Reference in a new issue