Rev 1874 | Rev 2288 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1874 | Rev 2171 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line -... | ||
8 | $Revision: 1874 $ |
- | |
9 | - | ||
10 | 8 | $Revision: 2171 $ |
|
11 | ;// mike.dld [ |
9 | |
12 | 10 | ||
13 | VKEY_LSHIFT = 0000000000000001b |
11 | VKEY_LSHIFT = 0000000000000001b |
14 | VKEY_RSHIFT = 0000000000000010b |
12 | VKEY_RSHIFT = 0000000000000010b |
Line 49... | Line 47... | ||
49 | dd hotkey_test2 |
47 | dd hotkey_test2 |
50 | dd hotkey_test3 |
48 | dd hotkey_test3 |
51 | dd hotkey_test4 |
49 | dd hotkey_test4 |
52 | hotkey_tests_num = 5 |
50 | hotkey_tests_num = 5 |
53 | endg |
51 | endg |
54 | - | ||
- | 52 | ;--------------------------------------------------------------------- |
|
55 | hotkey_test0: |
53 | hotkey_test0: |
56 | test al, al |
54 | test al,al |
57 | setz al |
55 | setz al |
58 | ret |
56 | ret |
- | 57 | ;--------------------------------------------------------------------- |
|
59 | hotkey_test1: |
58 | hotkey_test1: |
60 | test al, al |
59 | test al,al |
61 | setnp al |
60 | setnp al |
62 | ret |
61 | ret |
- | 62 | ;--------------------------------------------------------------------- |
|
63 | hotkey_test2: |
63 | hotkey_test2: |
64 | cmp al, 3 |
64 | cmp al,3 |
65 | setz al |
65 | setz al |
66 | ret |
66 | ret |
- | 67 | ;--------------------------------------------------------------------- |
|
67 | hotkey_test3: |
68 | hotkey_test3: |
68 | cmp al, 1 |
69 | cmp al,1 |
69 | setz al |
70 | setz al |
70 | ret |
71 | ret |
- | 72 | ;--------------------------------------------------------------------- |
|
71 | hotkey_test4: |
73 | hotkey_test4: |
72 | cmp al, 2 |
74 | cmp al,2 |
73 | setz al |
75 | setz al |
74 | ret |
76 | ret |
75 | - | ||
- | 77 | ;--------------------------------------------------------------------- |
|
76 | hotkey_do_test: |
78 | hotkey_do_test: |
77 | push eax |
79 | push eax |
78 | mov edx, [kb_state] |
80 | mov edx,[kb_state] |
79 | shr edx, cl |
81 | shr edx,cl |
80 | add cl, cl |
82 | add cl,cl |
81 | mov eax, [eax+4] |
83 | mov eax,[eax+4] |
82 | shr eax, cl |
84 | shr eax,cl |
83 | and eax, 15 |
85 | and eax,15 |
84 | cmp al, hotkey_tests_num |
86 | cmp al,hotkey_tests_num |
85 | jae .fail |
87 | jae .fail |
- | 88 | ||
86 | xchg eax, edx |
89 | xchg eax,edx |
87 | and al, 3 |
90 | and al,3 |
88 | call [hotkey_tests + edx*4] |
91 | call [hotkey_tests + edx*4] |
89 | cmp al, 1 |
92 | cmp al,1 |
90 | pop eax |
93 | pop eax |
91 | ret |
94 | ret |
- | 95 | ;-------------------------------------- |
|
92 | .fail: |
96 | .fail: |
93 | stc |
97 | stc |
94 | pop eax |
98 | pop eax |
95 | ret |
99 | ret |
96 | - | ||
97 | - | ||
- | 100 | ;--------------------------------------------------------------------- |
|
98 | align 4 |
101 | align 4 |
99 | - | ||
100 | set_keyboard_data: |
102 | set_keyboard_data: |
101 | - | ||
102 | movzx eax,word[TASK_COUNT] ; top window process |
103 | movzx eax,word[TASK_COUNT] ; top window process |
103 | movzx eax,word[WIN_POS+eax*2] |
104 | movzx eax,word[WIN_POS+eax*2] |
104 | shl eax,8 |
105 | shl eax,8 |
105 | mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode] |
106 | mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode] |
106 | mov [keyboard_mode],al |
107 | mov [keyboard_mode],al |
Line 107... | Line 108... | ||
107 | 108 | ||
Line 108... | Line -... | ||
108 | mov eax, ecx |
- | |
109 | - | ||
110 | push ebx |
- | |
111 | push esi |
109 | mov eax,ecx |
112 | push edi |
- | |
113 | push ebp |
110 | |
114 | - | ||
115 | call send_scancode |
- | |
116 | - | ||
117 | pop ebp |
- | |
118 | pop edi |
111 | push ebx esi edi ebp |
119 | pop esi |
112 | call send_scancode |
120 | pop ebx |
- | |
- | 113 | pop ebp edi esi ebx |
|
121 | ret |
114 | ret |
122 | 115 | ;--------------------------------------------------------------------- |
|
123 | align 4 |
- | |
124 | irq1: |
116 | align 4 |
125 | 117 | irq1: |
|
126 | movzx eax,word[TASK_COUNT] ; top window process |
118 | movzx eax,word[TASK_COUNT] ; top window process |
127 | movzx eax,word[WIN_POS+eax*2] |
119 | movzx eax,word[WIN_POS+eax*2] |
128 | shl eax,8 |
120 | shl eax,8 |
Line 129... | Line 121... | ||
129 | mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode] |
121 | mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode] |
130 | mov [keyboard_mode],al |
- | |
- | 122 | mov [keyboard_mode],al |
|
131 | 123 | ||
132 | in al,0x60 |
- | |
133 | 124 | in al,0x60 |
|
134 | send_scancode: |
- | |
135 | 125 | ;-------------------------------------- |
|
136 | mov [keyboard_data],al |
126 | send_scancode: |
137 | 127 | mov [keyboard_data],al |
|
138 | ; ch = scancode |
128 | ; ch = scancode |
139 | ; cl = ext_code |
129 | ; cl = ext_code |
140 | ; bh = 0 - normal key |
- | |
141 | ; bh = 1 - modifier (Shift/Ctrl/Alt) |
130 | ; bh = 0 - normal key |
142 | ; bh = 2 - extended code |
131 | ; bh = 1 - modifier (Shift/Ctrl/Alt) |
143 | 132 | ; bh = 2 - extended code |
|
- | 133 | mov ch,al |
|
144 | mov ch,al |
134 | cmp al,0xE0 |
145 | cmp al,0xE0 |
135 | je @f |
146 | je @f |
136 | |
147 | cmp al,0xE1 |
137 | cmp al,0xE1 |
148 | jne .normal_code |
138 | jne .normal_code |
149 | @@: |
139 | @@: |
- | 140 | mov bh,2 |
|
150 | mov bh, 2 |
141 | mov [ext_code],al |
151 | mov [ext_code], al |
142 | jmp .writekey |
152 | jmp .writekey |
143 | ;-------------------------------------- |
153 | .normal_code: |
144 | .normal_code: |
154 | mov cl, 0 |
145 | mov cl,0 |
- | 146 | xchg cl,[ext_code] |
|
155 | xchg cl, [ext_code] |
147 | and al,0x7F |
156 | and al,0x7F |
148 | mov bh,1 |
- | 149 | @@: |
|
157 | mov bh, 1 |
150 | cmp al,0x2A |
158 | @@: cmp al,0x2A |
151 | jne @f |
- | 152 | ||
159 | jne @f |
153 | cmp cl,0xE0 |
160 | cmp cl,0xE0 |
154 | je .writekey |
- | 155 | ||
- | 156 | mov eax,VKEY_LSHIFT |
|
161 | je .writekey |
157 | jmp .modifier |
162 | mov eax,VKEY_LSHIFT |
158 | ;-------------------------------------- |
- | 159 | @@: |
|
163 | jmp .modifier |
160 | cmp al,0x36 |
164 | @@: cmp al,0x36 |
161 | jne @f |
- | 162 | ||
165 | jne @f |
163 | cmp cl,0xE0 |
166 | cmp cl,0xE0 |
164 | je .writekey |
- | 165 | ||
- | 166 | mov eax,VKEY_RSHIFT |
|
167 | je .writekey |
167 | jmp .modifier |
168 | mov eax,VKEY_RSHIFT |
168 | ;-------------------------------------- |
- | 169 | @@: |
|
169 | jmp .modifier |
170 | cmp al,0x38 |
170 | @@: cmp al,0x38 |
171 | jne @f |
171 | jne @f |
172 | |
- | 173 | mov eax,VKEY_LALT |
|
172 | mov eax, VKEY_LALT |
174 | test cl,cl |
173 | test cl, cl |
175 | jz .modifier |
- | 176 | ||
- | 177 | mov al,VKEY_RALT |
|
174 | jz .modifier |
178 | jmp .modifier |
175 | mov al, VKEY_RALT |
179 | ;-------------------------------------- |
- | 180 | @@: |
|
176 | jmp .modifier |
181 | cmp al,0x1D |
177 | @@: cmp al,0x1D |
182 | jne @f |
178 | jne @f |
183 | |
- | 184 | mov eax,VKEY_LCONTROL |
|
179 | mov eax, VKEY_LCONTROL |
185 | test cl,cl |
180 | test cl, cl |
186 | jz .modifier |
181 | jz .modifier |
187 | |
- | 188 | mov al,VKEY_RCONTROL |
|
182 | mov al, VKEY_RCONTROL |
189 | cmp cl,0xE0 |
183 | cmp cl, 0xE0 |
190 | jz .modifier |
- | 191 | ||
- | 192 | mov [ext_code],cl |
|
184 | jz .modifier |
193 | jmp .writekey |
185 | mov [ext_code], cl |
194 | ;-------------------------------------- |
- | 195 | @@: |
|
186 | jmp .writekey |
196 | cmp al,0x3A |
187 | @@: cmp al,0x3A |
197 | jne @f |
188 | jne @f |
198 | |
- | 199 | mov bl,4 |
|
- | 200 | mov eax,VKEY_CAPSLOCK |
|
189 | mov bl,4 |
201 | jmp .no_key.xor |
190 | mov eax,VKEY_CAPSLOCK |
202 | ;-------------------------------------- |
191 | jmp .no_key.xor |
203 | @@: |
192 | @@: cmp al,0x45 |
204 | cmp al,0x45 |
- | 205 | jne @f |
|
193 | jne @f |
206 | test cl,cl |
194 | test cl, cl |
207 | jnz .writekey |
195 | jnz .writekey |
208 | |
- | 209 | mov bl,2 |
|
- | 210 | mov eax,VKEY_NUMLOCK |
|
196 | mov bl,2 |
211 | jmp .no_key.xor |
197 | mov eax,VKEY_NUMLOCK |
212 | ;-------------------------------------- |
- | 213 | @@: |
|
198 | jmp .no_key.xor |
214 | cmp al,0x46 |
199 | @@: cmp al,0x46 |
215 | jne @f |
200 | jne @f |
216 | |
- | 217 | mov bl,1 |
|
201 | mov bl,1 |
218 | mov eax,VKEY_SCRLOCK |
202 | mov eax,VKEY_SCRLOCK |
219 | jmp .no_key.xor |
203 | jmp .no_key.xor |
220 | ;-------------------------------------- |
204 | @@: |
221 | @@: |
- | 222 | xor ebx,ebx |
|
205 | xor ebx,ebx |
223 | test ch,ch |
206 | test ch,ch |
224 | js .writekey |
207 | js .writekey |
225 | |
208 | movzx eax,ch ; plain key |
226 | movzx eax,ch ; plain key |
209 | mov bl,[keymap+eax] |
227 | mov bl,[keymap+eax] |
- | 228 | mov edx,[kb_state] |
|
210 | mov edx,[kb_state] |
229 | test dl,VKEY_CONTROL ; ctrl alt del |
211 | test dl,VKEY_CONTROL ; ctrl alt del |
230 | jz .noctrlaltdel |
- | 231 | ||
212 | jz .noctrlaltdel |
232 | test dl,VKEY_ALT |
213 | test dl,VKEY_ALT |
233 | jz .noctrlaltdel |
- | 234 | ||
214 | jz .noctrlaltdel |
235 | cmp ch,53h |
215 | cmp ch,53h |
236 | jne .noctrlaltdel |
216 | jne .noctrlaltdel |
237 | |
217 | mov [ctrl_alt_del],1 |
238 | mov [ctrl_alt_del],1 |
- | 239 | .noctrlaltdel: |
|
218 | .noctrlaltdel: |
240 | test dl,VKEY_CONTROL ; ctrl on ? |
- | 241 | jz @f |
|
- | 242 | ||
- | 243 | sub bl,0x60 |
|
- | 244 | @@: |
|
219 | test dl,VKEY_CONTROL ; ctrl on ? |
245 | test dl,VKEY_CAPSLOCK ; caps lock on ? |
- | 246 | jz .no_caps_lock |
|
- | 247 | ||
- | 248 | test dl,VKEY_SHIFT ; shift on ? |
|
- | 249 | jz .keymap_shif |
|
- | 250 | ||
- | 251 | jmp @f |
|
220 | jz @f |
252 | ;-------------------------------------- |
- | 253 | .no_caps_lock: |
|
221 | sub bl,0x60 |
254 | test dl,VKEY_SHIFT ; shift on ? |
- | 255 | jz @f |
|
222 | @@: test dl,VKEY_SHIFT ; shift on ? |
256 | .keymap_shif: |
223 | jz @f |
257 | mov bl,[keymap_shift+eax] |
- | 258 | @@: |
|
224 | mov bl,[keymap_shift+eax] |
259 | test dl,VKEY_ALT ; alt on ? |
225 | @@: test dl,VKEY_ALT ; alt on ? |
260 | jz @f |
226 | jz @f |
261 | |
- | 262 | mov bl,[keymap_alt+eax] |
|
227 | mov bl,[keymap_alt+eax] |
263 | @@: |
228 | @@: |
264 | jmp .writekey |
229 | jmp .writekey |
265 | ;-------------------------------------- |
230 | .modifier: |
266 | .modifier: |
231 | test ch, ch |
267 | test ch, ch |
- | 268 | js .modifier.up |
|
232 | js .modifier.up |
269 | or [kb_state],eax |
233 | or [kb_state], eax |
270 | jmp .writekey |
234 | jmp .writekey |
271 | ;-------------------------------------- |
235 | .modifier.up: |
272 | .modifier.up: |
- | 273 | not eax |
|
236 | not eax |
274 | and [kb_state],eax |
237 | and [kb_state], eax |
275 | jmp .writekey |
238 | jmp .writekey |
276 | ;-------------------------------------- |
239 | .no_key.xor: |
277 | .no_key.xor: |
- | 278 | mov bh,0 |
|
240 | mov bh, 0 |
279 | test ch,ch |
241 | test ch, ch |
280 | js .writekey |
242 | js .writekey |
281 | |
243 | xor [kb_state], eax |
- | |
244 | xor [kb_lights], bl |
282 | xor [kb_state],eax |
245 | call set_lights |
283 | xor [kb_lights],bl |
246 | 284 | call set_lights |
|
247 | .writekey: |
285 | .writekey: |
248 | ; test for system hotkeys |
286 | ; test for system hotkeys |
249 | movzx eax, ch |
287 | movzx eax,ch |
- | 288 | cmp bh,1 |
|
250 | cmp bh, 1 |
289 | ja .nohotkey |
251 | ja .nohotkey |
290 | jb @f |
252 | jb @f |
291 | |
253 | xor eax, eax |
292 | xor eax,eax |
254 | @@: |
293 | @@: |
255 | mov eax, [hotkey_scancodes + eax*4] |
294 | mov eax, [hotkey_scancodes + eax*4] |
- | 295 | .hotkey_loop: |
|
256 | .hotkey_loop: |
296 | test eax, eax |
257 | test eax, eax |
297 | jz .nohotkey |
258 | jz .nohotkey |
298 | |
- | 299 | mov cl,0 |
|
259 | mov cl, 0 |
300 | call hotkey_do_test |
260 | call hotkey_do_test |
301 | jc .hotkey_cont |
261 | jc .hotkey_cont |
302 | |
- | 303 | mov cl,2 |
|
262 | mov cl, 2 |
304 | call hotkey_do_test |
263 | call hotkey_do_test |
305 | jc .hotkey_cont |
264 | jc .hotkey_cont |
306 | |
265 | mov cl, 4 |
307 | mov cl,4 |
266 | call hotkey_do_test |
308 | call hotkey_do_test |
267 | jnc .hotkey_found |
309 | jnc .hotkey_found |
- | 310 | .hotkey_cont: |
|
268 | .hotkey_cont: |
311 | mov eax,[eax] |
269 | mov eax, [eax] |
312 | jmp .hotkey_loop |
270 | jmp .hotkey_loop |
313 | ;-------------------------------------- |
271 | .hotkey_found: |
314 | .hotkey_found: |
272 | mov eax, [eax+8] |
315 | mov eax,[eax+8] |
273 | ; put key in buffer for process in slot eax |
316 | ; put key in buffer for process in slot eax |
274 | mov edi, hotkey_buffer |
317 | mov edi,hotkey_buffer |
- | 318 | @@: |
|
275 | @@: |
319 | cmp dword [edi],0 |
276 | cmp dword [edi], 0 |
320 | jz .found_free |
277 | jz .found_free |
321 | |
278 | add edi, 8 |
322 | add edi,8 |
279 | cmp edi, hotkey_buffer+120*8 |
323 | cmp edi,hotkey_buffer+120*8 |
280 | jb @b |
324 | jb @b |
281 | ; no free space - replace first entry |
325 | ; no free space - replace first entry |
282 | mov edi, hotkey_buffer |
326 | mov edi,hotkey_buffer |
283 | .found_free: |
327 | .found_free: |
284 | mov [edi], eax |
328 | mov [edi],eax |
- | 329 | movzx eax,ch |
|
285 | movzx eax, ch |
330 | cmp bh,1 |
286 | cmp bh, 1 |
331 | jnz @f |
287 | jnz @f |
332 | |
288 | xor eax, eax |
333 | xor eax, eax |
289 | @@: |
334 | @@: |
290 | mov [edi+4], ax |
335 | mov [edi+4],ax |
- | 336 | mov eax,[kb_state] |
|
291 | mov eax, [kb_state] |
337 | mov [edi+6],ax |
292 | mov [edi+6], ax |
338 | jmp .exit.irq1 |
293 | jmp .exit.irq1 |
339 | ;-------------------------------------- |
- | 340 | .nohotkey: |
|
294 | .nohotkey: |
341 | cmp [keyboard_mode],0 ; return from keymap |
295 | cmp [keyboard_mode],0 ; return from keymap |
342 | jne .scancode |
- | 343 | ||
296 | jne .scancode |
344 | test bh,bh |
297 | test bh, bh |
345 | jnz .exit.irq1 |
Line 298... | Line -... | ||
298 | jnz .exit.irq1 |
- | |
299 | test bl, bl |
346 | |
300 | jz .exit.irq1 |
347 | test bl,bl |
- | 348 | jz .exit.irq1 |
|
301 | 349 | ||
302 | ;.........................Part1 Start.......Code by Rus, optimize by Ghost................................... |
350 | test [kb_state],VKEY_NUMLOCK |
Line 303... | Line 351... | ||
303 | test [kb_state], VKEY_NUMLOCK |
351 | jz .dowrite |
304 | jz .dowrite |
352 | |
- | 353 | cmp cl,0xE0 |
|
305 | cmp cl, 0xE0 |
354 | jz .dowrite |
306 | jz .dowrite |
355 | |
- | 356 | cmp ch,55 |
|
307 | 357 | jnz @f |
|
308 | cmp ch, 55 |
358 | |
309 | jnz @f |
359 | mov bl,0x2A ;* |
- | 360 | jmp .dowrite |
|
310 | mov bl, 0x2A ;* |
361 | ;-------------------------------------- |
311 | jmp .dowrite |
362 | @@: |
312 | @@: |
363 | cmp ch,71 |
313 | cmp ch, 71 |
364 | jb .dowrite |
314 | jb .dowrite |
365 | |
315 | cmp ch, 83 |
- | |
316 | ja .dowrite |
- | |
317 | ;push eax |
- | |
318 | movzx eax, ch |
- | |
319 | mov bl, [numlock_map + eax - 71] |
366 | cmp ch,83 |
- | 367 | ja .dowrite |
|
320 | ;pop eax |
368 | |
321 | 369 | movzx eax, ch |
|
322 | ;.........................Part1 End................................................. |
370 | mov bl,[numlock_map + eax - 71] |
323 | 371 | jmp .dowrite |
|
324 | jmp .dowrite |
372 | ;-------------------------------------- |
325 | .scancode: |
373 | .scancode: |
326 | mov bl, ch |
374 | mov bl,ch |
327 | .dowrite: |
375 | .dowrite: |
328 | movzx eax,byte[KEY_COUNT] |
376 | movzx eax,byte[KEY_COUNT] |
329 | cmp al,120 |
- | |
330 | jae .exit.irq1 |
377 | cmp al,120 |
331 | inc eax |
378 | jae .exit.irq1 |
332 | mov [KEY_COUNT],al |
- | |
333 | mov [KEY_COUNT+eax],bl |
379 | inc eax |
334 | - | ||
- | 380 | mov [KEY_COUNT],al |
|
335 | .exit.irq1: |
381 | mov [KEY_COUNT+eax],bl |
336 | mov [check_idle_semaphore],5 |
382 | .exit.irq1: |
337 | 383 | mov [check_idle_semaphore],5 |
|
338 | ret |
384 | ret |
339 | 385 | ;--------------------------------------------------------------------- |
|
340 | set_lights: |
386 | set_lights: |
341 | mov al,0xED |
- | |
342 | call kb_write |
- | |
343 | mov al,[kb_lights] |
387 | mov al,0xED |
344 | call kb_write |
388 | call kb_write |
345 | ret |
389 | mov al,[kb_lights] |
346 | 390 | call kb_write |
|
347 | ;// mike.dld ] |
391 | ret |
348 | ;..........................Part2 Start.......Code by Rus....................................... |
392 | ;--------------------------------------------------------------------- |
Line 358... | Line 402... | ||
358 | db 0x31 ;Num 1 |
402 | db 0x31 ;Num 1 |
359 | db 0x32 ;Num 2 |
403 | db 0x32 ;Num 2 |
360 | db 0x33 ;Num 3 |
404 | db 0x33 ;Num 3 |
361 | db 0x30 ;Num 0 |
405 | db 0x30 ;Num 0 |
362 | db 0x2E ;Num . |
406 | db 0x2E ;Num . |
363 | ;..........................Part2 End................................................ |
407 | ;--------------------------------------------------------------------- |