1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
os-k/kaleid/kernel/io/scan.c

234 lines
8.9 KiB
C

//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Desc: Basic Scancode Tables //
// //
// //
// Copyright © 2018-2020 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 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, K_ESCAPE, 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, '\b', NONE),
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),
ENTRY (0x39, ' ', NONE),
ENTRY (0x40, '\a', INVISIBLE), // F6
// Numpad keys
ENTRY (0x37, '*', NONE),
ENTRY (0x47, '7', NONE),
ENTRY (0x48, '8', NONE),
ENTRY (0x49, '9', NONE),
ENTRY (0x4A, '-', NONE),
ENTRY (0x4B, '4', NONE),
ENTRY (0x4C, '5', NONE),
ENTRY (0x4D, '6', NONE),
ENTRY (0x4E, '+', NONE),
ENTRY (0x4F, '1', NONE),
ENTRY (0x50, '2', NONE),
ENTRY (0x51, '3', NONE),
ENTRY (0x52, '0', NONE),
ENTRY (0x53, '.', NONE),
ENTRY (0xE0, 0, INVISIBLE),
};
const uint LeftShiftScanCodes[2 * 256] =
{
ENTRY (0x00, 0, INVISIBLE|INVALID),
ENTRY (0x01, K_ESCAPE, 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, '\b', NONE),
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),
ENTRY (0x39, ' ', NONE),
// Numpad keys
ENTRY (0x47, K_HOME, INVISIBLE),
ENTRY (0x48, K_ARRW_UP, INVISIBLE),
ENTRY (0x49, K_PAGE_UP, INVISIBLE),
ENTRY (0x4B, K_ARRW_LEFT, INVISIBLE),
ENTRY (0x4D, K_ARRW_RIGHT, INVISIBLE),
ENTRY (0x4F, K_END, INVISIBLE),
ENTRY (0x50, K_ARRW_DOWN, INVISIBLE),
ENTRY (0x51, K_PAGE_DOWN, INVISIBLE),
ENTRY (0x52, K_INSERT, INVISIBLE),
ENTRY (0x53, K_DEL, INVISIBLE),
ENTRY (0xE0, 0, INVISIBLE),
};
const uint AltGrScanCodes[2 * 256] = {
ENTRY (0x03, '~', NONE),
ENTRY (0x04, '#', NONE),
ENTRY (0x05, '{', NONE),
ENTRY (0x06, '[', NONE),
ENTRY (0x07, '|', NONE),
ENTRY (0x08, '`', NONE),
ENTRY (0x09, '\\', NONE),
ENTRY (0x0A, '^', NONE),
ENTRY (0x0B, '@', NONE),
ENTRY (0x0C, ']', NONE),
ENTRY (0x0D, '}', NONE),
};
const uint LeftAltScanCodes[2 * 256] = { 0 };
const uint LeftControlScanCodes[2 * 256] = {
ENTRY (0x2E, K_ESCAPE, INVISIBLE), // Ctrl+C
};
const uint E0ScanCodes[2 * 256] = {
ENTRY (0x1C, '\n', NONE), // Numpad Enter
ENTRY (0x35, '/', NONE), // Numpad Slash
ENTRY (0x47, K_HOME, INVISIBLE), // Home key
ENTRY (0x48, K_ARRW_UP, INVISIBLE), // Cursor UP
ENTRY (0x49, K_PAGE_UP, INVISIBLE), // Page UP
ENTRY (0x4B, K_ARRW_LEFT, INVISIBLE), // Cursor LEFT
ENTRY (0x4D, K_ARRW_RIGHT, INVISIBLE), // Cursor RIGHT
ENTRY (0x4F, K_END, INVISIBLE), // End key
ENTRY (0x50, K_ARRW_DOWN, INVISIBLE), // Cursor DOWN
ENTRY (0x51, K_PAGE_DOWN, INVISIBLE), // Page DOWN
ENTRY (0x52, K_INSERT, INVISIBLE), // Insert mode
ENTRY (0x53, K_DEL, INVISIBLE), // Delete key
};