From 057052244c082ce85944c8a48dd333a94519b020 Mon Sep 17 00:00:00 2001 From: Julian Barathieu Date: Thu, 16 Jan 2020 17:44:03 +0100 Subject: [PATCH] up --- kaleid/kernel/io/keyb.c | 41 ++++++++++++++++++++++++----------------- kaleid/kernel/io/scan.c | 12 +++++------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/kaleid/kernel/io/keyb.c b/kaleid/kernel/io/keyb.c index 2a9a770..fdacbaa 100644 --- a/kaleid/kernel/io/keyb.c +++ b/kaleid/kernel/io/keyb.c @@ -28,37 +28,44 @@ #include "scan.c" +#define KEY(code) (table[2*(code)]) +#define FLAGS(code) (table[2*(code)+1]) + static bool capsLockActive = 0; -static bool leftAltPressed = 0; -static bool leftShiftPressed = 0; -static bool leftControlPressed = 0; +static bool altPressed = 0; +static bool shiftPressed = 0; +static bool controlPressed = 0; void KeybPrint(uchar _code) { uint code = (uint)_code; const uint *table = - (leftAltPressed ? LeftAltScanCodes - : (leftShiftPressed ? LeftShiftScanCodes - : (leftControlPressed ? LeftControlScanCodes + (altPressed ? LeftAltScanCodes + : (controlPressed ? LeftControlScanCodes + : (shiftPressed ? LeftShiftScanCodes : RegularScanCodes))); - if (capsLockActive && !leftShiftPressed && - !!(table[2 * code + 1] & CAPSLOCK) && !leftAltPressed) - table = LeftShiftScanCodes; + if (capsLockActive && (FLAGS(code) & CAPSLOCK)) + && !(altPressed || controlPressed)) { + if (shiftPressed) + table = RegularScanCodes; + else + table = LeftShiftScanCodes; + } - uchar ch = table[2 * code]; + uchar ch = KEY(code); if (!ch) { switch (code) { - case 0x38: leftAltPressed = 1; break; - case 0xB8: leftAltPressed = 0; break; + case 0x38: altPressed = 1; break; + case 0xB8: altPressed = 0; break; - case 0x36: case 0x2A: leftShiftPressed = 1; break; - case 0xB6: case 0xAA: leftShiftPressed = 0; break; + case 0x36: case 0x2A: shiftPressed = 1; break; + case 0xB6: case 0xAA: shiftPressed = 0; break; - case 0x1D: leftControlPressed = 1; break; - case 0x9D: leftControlPressed = 0; break; + case 0x1D: controlPressed = 1; break; + case 0x9D: controlPressed = 0; break; case 0x3A: capsLockActive = !capsLockActive; break; } @@ -66,7 +73,7 @@ void KeybPrint(uchar _code) } bputc(BStdIn, ch); - if (code && (table[2 * code + 1] & INVISIBLE) == 0) { + if (code && (FLAGS(code) & INVISIBLE) == 0) { bputc(BStdOut, table[2 * code]); BStdOut->flusher(BStdOut); } diff --git a/kaleid/kernel/io/scan.c b/kaleid/kernel/io/scan.c index 64766c9..a2f1a2b 100644 --- a/kaleid/kernel/io/scan.c +++ b/kaleid/kernel/io/scan.c @@ -94,7 +94,10 @@ const uint RegularScanCodes[2 * 256] = ENTRY (0x33, ';', CAPSLOCK), ENTRY (0x34, ':', CAPSLOCK), ENTRY (0x35, '!', CAPSLOCK), + + ENTRY (0x39, ' ', NONE), }; + const uint LeftShiftScanCodes[2 * 256] = { ENTRY (0x00, 0, INVISIBLE|INVALID), @@ -157,15 +160,10 @@ const uint LeftShiftScanCodes[2 * 256] = ENTRY (0x33, '.', NONE), ENTRY (0x34, '/', NONE), ENTRY (0x35, '!', NONE), + + ENTRY (0x39, ' ', NONE), }; const uint LeftAltScanCodes[2 * 256]; const uint LeftControlScanCodes[2 * 256]; - - - - - - -