iPXE
keys.h
Go to the documentation of this file.
1 #ifndef _IPXE_KEYS_H
2 #define _IPXE_KEYS_H
3 
4 /** @file
5  *
6  * Key definitions
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_SECBOOT ( PERMITTED );
12 
13 /*
14  * Symbolic names for some standard ASCII characters
15  *
16  */
17 
18 #define NUL 0x00
19 #define CTRL_A 0x01
20 #define CTRL_B 0x02
21 #define CTRL_C 0x03
22 #define CTRL_D 0x04
23 #define CTRL_E 0x05
24 #define CTRL_F 0x06
25 #define CTRL_G 0x07
26 #define CTRL_H 0x08
27 #define CTRL_I 0x09
28 #define CTRL_J 0x0a
29 #define CTRL_K 0x0b
30 #define CTRL_L 0x0c
31 #define CTRL_M 0x0d
32 #define CTRL_N 0x0e
33 #define CTRL_O 0x0f
34 #define CTRL_P 0x10
35 #define CTRL_Q 0x11
36 #define CTRL_R 0x12
37 #define CTRL_S 0x13
38 #define CTRL_T 0x14
39 #define CTRL_U 0x15
40 #define CTRL_V 0x16
41 #define CTRL_W 0x17
42 #define CTRL_X 0x18
43 #define CTRL_Y 0x19
44 #define CTRL_Z 0x1a
45 
46 #define BACKSPACE CTRL_H
47 #define TAB CTRL_I
48 #define LF CTRL_J
49 #define CR CTRL_M
50 #define ESC 0x1b
51 #define DEL 0x7f
52 
53 /*
54  * Special keys outside the normal Unicode range
55  *
56  * The names are chosen to match those used by curses. The values are
57  * chosen to facilitate easy conversion from a received ANSI escape
58  * sequence to a KEY_XXX constant.
59  *
60  * Note that the values are exposed to iPXE commands via parse_key()
61  * and therefore may not be changed without breaking existing scripts.
62  */
63 
64 /**
65  * Minimum value for special keypresses
66  *
67  * This value is chosen to lie above the maximum Unicode code point
68  * value 0x10ffff.
69  */
70 #define KEY_MIN 0x110000
71 
72 /**
73  * Construct relative key value for special key
74  *
75  * @v key Key value
76  * @ret rkey Relative key value
77  */
78 #define KEY_REL( key ) ( (key) - KEY_MIN )
79 
80 /**
81  * Construct ANSI escape sequence key value
82  *
83  * @v n ANSI escape sequence numeric portion, or 0 for none
84  * @v terminator ANSI escape sequence terminating character
85  * @ret key Key value
86  */
87 #define KEY_ANSI( n, terminator ) \
88  ( KEY_MIN + ( ( (n) + 1 ) << 8 ) + (terminator) )
89 
90 /**
91  * Extract ANSI escape sequence numeric portion
92  *
93  * @v key Key value (or relative key value)
94  * @ret n ANSI escape sequence numeric portion, or 0 for none
95  */
96 #define KEY_ANSI_N( key ) ( ( ( (key) >> 8 ) & 0xff ) - 1 )
97 
98 /**
99  * Extract ANSI escape sequence terminating character
100  *
101  * @v key Key value (or relative key value)
102  * @ret terminator ANSI escape sequence terminating character
103  */
104 #define KEY_ANSI_TERMINATOR( key ) ( (key) & 0xff )
105 
106 #define KEY_UP KEY_ANSI ( 0, 'A' ) /**< Up arrow */
107 #define KEY_DOWN KEY_ANSI ( 0, 'B' ) /**< Down arrow */
108 #define KEY_RIGHT KEY_ANSI ( 0, 'C' ) /**< Right arrow */
109 #define KEY_LEFT KEY_ANSI ( 0, 'D' ) /**< Left arrow */
110 #define KEY_END KEY_ANSI ( 0, 'F' ) /**< End */
111 #define KEY_HOME KEY_ANSI ( 0, 'H' ) /**< Home */
112 #define KEY_IC KEY_ANSI ( 2, '~' ) /**< Insert */
113 #define KEY_DC KEY_ANSI ( 3, '~' ) /**< Delete */
114 #define KEY_PPAGE KEY_ANSI ( 5, '~' ) /**< Page up */
115 #define KEY_NPAGE KEY_ANSI ( 6, '~' ) /**< Page down */
116 #define KEY_F5 KEY_ANSI ( 15, '~' ) /**< F5 */
117 #define KEY_F6 KEY_ANSI ( 17, '~' ) /**< F6 */
118 #define KEY_F7 KEY_ANSI ( 18, '~' ) /**< F7 */
119 #define KEY_F8 KEY_ANSI ( 19, '~' ) /**< F8 (for PXE) */
120 #define KEY_F9 KEY_ANSI ( 20, '~' ) /**< F9 */
121 #define KEY_F10 KEY_ANSI ( 21, '~' ) /**< F10 */
122 #define KEY_F11 KEY_ANSI ( 23, '~' ) /**< F11 */
123 #define KEY_F12 KEY_ANSI ( 24, '~' ) /**< F12 */
124 
125 /* Not in the [KEY_MIN,KEY_MAX] range; terminals seem to send these as
126  * normal ASCII values.
127  */
128 #define KEY_BACKSPACE BACKSPACE
129 #define KEY_ENTER LF
130 
131 #endif /* _IPXE_KEYS_H */
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
FILE_SECBOOT(PERMITTED)