00001 #ifndef KEYBOARD_H
00002 #define KEYBOARD_H
00003
00004 #define GENERALCODE_STATE 0
00005 #define EXTENDCODE_STATE 1
00006 #define EXTENDCODE2_1STCODE_STATE 2
00007 #define EXTENDCODE2_2NDCODE_STATE 3
00008
00009
00010 #define KEY_RELEASE 0x80
00011 #define KEY_PRESS 0x00
00012
00013 #define KEY_MINUS 0x0c
00014 #define KEY_EQUAL 0x0d
00015 #define KEY_UL2DR_SLASH 0x2b
00016 #define KEY_DIVIDE 0x035
00017 #define KEY_DOT 0x034 // .
00018 #define KEY_UPPER_DOT 0x028 // '
00019 #define KEY_COMMA 0x033 // ,
00020 #define KEY_UPPER_COMMA 0x29 // `
00021 #define KEY_SEMICOLON 0x27 // ; colon is ':'
00022 #define KEY_LEFT_BRACKET 0x1a // [
00023 #define KEY_RIGHT_BRACKET 0x1b // ]
00024
00025 #define KEY_0 0x0b
00026 #define KEY_1 0x02
00027 #define KEY_2 0x03
00028 #define KEY_3 0x04
00029 #define KEY_4 0x05
00030 #define KEY_5 0x06
00031 #define KEY_6 0x07
00032 #define KEY_7 0x08
00033 #define KEY_8 0x09
00034 #define KEY_9 0x0a
00035
00036 #define KEY_a 0x1e
00037 #define KEY_b 0x30
00038 #define KEY_c 0x2e
00039 #define KEY_d 0x20
00040 #define KEY_e 0x12
00041 #define KEY_f 0x21
00042 #define KEY_g 0x22
00043 #define KEY_h 0x23
00044 #define KEY_i 0x17
00045 #define KEY_j 0x24
00046 #define KEY_k 0x25
00047 #define KEY_l 0x26
00048 #define KEY_m 0x32
00049 #define KEY_n 0x31
00050 #define KEY_o 0x18
00051 #define KEY_p 0x19
00052 #define KEY_q 0x10
00053 #define KEY_r 0x13
00054 #define KEY_s 0x1f
00055 #define KEY_t 0x14
00056 #define KEY_u 0x16
00057 #define KEY_v 0x2f
00058 #define KEY_w 0x11
00059 #define KEY_x 0x2d
00060 #define KEY_y 0x15
00061 #define KEY_z 0x2c
00062
00063 #define KEY_F1 0x3b
00064 #define KEY_F2 0x3c
00065 #define KEY_F3 0x3d
00066 #define KEY_F4 0x3e
00067 #define KEY_F5 0x3f
00068 #define KEY_F6 0x40
00069 #define KEY_F7 0x41
00070 #define KEY_F8 0x42
00071 #define KEY_F9 0x43
00072 #define KEY_F10 0x44
00073 #define KEY_F11 0x57
00074 #define KEY_F12 0x58
00075
00076 #define KEY_ESC 0x01
00077 #define KEY_NUMLOCK 0x45
00078 #define KEY_SCROLL_LOCK 0x46
00079
00080 #define KEY_SHIFT_RIGHT 0x36
00081 #define KEY_SHIFT_LEFT 0x2a
00082 #define KEY_ALT_LEFT 0x38
00083 #define KEY_CAPSLOCK 0x3a
00084 #define KEY_TAB 0x0f
00085 #define KEY_CTRL_LEFT 0x1d
00086 #define KEY_ENTER 0x1c
00087 #define KEY_BACKSPACE 0x0e
00088 #define KEY_SPACE 0x39
00089
00090 #define KEY_NUMPAD_0 0x52
00091 #define KEY_NUMPAD_1 0x4f
00092 #define KEY_NUMPAD_2 0x50
00093 #define KEY_NUMPAD_3 0x51
00094 #define KEY_NUMPAD_4 0x4b
00095 #define KEY_NUMPAD_5 0x4c
00096 #define KEY_NUMPAD_6 0x4d
00097 #define KEY_NUMPAD_7 0x47
00098 #define KEY_NUMPAD_8 0x48
00099 #define KEY_NUMPAD_9 0x49
00100 #define KEY_NUMPAD_DOT 0x53
00101 #define KEY_NUMPAD_STAR 0x37
00102 #define KEY_NUMPAD_MINUS 0x4a
00103 #define KEY_NUMPAD_PLUS 0x4e
00104
00105 #define KEY_NUMPAD_DIVIDE 0x35 //e0 35 e0 b5
00106 #define KEY_NUMPAD_ENTER 0x1c //e0 1c e0 9c
00107 #define KEY_PRTSC 0x37 //e0 37 e0 b7
00108 #define KEY_HOME 0x47 //e0 47 e0 c7
00109 #define KEY_END 0x4f //e0 4f e0 cf
00110 #define KEY_PAGEUP 0x49 //e0 49 e0 c9
00111 #define KEY_PAGEDOWN 0x51 //e0 51 e0 d1
00112 #define KEY_ARROWUP 0x48 //e0 48 e0 c8
00113 #define KEY_ARROWDOWN 0x50 //e0 50 e0 d0
00114 #define KEY_ARROWLEFT 0x4b //e0 4b e0 cb
00115 #define KEY_ARRORRIGHT 0x4d //e0 4d e0 cd
00116 #define KEY_DEL 0x53 //e0 53 e0 d3
00117 #define KEY_INS 0x52 //e0 52 e0 d2
00118 #define KEY_ALT_RIGHT 0x38 //e0 38 e0 b8
00119 #define KEY_CTRL_RIGHT 0x1d //e0 1d e0 9d
00120
00121 #define KEY_WINDOWS_MENU 0x5d //e0 5d e0 dd
00122 #define KEY_WINDOWS_START 0x5b //e0 5b e0 db
00123
00124 #define KEY_PAUSE 0xe1 //0x1d 0x45 0xe1 0x9d 0xc5
00125
00126
00127
00128 #define ASCII_NUL 0x00
00129 #define ASCII_SOH 0x01
00130 #define ASCII_STX 0x02
00131 #define ASCII_ETX 0x03
00132 #define ASCII_EOT 0x04
00133 #define ASCII_ENQ 0x05
00134 #define ASCII_ACK 0x06
00135 #define ASCII_BEL 0x07
00136 #define ASCII_BS 0x08
00137 #define ASCII_HT 0x09
00138 #define ASCII_LF 0x0a
00139 #define ASCII_VT 0x0b
00140 #define ASCII_FF 0x0c
00141 #define ASCII_CR 0x0d
00142 #define ASCII_SO 0x0e
00143 #define ASCII_SI 0x0f
00144 #define ASCII_DLE 0x10
00145 #define ASCII_DC1 0x11
00146 #define ASCII_DC2 0x12
00147 #define ASCII_DC3 0x13
00148 #define ASCII_DC4 0x14
00149 #define ASCII_NAK 0x15
00150 #define ASCII_SYN 0x26
00151 #define ASCII_ETB 0x17
00152 #define ASCII_CAN 0x18
00153 #define ASCII_EM 0x19
00154 #define ASCII_SUB 0x1a
00155 #define ASCII_ESC 0x1b
00156 #define ASCII_FS 0x1c
00157 #define ASCII_GS 0x1d
00158 #define ASCII_RS 0x1e
00159 #define ASCII_US 0x1f
00160 #define ASCII_SP 0x20
00161 #define ASCII_DEL 0x7f
00162
00163 #define KB_SPECIAL_F1_KEY 0x80
00164 #define KB_SPECIAL_F2_KEY 0x81
00165 #define KB_SPECIAL_F3_KEY 0x82
00166 #define KB_SPECIAL_F4_KEY 0x83
00167 #define KB_SPECIAL_F5_KEY 0x84
00168 #define KB_SPECIAL_F6_KEY 0x85
00169 #define KB_SPECIAL_F7_KEY 0x86
00170 #define KB_SPECIAL_F8_KEY 0x87
00171 #define KB_SPECIAL_F9_KEY 0x88
00172 #define KB_SPECIAL_F10_KEY 0x89
00173 #define KB_SPECIAL_F11_KEY 0x8a
00174 #define KB_SPECIAL_F12_KEY 0x8b
00175 #define KB_SPECIAL_PRTSCR_KEY 0x8c
00176 #define KB_SPECIAL_SCROLL_LOCK_KEY 0x8d
00177 #define KB_SPECIAL_PAUSE_BREAK_KEY 0x8e
00178 #define KB_SPECIAL_TAB_KEY 0x8f
00179 #define KB_SPECIAL_SHIFT_AT_LEFT_KEY 0x90
00180 #define KB_SPECIAL_SHIFT_AT_RIGHT_KEY 0x91
00181 #define KB_SPECIAL_CTRL_AT_LEFT_KEY 0x92
00182 #define KB_SPECIAL_CTRL_AT_RIGHT_KEY 0x93
00183 #define KB_SPECIAL_WINDOW_AT_LEFT_KEY 0x94
00184 #define KB_SPECIAL_WINDOW_AT_RIGHT_KEY 0x95
00185 #define KB_SPECIAL_ATL_AT_LEFT_KEY 0x96
00186 #define KB_SPECIAL_ATL_AT_RIGHT_KEY 0x97
00187 #define KB_SPECIAL_MENUS_KEY 0x98
00188 #define KB_SPECIAL_INSERT_KEY 0x99
00189 #define KB_SPECIAL_HOME_KEY 0x9a
00190 #define KB_SPECIAL_PAGE_DOWN_KEY 0x9b
00191 #define KB_SPECIAL_END_KEY 0x9c
00192 #define KB_SPECIAL_PAGE_UP_KEY 0x9d
00193 #define KB_SPECIAL_CAP_LOCK_KEY 0x9e
00194 #define KB_SPECIAL_UP_ARROW_KEY 0x9f
00195 #define KB_SPECIAL_LEFT_ARROW_KEY 0xa0
00196 #define KB_SPECIAL_DOWN_ARROW_KEY 0xa1
00197 #define KB_SPECIAL_RIGHT_ARROW_KEY 0xa2
00198 #define KB_SPECIAL_NUM_LOCK_KEY 0xa3
00199 #define KB_SPECIAL_INS 0xa4
00200
00201
00202 #define KB_DATA_REG 0x60
00203 #define KB_CMD_REG 0x64
00204 #define KB_STATUS_REG 0x64
00205 #define LED_CODE 0xed
00206 #define KB_ACK 0xfa
00207
00208 #define KB_SCROLLLOCK_LED 0x01
00209 #define KB_NUMBERLOCK_LED 0x02
00210 #define KB_CAPSLOCK_LED 0x04
00211
00212
00213
00214 #define KEYBOARD_KEYBUFFER_SZIE 50
00215 typedef struct{
00216 U8 Put;
00217 U8 Get;
00218 U16 Data[KEYBOARD_KEYBUFFER_SZIE];
00219 }KEY_BUFFER;
00220
00221 typedef struct{
00222 U8 State;
00223 U8 LedValue;
00224 U16 Timer;
00225 bool LedChange;
00226 bool Ack;
00227 bool ScrollLock;
00228 bool CapsLock;
00229 bool NumLock;
00230 bool Shift;
00231 bool Pause;
00232 bool LeftCtrl;
00233 bool LeftShift;
00234 bool LeftAlt;
00235 bool RightCtrl;
00236 bool RightShift;
00237 bool RightAlt;
00238 KEY_BUFFER KeyBuffer;
00239 OS_EVENT KeyboardEvent;
00240 }KEYBOARD_CONTROL;
00241
00242 extern KEYBOARD_CONTROL KeyboardCtrl;
00243
00244 void KeyboardInit(void);
00245 void KeyboardStop(void);
00246 void KeyboardHandler(void);
00247
00248 U8 KeyboardKeyBufferCheck(void);
00249 U8 KeyboardKeyBufferCheckIsr(void);
00250 void KeyboardKeyBufferPut(U8 Data);
00251 void KeyboardKeyBufferPutIsr(U8 Data);
00252 U8 KeyboardKeyBufferGet(void);
00253
00254 #endif