2007-03-26 16:18:08 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
|
|
|
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2007-07-27 17:52:03 +04:00
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
2005-10-06 21:56:22 +04:00
|
|
|
;// mike.dld [
|
|
|
|
|
|
|
|
VKEY_LSHIFT = 0000000000000001b
|
|
|
|
VKEY_RSHIFT = 0000000000000010b
|
|
|
|
VKEY_LCONTROL = 0000000000000100b
|
|
|
|
VKEY_RCONTROL = 0000000000001000b
|
|
|
|
VKEY_LALT = 0000000000010000b
|
|
|
|
VKEY_RALT = 0000000000100000b
|
|
|
|
VKEY_CAPSLOCK = 0000000001000000b
|
|
|
|
VKEY_NUMLOCK = 0000000010000000b
|
|
|
|
VKEY_SCRLOCK = 0000000100000000b
|
|
|
|
|
|
|
|
VKEY_SHIFT = 0000000000000011b
|
|
|
|
VKEY_CONTROL = 0000000000001100b
|
|
|
|
VKEY_ALT = 0000000000110000b
|
|
|
|
|
|
|
|
uglobal
|
|
|
|
align 4
|
2007-07-17 00:21:34 +04:00
|
|
|
kb_state dd 0
|
|
|
|
ext_code db 0
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
keyboard_mode db 0
|
|
|
|
keyboard_data db 0
|
|
|
|
|
2007-07-17 00:21:34 +04:00
|
|
|
altmouseb db 0
|
|
|
|
ctrl_alt_del db 0
|
2005-10-06 21:56:22 +04:00
|
|
|
|
2007-07-17 00:21:34 +04:00
|
|
|
kb_lights db 0
|
2006-06-30 16:23:15 +04:00
|
|
|
|
|
|
|
align 4
|
2007-07-17 00:21:34 +04:00
|
|
|
hotkey_scancodes rd 256 ; we have 256 scancodes
|
|
|
|
hotkey_list rd 256*4 ; max 256 defined hotkeys
|
|
|
|
hotkey_buffer rd 120*2 ; buffer for 120 hotkeys
|
2006-06-30 16:23:15 +04:00
|
|
|
endg
|
|
|
|
|
|
|
|
iglobal
|
2007-07-17 00:21:34 +04:00
|
|
|
hotkey_tests dd hotkey_test0
|
|
|
|
dd hotkey_test1
|
|
|
|
dd hotkey_test2
|
|
|
|
dd hotkey_test3
|
|
|
|
dd hotkey_test4
|
2006-06-30 16:23:15 +04:00
|
|
|
hotkey_tests_num = 5
|
2005-10-06 21:56:22 +04:00
|
|
|
endg
|
|
|
|
|
2006-06-30 16:23:15 +04:00
|
|
|
hotkey_test0:
|
2007-07-17 00:21:34 +04:00
|
|
|
test al, al
|
|
|
|
setz al
|
|
|
|
ret
|
2006-06-30 16:23:15 +04:00
|
|
|
hotkey_test1:
|
2007-07-17 00:21:34 +04:00
|
|
|
test al, al
|
|
|
|
setnp al
|
|
|
|
ret
|
2006-06-30 16:23:15 +04:00
|
|
|
hotkey_test2:
|
2007-07-17 00:21:34 +04:00
|
|
|
cmp al, 3
|
|
|
|
setz al
|
|
|
|
ret
|
2006-06-30 16:23:15 +04:00
|
|
|
hotkey_test3:
|
2007-07-17 00:21:34 +04:00
|
|
|
cmp al, 1
|
|
|
|
setz al
|
|
|
|
ret
|
2006-06-30 16:23:15 +04:00
|
|
|
hotkey_test4:
|
2007-07-17 00:21:34 +04:00
|
|
|
cmp al, 2
|
|
|
|
setz al
|
|
|
|
ret
|
2006-06-30 16:23:15 +04:00
|
|
|
|
|
|
|
hotkey_do_test:
|
2007-07-17 00:21:34 +04:00
|
|
|
push eax
|
|
|
|
mov edx, [kb_state]
|
|
|
|
shr edx, cl
|
|
|
|
add cl, cl
|
|
|
|
mov eax, [eax+4]
|
|
|
|
shr eax, cl
|
|
|
|
and eax, 15
|
|
|
|
cmp al, hotkey_tests_num
|
|
|
|
jae .fail
|
|
|
|
xchg eax, edx
|
|
|
|
and al, 3
|
|
|
|
call [hotkey_tests + edx*4]
|
|
|
|
cmp al, 1
|
|
|
|
pop eax
|
|
|
|
ret
|
2006-06-30 16:23:15 +04:00
|
|
|
.fail:
|
2007-07-17 00:21:34 +04:00
|
|
|
stc
|
|
|
|
pop eax
|
|
|
|
ret
|
2006-06-30 16:23:15 +04:00
|
|
|
|
2005-10-06 21:56:22 +04:00
|
|
|
align 4
|
|
|
|
irq1:
|
2006-10-06 10:09:41 +04:00
|
|
|
; save_ring3_context
|
|
|
|
; mov ax, os_data
|
|
|
|
; mov ds, ax
|
|
|
|
; mov es, ax
|
2005-10-06 21:56:22 +04:00
|
|
|
|
2007-02-28 11:52:06 +03:00
|
|
|
movzx eax,word[TASK_COUNT] ; top window process
|
2007-02-28 13:51:05 +03:00
|
|
|
movzx eax,word[WIN_POS+eax*2]
|
2005-10-06 21:56:22 +04:00
|
|
|
shl eax,8
|
2007-02-28 13:51:05 +03:00
|
|
|
mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode]
|
2005-10-06 21:56:22 +04:00
|
|
|
mov [keyboard_mode],al
|
|
|
|
|
|
|
|
in al,0x60
|
|
|
|
mov [keyboard_data],al
|
|
|
|
|
2006-06-30 16:23:15 +04:00
|
|
|
; ch = scancode
|
|
|
|
; cl = ext_code
|
|
|
|
; bh = 0 - normal key
|
|
|
|
; bh = 1 - modifier (Shift/Ctrl/Alt)
|
|
|
|
; bh = 2 - extended code
|
|
|
|
|
2005-10-06 21:56:22 +04:00
|
|
|
mov ch,al
|
|
|
|
cmp al,0xE0
|
|
|
|
je @f
|
|
|
|
cmp al,0xE1
|
|
|
|
jne .normal_code
|
2006-06-30 16:23:15 +04:00
|
|
|
@@:
|
2007-07-17 00:21:34 +04:00
|
|
|
mov bh, 2
|
|
|
|
mov [ext_code], al
|
|
|
|
jmp .writekey
|
2005-10-06 21:56:22 +04:00
|
|
|
.normal_code:
|
2007-07-17 00:21:34 +04:00
|
|
|
mov cl, 0
|
|
|
|
xchg cl, [ext_code]
|
2005-10-06 21:56:22 +04:00
|
|
|
and al,0x7F
|
2007-07-17 00:21:34 +04:00
|
|
|
mov bh, 1
|
2005-10-06 21:56:22 +04:00
|
|
|
@@: cmp al,0x2A
|
|
|
|
jne @f
|
|
|
|
cmp cl,0xE0
|
2006-06-30 16:23:15 +04:00
|
|
|
je .writekey
|
2005-10-06 21:56:22 +04:00
|
|
|
mov eax,VKEY_LSHIFT
|
2006-06-30 16:23:15 +04:00
|
|
|
jmp .modifier
|
2005-10-06 21:56:22 +04:00
|
|
|
@@: cmp al,0x36
|
|
|
|
jne @f
|
|
|
|
cmp cl,0xE0
|
2006-06-30 16:23:15 +04:00
|
|
|
je .writekey
|
2005-10-06 21:56:22 +04:00
|
|
|
mov eax,VKEY_RSHIFT
|
2006-06-30 16:23:15 +04:00
|
|
|
jmp .modifier
|
2005-10-06 21:56:22 +04:00
|
|
|
@@: cmp al,0x38
|
|
|
|
jne @f
|
2007-07-17 00:21:34 +04:00
|
|
|
mov eax, VKEY_LALT
|
|
|
|
test cl, cl
|
|
|
|
jz .modifier
|
|
|
|
mov al, VKEY_RALT
|
|
|
|
jmp .modifier
|
2005-10-06 21:56:22 +04:00
|
|
|
@@: cmp al,0x1D
|
|
|
|
jne @f
|
2007-07-17 00:21:34 +04:00
|
|
|
mov eax, VKEY_LCONTROL
|
|
|
|
test cl, cl
|
|
|
|
jz .modifier
|
|
|
|
mov al, VKEY_RCONTROL
|
|
|
|
cmp cl, 0xE0
|
|
|
|
jz .modifier
|
|
|
|
mov [ext_code], cl
|
|
|
|
jmp .writekey
|
2005-10-06 21:56:22 +04:00
|
|
|
@@: cmp al,0x3A
|
|
|
|
jne @f
|
|
|
|
mov bl,4
|
|
|
|
mov eax,VKEY_CAPSLOCK
|
|
|
|
jmp .no_key.xor
|
|
|
|
@@: cmp al,0x45
|
|
|
|
jne @f
|
2007-07-17 00:21:34 +04:00
|
|
|
test cl, cl
|
|
|
|
jnz .writekey
|
2005-10-06 21:56:22 +04:00
|
|
|
mov bl,2
|
|
|
|
mov eax,VKEY_NUMLOCK
|
|
|
|
jmp .no_key.xor
|
|
|
|
@@: cmp al,0x46
|
|
|
|
jne @f
|
|
|
|
mov bl,1
|
|
|
|
mov eax,VKEY_SCRLOCK
|
|
|
|
jmp .no_key.xor
|
|
|
|
@@:
|
2010-08-23 00:17:11 +04:00
|
|
|
mov bh,0
|
2006-06-30 16:23:15 +04:00
|
|
|
test ch,ch
|
|
|
|
js .writekey
|
2007-07-17 00:21:34 +04:00
|
|
|
movzx eax,ch ; plain key
|
2005-10-06 21:56:22 +04:00
|
|
|
mov bl,[keymap+eax]
|
|
|
|
mov edx,[kb_state]
|
2007-07-17 00:21:34 +04:00
|
|
|
test dl,VKEY_CONTROL ; ctrl alt del
|
2005-10-06 21:56:22 +04:00
|
|
|
jz .noctrlaltdel
|
|
|
|
test dl,VKEY_ALT
|
|
|
|
jz .noctrlaltdel
|
2006-06-30 16:23:15 +04:00
|
|
|
cmp ch,53h
|
2005-10-06 21:56:22 +04:00
|
|
|
jne .noctrlaltdel
|
|
|
|
mov [ctrl_alt_del],1
|
|
|
|
.noctrlaltdel:
|
2007-07-17 00:21:34 +04:00
|
|
|
test dl,VKEY_CONTROL ; ctrl on ?
|
2005-10-06 21:56:22 +04:00
|
|
|
jz @f
|
|
|
|
sub bl,0x60
|
2007-07-17 00:21:34 +04:00
|
|
|
@@: test dl,VKEY_SHIFT ; shift on ?
|
2005-10-06 21:56:22 +04:00
|
|
|
jz @f
|
|
|
|
mov bl,[keymap_shift+eax]
|
2007-07-17 00:21:34 +04:00
|
|
|
@@: test dl,VKEY_ALT ; alt on ?
|
2005-10-06 21:56:22 +04:00
|
|
|
jz @f
|
|
|
|
mov bl,[keymap_alt+eax]
|
|
|
|
@@:
|
2007-07-17 00:21:34 +04:00
|
|
|
jmp .writekey
|
2006-06-30 16:23:15 +04:00
|
|
|
.modifier:
|
2007-07-17 00:21:34 +04:00
|
|
|
test ch, ch
|
|
|
|
js .modifier.up
|
|
|
|
or [kb_state], eax
|
|
|
|
jmp .writekey
|
2006-06-30 16:23:15 +04:00
|
|
|
.modifier.up:
|
2007-07-17 00:21:34 +04:00
|
|
|
not eax
|
|
|
|
and [kb_state], eax
|
|
|
|
jmp .writekey
|
2006-06-30 16:23:15 +04:00
|
|
|
.no_key.xor:
|
2007-07-17 00:21:34 +04:00
|
|
|
mov bh, 0
|
|
|
|
test ch, ch
|
|
|
|
js .writekey
|
|
|
|
xor [kb_state], eax
|
|
|
|
xor [kb_lights], bl
|
|
|
|
call set_lights
|
2006-06-30 16:23:15 +04:00
|
|
|
|
|
|
|
.writekey:
|
|
|
|
; test for system hotkeys
|
2007-07-17 00:21:34 +04:00
|
|
|
movzx eax, ch
|
|
|
|
cmp bh, 1
|
|
|
|
ja .nohotkey
|
|
|
|
jb @f
|
|
|
|
xor eax, eax
|
2006-06-30 16:23:15 +04:00
|
|
|
@@:
|
2007-07-17 00:21:34 +04:00
|
|
|
mov eax, [hotkey_scancodes + eax*4]
|
2006-06-30 16:23:15 +04:00
|
|
|
.hotkey_loop:
|
2007-07-17 00:21:34 +04:00
|
|
|
test eax, eax
|
|
|
|
jz .nohotkey
|
|
|
|
mov cl, 0
|
|
|
|
call hotkey_do_test
|
|
|
|
jc .hotkey_cont
|
|
|
|
mov cl, 2
|
|
|
|
call hotkey_do_test
|
|
|
|
jc .hotkey_cont
|
|
|
|
mov cl, 4
|
|
|
|
call hotkey_do_test
|
|
|
|
jnc .hotkey_found
|
2006-06-30 16:23:15 +04:00
|
|
|
.hotkey_cont:
|
2007-07-17 00:21:34 +04:00
|
|
|
mov eax, [eax]
|
|
|
|
jmp .hotkey_loop
|
2006-06-30 16:23:15 +04:00
|
|
|
.hotkey_found:
|
2007-07-17 00:21:34 +04:00
|
|
|
mov eax, [eax+8]
|
2006-06-30 16:23:15 +04:00
|
|
|
; put key in buffer for process in slot eax
|
2007-07-17 00:21:34 +04:00
|
|
|
mov edi, hotkey_buffer
|
2006-06-30 16:23:15 +04:00
|
|
|
@@:
|
2007-07-17 00:21:34 +04:00
|
|
|
cmp dword [edi], 0
|
|
|
|
jz .found_free
|
|
|
|
add edi, 8
|
|
|
|
cmp edi, hotkey_buffer+120*8
|
|
|
|
jb @b
|
2006-06-30 16:23:15 +04:00
|
|
|
; no free space - replace first entry
|
2007-07-17 00:21:34 +04:00
|
|
|
mov edi, hotkey_buffer
|
2006-06-30 16:23:15 +04:00
|
|
|
.found_free:
|
2007-07-17 00:21:34 +04:00
|
|
|
mov [edi], eax
|
|
|
|
movzx eax, ch
|
|
|
|
cmp bh, 1
|
|
|
|
jnz @f
|
|
|
|
xor eax, eax
|
2006-06-30 16:23:15 +04:00
|
|
|
@@:
|
2007-07-17 00:21:34 +04:00
|
|
|
mov [edi+4], ax
|
|
|
|
mov eax, [kb_state]
|
|
|
|
mov [edi+6], ax
|
|
|
|
jmp .exit.irq1
|
2006-06-30 16:23:15 +04:00
|
|
|
.nohotkey:
|
2005-10-06 21:56:22 +04:00
|
|
|
cmp [keyboard_mode],0 ; return from keymap
|
2006-06-30 16:23:15 +04:00
|
|
|
jne .scancode
|
2007-07-17 00:21:34 +04:00
|
|
|
test bh, bh
|
|
|
|
jnz .exit.irq1
|
|
|
|
test bl, bl
|
|
|
|
jz .exit.irq1
|
|
|
|
|
|
|
|
;.........................Part1 Start.......Code by Rus, optimize by Ghost...................................
|
|
|
|
test [kb_state], VKEY_NUMLOCK
|
|
|
|
jz .dowrite
|
2007-09-24 00:58:50 +04:00
|
|
|
cmp cl, 0xE0
|
|
|
|
jz .dowrite
|
2007-07-17 00:21:34 +04:00
|
|
|
|
|
|
|
cmp ch, 55
|
|
|
|
jnz @f
|
|
|
|
mov bl, 0x2A ;*
|
|
|
|
jmp .dowrite
|
|
|
|
@@:
|
|
|
|
cmp ch, 71
|
|
|
|
jb .dowrite
|
|
|
|
cmp ch, 83
|
|
|
|
ja .dowrite
|
2007-08-03 04:23:50 +04:00
|
|
|
;push eax
|
2007-07-17 00:21:34 +04:00
|
|
|
movzx eax, ch
|
|
|
|
mov bl, [numlock_map + eax - 71]
|
2007-08-03 04:23:50 +04:00
|
|
|
;pop eax
|
2007-07-17 00:21:34 +04:00
|
|
|
|
|
|
|
;.........................Part1 End.................................................
|
|
|
|
|
|
|
|
jmp .dowrite
|
2006-06-30 16:23:15 +04:00
|
|
|
.scancode:
|
2007-07-17 00:21:34 +04:00
|
|
|
mov bl, ch
|
2006-06-30 16:23:15 +04:00
|
|
|
.dowrite:
|
2007-03-01 23:32:19 +03:00
|
|
|
movzx eax,byte[KEY_COUNT]
|
2005-10-06 21:56:22 +04:00
|
|
|
cmp al,120
|
2006-06-30 16:23:15 +04:00
|
|
|
jae .exit.irq1
|
|
|
|
inc eax
|
2007-03-01 23:32:19 +03:00
|
|
|
mov [KEY_COUNT],al
|
|
|
|
mov [KEY_COUNT+eax],bl
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
.exit.irq1:
|
|
|
|
mov [check_idle_semaphore],5
|
|
|
|
|
2006-10-06 10:09:41 +04:00
|
|
|
; mov al,0x20 ; ready for next irq
|
|
|
|
; out 0x20,al
|
2005-10-06 21:56:22 +04:00
|
|
|
|
2006-10-06 10:09:41 +04:00
|
|
|
; restore_ring3_context
|
|
|
|
; iret
|
2007-07-17 00:21:34 +04:00
|
|
|
ret
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
set_lights:
|
|
|
|
mov al,0xED
|
|
|
|
call kb_write
|
|
|
|
mov al,[kb_lights]
|
|
|
|
call kb_write
|
|
|
|
ret
|
|
|
|
|
|
|
|
;// mike.dld ]
|
2007-07-17 00:21:34 +04:00
|
|
|
;..........................Part2 Start.......Code by Rus.......................................
|
|
|
|
numlock_map:
|
|
|
|
db 0x37 ;Num 7
|
|
|
|
db 0x38 ;Num 8
|
|
|
|
db 0x39 ;Num 9
|
|
|
|
db 0x2D ;Num -
|
|
|
|
db 0x34 ;Num 4
|
|
|
|
db 0x35 ;Num 5
|
|
|
|
db 0x36 ;Num 6
|
|
|
|
db 0x2B ;Num +
|
|
|
|
db 0x31 ;Num 1
|
|
|
|
db 0x32 ;Num 2
|
|
|
|
db 0x33 ;Num 3
|
|
|
|
db 0x30 ;Num 0
|
|
|
|
db 0x2E ;Num .
|
|
|
|
;..........................Part2 End................................................
|