|
AquilaOS documentation
How it works, and its code
|
The keyboard of the virtual terminals. More...
#include <core/system.h>#include <core/string.h>#include <dev/vt.h>#include <sys/reboot.h>#include <aquila/keyboard.h>Go to the source code of this file.
Macros | |
| #define | SC_ESC 0x01 |
| #define | SC_BS 0x0E |
| #define | SC_TAB 0x0F |
| #define | SC_ENTER 0x1C |
| #define | SC_CTRL 0x1D |
| #define | SC_LSHIFT 0x2A |
| #define | SC_RSHIFT 0x36 |
| #define | SC_KP_MUL 0x37 |
| #define | SC_ALT 0x38 |
| #define | SC_CAPS 0x3A |
| #define | SC_F1 0x3B |
| #define | SC_F10 0x44 |
| #define | SC_NUM 0x45 |
| #define | SC_KP7 0x47 |
| #define | SC_KP_DEL 0x53 |
| #define | SC_F11 0x57 |
| #define | SC_F12 0x58 |
| #define | KEY_PAUSE 119 |
Functions | |
| static void | send (const char *s) |
| Sends a string to the foreground terminal, as typed input. | |
| static void | send_byte (int c) |
| Sends one byte to the foreground terminal, as typed input. | |
| int | vt_keymap (int table, int keycode) |
| Says what a key is, for KDGKBENT: programs that read key codes (K_MEDIUMRAW) use it to know what each key means. | |
| void | vt_keyboard_reset (void) |
| Forgets a prefix or a sequence that a change of mode cut in the middle. | |
| static void | send_key (const char *s) |
| Sends what a key sends, with ESC before it if Alt is held. | |
| static void | send_char (char c) |
| Sends one character, with ESC before it if Alt is held. | |
| static void | cursor_key (char dir) |
| Sends a cursor key: ESC [ x, or ESC O x in the terminal's application cursor key mode (DECCKM). | |
| static void | editing_key (const char *s) |
| Sends a key of the editing block: its sequence, or a cursor key if it is one letter. | |
| static int | control (char c) |
| Returns the control character that Ctrl with a key sends, as the Linux console does (Ctrl+A is 1, Ctrl+[ is ESC, ...). | |
| static int | modifier (int code, int release, int ext) |
| Keeps track of Shift, Ctrl and Alt, in every mode, since they may be held while the mode changes. | |
| void | vt_scancode (int scancode) |
| Takes a scancode from the keyboard, and sends what the key means to the foreground terminal, in its keyboard mode. | |
Variables | |
| static const char | keys [128] |
| static const char | shifted [128] |
| static const char * | fkeys [12] |
| static const char * | keypad_keys [13] |
| static const char | keypad_digits [] = "789-456+1230." |
| static const uint8_t | e0_keycodes [128] |
| static int | shift |
| static int | ctrl |
| static int | alt |
| static int | caps |
| static int | num |
| static int | extended |
| static int | skip |
The keyboard of the virtual terminals.
The keyboard sends PS/2 scancodes (set 1, which the i8042 translates to). This file turns them into what the Linux console sends for each key, with the US layout, and gives that to the foreground terminal. Alt sends ESC before the key, Alt+F1 to Alt+F6 switch terminals, and Ctrl+Alt+Del restarts the machine (or tells init: see sys/reboot.c).
A program can ask for raw input instead (KDSKBMODE): the scancodes as they come (K_RAW), or Linux key codes, with 0x80 added for a release (K_MEDIUMRAW). The program then handles every key itself, switching terminals too.
Definition in file keyboard.c.
| #define KEY_PAUSE 119 |
Definition at line 99 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_ALT 0x38 |
Definition at line 31 of file keyboard.c.
Referenced by modifier(), and vt_keymap().
| #define SC_BS 0x0E |
Definition at line 24 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_CAPS 0x3A |
Definition at line 32 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_CTRL 0x1D |
Definition at line 27 of file keyboard.c.
Referenced by modifier(), and vt_keymap().
| #define SC_ENTER 0x1C |
Definition at line 26 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_ESC 0x01 |
Definition at line 23 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_F1 0x3B |
Definition at line 33 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_F10 0x44 |
Definition at line 34 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_F11 0x57 |
Definition at line 38 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_F12 0x58 |
Definition at line 39 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_KP7 0x47 |
Definition at line 36 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_KP_DEL 0x53 |
Definition at line 37 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_KP_MUL 0x37 |
Definition at line 30 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_LSHIFT 0x2A |
Definition at line 28 of file keyboard.c.
Referenced by modifier(), vt_keymap(), and vt_scancode().
| #define SC_NUM 0x45 |
Definition at line 35 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
| #define SC_RSHIFT 0x36 |
Definition at line 29 of file keyboard.c.
Referenced by modifier(), vt_keymap(), and vt_scancode().
| #define SC_TAB 0x0F |
Definition at line 25 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
|
static |
Returns the control character that Ctrl with a key sends, as the Linux console does (Ctrl+A is 1, Ctrl+[ is ESC, ...).
Definition at line 249 of file keyboard.c.
Referenced by vt_scancode().
|
static |
Sends a cursor key: ESC [ x, or ESC O x in the terminal's application cursor key mode (DECCKM).
Definition at line 229 of file keyboard.c.
References cursor_key(), vt::cursor_keys, send_key(), and vt_foreground().
Referenced by cursor_key(), editing_key(), and vt_scancode().
|
static |
Sends a key of the editing block: its sequence, or a cursor key if it is one letter.
Definition at line 239 of file keyboard.c.
References cursor_key(), editing_key(), and send_key().
Referenced by editing_key(), and vt_scancode().
|
static |
Keeps track of Shift, Ctrl and Alt, in every mode, since they may be held while the mode changes.
Returns whether the key was one of them.
Definition at line 279 of file keyboard.c.
References alt, ctrl, modifier(), SC_ALT, SC_CTRL, SC_LSHIFT, SC_RSHIFT, and shift.
Referenced by modifier(), and vt_scancode().
|
static |
Sends a string to the foreground terminal, as typed input.
Definition at line 108 of file keyboard.c.
References vt_input().
Referenced by send_char(), send_key(), and vt_scancode().
|
static |
Sends one byte to the foreground terminal, as typed input.
Definition at line 114 of file keyboard.c.
References send_byte(), and vt_input().
Referenced by send_byte(), and vt_scancode().
|
static |
Sends one character, with ESC before it if Alt is held.
Definition at line 212 of file keyboard.c.
References alt, send(), send_char(), send_key(), and vt_input().
Referenced by send_char(), and vt_scancode().
|
static |
Sends what a key sends, with ESC before it if Alt is held.
Definition at line 204 of file keyboard.c.
References alt, send(), and send_key().
Referenced by cursor_key(), editing_key(), send_char(), send_key(), and vt_scancode().
| void vt_keyboard_reset | ( | void | ) |
Forgets a prefix or a sequence that a change of mode cut in the middle.
Definition at line 198 of file keyboard.c.
References extended, skip, and vt_keyboard_reset().
Referenced by vt_check(), vt_kd_ioctl(), vt_keyboard_reset(), and vt_switch_now().
| int vt_keymap | ( | int | table, |
| int | keycode ) |
Says what a key is, for KDGKBENT: programs that read key codes (K_MEDIUMRAW) use it to know what each key means.
| table | the table: none, Shift, AltGr, or both (AltGr is the same as without: the US layout has no AltGr) |
| keycode | the key's Linux key code |
Definition at line 130 of file keyboard.c.
References KEY_PAUSE, keys, SC_ALT, SC_BS, SC_CAPS, SC_CTRL, SC_ENTER, SC_ESC, SC_F1, SC_F10, SC_F11, SC_F12, SC_KP7, SC_KP_DEL, SC_KP_MUL, SC_LSHIFT, SC_NUM, SC_RSHIFT, SC_TAB, shifted, table(), and vt_keymap().
Referenced by vt_kd_ioctl(), and vt_keymap().
| void vt_scancode | ( | int | scancode | ) |
Takes a scancode from the keyboard, and sends what the key means to the foreground terminal, in its keyboard mode.
The PS/2 keyboard driver calls it from the keyboard's interrupt.
| scancode | the scancode (set 1) |
Definition at line 307 of file keyboard.c.
References alt, caps, control(), ctrl, cursor_key(), e0_keycodes, editing_key(), extended, fkeys, vt::kb_mode, kernel_ctrlaltdel(), KEY_PAUSE, keypad_digits, keypad_keys, keys, vt::mode, modifier(), num, SC_BS, SC_CAPS, SC_ENTER, SC_ESC, SC_F1, SC_F10, SC_F11, SC_F12, SC_KP7, SC_KP_DEL, SC_KP_MUL, SC_LSHIFT, SC_NUM, SC_RSHIFT, SC_TAB, send(), send_byte(), send_char(), send_key(), shift, shifted, skip, vt_foreground(), vt_keypress(), vt_scancode(), and vt_switch().
Referenced by ps2kbd_probe(), and vt_scancode().
|
static |
Definition at line 101 of file keyboard.c.
Referenced by modifier(), send_char(), send_key(), and vt_scancode().
|
static |
Definition at line 101 of file keyboard.c.
Referenced by vt_scancode().
|
static |
Definition at line 101 of file keyboard.c.
Referenced by modifier(), and vt_scancode().
|
static |
Definition at line 78 of file keyboard.c.
Referenced by vt_scancode().
|
static |
Definition at line 105 of file keyboard.c.
Referenced by vt_keyboard_reset(), and vt_scancode().
|
static |
Definition at line 61 of file keyboard.c.
Referenced by vt_scancode().
|
static |
Definition at line 74 of file keyboard.c.
Referenced by vt_scancode().
|
static |
Definition at line 69 of file keyboard.c.
Referenced by vt_scancode().
|
static |
Definition at line 42 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
|
static |
Definition at line 101 of file keyboard.c.
Referenced by vt_scancode().
|
static |
Definition at line 101 of file keyboard.c.
Referenced by modifier(), vfs_access(), and vt_scancode().
|
static |
Definition at line 51 of file keyboard.c.
Referenced by vt_keymap(), and vt_scancode().
|
static |
Definition at line 105 of file keyboard.c.