v0.5.1 console key releases: Linux VT and FreeBSD vt(4), with a guard
* linux console source: releases from the console's own keyboard, typed by its keymap SetKeyReport with KeySourceConsole, on a Linux virtual console the game runs on, switches the keyboard to raw keycodes (K_MEDIUMRAW) while releases are reported. The kernel allows the switch on the caller's controlling tty, so no root is needed; a console that refuses is not asked again and the protocol is next. Going back to presses, Fini and EmergencyReset switch it back. Each keycode is typed as the console types it cooked, after drivers/tty/vt/keyboard.c, by the console's own tables read at the switch (KDGKBENT, KDGKBSENT, KDGKBDIACRUC, KDGKBMETA): modifiers and their left and right groups, Caps and Num Lock with their lights kept in step (KDSKBLED), sticky and locked modifiers, Unicode entries, dead keys and compose, the keypad by Num Lock, function strings, Meta as ESC prefix or bit 7, console switching by Alt+Fn and Alt+arrows to consoles in use, and from kernel 7.1 cursor and CSI keys with their modifiers. Translation starts from the console's modifiers and locks (TIOCLINUX 6, KDGKBLED). Each key is held by its keycode; a key typing several keys taps all but its last. Switching to another console ends every hold Lost. Mouse reports are off while the keyboard is raw, since the console types them into the same input, and come back after it. The guard: before the first switch the package runs the binary again, named console-guard, holding the console and the read end of a pipe only the game writes. If the pipe ends while the keyboard is raw (kill -9, the OOM killer, a Go fatal error), the guard switches the keyboard back, restores the termios the game found and shows the cursor, without a reset that would clear the game's last words. A game leading its console's session takes the console with it as it dies; its guard then leads a session of its own and opens the console again once the kernel has hung it up, to restore it. Checked in QEMU on a real VT, kernels 6.8 and 7.2, the game as uid 1000: the same key strokes read identically raw and cooked (Shift released first, Ctrl, Alt, AltGr, Caps and Num Lock, the keypad, function keys, modified cursor keys on 7.2; dead grave and tilde, compose, a euro sign and Cyrillic from a loaded keymap), Alt+F2 away ended the hold Lost and Alt+F1 came back, and the keyboard came back to K_UNICODE with ICANON and ECHO after Fini, a panic with EmergencyReset, kill -9, and kill -9 of a game leading its session (left raw without the guard's own session). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B3zCVjspRDuEuMrDTumVhp * freebsd console source: releases from vt(4)'s keyboard, typed by its keymap On FreeBSD's vt(4) console the keyboard switches to keycodes (K_CODE), which vt allows any process with the console open, no root needed. Each keycode types what vt types for it cooked: the keyboard's keymap and accent map (GIO_KEYMAP, GIO_DEADKEYMAP) run through a port of the kernel's genkbd_keyaction, kbdmux's left Alt keypad codes, and vt_processkey's xterm sequences, ESC for Alt and console switching. The locks go back to the keyboard and its lights with KDSKBSTATE. Scroll Lock is inert while raw; with the console's history mode on (Scroll Lock lit) the keyboard stays as it is and the ask reports presses. Shared with the Linux source now: the restore EmergencyReset runs, the guard, which opens again a console revoked or hung up with its session's leader, and what a key asks of the console. A console that can't go raw just now (Scroll Lock on, its guard gone, output not drained) is tried again at the next ask rather than never; a refusal at prepare still holds for good. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B3zCVjspRDuEuMrDTumVhp * example-keys: show each key event, for trying key releases A viewer for the key events a terminal or console reports: F2 asks for releases from the console or the terminal's protocol, or gives them back, and the report each ask came to shows above the events. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B3zCVjspRDuEuMrDTumVhp --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
97f66b1f1c
commit
e9aeed0be0
23 files changed
+3580
-9
No files matched your search
Vendored
+116
@@ -0,0 +1,116 @@
|
||||
key 0 0 0 0 0 0 0 0 0 ff 0
|
||||
key 1 1b 1b 1b 1b 1b 1b 86 1b 2 0
|
||||
key 2 31 21 0 0 31 21 0 0 33 0
|
||||
key 3 32 40 0 0 32 40 0 0 0 0
|
||||
key 4 33 23 0 0 33 23 0 0 33 0
|
||||
key 5 34 24 0 0 34 24 0 0 33 0
|
||||
key 6 35 25 0 0 35 25 0 0 33 0
|
||||
key 7 36 5e 1e 1e 36 5e 1e 1e 0 0
|
||||
key 8 37 26 0 0 37 26 0 0 33 0
|
||||
key 9 38 2a 0 0 38 2a 0 0 33 0
|
||||
key 10 39 28 0 0 39 28 0 0 33 0
|
||||
key 11 30 29 0 0 30 29 0 0 33 0
|
||||
key 12 2d 5f 1f 1f 2d 5f 1f 1f 0 0
|
||||
key 13 3d 2b 0 0 3d 2b 0 0 33 0
|
||||
key 14 8 8 7f 7f 8 8 7f 7f 0 0
|
||||
key 15 9 8 0 0 9 8 0 0 77 0
|
||||
key 16 71 51 11 11 71 51 11 11 0 1
|
||||
key 17 77 57 17 17 77 57 17 17 0 1
|
||||
key 18 65 45 5 5 65 45 5 5 0 1
|
||||
key 19 72 52 12 12 72 52 12 12 0 1
|
||||
key 20 74 54 14 14 74 54 14 14 0 1
|
||||
key 21 79 59 19 19 79 59 19 19 0 1
|
||||
key 22 75 55 15 15 75 55 15 15 0 1
|
||||
key 23 69 49 9 9 69 49 9 9 0 1
|
||||
key 24 6f 4f f f 6f 4f f f 0 1
|
||||
key 25 70 50 10 10 70 50 10 10 0 1
|
||||
key 26 5b 7b 1b 1b 5b 7b 1b 1b 0 0
|
||||
key 27 5d 7d 1d 1d 5d 7d 1d 1d 0 0
|
||||
key 28 d d a a d d a a 0 0
|
||||
key 29 9 9 9 9 9 9 9 9 ff 0
|
||||
key 30 61 41 1 1 61 41 1 1 0 1
|
||||
key 31 73 53 13 13 73 53 13 13 0 1
|
||||
key 32 64 44 4 4 64 44 4 4 0 1
|
||||
key 33 66 46 6 6 66 46 6 6 0 1
|
||||
key 34 67 47 7 7 67 47 7 7 0 1
|
||||
key 35 68 48 8 8 68 48 8 8 0 1
|
||||
key 36 6a 4a a a 6a 4a a a 0 1
|
||||
key 37 6b 4b b b 6b 4b b b 0 1
|
||||
key 38 6c 4c c c 6c 4c c c 0 1
|
||||
key 39 3b 3a 0 0 3b 3a 0 0 33 0
|
||||
key 40 27 22 0 0 27 22 0 0 33 0
|
||||
key 41 60 7e 0 0 60 7e 0 0 33 0
|
||||
key 42 2 2 2 2 2 2 2 2 ff 0
|
||||
key 43 5c 7c 1c 1c 5c 7c 1c 1c 0 0
|
||||
key 44 7a 5a 1a 1a 7a 5a 1a 1a 0 1
|
||||
key 45 78 58 18 18 78 58 18 18 0 1
|
||||
key 46 63 43 3 3 63 43 3 3 0 1
|
||||
key 47 76 56 16 16 76 56 16 16 0 1
|
||||
key 48 62 42 2 2 62 42 2 2 0 1
|
||||
key 49 6e 4e e e 6e 4e e e 0 1
|
||||
key 50 6d 4d d d 6d 4d d d 0 1
|
||||
key 51 2c 3c 0 0 2c 3c 0 0 33 0
|
||||
key 52 2e 3e 0 0 2e 3e 0 0 33 0
|
||||
key 53 2f 3f 0 0 2f 3f 0 0 33 0
|
||||
key 54 3 3 3 3 3 3 3 3 ff 0
|
||||
key 55 2a 2a 2a 2a 2a 2a 2a 2a 0 0
|
||||
key 56 7 7 7 7 7 7 7 7 ff 0
|
||||
key 57 20 20 0 20 20 20 87 20 2 0
|
||||
key 58 4 4 4 4 4 4 4 4 ff 0
|
||||
key 59 1b 27 33 3f b 15 b 15 ff 0
|
||||
key 60 1c 28 34 40 c 16 c 16 ff 0
|
||||
key 61 1d 29 35 41 d 17 d 17 ff 0
|
||||
key 62 1e 2a 36 42 e 18 e 18 ff 0
|
||||
key 63 1f 2b 37 43 f 19 f 19 ff 0
|
||||
key 64 20 2c 38 44 10 1a 10 1a ff 0
|
||||
key 65 21 2d 39 45 11 11 11 11 ff 0
|
||||
key 66 22 2e 3a 46 12 12 12 12 ff 0
|
||||
key 67 23 2f 3b 47 13 13 13 13 ff 0
|
||||
key 68 24 30 3c 48 14 14 14 14 ff 0
|
||||
key 69 5 5 5 5 5 5 5 5 ff 0
|
||||
key 70 6 6 6 6 6 6 6 6 ff 0
|
||||
key 71 4b 37 37 37 37 37 37 37 80 2
|
||||
key 72 4c 38 38 38 38 38 38 38 80 2
|
||||
key 73 4d 39 39 39 39 39 39 39 80 2
|
||||
key 74 4e 2d 2d 2d 2d 2d 2d 2d 80 2
|
||||
key 75 4f 34 34 34 34 34 34 34 80 2
|
||||
key 76 50 35 35 35 35 35 35 35 80 2
|
||||
key 77 51 36 36 36 36 36 36 36 80 2
|
||||
key 78 52 2b 2b 2b 2b 2b 2b 2b 80 2
|
||||
key 79 53 31 31 31 31 31 31 31 80 2
|
||||
key 80 54 32 32 32 32 32 32 32 80 2
|
||||
key 81 55 33 33 33 33 33 33 33 80 2
|
||||
key 82 56 30 30 30 30 30 30 30 80 2
|
||||
key 83 7f 2e 2e 2e 2e 2e 85 85 3 2
|
||||
key 84 0 0 0 0 0 0 0 0 ff 0
|
||||
key 85 0 0 0 0 0 0 0 0 ff 0
|
||||
key 86 0 0 0 0 0 0 0 0 ff 0
|
||||
key 87 25 31 3d 49 15 15 15 15 ff 0
|
||||
key 88 26 32 3e 4a 16 16 16 16 ff 0
|
||||
key 89 d d a a d d a a 0 0
|
||||
key 90 80 80 80 80 80 80 80 80 ff 0
|
||||
key 91 2f 2f 2f 2f 2f 2f 2f 2f 0 2
|
||||
key 92 a 99 86 86 0 0 0 0 ff 0
|
||||
key 93 81 81 81 81 81 81 81 81 ff 0
|
||||
key 94 4b 4b 4b 4b 4b 4b 4b 4b ff 0
|
||||
key 95 4c 4c 4c 4c 4c 4c 4c 4c ff 0
|
||||
key 96 4d 4d 4d 4d 4d 4d 4d 4d ff 0
|
||||
key 97 4f 4f 4f 4f 4f 4f 4f 4f ff 0
|
||||
key 98 51 51 51 51 51 51 51 51 ff 0
|
||||
key 99 53 53 53 53 53 53 53 53 ff 0
|
||||
key 100 54 54 54 54 54 54 54 54 ff 0
|
||||
key 101 55 55 55 55 55 55 55 55 ff 0
|
||||
key 102 56 a3 56 56 56 56 56 56 ff 0
|
||||
key 103 57 57 57 57 57 57 85 57 ff 0
|
||||
key 104 6 88 6 88 87 0 87 0 ff 0
|
||||
key 105 58 58 58 58 58 58 58 58 ff 0
|
||||
key 106 59 59 59 59 59 59 59 59 ff 0
|
||||
key 107 5a 5a 5a 5a 5a 5a 5a 5a ff 0
|
||||
key 108 0 0 0 0 0 0 0 0 ff 0
|
||||
acc 0 60 61:e0 41:c0 65:e8 45:c8 69:ec 49:cc 6f:f2 4f:d2 75:f9 55:d9
|
||||
acc 1 b4 61:e1 41:c1 65:e9 45:c9 69:ed 49:cd 6f:f3 4f:d3 75:fa 55:da 79:fd 59:dd
|
||||
acc 2 5e 61:e2 41:c2 65:ea 45:ca 69:ee 49:ce 6f:f4 4f:d4 75:fb 55:db
|
||||
acc 3 7e 61:e3 41:c3 6e:f1 4e:d1 6f:f5 4f:d5
|
||||
acc 7 a8 61:e4 41:c4 65:eb 45:cb 69:ef 49:cf 6f:f6 4f:d6 75:fc 55:dc 79:ff
|
||||
acc 9 b0 61:e5 41:c5
|
||||
acc 10 b8 63:e7 43:c7
|
||||
Reference in new issue
Block a user