Rev 1161 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1159 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
||
5 | ;; Distributed under terms of the GNU General Public License ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
1206 | hidnplayr | 8 | $Revision: 1206 $ |
1159 | hidnplayr | 9 | |
10 | |||
11 | ;// mike.dld [ |
||
12 | |||
13 | VKEY_LSHIFT = 0000000000000001b |
||
14 | VKEY_RSHIFT = 0000000000000010b |
||
15 | VKEY_LCONTROL = 0000000000000100b |
||
16 | VKEY_RCONTROL = 0000000000001000b |
||
17 | VKEY_LALT = 0000000000010000b |
||
18 | VKEY_RALT = 0000000000100000b |
||
19 | VKEY_CAPSLOCK = 0000000001000000b |
||
20 | VKEY_NUMLOCK = 0000000010000000b |
||
21 | VKEY_SCRLOCK = 0000000100000000b |
||
22 | |||
23 | VKEY_SHIFT = 0000000000000011b |
||
24 | VKEY_CONTROL = 0000000000001100b |
||
25 | VKEY_ALT = 0000000000110000b |
||
26 | |||
27 | uglobal |
||
28 | align 4 |
||
29 | kb_state dd 0 |
||
30 | ext_code db 0 |
||
31 | |||
32 | keyboard_mode db 0 |
||
33 | keyboard_data db 0 |
||
34 | |||
35 | altmouseb db 0 |
||
36 | ctrl_alt_del db 0 |
||
37 | |||
38 | kb_lights db 0 |
||
39 | |||
40 | align 4 |
||
41 | hotkey_scancodes rd 256 ; we have 256 scancodes |
||
42 | hotkey_list rd 256*4 ; max 256 defined hotkeys |
||
43 | hotkey_buffer rd 120*2 ; buffer for 120 hotkeys |
||
44 | endg |
||
45 | |||
46 | iglobal |
||
47 | hotkey_tests dd hotkey_test0 |
||
48 | dd hotkey_test1 |
||
49 | dd hotkey_test2 |
||
50 | dd hotkey_test3 |
||
51 | dd hotkey_test4 |
||
52 | hotkey_tests_num = 5 |
||
53 | endg |
||
54 | |||
55 | hotkey_test0: |
||
56 | test al, al |
||
57 | setz al |
||
58 | ret |
||
59 | hotkey_test1: |
||
60 | test al, al |
||
61 | setnp al |
||
62 | ret |
||
63 | hotkey_test2: |
||
64 | cmp al, 3 |
||
65 | setz al |
||
66 | ret |
||
67 | hotkey_test3: |
||
68 | cmp al, 1 |
||
69 | setz al |
||
70 | ret |
||
71 | hotkey_test4: |
||
72 | cmp al, 2 |
||
73 | setz al |
||
74 | ret |
||
75 | |||
76 | hotkey_do_test: |
||
77 | push eax |
||
78 | mov edx, [kb_state] |
||
79 | shr edx, cl |
||
80 | add cl, cl |
||
81 | mov eax, [eax+4] |
||
82 | shr eax, cl |
||
83 | and eax, 15 |
||
84 | cmp al, hotkey_tests_num |
||
85 | jae .fail |
||
86 | xchg eax, edx |
||
87 | and al, 3 |
||
88 | call [hotkey_tests + edx*4] |
||
89 | cmp al, 1 |
||
90 | pop eax |
||
91 | ret |
||
92 | .fail: |
||
93 | stc |
||
94 | pop eax |
||
95 | ret |
||
96 | |||
97 | align 4 |
||
98 | irq1: |
||
99 | ; save_ring3_context |
||
100 | ; mov ax, os_data |
||
101 | ; mov ds, ax |
||
102 | ; mov es, ax |
||
103 | |||
104 | movzx eax,word[TASK_COUNT] ; top window process |
||
105 | movzx eax,word[WIN_POS+eax*2] |
||
106 | shl eax,8 |
||
107 | mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode] |
||
108 | mov [keyboard_mode],al |
||
109 | |||
110 | in al,0x60 |
||
111 | mov [keyboard_data],al |
||
112 | |||
113 | ; ch = scancode |
||
114 | ; cl = ext_code |
||
115 | ; bh = 0 - normal key |
||
116 | ; bh = 1 - modifier (Shift/Ctrl/Alt) |
||
117 | ; bh = 2 - extended code |
||
118 | |||
119 | mov ch,al |
||
120 | cmp al,0xE0 |
||
121 | je @f |
||
122 | cmp al,0xE1 |
||
123 | jne .normal_code |
||
124 | @@: |
||
125 | mov bh, 2 |
||
126 | mov [ext_code], al |
||
127 | jmp .writekey |
||
128 | .normal_code: |
||
129 | mov cl, 0 |
||
130 | xchg cl, [ext_code] |
||
131 | and al,0x7F |
||
132 | mov bh, 1 |
||
133 | @@: cmp al,0x2A |
||
134 | jne @f |
||
135 | cmp cl,0xE0 |
||
136 | je .writekey |
||
137 | mov eax,VKEY_LSHIFT |
||
138 | jmp .modifier |
||
139 | @@: cmp al,0x36 |
||
140 | jne @f |
||
141 | cmp cl,0xE0 |
||
142 | je .writekey |
||
143 | mov eax,VKEY_RSHIFT |
||
144 | jmp .modifier |
||
145 | @@: cmp al,0x38 |
||
146 | jne @f |
||
147 | mov eax, VKEY_LALT |
||
148 | test cl, cl |
||
149 | jz .modifier |
||
150 | mov al, VKEY_RALT |
||
151 | jmp .modifier |
||
152 | @@: cmp al,0x1D |
||
153 | jne @f |
||
154 | mov eax, VKEY_LCONTROL |
||
155 | test cl, cl |
||
156 | jz .modifier |
||
157 | mov al, VKEY_RCONTROL |
||
158 | cmp cl, 0xE0 |
||
159 | jz .modifier |
||
160 | mov [ext_code], cl |
||
161 | jmp .writekey |
||
162 | @@: cmp al,0x3A |
||
163 | jne @f |
||
164 | mov bl,4 |
||
165 | mov eax,VKEY_CAPSLOCK |
||
166 | jmp .no_key.xor |
||
167 | @@: cmp al,0x45 |
||
168 | jne @f |
||
169 | test cl, cl |
||
170 | jnz .writekey |
||
171 | mov bl,2 |
||
172 | mov eax,VKEY_NUMLOCK |
||
173 | jmp .no_key.xor |
||
174 | @@: cmp al,0x46 |
||
175 | jne @f |
||
176 | mov bl,1 |
||
177 | mov eax,VKEY_SCRLOCK |
||
178 | jmp .no_key.xor |
||
179 | @@: |
||
180 | test ch,ch |
||
181 | js .writekey |
||
182 | movzx eax,ch ; plain key |
||
183 | mov bl,[keymap+eax] |
||
184 | mov edx,[kb_state] |
||
185 | test dl,VKEY_CONTROL ; ctrl alt del |
||
186 | jz .noctrlaltdel |
||
187 | test dl,VKEY_ALT |
||
188 | jz .noctrlaltdel |
||
189 | cmp ch,53h |
||
190 | jne .noctrlaltdel |
||
191 | mov [ctrl_alt_del],1 |
||
192 | .noctrlaltdel: |
||
193 | test dl,VKEY_CONTROL ; ctrl on ? |
||
194 | jz @f |
||
195 | sub bl,0x60 |
||
196 | @@: test dl,VKEY_SHIFT ; shift on ? |
||
197 | jz @f |
||
198 | mov bl,[keymap_shift+eax] |
||
199 | @@: test dl,VKEY_ALT ; alt on ? |
||
200 | jz @f |
||
201 | mov bl,[keymap_alt+eax] |
||
202 | @@: |
||
203 | mov bh, 0 |
||
204 | jmp .writekey |
||
205 | .modifier: |
||
206 | test ch, ch |
||
207 | js .modifier.up |
||
208 | or [kb_state], eax |
||
209 | jmp .writekey |
||
210 | .modifier.up: |
||
211 | not eax |
||
212 | and [kb_state], eax |
||
213 | jmp .writekey |
||
214 | .no_key.xor: |
||
215 | mov bh, 0 |
||
216 | test ch, ch |
||
217 | js .writekey |
||
218 | xor [kb_state], eax |
||
219 | xor [kb_lights], bl |
||
220 | call set_lights |
||
221 | |||
222 | .writekey: |
||
223 | ; test for system hotkeys |
||
224 | movzx eax, ch |
||
225 | cmp bh, 1 |
||
226 | ja .nohotkey |
||
227 | jb @f |
||
228 | xor eax, eax |
||
229 | @@: |
||
230 | mov eax, [hotkey_scancodes + eax*4] |
||
231 | .hotkey_loop: |
||
232 | test eax, eax |
||
233 | jz .nohotkey |
||
234 | mov cl, 0 |
||
235 | call hotkey_do_test |
||
236 | jc .hotkey_cont |
||
237 | mov cl, 2 |
||
238 | call hotkey_do_test |
||
239 | jc .hotkey_cont |
||
240 | mov cl, 4 |
||
241 | call hotkey_do_test |
||
242 | jnc .hotkey_found |
||
243 | .hotkey_cont: |
||
244 | mov eax, [eax] |
||
245 | jmp .hotkey_loop |
||
246 | .hotkey_found: |
||
247 | mov eax, [eax+8] |
||
248 | ; put key in buffer for process in slot eax |
||
249 | mov edi, hotkey_buffer |
||
250 | @@: |
||
251 | cmp dword [edi], 0 |
||
252 | jz .found_free |
||
253 | add edi, 8 |
||
254 | cmp edi, hotkey_buffer+120*8 |
||
255 | jb @b |
||
256 | ; no free space - replace first entry |
||
257 | mov edi, hotkey_buffer |
||
258 | .found_free: |
||
259 | mov [edi], eax |
||
260 | movzx eax, ch |
||
261 | cmp bh, 1 |
||
262 | jnz @f |
||
263 | xor eax, eax |
||
264 | @@: |
||
265 | mov [edi+4], ax |
||
266 | mov eax, [kb_state] |
||
267 | mov [edi+6], ax |
||
268 | jmp .exit.irq1 |
||
269 | .nohotkey: |
||
270 | cmp [keyboard_mode],0 ; return from keymap |
||
271 | jne .scancode |
||
272 | test bh, bh |
||
273 | jnz .exit.irq1 |
||
274 | test bl, bl |
||
275 | jz .exit.irq1 |
||
276 | |||
277 | ;.........................Part1 Start.......Code by Rus, optimize by Ghost................................... |
||
278 | test [kb_state], VKEY_NUMLOCK |
||
279 | jz .dowrite |
||
280 | cmp cl, 0xE0 |
||
281 | jz .dowrite |
||
282 | |||
283 | cmp ch, 55 |
||
284 | jnz @f |
||
285 | mov bl, 0x2A ;* |
||
286 | jmp .dowrite |
||
287 | @@: |
||
288 | cmp ch, 71 |
||
289 | jb .dowrite |
||
290 | cmp ch, 83 |
||
291 | ja .dowrite |
||
292 | ;push eax |
||
293 | movzx eax, ch |
||
294 | mov bl, [numlock_map + eax - 71] |
||
295 | ;pop eax |
||
296 | |||
297 | ;.........................Part1 End................................................. |
||
298 | |||
299 | jmp .dowrite |
||
300 | .scancode: |
||
301 | mov bl, ch |
||
302 | .dowrite: |
||
303 | movzx eax,byte[KEY_COUNT] |
||
304 | cmp al,120 |
||
305 | jae .exit.irq1 |
||
306 | inc eax |
||
307 | mov [KEY_COUNT],al |
||
308 | mov [KEY_COUNT+eax],bl |
||
309 | |||
310 | .exit.irq1: |
||
311 | mov [check_idle_semaphore],5 |
||
312 | |||
313 | ; mov al,0x20 ; ready for next irq |
||
314 | ; out 0x20,al |
||
315 | |||
316 | ; restore_ring3_context |
||
317 | ; iret |
||
318 | ret |
||
319 | |||
320 | set_lights: |
||
321 | mov al,0xED |
||
322 | call kb_write |
||
323 | mov al,[kb_lights] |
||
324 | call kb_write |
||
325 | ret |
||
326 | |||
327 | ;// mike.dld ] |
||
328 | ;..........................Part2 Start.......Code by Rus....................................... |
||
329 | numlock_map: |
||
330 | db 0x37 ;Num 7 |
||
331 | db 0x38 ;Num 8 |
||
332 | db 0x39 ;Num 9 |
||
333 | db 0x2D ;Num - |
||
334 | db 0x34 ;Num 4 |
||
335 | db 0x35 ;Num 5 |
||
336 | db 0x36 ;Num 6 |
||
337 | db 0x2B ;Num + |
||
338 | db 0x31 ;Num 1 |
||
339 | db 0x32 ;Num 2 |
||
340 | db 0x33 ;Num 3 |
||
341 | db 0x30 ;Num 0 |
||
342 | db 0x2E ;Num . |
||
343 | ;..........................Part2 End................................................ |