3 * Copyright (c) 2001, David H. Hovemeyer <daveho@cs.umd.edu>
6 * This is free software. You are permitted to use,
7 * redistribute, and modify it as specified in the file "COPYING".
10 #ifndef GEEKOS_KEYBOARD_H
11 #define GEEKOS_KEYBOARD_H
13 #include <geekos/ktypes.h>
15 /* ----------------------------------------------------------------------
17 * ---------------------------------------------------------------------- */
32 #define KB_OUTPUT_FULL 0x01
35 * High bit in scan code is set when key is released
37 #define KB_KEY_RELEASE 0x80
41 /* ----------------------------------------------------------------------
43 * ---------------------------------------------------------------------- */
46 * Each keyboard event generates a 16 bit code.
47 * - The low 10 bits indicate which key was used.
48 * - If bit 8 (KEY_SPECIAL_FLAG) is 0, then the low 8 bits contain
50 * - The flags indicate the shift/alt/control state,
51 * and whether the event was a make or release.
54 typedef ushort_t Keycode;
59 #define KEY_SPECIAL_FLAG 0x0100
60 #define KEY_KEYPAD_FLAG 0x0200
61 #define KEY_SHIFT_FLAG 0x1000
62 #define KEY_ALT_FLAG 0x2000
63 #define KEY_CTRL_FLAG 0x4000
64 #define KEY_RELEASE_FLAG 0x8000
69 #define _SPECIAL(num) (KEY_SPECIAL_FLAG | (num))
70 #define KEY_UNKNOWN _SPECIAL(0)
71 #define KEY_F1 _SPECIAL(1)
72 #define KEY_F2 _SPECIAL(2)
73 #define KEY_F3 _SPECIAL(3)
74 #define KEY_F4 _SPECIAL(4)
75 #define KEY_F5 _SPECIAL(5)
76 #define KEY_F6 _SPECIAL(6)
77 #define KEY_F7 _SPECIAL(7)
78 #define KEY_F8 _SPECIAL(8)
79 #define KEY_F9 _SPECIAL(9)
80 #define KEY_F10 _SPECIAL(10)
81 #define KEY_F11 _SPECIAL(11)
82 #define KEY_F12 _SPECIAL(12)
83 #define KEY_LCTRL _SPECIAL(13)
84 #define KEY_RCTRL _SPECIAL(14)
85 #define KEY_LSHIFT _SPECIAL(15)
86 #define KEY_RSHIFT _SPECIAL(16)
87 #define KEY_LALT _SPECIAL(17)
88 #define KEY_RALT _SPECIAL(18)
89 #define KEY_PRINTSCRN _SPECIAL(19)
90 #define KEY_CAPSLOCK _SPECIAL(20)
91 #define KEY_NUMLOCK _SPECIAL(21)
92 #define KEY_SCRLOCK _SPECIAL(22)
93 #define KEY_SYSREQ _SPECIAL(23)
98 #define KEYPAD_START 128
99 #define _KEYPAD(num) (KEY_KEYPAD_FLAG | KEY_SPECIAL_FLAG | (num+KEYPAD_START))
100 #define KEY_KPHOME _KEYPAD(0)
101 #define KEY_KPUP _KEYPAD(1)
102 #define KEY_KPPGUP _KEYPAD(2)
103 #define KEY_KPMINUS _KEYPAD(3)
104 #define KEY_KPLEFT _KEYPAD(4)
105 #define KEY_KPCENTER _KEYPAD(5)
106 #define KEY_KPRIGHT _KEYPAD(6)
107 #define KEY_KPPLUS _KEYPAD(7)
108 #define KEY_KPEND _KEYPAD(8)
109 #define KEY_KPDOWN _KEYPAD(9)
110 #define KEY_KPPGDN _KEYPAD(10)
111 #define KEY_KPINSERT _KEYPAD(11)
112 #define KEY_KPDEL _KEYPAD(12)
115 * ASCII codes for which there is no convenient C representation
117 #define ASCII_ESC 0x1B
118 #define ASCII_BS 0x08
125 void Init_Keyboard(void);
126 bool Read_Key(Keycode* keycode);
127 Keycode Wait_For_Key(void);
131 #endif /* GEEKOS_KEYBOARD_H */