Rev 7981 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6285 | leency | 1 | #ifndef INCLUDE_KEYBOARD_H |
2 | #define INCLUDE_KEYBOARD_H |
||
3 | |||
4 | //ASCII KEYS |
||
5 | #define ASCII_KEY_BS 008 |
||
6 | #define ASCII_KEY_TAB 009 |
||
7 | #define ASCII_KEY_ENTER 013 |
||
8 | #define ASCII_KEY_ESC 027 |
||
9 | #define ASCII_KEY_DEL 182 |
||
10 | #define ASCII_KEY_INS 185 |
||
11 | #define ASCII_KEY_SPACE 032 |
||
12 | |||
7422 | leency | 13 | #define ASCII_KEY_PLUS 043 |
14 | #define ASCII_KEY_MINUS 045 |
||
15 | #define ASCII_KEY_EQU 061 |
||
16 | |||
6285 | leency | 17 | #define ASCII_KEY_LEFT 176 |
18 | #define ASCII_KEY_RIGHT 179 |
||
19 | #define ASCII_KEY_DOWN 177 |
||
20 | #define ASCII_KEY_UP 178 |
||
21 | #define ASCII_KEY_HOME 180 |
||
22 | #define ASCII_KEY_END 181 |
||
23 | #define ASCII_KEY_PGDN 183 |
||
24 | #define ASCII_KEY_PGUP 184 |
||
25 | |||
26 | //SCAN CODE KEYS |
||
27 | #define SCAN_CODE_BS 014 |
||
28 | #define SCAN_CODE_TAB 015 |
||
29 | #define SCAN_CODE_ENTER 028 |
||
30 | #define SCAN_CODE_ESC 001 |
||
31 | #define SCAN_CODE_DEL 083 |
||
32 | #define SCAN_CODE_INS 082 |
||
33 | #define SCAN_CODE_SPACE 057 |
||
7490 | leency | 34 | #define SCAN_CODE_MENU 093 |
6285 | leency | 35 | |
36 | #define SCAN_CODE_LEFT 075 |
||
37 | #define SCAN_CODE_RIGHT 077 |
||
38 | #define SCAN_CODE_DOWN 080 |
||
39 | #define SCAN_CODE_UP 072 |
||
40 | #define SCAN_CODE_HOME 071 |
||
41 | #define SCAN_CODE_END 079 |
||
42 | #define SCAN_CODE_PGDN 081 |
||
43 | #define SCAN_CODE_PGUP 073 |
||
44 | |||
7153 | leency | 45 | #define SCAN_CODE_MINUS 012 |
46 | #define SCAN_CODE_PLUS 013 |
||
47 | |||
7218 | leency | 48 | #define SCAN_CODE_F1 059 |
7293 | leency | 49 | #define SCAN_CODE_F2 060 |
50 | #define SCAN_CODE_F3 061 |
||
51 | #define SCAN_CODE_F4 062 |
||
52 | #define SCAN_CODE_F5 063 |
||
53 | #define SCAN_CODE_F6 064 |
||
54 | #define SCAN_CODE_F7 065 |
||
55 | #define SCAN_CODE_F8 066 |
||
56 | #define SCAN_CODE_F9 067 |
||
57 | #define SCAN_CODE_F10 068 |
||
7282 | leency | 58 | #define SCAN_CODE_F11 087 |
59 | #define SCAN_CODE_F12 088 |
||
7218 | leency | 60 | |
7628 | leency | 61 | #define SCAN_CODE_1 002 |
62 | #define SCAN_CODE_2 003 |
||
63 | #define SCAN_CODE_3 004 |
||
64 | #define SCAN_CODE_4 005 |
||
65 | #define SCAN_CODE_5 006 |
||
66 | #define SCAN_CODE_6 007 |
||
67 | #define SCAN_CODE_7 008 |
||
68 | #define SCAN_CODE_8 009 |
||
69 | #define SCAN_CODE_9 010 |
||
70 | #define SCAN_CODE_10 011 |
||
71 | |||
7490 | leency | 72 | #define SCAN_CODE_KEY_A 030 |
7260 | leency | 73 | #define SCAN_CODE_KEY_B 048 |
6791 | leency | 74 | #define SCAN_CODE_KEY_C 046 |
7490 | leency | 75 | #define SCAN_CODE_KEY_D 032 |
7218 | leency | 76 | #define SCAN_CODE_KEY_E 018 |
7187 | leency | 77 | #define SCAN_CODE_KEY_F 033 |
7814 | leency | 78 | #define SCAN_CODE_KEY_G 034 |
7742 | leency | 79 | #define SCAN_CODE_KEY_J 036 |
7293 | leency | 80 | #define SCAN_CODE_KEY_H 035 |
7187 | leency | 81 | #define SCAN_CODE_KEY_I 023 |
82 | #define SCAN_CODE_KEY_L 038 |
||
6791 | leency | 83 | #define SCAN_CODE_KEY_M 050 |
7490 | leency | 84 | #define SCAN_CODE_KEY_N 049 |
6791 | leency | 85 | #define SCAN_CODE_KEY_O 024 |
86 | #define SCAN_CODE_KEY_P 025 |
||
7521 | leency | 87 | #define SCAN_CODE_KEY_Q 016 |
7187 | leency | 88 | #define SCAN_CODE_KEY_R 019 |
7192 | leency | 89 | #define SCAN_CODE_KEY_S 031 |
7265 | leency | 90 | #define SCAN_CODE_KEY_T 020 |
7490 | leency | 91 | #define SCAN_CODE_KEY_U 022 |
7248 | leency | 92 | #define SCAN_CODE_KEY_V 047 |
7742 | leency | 93 | #define SCAN_CODE_KEY_W 017 |
7248 | leency | 94 | #define SCAN_CODE_KEY_X 045 |
95 | #define SCAN_CODE_KEY_Y 021 |
||
96 | #define SCAN_CODE_KEY_Z 044 |
||
6791 | leency | 97 | |
7248 | leency | 98 | |
6285 | leency | 99 | #define KEY_LSHIFT 00000000001b |
100 | #define KEY_RSHIFT 00000000010b |
||
101 | #define KEY_LCTRL 00000000100b |
||
102 | #define KEY_RCTRL 00000001000b |
||
103 | #define KEY_LALT 00000010000b |
||
104 | #define KEY_RALT 00000100000b |
||
105 | #define KEY_CAPSLOCK 00001000000b |
||
106 | #define KEY_NUMLOCK 00010000000b |
||
107 | #define KEY_SCROLLLOCK 00100000000b |
||
108 | #define KEY_LWIN 01000000000b |
||
109 | #define KEY_RWIN 10000000000b |
||
110 | |||
6735 | leency | 111 | :unsigned char key_ascii; |
112 | :dword key_scancode, key_modifier, key_editbox; |
||
113 | :int GetKeys() |
||
6285 | leency | 114 | { |
115 | $push edx |
||
116 | GETKEY: |
||
117 | $mov eax,2 |
||
118 | $int 0x40 |
||
119 | $cmp eax,1 |
||
120 | $jne GETKEYI |
||
121 | $mov eax,edx |
||
122 | $jmp GETKEYII |
||
123 | GETKEYI: |
||
124 | $mov edx,eax |
||
125 | $jmp GETKEY |
||
126 | GETKEYII: |
||
127 | $pop edx |
||
6640 | leency | 128 | key_editbox = EAX; |
6285 | leency | 129 | key_ascii = AH; |
130 | $shr eax,16 |
||
131 | key_scancode = AL; |
||
7771 | leency | 132 | key_modifier = GetKeyModifier(); |
133 | EAX = key_editbox; |
||
134 | } |
||
135 | |||
7981 | leency | 136 | inline fastcall byte GetKeyScancode() |
137 | { |
||
138 | $mov eax,2 |
||
139 | $int 0x40 |
||
140 | $shr eax,16 |
||
141 | return AL; |
||
142 | } |
||
143 | |||
7984 | leency | 144 | inline fastcall GetKey() |
145 | { |
||
146 | $mov eax,2 |
||
147 | $int 0x40 |
||
148 | } |
||
149 | |||
7771 | leency | 150 | // ECX is a mode: 1 - scancodes, 0 - ascii |
151 | inline fastcall SetKeyboardMode(ECX) |
||
152 | { |
||
153 | $mov eax,66 |
||
7984 | leency | 154 | $mov ebx,1 |
7771 | leency | 155 | $int 0x40 |
156 | } |
||
157 | |||
158 | //get alt/shift/ctrl key status |
||
159 | inline fastcall dword GetKeyModifier() |
||
160 | { |
||
6285 | leency | 161 | $mov eax,66 |
162 | $mov ebx,3 |
||
163 | $int 0x40 |
||
164 | key_modifier = EAX; |
||
165 | } |
||
166 | |||
167 | #endif |