CAPS LOCK for ASCII key

git-svn-id: svn://kolibrios.org@2171 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2011-09-11 17:31:15 +00:00
parent 8a41ae1b3e
commit 213f39d0cd

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -8,8 +8,6 @@
$Revision$ $Revision$
;// mike.dld [
VKEY_LSHIFT = 0000000000000001b VKEY_LSHIFT = 0000000000000001b
VKEY_RSHIFT = 0000000000000010b VKEY_RSHIFT = 0000000000000010b
VKEY_LCONTROL = 0000000000000100b VKEY_LCONTROL = 0000000000000100b
@ -51,301 +49,347 @@ hotkey_tests dd hotkey_test0
dd hotkey_test4 dd hotkey_test4
hotkey_tests_num = 5 hotkey_tests_num = 5
endg endg
;---------------------------------------------------------------------
hotkey_test0: hotkey_test0:
test al, al test al,al
setz al setz al
ret ret
;---------------------------------------------------------------------
hotkey_test1: hotkey_test1:
test al, al test al,al
setnp al setnp al
ret ret
;---------------------------------------------------------------------
hotkey_test2: hotkey_test2:
cmp al, 3 cmp al,3
setz al setz al
ret ret
;---------------------------------------------------------------------
hotkey_test3: hotkey_test3:
cmp al, 1 cmp al,1
setz al setz al
ret ret
;---------------------------------------------------------------------
hotkey_test4: hotkey_test4:
cmp al, 2 cmp al,2
setz al setz al
ret ret
;---------------------------------------------------------------------
hotkey_do_test: hotkey_do_test:
push eax push eax
mov edx, [kb_state] mov edx,[kb_state]
shr edx, cl shr edx,cl
add cl, cl add cl,cl
mov eax, [eax+4] mov eax,[eax+4]
shr eax, cl shr eax,cl
and eax, 15 and eax,15
cmp al, hotkey_tests_num cmp al,hotkey_tests_num
jae .fail jae .fail
xchg eax, edx
and al, 3 xchg eax,edx
and al,3
call [hotkey_tests + edx*4] call [hotkey_tests + edx*4]
cmp al, 1 cmp al,1
pop eax pop eax
ret ret
;--------------------------------------
.fail: .fail:
stc stc
pop eax pop eax
ret ret
;---------------------------------------------------------------------
align 4 align 4
set_keyboard_data: set_keyboard_data:
movzx eax,word[TASK_COUNT] ; top window process
movzx eax,word[TASK_COUNT] ; top window process movzx eax,word[WIN_POS+eax*2]
movzx eax,word[WIN_POS+eax*2] shl eax,8
shl eax,8 mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode]
mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode] mov [keyboard_mode],al
mov [keyboard_mode],al
mov eax,ecx
mov eax, ecx
push ebx esi edi ebp
push ebx call send_scancode
push esi pop ebp edi esi ebx
push edi ret
push ebp ;---------------------------------------------------------------------
call send_scancode
pop ebp
pop edi
pop esi
pop ebx
ret
align 4 align 4
irq1: irq1:
movzx eax,word[TASK_COUNT] ; top window process
movzx eax,word[TASK_COUNT] ; top window process movzx eax,word[WIN_POS+eax*2]
movzx eax,word[WIN_POS+eax*2] shl eax,8
shl eax,8 mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode]
mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode] mov [keyboard_mode],al
mov [keyboard_mode],al
in al,0x60
in al,0x60 ;--------------------------------------
send_scancode: send_scancode:
mov [keyboard_data],al
mov [keyboard_data],al
; ch = scancode ; ch = scancode
; cl = ext_code ; cl = ext_code
; bh = 0 - normal key ; bh = 0 - normal key
; bh = 1 - modifier (Shift/Ctrl/Alt) ; bh = 1 - modifier (Shift/Ctrl/Alt)
; bh = 2 - extended code ; bh = 2 - extended code
mov ch,al
mov ch,al cmp al,0xE0
cmp al,0xE0 je @f
je @f
cmp al,0xE1 cmp al,0xE1
jne .normal_code jne .normal_code
@@: @@:
mov bh, 2 mov bh,2
mov [ext_code], al mov [ext_code],al
jmp .writekey jmp .writekey
.normal_code: ;--------------------------------------
mov cl, 0 .normal_code:
xchg cl, [ext_code] mov cl,0
and al,0x7F xchg cl,[ext_code]
mov bh, 1 and al,0x7F
@@: cmp al,0x2A mov bh,1
jne @f @@:
cmp cl,0xE0 cmp al,0x2A
je .writekey jne @f
mov eax,VKEY_LSHIFT
jmp .modifier cmp cl,0xE0
@@: cmp al,0x36 je .writekey
jne @f
cmp cl,0xE0 mov eax,VKEY_LSHIFT
je .writekey
mov eax,VKEY_RSHIFT
jmp .modifier
@@: cmp al,0x38
jne @f
mov eax, VKEY_LALT
test cl, cl
jz .modifier
mov al, VKEY_RALT
jmp .modifier jmp .modifier
@@: cmp al,0x1D ;--------------------------------------
jne @f @@:
mov eax, VKEY_LCONTROL cmp al,0x36
test cl, cl jne @f
cmp cl,0xE0
je .writekey
mov eax,VKEY_RSHIFT
jmp .modifier
;--------------------------------------
@@:
cmp al,0x38
jne @f
mov eax,VKEY_LALT
test cl,cl
jz .modifier jz .modifier
mov al, VKEY_RCONTROL
cmp cl, 0xE0 mov al,VKEY_RALT
jmp .modifier
;--------------------------------------
@@:
cmp al,0x1D
jne @f
mov eax,VKEY_LCONTROL
test cl,cl
jz .modifier jz .modifier
mov [ext_code], cl
mov al,VKEY_RCONTROL
cmp cl,0xE0
jz .modifier
mov [ext_code],cl
jmp .writekey jmp .writekey
@@: cmp al,0x3A ;--------------------------------------
jne @f @@:
mov bl,4 cmp al,0x3A
mov eax,VKEY_CAPSLOCK jne @f
jmp .no_key.xor
@@: cmp al,0x45 mov bl,4
jne @f mov eax,VKEY_CAPSLOCK
test cl, cl jmp .no_key.xor
;--------------------------------------
@@:
cmp al,0x45
jne @f
test cl,cl
jnz .writekey jnz .writekey
mov bl,2
mov eax,VKEY_NUMLOCK mov bl,2
jmp .no_key.xor mov eax,VKEY_NUMLOCK
@@: cmp al,0x46 jmp .no_key.xor
jne @f ;--------------------------------------
mov bl,1 @@:
mov eax,VKEY_SCRLOCK cmp al,0x46
jmp .no_key.xor jne @f
@@:
xor ebx,ebx mov bl,1
test ch,ch mov eax,VKEY_SCRLOCK
js .writekey jmp .no_key.xor
movzx eax,ch ; plain key ;--------------------------------------
mov bl,[keymap+eax] @@:
mov edx,[kb_state] xor ebx,ebx
test dl,VKEY_CONTROL ; ctrl alt del test ch,ch
jz .noctrlaltdel js .writekey
test dl,VKEY_ALT
jz .noctrlaltdel movzx eax,ch ; plain key
cmp ch,53h mov bl,[keymap+eax]
jne .noctrlaltdel mov edx,[kb_state]
mov [ctrl_alt_del],1 test dl,VKEY_CONTROL ; ctrl alt del
.noctrlaltdel: jz .noctrlaltdel
test dl,VKEY_CONTROL ; ctrl on ?
jz @f test dl,VKEY_ALT
sub bl,0x60 jz .noctrlaltdel
@@: test dl,VKEY_SHIFT ; shift on ?
jz @f cmp ch,53h
mov bl,[keymap_shift+eax] jne .noctrlaltdel
@@: test dl,VKEY_ALT ; alt on ?
jz @f mov [ctrl_alt_del],1
mov bl,[keymap_alt+eax] .noctrlaltdel:
@@: test dl,VKEY_CONTROL ; ctrl on ?
jz @f
sub bl,0x60
@@:
test dl,VKEY_CAPSLOCK ; caps lock on ?
jz .no_caps_lock
test dl,VKEY_SHIFT ; shift on ?
jz .keymap_shif
jmp @f
;--------------------------------------
.no_caps_lock:
test dl,VKEY_SHIFT ; shift on ?
jz @f
.keymap_shif:
mov bl,[keymap_shift+eax]
@@:
test dl,VKEY_ALT ; alt on ?
jz @f
mov bl,[keymap_alt+eax]
@@:
jmp .writekey jmp .writekey
;--------------------------------------
.modifier: .modifier:
test ch, ch test ch, ch
js .modifier.up js .modifier.up
or [kb_state], eax or [kb_state],eax
jmp .writekey jmp .writekey
;--------------------------------------
.modifier.up: .modifier.up:
not eax not eax
and [kb_state], eax and [kb_state],eax
jmp .writekey jmp .writekey
;--------------------------------------
.no_key.xor: .no_key.xor:
mov bh, 0 mov bh,0
test ch, ch test ch,ch
js .writekey js .writekey
xor [kb_state], eax
xor [kb_lights], bl xor [kb_state],eax
xor [kb_lights],bl
call set_lights call set_lights
.writekey: .writekey:
; test for system hotkeys ; test for system hotkeys
movzx eax, ch movzx eax,ch
cmp bh, 1 cmp bh,1
ja .nohotkey ja .nohotkey
jb @f jb @f
xor eax, eax
xor eax,eax
@@: @@:
mov eax, [hotkey_scancodes + eax*4] mov eax, [hotkey_scancodes + eax*4]
.hotkey_loop: .hotkey_loop:
test eax, eax test eax, eax
jz .nohotkey jz .nohotkey
mov cl, 0
mov cl,0
call hotkey_do_test call hotkey_do_test
jc .hotkey_cont jc .hotkey_cont
mov cl, 2
mov cl,2
call hotkey_do_test call hotkey_do_test
jc .hotkey_cont jc .hotkey_cont
mov cl, 4
mov cl,4
call hotkey_do_test call hotkey_do_test
jnc .hotkey_found jnc .hotkey_found
.hotkey_cont: .hotkey_cont:
mov eax, [eax] mov eax,[eax]
jmp .hotkey_loop jmp .hotkey_loop
;--------------------------------------
.hotkey_found: .hotkey_found:
mov eax, [eax+8] mov eax,[eax+8]
; put key in buffer for process in slot eax ; put key in buffer for process in slot eax
mov edi, hotkey_buffer mov edi,hotkey_buffer
@@: @@:
cmp dword [edi], 0 cmp dword [edi],0
jz .found_free jz .found_free
add edi, 8
cmp edi, hotkey_buffer+120*8 add edi,8
cmp edi,hotkey_buffer+120*8
jb @b jb @b
; no free space - replace first entry ; no free space - replace first entry
mov edi, hotkey_buffer mov edi,hotkey_buffer
.found_free: .found_free:
mov [edi], eax mov [edi],eax
movzx eax, ch movzx eax,ch
cmp bh, 1 cmp bh,1
jnz @f jnz @f
xor eax, eax xor eax, eax
@@: @@:
mov [edi+4], ax mov [edi+4],ax
mov eax, [kb_state] mov eax,[kb_state]
mov [edi+6], ax mov [edi+6],ax
jmp .exit.irq1 jmp .exit.irq1
;--------------------------------------
.nohotkey: .nohotkey:
cmp [keyboard_mode],0 ; return from keymap cmp [keyboard_mode],0 ; return from keymap
jne .scancode jne .scancode
test bh, bh
test bh,bh
jnz .exit.irq1 jnz .exit.irq1
test bl, bl
test bl,bl
jz .exit.irq1 jz .exit.irq1
;.........................Part1 Start.......Code by Rus, optimize by Ghost................................... test [kb_state],VKEY_NUMLOCK
test [kb_state], VKEY_NUMLOCK jz .dowrite
jz .dowrite
cmp cl, 0xE0 cmp cl,0xE0
jz .dowrite jz .dowrite
cmp ch, 55 cmp ch,55
jnz @f jnz @f
mov bl, 0x2A ;*
mov bl,0x2A ;*
jmp .dowrite jmp .dowrite
@@: ;--------------------------------------
cmp ch, 71 @@:
cmp ch,71
jb .dowrite jb .dowrite
cmp ch, 83
cmp ch,83
ja .dowrite ja .dowrite
;push eax
movzx eax, ch movzx eax, ch
mov bl, [numlock_map + eax - 71] mov bl,[numlock_map + eax - 71]
;pop eax
;.........................Part1 End.................................................
jmp .dowrite jmp .dowrite
;--------------------------------------
.scancode: .scancode:
mov bl, ch mov bl,ch
.dowrite: .dowrite:
movzx eax,byte[KEY_COUNT] movzx eax,byte[KEY_COUNT]
cmp al,120 cmp al,120
jae .exit.irq1 jae .exit.irq1
inc eax inc eax
mov [KEY_COUNT],al mov [KEY_COUNT],al
mov [KEY_COUNT+eax],bl mov [KEY_COUNT+eax],bl
.exit.irq1:
.exit.irq1: mov [check_idle_semaphore],5
mov [check_idle_semaphore],5
ret ret
;---------------------------------------------------------------------
set_lights: set_lights:
mov al,0xED mov al,0xED
call kb_write call kb_write
mov al,[kb_lights] mov al,[kb_lights]
call kb_write call kb_write
ret ret
;---------------------------------------------------------------------
;// mike.dld ]
;..........................Part2 Start.......Code by Rus.......................................
numlock_map: numlock_map:
db 0x37 ;Num 7 db 0x37 ;Num 7
db 0x38 ;Num 8 db 0x38 ;Num 8
@ -360,4 +404,4 @@ numlock_map:
db 0x33 ;Num 3 db 0x33 ;Num 3
db 0x30 ;Num 0 db 0x30 ;Num 0
db 0x2E ;Num . db 0x2E ;Num .
;..........................Part2 End................................................ ;---------------------------------------------------------------------