This commit is contained in:
parent
5fba767e64
commit
2f1fefe724
|
@ -39,10 +39,14 @@ void IoChangeCodePage(char *);
|
|||
#define KEY_ESC 27
|
||||
#define KEY_BS 8
|
||||
#define KEY_BEL 7
|
||||
#define KEY_DC1 17
|
||||
#define KEY_DC2 18
|
||||
#define KEY_DC3 19
|
||||
#define KEY_DC4 20
|
||||
|
||||
#define KEY_DC1 17 // Arrow Up
|
||||
#define KEY_DC2 18 // Arrow Down
|
||||
#define KEY_DC3 19 // Arrow Left
|
||||
#define KEY_DC4 20 // Arrow Right
|
||||
|
||||
#define KEY_DC5 17 // Page Up
|
||||
#define KEY_DC6 18 // Page Down
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
|
|
|
@ -26,104 +26,56 @@
|
|||
#include <io/keyb.h>
|
||||
#include <ke/idt.h>
|
||||
|
||||
static char EarlyScanCodes[100] = { 0 };
|
||||
static char Invisible[100] = { 0 };
|
||||
#include "scan.c"
|
||||
|
||||
char *ScanCodes = 0;
|
||||
static bool capsLockActive = 0;
|
||||
static bool leftAltPressed = 0;
|
||||
static bool leftShiftPressed = 0;
|
||||
static bool leftControlPressed = 0;
|
||||
|
||||
void KeybPrint(char code)
|
||||
{
|
||||
uchar ch = ScanCodes[(int)code];
|
||||
void KeybPrint(uchar _code)
|
||||
{
|
||||
uint code = (uint)_code;
|
||||
|
||||
if (ch != 0) {
|
||||
bputc(BStdIn, ch);
|
||||
if (code && Invisible[(int)code] == 0) {
|
||||
bputc(BStdOut, ScanCodes[(int)code]);
|
||||
//bprintf(BStdOut, "%x ", code);
|
||||
BStdOut->flusher(BStdOut);
|
||||
const uint *table =
|
||||
(leftAltPressed ? LeftAltScanCodes
|
||||
: (leftShiftPressed ? LeftShiftScanCodes
|
||||
: (leftControlPressed ? LeftControlScanCodes
|
||||
: RegularScanCodes)));
|
||||
|
||||
if (capsLockActive && !leftShiftPressed &&
|
||||
!!(table[2 * code + 1] & CAPSLOCK) && !leftAltPressed)
|
||||
table = LeftShiftScanCodes;
|
||||
|
||||
uchar ch = table[2 * code];
|
||||
|
||||
if (!ch) {
|
||||
switch (code) {
|
||||
case 0x38: leftAltPressed = 1; break;
|
||||
case 0xB8: leftAltPressed = 0; break;
|
||||
|
||||
case 0x36: case 0x2A: leftShiftPressed = 1; break;
|
||||
case 0xB6: case 0xAA: leftShiftPressed = 0; break;
|
||||
|
||||
case 0x1D: leftControlPressed = 1; break;
|
||||
case 0x9D: leftControlPressed = 0; break;
|
||||
|
||||
case 0x3A: capsLockActive = !capsLockActive; break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bputc(BStdIn, ch);
|
||||
if (code && (table[2 * code + 1] & INVISIBLE) == 0) {
|
||||
bputc(BStdOut, table[2 * code]);
|
||||
BStdOut->flusher(BStdOut);
|
||||
}
|
||||
}
|
||||
|
||||
void ScanCodesInit(void)
|
||||
{
|
||||
ScanCodes = &EarlyScanCodes[0];
|
||||
|
||||
ScanCodes[0x01] = KEY_ESC;
|
||||
Invisible[0x01] = 1;
|
||||
ScanCodes[0x02] = '1';
|
||||
ScanCodes[0x03] = '2';
|
||||
ScanCodes[0x04] = '3';
|
||||
ScanCodes[0x05] = '4';
|
||||
ScanCodes[0x06] = '5';
|
||||
ScanCodes[0x07] = '6';
|
||||
ScanCodes[0x08] = '7';
|
||||
ScanCodes[0x09] = '8';
|
||||
ScanCodes[0x0A] = '9';
|
||||
ScanCodes[0x0B] = '0';
|
||||
ScanCodes[0x0C] = ' ';
|
||||
ScanCodes[0x0D] = '+';
|
||||
ScanCodes[0x0E] = 0x8;
|
||||
ScanCodes[0x0F] = '\t';
|
||||
|
||||
ScanCodes[0x10] = 'a';
|
||||
ScanCodes[0x11] = 'z';
|
||||
ScanCodes[0x12] = 'e';
|
||||
ScanCodes[0x13] = 'r';
|
||||
ScanCodes[0x14] = 't';
|
||||
ScanCodes[0x15] = 'y';
|
||||
ScanCodes[0x16] = 'u';
|
||||
ScanCodes[0x17] = 'i';
|
||||
ScanCodes[0x18] = 'o';
|
||||
ScanCodes[0x19] = 'p';
|
||||
ScanCodes[0x1A] = '^';
|
||||
ScanCodes[0x1B] = '$';
|
||||
|
||||
ScanCodes[0x1E] = 'q';
|
||||
ScanCodes[0x1F] = 's';
|
||||
ScanCodes[0x20] = 'd';
|
||||
ScanCodes[0x21] = 'f';
|
||||
ScanCodes[0x22] = 'g';
|
||||
ScanCodes[0x23] = 'h';
|
||||
ScanCodes[0x24] = 'j';
|
||||
ScanCodes[0x25] = 'k';
|
||||
ScanCodes[0x26] = 'l';
|
||||
ScanCodes[0x27] = 'm';
|
||||
ScanCodes[0x28] = 'u';
|
||||
ScanCodes[0x29] = '*';
|
||||
|
||||
ScanCodes[0x2C] = 'w';
|
||||
ScanCodes[0x2D] = 'x';
|
||||
ScanCodes[0x2E] = 'c';
|
||||
ScanCodes[0x2F] = 'v';
|
||||
ScanCodes[0x30] = 'b';
|
||||
ScanCodes[0x31] = 'n';
|
||||
ScanCodes[0x32] = ',';
|
||||
ScanCodes[0x33] = ';';
|
||||
ScanCodes[0x34] = ':';
|
||||
ScanCodes[0x35] = '!';
|
||||
|
||||
ScanCodes[0x1C] = '\n';
|
||||
ScanCodes[0x39] = ' ';
|
||||
|
||||
ScanCodes[0x40] = KEY_BEL;
|
||||
Invisible[0x40] = 1;
|
||||
|
||||
// Numpad
|
||||
ScanCodes[0x48] = KEY_DC1; // DC1, will serve as Arrow Up
|
||||
ScanCodes[0x50] = KEY_DC2; // DC2, will serve as Arrow Down
|
||||
ScanCodes[0x4B] = KEY_DC3; // DC3, will serve as Arrow Left
|
||||
ScanCodes[0x4D] = KEY_DC4; // DC4, will serve as Arrow Right
|
||||
Invisible[0x48] = 1;
|
||||
Invisible[0x50] = 1;
|
||||
Invisible[0x4B] = 1;
|
||||
Invisible[0x4D] = 1;
|
||||
}
|
||||
|
||||
static void KeybHandler(ISRFrame_t *regs)
|
||||
{
|
||||
char status;
|
||||
char code = 0;
|
||||
uchar code = 0;
|
||||
|
||||
// write EOI
|
||||
IoWriteByteOnPort(0x20, 0x20);
|
||||
|
@ -132,10 +84,8 @@ static void KeybHandler(ISRFrame_t *regs)
|
|||
|
||||
if (status & 0x01) {
|
||||
code = IoReadByteFromPort(0x60);
|
||||
|
||||
if(code < 0) code = 0;
|
||||
}
|
||||
KeybPrint((int)code);
|
||||
KeybPrint(code);
|
||||
KeSendEOItoPIC(0x21);
|
||||
}
|
||||
|
||||
|
@ -162,12 +112,7 @@ void IoEnableKeyb(void)
|
|||
KeRestoreIRQs(flags);
|
||||
|
||||
KeEnableNMI();
|
||||
ScanCodesInit();
|
||||
|
||||
IoCreateInputBuffer();
|
||||
}
|
||||
|
||||
void IoChangeCodePage(char *CodePage)
|
||||
{
|
||||
ScanCodes = &CodePage[0];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,171 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Desc: Basic Scancode Tables //
|
||||
// //
|
||||
// //
|
||||
// Copyright © 2018-2019 The OS/K Team //
|
||||
// //
|
||||
// This file is part of OS/K. //
|
||||
// //
|
||||
// OS/K is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// any later version. //
|
||||
// //
|
||||
// OS/K is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#define WANT_AZERTY 1
|
||||
|
||||
#define NONE 0
|
||||
#define INVISIBLE 1
|
||||
#define CAPSLOCK 2
|
||||
#define INVALID 256
|
||||
|
||||
#define ENTRY(index, character, flags) [2 * index] = character, \
|
||||
[2 * index + 1] = flags
|
||||
|
||||
const uint RegularScanCodes[2 * 256] =
|
||||
{
|
||||
ENTRY (0x00, 0, INVISIBLE|INVALID),
|
||||
ENTRY (0x01, KEY_ESC, INVISIBLE),
|
||||
|
||||
ENTRY (0x02, '&', NONE),
|
||||
ENTRY (0x03, 'e', NONE),
|
||||
ENTRY (0x04, '"', NONE),
|
||||
ENTRY (0x05, '\'', NONE),
|
||||
ENTRY (0x06, '(', NONE),
|
||||
ENTRY (0x07, '-', NONE),
|
||||
ENTRY (0x08, 'e', NONE),
|
||||
ENTRY (0x09, '_', NONE),
|
||||
ENTRY (0x0A, 'c', NONE),
|
||||
ENTRY (0x0B, 'a', NONE),
|
||||
ENTRY (0x0C, ')', NONE),
|
||||
ENTRY (0x0D, '=', NONE),
|
||||
ENTRY (0x0E, KEY_BS, NONE), // Backspace
|
||||
ENTRY (0x0F, '\t', NONE),
|
||||
|
||||
ENTRY (0x10, 'a', CAPSLOCK),
|
||||
ENTRY (0x11, 'z', CAPSLOCK),
|
||||
ENTRY (0x12, 'e', CAPSLOCK),
|
||||
ENTRY (0x13, 'r', CAPSLOCK),
|
||||
ENTRY (0x14, 't', CAPSLOCK),
|
||||
ENTRY (0x15, 'y', CAPSLOCK),
|
||||
ENTRY (0x16, 'u', CAPSLOCK),
|
||||
ENTRY (0x17, 'i', CAPSLOCK),
|
||||
ENTRY (0x18, 'o', CAPSLOCK),
|
||||
ENTRY (0x19, 'p', CAPSLOCK),
|
||||
|
||||
ENTRY (0x1A, '^', NONE),
|
||||
ENTRY (0x1B, '$', NONE),
|
||||
ENTRY (0x1C, '\n', NONE),
|
||||
ENTRY (0x1D, 0, INVISIBLE|INVALID), // Left Control
|
||||
|
||||
ENTRY (0x1E, 'q', CAPSLOCK),
|
||||
ENTRY (0x1F, 's', CAPSLOCK),
|
||||
ENTRY (0x20, 'd', CAPSLOCK),
|
||||
ENTRY (0x21, 'f', CAPSLOCK),
|
||||
ENTRY (0x22, 'g', CAPSLOCK),
|
||||
ENTRY (0x23, 'h', CAPSLOCK),
|
||||
ENTRY (0x24, 'j', CAPSLOCK),
|
||||
ENTRY (0x25, 'k', CAPSLOCK),
|
||||
ENTRY (0x26, 'l', CAPSLOCK),
|
||||
ENTRY (0x27, 'm', CAPSLOCK),
|
||||
|
||||
ENTRY (0x28, '%', NONE),
|
||||
ENTRY (0x29, '2', NONE), // ²
|
||||
ENTRY (0x2A, 0, INVISIBLE|INVALID), // Left Shift
|
||||
ENTRY (0x2B, '*', NONE),
|
||||
|
||||
ENTRY (0x2C, 'w', CAPSLOCK),
|
||||
ENTRY (0x2D, 'x', CAPSLOCK),
|
||||
ENTRY (0x2E, 'c', CAPSLOCK),
|
||||
ENTRY (0x2F, 'v', CAPSLOCK),
|
||||
ENTRY (0x30, 'b', CAPSLOCK),
|
||||
ENTRY (0x31, 'n', CAPSLOCK),
|
||||
ENTRY (0x32, ',', CAPSLOCK),
|
||||
ENTRY (0x33, ';', CAPSLOCK),
|
||||
ENTRY (0x34, ':', CAPSLOCK),
|
||||
ENTRY (0x35, '!', CAPSLOCK),
|
||||
};
|
||||
const uint LeftShiftScanCodes[2 * 256] =
|
||||
{
|
||||
ENTRY (0x00, 0, INVISIBLE|INVALID),
|
||||
ENTRY (0x01, KEY_ESC, INVISIBLE),
|
||||
|
||||
ENTRY (0x02, '1', NONE),
|
||||
ENTRY (0x03, '2', NONE),
|
||||
ENTRY (0x04, '3', NONE),
|
||||
ENTRY (0x05, '4', NONE),
|
||||
ENTRY (0x06, '5', NONE),
|
||||
ENTRY (0x07, '6', NONE),
|
||||
ENTRY (0x08, '7', NONE),
|
||||
ENTRY (0x09, '8', NONE),
|
||||
ENTRY (0x0A, '9', NONE),
|
||||
ENTRY (0x0B, '0', NONE),
|
||||
ENTRY (0x0C, 'o', NONE),
|
||||
ENTRY (0x0D, '+', NONE),
|
||||
ENTRY (0x0E, KEY_BS, NONE), // Backspace
|
||||
ENTRY (0x0F, '\t', NONE),
|
||||
|
||||
ENTRY (0x10, 'A', CAPSLOCK),
|
||||
ENTRY (0x11, 'Z', CAPSLOCK),
|
||||
ENTRY (0x12, 'E', CAPSLOCK),
|
||||
ENTRY (0x13, 'R', CAPSLOCK),
|
||||
ENTRY (0x14, 'T', CAPSLOCK),
|
||||
ENTRY (0x15, 'Y', CAPSLOCK),
|
||||
ENTRY (0x16, 'U', CAPSLOCK),
|
||||
ENTRY (0x17, 'I', CAPSLOCK),
|
||||
ENTRY (0x18, 'O', CAPSLOCK),
|
||||
ENTRY (0x19, 'P', CAPSLOCK),
|
||||
|
||||
ENTRY (0x1A, '^', NONE),
|
||||
ENTRY (0x1B, '$', NONE),
|
||||
ENTRY (0x1C, '\n', NONE),
|
||||
ENTRY (0x1D, 0, INVISIBLE|INVALID), // Left Control
|
||||
|
||||
ENTRY (0x1E, 'Q', CAPSLOCK),
|
||||
ENTRY (0x1F, 'S', CAPSLOCK),
|
||||
ENTRY (0x20, 'D', CAPSLOCK),
|
||||
ENTRY (0x21, 'F', CAPSLOCK),
|
||||
ENTRY (0x22, 'G', CAPSLOCK),
|
||||
ENTRY (0x23, 'H', CAPSLOCK),
|
||||
ENTRY (0x24, 'J', CAPSLOCK),
|
||||
ENTRY (0x25, 'K', CAPSLOCK),
|
||||
ENTRY (0x26, 'L', CAPSLOCK),
|
||||
ENTRY (0x27, 'M', CAPSLOCK),
|
||||
|
||||
ENTRY (0x28, '%', NONE),
|
||||
ENTRY (0x29, '2', NONE), // ²
|
||||
ENTRY (0x2A, 0, INVISIBLE|INVALID), // Left Shift
|
||||
ENTRY (0x2B, '*', NONE),
|
||||
|
||||
ENTRY (0x2C, 'W', CAPSLOCK),
|
||||
ENTRY (0x2D, 'X', CAPSLOCK),
|
||||
ENTRY (0x2E, 'C', CAPSLOCK),
|
||||
ENTRY (0x2F, 'V', CAPSLOCK),
|
||||
ENTRY (0x30, 'B', CAPSLOCK),
|
||||
ENTRY (0x31, 'N', CAPSLOCK),
|
||||
ENTRY (0x32, '?', NONE),
|
||||
ENTRY (0x33, '.', NONE),
|
||||
ENTRY (0x34, '/', NONE),
|
||||
ENTRY (0x35, '!', NONE),
|
||||
};
|
||||
|
||||
const uint LeftAltScanCodes[2 * 256];
|
||||
const uint LeftControlScanCodes[2 * 256];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue