Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Added key event diagnostic messages to calculator devices
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Aug 11, 2019
1 parent ff38a34 commit 270812b
Show file tree
Hide file tree
Showing 19 changed files with 390 additions and 311 deletions.
2 changes: 1 addition & 1 deletion _posts/2018-11-21-building-ms-dos-2x-source-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Attempting to build the sources raises several questions, including:

If you look at the pictures that the [Computer History Museum](http://www.computerhistory.org/) originally
[posted](http://www.computerhistory.org/atchm/microsoft-ms-dos-early-source-code/) when these files were first shared,
you'd get the impression that two of those questions have already been answered: DOS 2.00, final distribution.
you'd get the impression that one of those questions had already been answered: DOS 2.00, final distribution.

![MS-DOS 2.00]({{ site.demo-disks.baseurl }}/pcx86/dos/microsoft/2.00/MSDOS200-DISKS.jpg)

Expand Down
2 changes: 1 addition & 1 deletion devices/ti42/machine/diags/ti42.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
["sto", "7", "8", "9", "*"],
["rcl", "4", "5", "6", "-"],
["sum", "1", "2", "3", "+"],
["\\b", "0", ".", "+/-", "=|\\r"]
["\b", "0", ".", "+/-", "=|\r"]
],
"bindings": {
"surface": "imageTI42",
Expand Down
2 changes: 1 addition & 1 deletion devices/ti55/machine/diags/ti55.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
["sto", "7", "8", "9", "*"],
["rcl", "4", "5", "6", "-"],
["sum", "1", "2", "3", "+"],
["\\b", "0", ".", "+/-", "=|\\r"]
["\b", "0", ".", "+/-", "=|\r"]
],
"bindings": {
"surface": "imageTI55",
Expand Down
4 changes: 2 additions & 2 deletions devices/ti57/machine/rev0/ti57.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"buttonDelay": 50,
"location": [45, 316, 372, 478, 0.34, 0.5, 459, 832, 322, 168, 75, 38],
"map": [
["2nd", "inv", "lnx", "\\b", "clr"],
["2nd", "inv", "lnx", "\b", "clr"],
["lrn", "xchg", "sq", "sqrt", "rcp"],
["sst", "sto", "rcl", "sum", "ypow"],
["bst", "ee", "(", ")", "/"],
["gto", "7", "8", "9", "*"],
["sbr", "4", "5", "6", "-"],
["rst", "1", "2", "3", "+"],
["r/s", "0", ".", "+/-", "=|\\r"]
["r/s", "0", ".", "+/-", "=|\r"]
],
"bindings": {
"surface": "imageTI57",
Expand Down
4 changes: 2 additions & 2 deletions devices/ti57/machine/rev1/ti57.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
"buttonDelay": 50,
"location": [45, 316, 372, 478, 0.34, 0.5, 459, 832, 322, 168, 75, 38],
"map": [
["2nd", "inv", "lnx", "\\b", "clr"],
["2nd", "inv", "lnx", "\b", "clr"],
["lrn", "xchg", "sq", "sqrt", "rcp"],
["sst", "sto", "rcl", "sum", "ypow"],
["bst", "ee", "(", ")", "/"],
["gto", "7", "8", "9", "*"],
["sbr", "4", "5", "6", "-"],
["rst", "1", "2", "3", "+"],
["r/s", "0", ".", "+/-", "=|\\r"]
["r/s", "0", ".", "+/-", "=|\r"]
],
"bindings": {
"surface": "imageTI57",
Expand Down
4 changes: 2 additions & 2 deletions modules/devices/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var VERSION = "2.00";
/*
* List of standard message groups.
*
* NOTE: Since we want to support more than 32 message groups, be sure to use "+", not "|", when concatenating.
* NOTE: To support more than 32 message groups, be sure to use "+", not "|", when concatenating.
*/
var MESSAGES = {
NONE: 0x000000000000,
Expand Down Expand Up @@ -429,7 +429,7 @@ class Device extends StdIO {
switch(aTokens[0]) {
case 'm':
token = aTokens[aTokens.length-1].toLowerCase();
on = (token == "true"? true : (token == "false"? false : undefined));
on = (token == "true" || token == "on"? true : (token == "false" || token == "off"? false : undefined));
if (on != undefined) {
aTokens.pop();
} else {
Expand Down
29 changes: 22 additions & 7 deletions modules/devices/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,10 @@ class Input extends Device {
let activeElement = document.activeElement;
if (activeElement == input.bindings[Input.BINDING.POWER]) {
let keyCode = event.which || event.keyCode;
let ch = Input.KEYCODE[keyCode];
if (ch && input.onKeyPress(ch)) event.preventDefault();
let ch = Input.KEYCODE[keyCode], used = false;
if (ch) used = input.onKeyActive(ch);
input.printf(MESSAGES.KEY + MESSAGES.EVENT, "onKeyDown(keyCode=%#04x): %5.2f (%s)\n", keyCode, (Date.now() / 1000) % 60, ch? (used? "used" : "unused") : "ignored");
if (used) event.preventDefault();
}
}
);
Expand All @@ -376,8 +378,21 @@ class Input extends Device {
function onKeyPress(event) {
event = event || window.event;
let charCode = event.which || event.charCode;
let ch = String.fromCharCode(charCode);
if (ch && input.onKeyPress(ch)) event.preventDefault();
let ch = String.fromCharCode(charCode), used = false;
if (ch) used = input.onKeyActive(ch);
input.printf(MESSAGES.KEY + MESSAGES.EVENT, "onKeyPress(charCode=%#04x): %5.2f (%s)\n", charCode, (Date.now() / 1000) % 60, ch? (used? "used" : "unused") : "ignored");
if (used) event.preventDefault();
}
);
element.addEventListener(
'keyup',
function onKeyUp(event) {
event = event || window.event;
let activeElement = document.activeElement;
if (activeElement == input.bindings[Input.BINDING.POWER]) {
let keyCode = event.which || event.keyCode;
input.printf(MESSAGES.KEY + MESSAGES.EVENT, "onKeyUp(keyCode=%#04x): %5.2f (ignored)\n", keyCode, (Date.now() / 1000) % 60);
}
}
);
}
Expand Down Expand Up @@ -492,13 +507,13 @@ class Input extends Device {
}

/**
* onKeyPress(ch)
* onKeyActive(ch)
*
* @this {Input}
* @param {string} ch
* @returns {boolean} (true if processed, false if not)
*/
onKeyPress(ch)
onKeyActive(ch)
{
for (let row = 0; row < this.map.length; row++) {
let rowMap = this.map[row];
Expand Down Expand Up @@ -537,7 +552,7 @@ class Input extends Device {
} else {
this.keyState = 0;
if (this.keysPressed.length) {
this.onKeyPress(this.keysPressed.shift());
this.onKeyActive(this.keysPressed.shift());
}
}
}
Expand Down
33 changes: 24 additions & 9 deletions versions/devices/2.00/leds-uncompiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ var VERSION = "2.00";
/*
* List of standard message groups.
*
* NOTE: Since we want to support more than 32 message groups, be sure to use "+", not "|", when concatenating.
* NOTE: To support more than 32 message groups, be sure to use "+", not "|", when concatenating.
*/
var MESSAGES = {
NONE: 0x000000000000,
Expand Down Expand Up @@ -989,7 +989,7 @@ class Device extends StdIO {
switch(aTokens[0]) {
case 'm':
token = aTokens[aTokens.length-1].toLowerCase();
on = (token == "true"? true : (token == "false"? false : undefined));
on = (token == "true" || token == "on"? true : (token == "false" || token == "off"? false : undefined));
if (on != undefined) {
aTokens.pop();
} else {
Expand Down Expand Up @@ -1924,8 +1924,10 @@ class Input extends Device {
let activeElement = document.activeElement;
if (activeElement == input.bindings[Input.BINDING.POWER]) {
let keyCode = event.which || event.keyCode;
let ch = Input.KEYCODE[keyCode];
if (ch && input.onKeyPress(ch)) event.preventDefault();
let ch = Input.KEYCODE[keyCode], used = false;
if (ch) used = input.onKeyActive(ch);
input.printf(MESSAGES.KEY + MESSAGES.EVENT, "onKeyDown(keyCode=%#04x): %5.2f (%s)\n", keyCode, (Date.now() / 1000) % 60, ch? (used? "used" : "unused") : "ignored");
if (used) event.preventDefault();
}
}
);
Expand All @@ -1934,8 +1936,21 @@ class Input extends Device {
function onKeyPress(event) {
event = event || window.event;
let charCode = event.which || event.charCode;
let ch = String.fromCharCode(charCode);
if (ch && input.onKeyPress(ch)) event.preventDefault();
let ch = String.fromCharCode(charCode), used = false;
if (ch) used = input.onKeyActive(ch);
input.printf(MESSAGES.KEY + MESSAGES.EVENT, "onKeyPress(charCode=%#04x): %5.2f (%s)\n", charCode, (Date.now() / 1000) % 60, ch? (used? "used" : "unused") : "ignored");
if (used) event.preventDefault();
}
);
element.addEventListener(
'keyup',
function onKeyUp(event) {
event = event || window.event;
let activeElement = document.activeElement;
if (activeElement == input.bindings[Input.BINDING.POWER]) {
let keyCode = event.which || event.keyCode;
input.printf(MESSAGES.KEY + MESSAGES.EVENT, "onKeyUp(keyCode=%#04x): %5.2f (ignored)\n", keyCode, (Date.now() / 1000) % 60);
}
}
);
}
Expand Down Expand Up @@ -2050,13 +2065,13 @@ class Input extends Device {
}

/**
* onKeyPress(ch)
* onKeyActive(ch)
*
* @this {Input}
* @param {string} ch
* @returns {boolean} (true if processed, false if not)
*/
onKeyPress(ch)
onKeyActive(ch)
{
for (let row = 0; row < this.map.length; row++) {
let rowMap = this.map[row];
Expand Down Expand Up @@ -2095,7 +2110,7 @@ class Input extends Device {
} else {
this.keyState = 0;
if (this.keysPressed.length) {
this.onKeyPress(this.keysPressed.shift());
this.onKeyActive(this.keysPressed.shift());
}
}
}
Expand Down
Loading

0 comments on commit 270812b

Please sign in to comment.