Skip to content

Commit ebe8390

Browse files
authored
Merge pull request #8807 from iyalosovetsky/main
usb_host keyboard, keys f1-f12, ctrl-left, ctrl-right, ctrl-up, ctrl-down, page down, page up, insert, delete, pause in VT100 CSI
2 parents 677c194 + a28e929 commit ebe8390

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

supervisor/shared/usb/host_keyboard.c

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,48 @@ struct keycode_mapper {
7878
#define CURSOR_INS "\e[2~"
7979
#define CURSOR_DEL "\e[3~"
8080

81+
// https://learn.microsoft.com/ru-ru/windows/console/console-virtual-terminal-sequences
82+
// https://aperiodic.net/phil/archives/Geekery/term-function-keys/
83+
// https://www.microfocus.com/documentation/rumba/desktop951/RumbaSystemAdminGuide/GUID-5F92BA7F-107A-4101-B4E7-E0FC73F0CD99.html
84+
// showkey -a
85+
#define F1 "\eOP"
86+
#define F2 "\eOQ"
87+
#define F3 "\eOR"
88+
#define F4 "\eOS"
89+
#define F5 "\e[15~"
90+
#define F6 "\e[17~"
91+
#define F7 "\e[18~"
92+
#define F8 "\e[19~"
93+
#define F9 "\e[20~"
94+
#define F10 "\e[21~"
95+
#define F11 "\e[23~"
96+
#define F12 "\e[24~"
97+
98+
#define PRINT_SCREEN "\e[i"
99+
#define CTRL_UP "\e[1;5A"
100+
#define CTRL_DOWN "\e[1;5B"
101+
#define CTRL_RIGHT "\e[1;5C"
102+
#define CTRL_LEFT "\e[1;5D"
103+
#define CTRL_PGUP "\e[5;5~"
104+
#define CTRL_PGDN "\e[6;5~"
105+
#define CTRL_HOME "\e[1;5H"
106+
#define CTRL_END "\e[1;5F"
107+
#define CTRL_INS "\e[2;5~"
108+
#define CTRL_DEL "\e[3;5~"
109+
#define CTRL_F1 "\e[1;5P"
110+
#define CTRL_F2 "\e[1;5Q"
111+
#define CTRL_F3 "\e[1;5R"
112+
#define CTRL_F4 "\e[1;5S"
113+
#define CTRL_F5 "\e[15;5~"
114+
#define CTRL_F6 "\e[17;5~"
115+
#define CTRL_F7 "\e[18;5~"
116+
#define CTRL_F8 "\e[19;5~"
117+
#define CTRL_F9 "\e[20;5~"
118+
#define CTRL_F10 "\e[21;5~"
119+
#define CTRL_F11 "\e[23;5~"
120+
#define CTRL_F12 "\e[24;5~"
121+
122+
81123
STATIC struct keycode_mapper keycode_to_ascii[] = {
82124
{ HID_KEY_A, HID_KEY_Z, 'a', 0, NULL},
83125

@@ -90,13 +132,17 @@ STATIC struct keycode_mapper keycode_to_ascii[] = {
90132
{ HID_KEY_ENTER, HID_KEY_SLASH, 0, FLAG_SHIFT, "\n\x1b\177\t _+{}|~:\"~<>?" },
91133
{ HID_KEY_ENTER, HID_KEY_SLASH, 0, 0, "\r\x1b\10\t -=[]\\#;'`,./" },
92134

93-
{ HID_KEY_F1, HID_KEY_F1, 0x1e, 0, }, // help key on xerox 820 kbd
94-
95135
{ HID_KEY_KEYPAD_DIVIDE, HID_KEY_KEYPAD_DECIMAL, 0, FLAG_NUMLOCK | FLAG_STRING,
96-
"/\0" "*\0" "-\0" "+\0" "\n\0" CURSOR_END SEP CURSOR_DOWN SEP CURSOR_PGDN SEP CURSOR_LEFT SEP NOTHING SEP CURSOR_RIGHT SEP CURSOR_HOME SEP CURSOR_UP SEP CURSOR_PGDN SEP CURSOR_INS SEP CURSOR_DEL},
136+
"/\0" "*\0" "-\0" "+\0" "\n\0" CURSOR_END SEP CURSOR_DOWN SEP CURSOR_PGDN SEP CURSOR_LEFT SEP NOTHING SEP CURSOR_RIGHT SEP CURSOR_HOME SEP CURSOR_UP SEP CURSOR_PGUP SEP CURSOR_INS SEP CURSOR_DEL},
97137
{ HID_KEY_KEYPAD_DIVIDE, HID_KEY_KEYPAD_DECIMAL, 0, 0, "/*-+\n1234567890." },
98138

99-
{ HID_KEY_ARROW_RIGHT, HID_KEY_ARROW_UP, 0, FLAG_STRING, CURSOR_RIGHT SEP CURSOR_LEFT SEP CURSOR_DOWN SEP CURSOR_UP },
139+
{ HID_KEY_INSERT, HID_KEY_ARROW_UP, 0, FLAG_STRING | FLAG_CTRL, CTRL_INS SEP CTRL_HOME SEP CTRL_PGUP SEP CTRL_DEL SEP CTRL_END SEP CTRL_PGDN SEP CTRL_RIGHT SEP CTRL_LEFT SEP CTRL_DOWN SEP CTRL_UP},
140+
{ HID_KEY_INSERT, HID_KEY_ARROW_UP, 0, FLAG_STRING, CURSOR_INS SEP CURSOR_HOME SEP CURSOR_PGUP SEP CURSOR_DEL SEP CURSOR_END SEP CURSOR_PGDN SEP CURSOR_RIGHT SEP CURSOR_LEFT SEP CURSOR_DOWN SEP CURSOR_UP},
141+
{ HID_KEY_F1, HID_KEY_F12, 0, FLAG_STRING | FLAG_CTRL, CTRL_F1 SEP CTRL_F2 SEP CTRL_F3 SEP CTRL_F4 SEP CTRL_F5 SEP CTRL_F6 SEP CTRL_F7 SEP CTRL_F8 SEP CTRL_F9 SEP CTRL_F10 SEP CTRL_F11 SEP CTRL_F12},
142+
{ HID_KEY_F1, HID_KEY_F12, 0, FLAG_STRING, F1 SEP F2 SEP F3 SEP F4 SEP F5 SEP F6 SEP F7 SEP F8 SEP F9 SEP F10 SEP F11 SEP F12},
143+
144+
{ HID_KEY_PAUSE, HID_KEY_PAUSE, 0x1a, 0, },
145+
{ HID_KEY_PRINT_SCREEN, HID_KEY_PRINT_SCREEN, 0, FLAG_STRING, PRINT_SCREEN},
100146

101147
};
102148

0 commit comments

Comments
 (0)