FDOSTUI
FreeDOS Text User Interface
keyboard.h
Go to the documentation of this file.
1 /*
2  KEYBOARD.H
3 
4  License CC0 PUBLIC DOMAIN
5 
6  To the extent possible under law, Mark J. Olesen has waived all copyright
7  and related or neighboring rights to FDOSTUI Library. This work is published
8  from: United States.
9 */
10 #ifndef __keyboard_h__
11 
12 #if defined(__CURSES__)
13 #include <curses.h>
14 #endif
15 
17 {
18  ASCII_BS = 0x08,
19  ASCII_TAB = 0x09,
20  ASCII_ENTER = 0x0d,
21  ASCII_ESC = 0x1b,
22  ASCII_SPACE = 0x20
23 };
24 
25 #if (defined(__DOS__) || defined(__DJGPP__)) && !defined(__CURSES__)
27 {
28  SCAN_NONE =0x00,
29  SCAN_F1 =0x3b,
30  SCAN_F2 =0x3c,
31  SCAN_F3 =0x3d,
32  SCAN_F4 =0x3e,
33  SCAN_F5 =0x3f,
34  SCAN_F6 =0x40,
35  SCAN_F7 =0x41,
36  SCAN_F8 =0x42,
37  SCAN_F9 =0x43,
38  SCAN_F10 =0x44,
39  SCAN_HOME =0x47,
40  SCAN_UP =0x48,
41  SCAN_PGUP =0x49,
42  SCAN_LEFT =0x4b,
43  SCAN_RIGHT =0x4d,
44  SCAN_END =0x4f,
45  SCAN_DOWN =0x50,
46  SCAN_PGDN =0x51,
47  SCAN_INS =0x52,
48  SCAN_DEL =0x53,
49  SCAN_SHIFT_TAB =0xf,
50  SCAN_SHIFT_F1 =0x54,
51  SCAN_SHIFT_F2 =0x55,
52  SCAN_SHIFT_F3 =0x56,
53  SCAN_SHIFT_F4 =0x57,
54  SCAN_SHIFT_F5 =0x58,
55  SCAN_SHIFT_F6 =0x59,
56  SCAN_SHIFT_F7 =0x5a,
57  SCAN_SHIFT_F8 =0x5b,
58  SCAN_SHIFT_F9 =0x5c,
59  SCAN_SHIFT_F10 =0x5d,
60  SCAN_ALT_1 =0x78,
61  SCAN_ALT_2 =0x79,
62  SCAN_ALT_3 =0x7A,
63  SCAN_ALT_4 =0x7B,
64  SCAN_ALT_5 =0x7C,
65  SCAN_ALT_6 =0x7D,
66  SCAN_ALT_7 =0x7E,
67  SCAN_ALT_8 =0x7F,
68  SCAN_ALT_9 =0x80,
69  SCAN_ALT_0 =0x81,
70  SCAN_ALT_MINUS =0x82,
71  SCAN_ALT_PLUS =0x83,
72  SCAN_ALT_Q =0x10,
73  SCAN_ALT_W =0x11,
74  SCAN_ALT_E =0x12,
75  SCAN_ALT_R =0x13,
76  SCAN_ALT_T =0x14,
77  SCAN_ALT_Y =0x15,
78  SCAN_ALT_U =0x16,
79  SCAN_ALT_I =0x17,
80  SCAN_ALT_O =0x18,
81  SCAN_ALT_P =0x19,
82  SCAN_ALT_A =0x1e,
83  SCAN_ALT_S =0x1f,
84  SCAN_ALT_D =0x20,
85  SCAN_ALT_F =0x21,
86  SCAN_ALT_G =0x22,
87  SCAN_ALT_H =0x23,
88  SCAN_ALT_J =0x24,
89  SCAN_ALT_K =0x25,
90  SCAN_ALT_L =0x26,
91  SCAN_ALT_Z =0x2c,
92  SCAN_ALT_X =0x2d,
93  SCAN_ALT_C =0x2e,
94  SCAN_ALT_V =0x2f,
95  SCAN_ALT_B =0x30,
96  SCAN_ALT_N =0x31,
97  SCAN_ALT_M =0x32,
98  SCAN_ALT_F1 =0x68,
99  SCAN_ALT_F2 =0x69,
100  SCAN_ALT_F3 =0x6a,
101  SCAN_ALT_F4 =0x6b,
102  SCAN_ALT_F5 =0x6c,
103  SCAN_ALT_F6 =0x6d,
104  SCAN_ALT_F7 =0x6e,
105  SCAN_ALT_F8 =0x6f,
106  SCAN_ALT_F9 =0x70,
107  SCAN_ALT_F10 =0x71,
108  SCAN_CTL_F1 =0x5e,
109  SCAN_CTL_F2 =0x5f,
110  SCAN_CTL_F3 =0x60,
111  SCAN_CTL_F4 =0x61,
112  SCAN_CTL_F5 =0x62,
113  SCAN_CTL_F6 =0x63,
114  SCAN_CTL_F7 =0x64,
115  SCAN_CTL_F8 =0x65,
116  SCAN_CTL_F9 =0x66,
117  SCAN_CTL_F10 =0x67,
118  SCAN_CTL_HOME =0x77,
119  SCAN_CTL_PGUP =0x84,
120  SCAN_CTL_LEFT =0x73,
121  SCAN_CTL_RIGHT =0x74,
122  SCAN_CTL_END =0x75,
123  SCAN_CTL_PGDN =0x76
124 };
125 
126 #endif /* #if defined(__DOS__) && !defined(__CURSES__) */
127 
128 #if defined(__NT__) && !defined(__CURSES__)
129 enum scancodes
130 {
131  SCAN_NONE =0x00,
132  SCAN_HOME =0x47,
133  SCAN_UP =0x48,
134  SCAN_PGUP =0x49,
135  SCAN_LEFT =0x4b,
136  SCAN_RIGHT =0x4d,
137  SCAN_END =0x4f,
138  SCAN_DOWN =0x50,
139  SCAN_PGDN =0x51,
140  SCAN_INS =0x52,
141  SCAN_DEL =0x53,
142  SCAN_SHIFT_TAB =0xf,
143  SCAN_ALT_MASK =1000,
144  SCAN_ALT_1 =('1' | SCAN_ALT_MASK),
145  SCAN_ALT_2 =('2' | SCAN_ALT_MASK),
146  SCAN_ALT_3 =('3' | SCAN_ALT_MASK),
147  SCAN_ALT_4 =('4' | SCAN_ALT_MASK),
148  SCAN_ALT_5 =('5' | SCAN_ALT_MASK),
149  SCAN_ALT_6 =('6' | SCAN_ALT_MASK),
150  SCAN_ALT_7 =('7' | SCAN_ALT_MASK),
151  SCAN_ALT_8 =('8' | SCAN_ALT_MASK),
152  SCAN_ALT_9 =('9' | SCAN_ALT_MASK),
153  SCAN_ALT_0 =('0' | SCAN_ALT_MASK),
154  SCAN_ALT_MINUS =('-' | SCAN_ALT_MASK),
155  SCAN_ALT_PLUS =('=' | SCAN_ALT_MASK),
156  SCAN_ALT_Q =('q' | SCAN_ALT_MASK),
157  SCAN_ALT_W =('w' | SCAN_ALT_MASK),
158  SCAN_ALT_E =('e' | SCAN_ALT_MASK),
159  SCAN_ALT_R =('r' | SCAN_ALT_MASK),
160  SCAN_ALT_T =('t' | SCAN_ALT_MASK),
161  SCAN_ALT_Y =('y' | SCAN_ALT_MASK),
162  SCAN_ALT_U =('u' | SCAN_ALT_MASK),
163  SCAN_ALT_I =('i' | SCAN_ALT_MASK),
164  SCAN_ALT_O =('o' | SCAN_ALT_MASK),
165  SCAN_ALT_P =('p' | SCAN_ALT_MASK),
166  SCAN_ALT_A =('a' | SCAN_ALT_MASK),
167  SCAN_ALT_S =('s' | SCAN_ALT_MASK),
168  SCAN_ALT_D =('d' | SCAN_ALT_MASK),
169  SCAN_ALT_F =('f' | SCAN_ALT_MASK),
170  SCAN_ALT_G =('g' | SCAN_ALT_MASK),
171  SCAN_ALT_H =('h' | SCAN_ALT_MASK),
172  SCAN_ALT_J =('j' | SCAN_ALT_MASK),
173  SCAN_ALT_K =('k' | SCAN_ALT_MASK),
174  SCAN_ALT_L =('l' | SCAN_ALT_MASK),
175  SCAN_ALT_Z =('z' | SCAN_ALT_MASK),
176  SCAN_ALT_X =('x' | SCAN_ALT_MASK),
177  SCAN_ALT_C =('c' | SCAN_ALT_MASK),
178  SCAN_ALT_V =('v' | SCAN_ALT_MASK),
179  SCAN_ALT_B =('b' | SCAN_ALT_MASK),
180  SCAN_ALT_N =('n' | SCAN_ALT_MASK),
181  SCAN_ALT_M =('m' | SCAN_ALT_MASK)
182 };
183 
184 #endif /* #if defined(__NT__) && !defined(__CURSES__) */
185 
186 #if defined(__CURSES__) && !defined(__PDCURSES__)
187 enum scancodes
188 {
189  SCAN_NONE =0x00,
190  SCAN_HOME =KEY_HOME,
191  SCAN_UP =KEY_UP,
192  SCAN_PGUP =KEY_NPAGE,
193  SCAN_LEFT =KEY_LEFT,
194  SCAN_RIGHT =KEY_RIGHT,
195  SCAN_END =KEY_END,
196  SCAN_DOWN =KEY_DOWN,
197  SCAN_PGDN =KEY_PPAGE,
198  SCAN_INS =KEY_IC,
199  SCAN_DEL =KEY_DC,
200  SCAN_SHIFT_TAB =KEY_BTAB,
201  SCAN_ESC_MASK =(1+KEY_MAX),
202  SCAN_ALT_1 =('1' | SCAN_ESC_MASK),
203  SCAN_ALT_2 =('2' | SCAN_ESC_MASK),
204  SCAN_ALT_3 =('3' | SCAN_ESC_MASK),
205  SCAN_ALT_4 =('4' | SCAN_ESC_MASK),
206  SCAN_ALT_5 =('5' | SCAN_ESC_MASK),
207  SCAN_ALT_6 =('6' | SCAN_ESC_MASK),
208  SCAN_ALT_7 =('7' | SCAN_ESC_MASK),
209  SCAN_ALT_8 =('8' | SCAN_ESC_MASK),
210  SCAN_ALT_9 =('9' | SCAN_ESC_MASK),
211  SCAN_ALT_0 =('0' | SCAN_ESC_MASK),
212  SCAN_ALT_MINUS =('-' | SCAN_ESC_MASK),
213  SCAN_ALT_PLUS =('=' | SCAN_ESC_MASK),
214  SCAN_ALT_Q =('q' | SCAN_ESC_MASK),
215  SCAN_ALT_W =('w' | SCAN_ESC_MASK),
216  SCAN_ALT_E =('e' | SCAN_ESC_MASK),
217  SCAN_ALT_R =('r' | SCAN_ESC_MASK),
218  SCAN_ALT_T =('t' | SCAN_ESC_MASK),
219  SCAN_ALT_Y =('y' | SCAN_ESC_MASK),
220  SCAN_ALT_U =('u' | SCAN_ESC_MASK),
221  SCAN_ALT_I =('i' | SCAN_ESC_MASK),
222  SCAN_ALT_O =('o' | SCAN_ESC_MASK),
223  SCAN_ALT_P =('p' | SCAN_ESC_MASK),
224  SCAN_ALT_A =('a' | SCAN_ESC_MASK),
225  SCAN_ALT_S =('s' | SCAN_ESC_MASK),
226  SCAN_ALT_D =('d' | SCAN_ESC_MASK),
227  SCAN_ALT_F =('f' | SCAN_ESC_MASK),
228  SCAN_ALT_G =('g' | SCAN_ESC_MASK),
229  SCAN_ALT_H =('h' | SCAN_ESC_MASK),
230  SCAN_ALT_J =('j' | SCAN_ESC_MASK),
231  SCAN_ALT_K =('k' | SCAN_ESC_MASK),
232  SCAN_ALT_L =('l' | SCAN_ESC_MASK),
233  SCAN_ALT_Z =('z' | SCAN_ESC_MASK),
234  SCAN_ALT_X =('x' | SCAN_ESC_MASK),
235  SCAN_ALT_C =('c' | SCAN_ESC_MASK),
236  SCAN_ALT_V =('v' | SCAN_ESC_MASK),
237  SCAN_ALT_B =('b' | SCAN_ESC_MASK),
238  SCAN_ALT_N =('n' | SCAN_ESC_MASK),
239  SCAN_ALT_M =('m' | SCAN_ESC_MASK)
240 };
241 
242 #endif /* #if defined(__CURSES__) && !defined(__PDCURSES__) */
243 
244 #if defined(__PDCURSES__)
245 enum scancodes
246 {
247  SCAN_NONE =0x00,
248  SCAN_HOME =KEY_HOME,
249  SCAN_UP =KEY_UP,
250  SCAN_PGUP =KEY_NPAGE,
251  SCAN_LEFT =KEY_LEFT,
252  SCAN_RIGHT =KEY_RIGHT,
253  SCAN_END =KEY_END,
254  SCAN_DOWN =KEY_DOWN,
255  SCAN_PGDN =KEY_PPAGE,
256  SCAN_INS =KEY_IC,
257  SCAN_DEL =KEY_DC,
258  SCAN_SHIFT_TAB =KEY_BTAB,
259  SCAN_ALT_1 = ALT_1,
260  SCAN_ALT_2 = ALT_2,
261  SCAN_ALT_3 = ALT_3,
262  SCAN_ALT_4 = ALT_4,
263  SCAN_ALT_5 = ALT_5,
264  SCAN_ALT_6 = ALT_6,
265  SCAN_ALT_7 = ALT_7,
266  SCAN_ALT_8 = ALT_8,
267  SCAN_ALT_9 = ALT_9,
268  SCAN_ALT_0 = ALT_0,
269  SCAN_ALT_MINUS = ALT_MINUS,
270  SCAN_ALT_PLUS = ALT_EQUAL,
271  SCAN_ALT_Q = ALT_Q,
272  SCAN_ALT_W = ALT_W,
273  SCAN_ALT_E = ALT_E,
274  SCAN_ALT_R = ALT_R,
275  SCAN_ALT_T = ALT_T,
276  SCAN_ALT_Y = ALT_Y,
277  SCAN_ALT_U = ALT_U,
278  SCAN_ALT_I = ALT_I,
279  SCAN_ALT_O = ALT_O,
280  SCAN_ALT_P = ALT_P,
281  SCAN_ALT_A = ALT_A,
282  SCAN_ALT_S = ALT_S,
283  SCAN_ALT_D = ALT_D,
284  SCAN_ALT_F = ALT_F,
285  SCAN_ALT_G = ALT_G,
286  SCAN_ALT_H = ALT_H,
287  SCAN_ALT_J = ALT_J,
288  SCAN_ALT_K = ALT_K,
289  SCAN_ALT_L = ALT_L,
290  SCAN_ALT_Z = ALT_Z,
291  SCAN_ALT_X = ALT_X,
292  SCAN_ALT_C = ALT_C,
293  SCAN_ALT_V = ALT_V,
294  SCAN_ALT_B = ALT_B,
295  SCAN_ALT_N = ALT_N,
296  SCAN_ALT_M = ALT_M
297 };
298 
299 #endif /* #if defined(__PDCURSES__) */
300 
301 #ifdef __cplusplus
302 extern "C" {
303 #endif
304 
305 #if !defined(__CURSES__)
306 
307 short int
309 
310 void
312  unsigned char *const o_scan,
313  unsigned char *const o_ascii);
314 
315 #endif
316 
317 #if defined(__DOS__) && !defined(__CURSES__)
318 
319 #pragma aux keyboard_query = \
320  "mov ah, 01h" \
321  "int 16h" \
322  "jz qnokey"\
323  "mov ax, 0xffff"\
324  "jmp qdone"\
325  "qnokey:"\
326  "xor ax, ax"\
327  "qdone:"\
328  value [ax];
329 
330 #ifdef __FLAT__
331 
332 #pragma aux keyboard_read= \
333  "mov esi, eax" \
334  "xor ah, ah" \
335  "int 16h" \
336  "mov [byte ptr esi], ah"\
337  "mov [byte ptr ecx], al"\
338  parm [eax][ecx]\
339  modify [ esi ];
340 
341 #else
342 
343 #pragma aux keyboard_read= \
344  "mov si, ax" \
345  "xor ah, ah" \
346  "int 16h" \
347  "mov [byte ptr si], ah"\
348  "mov si, cx"\
349  "mov [byte ptr si], al"\
350  parm [ax][cx]\
351  modify [ si ];
352 
353 #endif /* #ifdef __FLAT__ */
354 
355 #endif /* #if defined(__DOS__) && !defined(__CURSES__) */
356 
357 #ifdef __cplusplus
358 }
359 #endif
360 
361 #define __keyboard_h__
362 #endif
scancodes
ASCII Scan Codes.
Definition: keyboard.h:26
void keyboard_read(unsigned char *const o_scan, unsigned char *const o_ascii)
read a key from the console
Definition: keyboard.c:24
short int keyboard_query()
query if key is ready
Definition: keyboard.c:14
asciicodes
ASCII codes.
Definition: keyboard.h:16