From 9e5b9e3767bdc189ced461aec906cec279ce22d6 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 5 Dec 2011 21:14:22 +0100 Subject: [PATCH] Hacks to make the JSVM serial driver work better. --- sortix/serialterminal.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/sortix/serialterminal.cpp b/sortix/serialterminal.cpp index 67dad3be..f02a5a6b 100644 --- a/sortix/serialterminal.cpp +++ b/sortix/serialterminal.cpp @@ -48,6 +48,7 @@ namespace Sortix bool isEsc; bool isEscDepress; + int sigpending; void Init() { @@ -55,6 +56,7 @@ namespace Sortix Reset(); isEsc = isEscDepress = false; + sigpending = -1; } void OnTick() @@ -80,10 +82,35 @@ namespace Sortix if ( isEsc ) { isEsc = false; isEscDepress = false; continue; } if ( c == '\e' ) { c = ESC; } if ( c == ('\e' | (1<<7)) ) { c = ESC | DEPRESSED; } - if ( c == 'c' - 'a'+1 ) { Scheduler::SigIntHack(); continue; } - if ( c == 'o' - 'a'+1 ) { Keyboard::QueueKeystroke(CTRL); Keyboard::QueueKeystroke('O'); Keyboard::QueueKeystroke(CTRL | DEPRESSED); continue; } - if ( c == 'r' - 'a'+1 ) { Keyboard::QueueKeystroke(CTRL); Keyboard::QueueKeystroke('R'); Keyboard::QueueKeystroke(CTRL | DEPRESSED); continue; } - if ( c == 'x' - 'a'+1 ) { Keyboard::QueueKeystroke(CTRL); Keyboard::QueueKeystroke('X'); Keyboard::QueueKeystroke(CTRL | DEPRESSED); continue; } + if ( c == 145 ) // Control Depressed + { + if ( sigpending < 0 ) { continue; } + if ( sigpending == 'C' - 'A' + 1 ) + { + Scheduler::SigIntHack(); + continue; + } + + Keyboard::QueueKeystroke(CTRL); + Keyboard::QueueKeystroke('A' + sigpending - 1); + Keyboard::QueueKeystroke(CTRL | DEPRESSED); + sigpending = -1; + continue; + } + if ( c < 32 ) { sigpending = c; } else { sigpending = -1; } + switch ( c ) + { + default: + // Ignore most unprintable characters. + if ( c < 32 ) { continue; } + case '\b': + case '\t': + case '\r': + case '\n': + case '\e': + case '\f': + break; + } if ( c == 127 ) { c = '\b'; } if ( c & (1<<7) ) {