mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-10 21:21:51 +09:00
fixed a bug caused by lwjgl3 where Ctrl-<alph> won't be recognised
This commit is contained in:
@@ -418,7 +418,7 @@ con.KEY_HOME = 199;
|
||||
con.KEY_UP = 200;
|
||||
con.KEY_PAGE_UP = 201;
|
||||
con.KEY_LEFT = 203;
|
||||
con.KEY_RIGHT = 205
|
||||
con.KEY_RIGHT = 205;
|
||||
con.KEY_END = 207;
|
||||
con.KEY_DOWN = 208
|
||||
con.KEY_PAGE_DOWN = 209;
|
||||
@@ -427,6 +427,51 @@ con.KEY_DELETE = 211;
|
||||
con.KEY_BACKSPACE = 8;
|
||||
con.KEY_TAB = 9;
|
||||
con.KEY_RETURN = 13;
|
||||
let _79kfQgystrobocounter = 4294967296*0; // 0L
|
||||
let _pur82anstrobotime = 4294967296*0;
|
||||
let _acpgrUzstrobodelays = [0,250000000,0,25000000,0]; // 250ms, 25ms
|
||||
let _sT9mpKGstrobostatus = 0; // 0: first key, 1: waiting for initial delay, 2: repeating key, 3: waiting for repeat delay
|
||||
let _9gyFcs7oldkeys = [];
|
||||
let _qtkf932repeatcnt932repeatcnt = 0;
|
||||
let _x93paQZshiftin = false;
|
||||
// basically a multi-key version of con.getch() with GDX keycodes
|
||||
con.scankeys = function(callback) {
|
||||
// TODO: char as a first argument of callback, which needs KeyboardLayout(QWERTY, Colemak, Dvorak, etc)
|
||||
function arrayEq(a,b) {
|
||||
for (var i = 0; i < a.length; ++i) {
|
||||
if (a[i] !== b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
sys.poke(-40, 255);
|
||||
let keys = [sys.peek(-41),sys.peek(-42),sys.peek(-43),sys.peek(-44),sys.peek(-45),sys.peek(-46),sys.peek(-47),sys.peek(-48)];
|
||||
if (_sT9mpKGstrobostatus % 2 == 0 && keys[0] != 0) {
|
||||
_sT9mpKGstrobostatus += 1;
|
||||
_pur82anstrobotime = sys.nanoTime();
|
||||
_qtkf932repeatcnt += 1;
|
||||
_x93paQZshiftin = keys.includes(59) || keys.includes(60);
|
||||
|
||||
callback('x', keys, _qtkf932repeatcnt);
|
||||
}
|
||||
else if (!arrayEq(keys, _9gyFcs7oldkeys) || keys[0] == 0) {
|
||||
_sT9mpKGstrobostatus = 0;
|
||||
_qtkf932repeatcnt = 0;
|
||||
_x93paQZshiftin = keys.includes(59) || keys.includes(60);
|
||||
}
|
||||
else if (_sT9mpKGstrobostatus % 2 == 1 && sys.nanoTime() - _pur82anstrobotime < _acpgrUzstrobodelays[_sT9mpKGstrobostatus]) {
|
||||
sys.spin();
|
||||
}
|
||||
else {
|
||||
_sT9mpKGstrobostatus += 1;
|
||||
if (_sT9mpKGstrobostatus >= 4) {
|
||||
_sT9mpKGstrobostatus = 2;
|
||||
}
|
||||
}
|
||||
|
||||
_9gyFcs7oldkeys = keys;
|
||||
// sys.spin();
|
||||
};
|
||||
con.getch = function() {
|
||||
return sys.readKey();
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
con.reset_graphics();con.curs_set(0);con.clear();
|
||||
graphics.resetPalette();graphics.setBackground(0,0,13);
|
||||
graphics.resetPalette();//graphics.setBackground(0,0,13);
|
||||
|
||||
let logo = gzip.decomp(base64.atob("H4sICJoBTGECA3Rzdm1sb2dvLnJhdwDtneu2nCoQhPf7v6xLEMUL5lxyVk6yhxm7mmZGpfqnK7uC+gkN1TA/fhTFF+Ni8eOjwedPXsgLeSEvDPLCIC8M8sIgL+SFvJAX8kJeGOSFQV4Y5IVBXsgLeSEv5IW8MMgLow1e1i4XfH/kJR8deSEvcl48eSEvAC+RvJAXgJedvJAXOS9DR17Ii5yXSF7IC8DLTl7Ii5yX0JEX8iLnZSUv5EXOy7Nsl7yQF6h7IS/kBcheyAt5eYx+Jy/kRc7L0pEX8iLmZezIC3kR8zJ05IW8iHnxO3khL2JeDnAhL+Tlj8HoABfyQl6kqS55IS9/rrssHXkhL1Jewt6RF/Ii5GVYO4vYctouxGVLe2cXXvH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QRrQylr0d77s/PizsmLw3Os/PHMS5X8bStUXS7Ly0d+tRNca5edoft6j/2z0P1q2lio+rzXOz0v8xl5mfGs9GCPvWnGe1gld6gaL8vLcEZeBjwpx6yjsoQ/Fqumy/JyxgEp4UkWaB2VJXCuXDVclpcTzqgjWoQk2WP/LPCfHlkNVNfL8nLCGZLDZ/2odVSyohAMVHd/VV7Ol/E+9gqHpdcpuxAvOoUdPvNIdO5Pr9x7fwFe3Om7F6ElA1lHehNpMlF9klpdgJezZTBRw/SIWkf678XZqI6X5aU/1RQp391LtqauAvDKPdfFSHW7LC/nMpGC1pIBrSOtieStVIfL8nKmlHdWWzJR2RFgJtJmprpcl5fzlE1takvGJ8n3W2wijWaq2f7vIry4k6QwyaktmUXdESAm0t7bqU7X5aXGKXQaI8/ZjZnyjgDRng1V04V5qXAKnQIXb1fatCOV6nJtb6kaLszLCYak5AyNHqQjkGuvpqrrlXmxP4UOTXWd5azfQ/cu1Q6mqpnh90K8fHhafdghQMuKG3bnQu3U26rGa/NifAodNBYJvlzE6Angncu0J2PVxyTrWrwYn0IHeEaSDxcwenZ0X6ZM21mrjhfnxfYUOvFQJHwPcqMnwvct0V7MVbfL82J5Cp1sJIrir1Zca7w7+K4l2oO9qr8+L19mp9AJYJmhdyCdwa2Kez7W3iqozrfg5cvmFLpXPUDalhjQbkBq9ATFDR9rjxVUv/eEl+WF8ZEgLwzywiAvDPLC509eyAt5IS8M8sIgLwzywiAv5IW8kBfyQl4Y5IVBXhjkhUFeyAt5IS/khbwwyAuDvDDIC+OWvPwFgd7gz8BmAQA="));
|
||||
|
||||
|
||||
11
assets/disk0/home/strobotest.js
Normal file
11
assets/disk0/home/strobotest.js
Normal file
@@ -0,0 +1,11 @@
|
||||
function hitCtrlQ(keys) {
|
||||
return (keys[0] == 45 && (keys[1] == 129 || keys[1] == 130));
|
||||
}
|
||||
|
||||
println("Hit Ctrl+Shift+T+R to exit")
|
||||
|
||||
while (true) {
|
||||
con.scankeys((char, keys, counter) => {
|
||||
println(`${keys}\t'${char}' (${counter})`)
|
||||
})
|
||||
}
|
||||
@@ -240,10 +240,6 @@ function hitAny() {
|
||||
sys.poke(-40, 255);sys.spin();
|
||||
return sys.peek(-41) != 0;
|
||||
}
|
||||
function getch() {
|
||||
sys.poke(-40, 255);
|
||||
return sys.peek(-41);
|
||||
}
|
||||
|
||||
function insertChar(code, row, col) {
|
||||
if (textbuffer[row] === undefined)
|
||||
@@ -431,83 +427,77 @@ else {
|
||||
}
|
||||
|
||||
while (!exit) {
|
||||
let key = getch();
|
||||
let key = con.getch();
|
||||
// TODO: either implement the new strobing-getch() by yourself or modify the sys.getch() so that CTRL-alph would return correct numbers
|
||||
if (key != 0) {
|
||||
|
||||
serial.println(`getch = ${key}`)
|
||||
// serial.println(`getch = ${key}`)
|
||||
|
||||
if (bulletinShown) dismissBulletin();
|
||||
if (bulletinShown) dismissBulletin();
|
||||
|
||||
sys.poke(-40, 255)
|
||||
serial.println(`strobe: ${sys.peek(-41)}\t${sys.peek(-42)}`)
|
||||
if (key == 17) // Ctrl-Q
|
||||
exit = true;
|
||||
else if (key == 19 && !bulletinShown) {
|
||||
writeout();
|
||||
displayBulletin(`Wrote ${textbuffer.length} lines`);
|
||||
}
|
||||
else if (key == con.KEY_BACKSPACE) { // Bksp
|
||||
backspaceOnce();
|
||||
drawLnCol(); gotoText();
|
||||
}
|
||||
else if (key == con.KEY_RETURN) { // Return
|
||||
appendLine(); drawLnCol(); gotoText();
|
||||
}
|
||||
else if (key == con.KEY_LEFT) {
|
||||
cursoringCol = cursorCol - 1;
|
||||
if (cursoringCol < 0) cursoringCol = 0;
|
||||
cursorMoveRelative(-1,0);
|
||||
}
|
||||
else if (key == con.KEY_RIGHT) {
|
||||
cursoringCol = cursorCol + 1;
|
||||
if (cursoringCol > textbuffer[cursorRow].length) cursoringCol = textbuffer[cursorRow].length;
|
||||
cursorMoveRelative(1,0);
|
||||
}
|
||||
else if (key == con.KEY_UP) {
|
||||
cursorMoveRelative(0,-1);
|
||||
}
|
||||
else if (key == con.KEY_DOWN) {
|
||||
cursorMoveRelative(0,1);
|
||||
}
|
||||
else if (key == con.KEY_PAGE_UP) {
|
||||
cursorMoveRelative(0, -paintHeight + scrollPeek);
|
||||
}
|
||||
else if (key == con.KEY_PAGE_DOWN) {
|
||||
cursorMoveRelative(0, paintHeight - scrollPeek);
|
||||
}
|
||||
else if (key == con.KEY_HOME) {
|
||||
cursoringCol = 0;
|
||||
cursorMoveRelative(-BIG_STRIDE, 0);
|
||||
}
|
||||
else if (key == con.KEY_END) {
|
||||
cursoringCol = textbuffer[cursorRow].length;
|
||||
cursorMoveRelative(BIG_STRIDE, 0);
|
||||
}
|
||||
else if (key == con.KEY_TAB) { // insert spaces appropriately
|
||||
let tabsize = TAB_SIZE - (cursorCol % TAB_SIZE);
|
||||
|
||||
|
||||
if (hitCtrlQ()) // Ctrl-Q
|
||||
exit = true;
|
||||
else if (hitCtrlS() && !bulletinShown) {
|
||||
writeout();
|
||||
displayBulletin(`Wrote ${textbuffer.length} lines`);
|
||||
}
|
||||
else if (key == con.KEY_BACKSPACE) { // Bksp
|
||||
backspaceOnce();
|
||||
drawLnCol(); gotoText();
|
||||
}
|
||||
else if (key == con.KEY_RETURN) { // Return
|
||||
appendLine(); drawLnCol(); gotoText();
|
||||
}
|
||||
else if (key == con.KEY_LEFT) {
|
||||
cursoringCol = cursorCol - 1;
|
||||
if (cursoringCol < 0) cursoringCol = 0;
|
||||
cursorMoveRelative(-1,0);
|
||||
}
|
||||
else if (key == con.KEY_RIGHT) {
|
||||
cursoringCol = cursorCol + 1;
|
||||
if (cursoringCol > textbuffer[cursorRow].length) cursoringCol = textbuffer[cursorRow].length;
|
||||
cursorMoveRelative(1,0);
|
||||
}
|
||||
else if (key == con.KEY_UP) {
|
||||
cursorMoveRelative(0,-1);
|
||||
}
|
||||
else if (key == con.KEY_DOWN) {
|
||||
cursorMoveRelative(0,1);
|
||||
}
|
||||
else if (key == con.KEY_PAGE_UP) {
|
||||
cursorMoveRelative(0, -paintHeight + scrollPeek);
|
||||
}
|
||||
else if (key == con.KEY_PAGE_DOWN) {
|
||||
cursorMoveRelative(0, paintHeight - scrollPeek);
|
||||
}
|
||||
else if (key == con.KEY_HOME) {
|
||||
cursoringCol = 0;
|
||||
cursorMoveRelative(-BIG_STRIDE, 0);
|
||||
}
|
||||
else if (key == con.KEY_END) {
|
||||
cursoringCol = textbuffer[cursorRow].length;
|
||||
cursorMoveRelative(BIG_STRIDE, 0);
|
||||
}
|
||||
else if (key == con.KEY_TAB) { // insert spaces appropriately
|
||||
let tabsize = TAB_SIZE - (cursorCol % TAB_SIZE);
|
||||
|
||||
for (let k = 0; k < tabsize; k++) {
|
||||
insertChar(32, cursorRow, cursorCol);
|
||||
// identical to con.KEY_RIGHT
|
||||
cursoringCol = cursorCol + 1;
|
||||
if (cursoringCol > textbuffer[cursorRow].length) cursoringCol = textbuffer[cursorRow].length;
|
||||
cursorMoveRelative(1,0);
|
||||
// end of con.KEY_RIGHT
|
||||
}
|
||||
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
|
||||
}
|
||||
else if (key >= 32 && key < 128) { // printables (excludes \n)
|
||||
insertChar(key, cursorRow, cursorCol);
|
||||
for (let k = 0; k < tabsize; k++) {
|
||||
insertChar(32, cursorRow, cursorCol);
|
||||
// identical to con.KEY_RIGHT
|
||||
cursoringCol = cursorCol + 1;
|
||||
if (cursoringCol > textbuffer[cursorRow].length) cursoringCol = textbuffer[cursorRow].length;
|
||||
cursorMoveRelative(1,0);
|
||||
// end of con.KEY_RIGHT
|
||||
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
|
||||
}
|
||||
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
|
||||
}
|
||||
else if (key >= 32 && key < 128) { // printables (excludes \n)
|
||||
insertChar(key, cursorRow, cursorCol);
|
||||
// identical to con.KEY_RIGHT
|
||||
cursoringCol = cursorCol + 1;
|
||||
if (cursoringCol > textbuffer[cursorRow].length) cursoringCol = textbuffer[cursorRow].length;
|
||||
cursorMoveRelative(1,0);
|
||||
// end of con.KEY_RIGHT
|
||||
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -318,9 +318,14 @@ class IOSpace(val vm: VM) : PeriBase, InputProcessor {
|
||||
)
|
||||
override fun keyDown(p0: Int): Boolean {
|
||||
if (keyboardInputRequested) {
|
||||
specialKeys[p0]?.let {
|
||||
//println("[IO] key special = ${it.toUInt()}")
|
||||
keyboardBuffer.appendHead(it)
|
||||
if (p0 in Input.Keys.A..Input.Keys.Z && (Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Input.Keys.CONTROL_RIGHT))) {
|
||||
keyboardBuffer.appendHead((p0 - 28).toByte())
|
||||
}
|
||||
else {
|
||||
specialKeys[p0]?.let {
|
||||
//println("[IO] key special = ${it.toUInt()}")
|
||||
keyboardBuffer.appendHead(it)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user