From 2199c90dd9f3963c8dd01fbc399e8b4fa1881789 Mon Sep 17 00:00:00 2001 From: Rus Date: Mon, 16 Jul 2007 20:21:34 +0000 Subject: [PATCH] Added Num Pad. git-svn-id: svn://kolibrios.org@582 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/hid/keyboard.inc | 297 +++++++++++++++++++--------------- 1 file changed, 167 insertions(+), 130 deletions(-) diff --git a/kernel/trunk/hid/keyboard.inc b/kernel/trunk/hid/keyboard.inc index ee2afc0ea..10d1e7271 100644 --- a/kernel/trunk/hid/keyboard.inc +++ b/kernel/trunk/hid/keyboard.inc @@ -24,73 +24,73 @@ VKEY_ALT = 0000000000110000b uglobal align 4 - kb_state dd 0 - ext_code db 0 + kb_state dd 0 + ext_code db 0 keyboard_mode db 0 keyboard_data db 0 - altmouseb db 0 - ctrl_alt_del db 0 + altmouseb db 0 + ctrl_alt_del db 0 - kb_lights db 0 + kb_lights db 0 align 4 - 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 + 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 endg iglobal -hotkey_tests dd hotkey_test0 - dd hotkey_test1 - dd hotkey_test2 - dd hotkey_test3 - dd hotkey_test4 +hotkey_tests dd hotkey_test0 + dd hotkey_test1 + dd hotkey_test2 + dd hotkey_test3 + dd hotkey_test4 hotkey_tests_num = 5 endg hotkey_test0: - test al, al - setz al - ret + test al, al + setz al + ret hotkey_test1: - test al, al - setnp al - ret + test al, al + setnp al + ret hotkey_test2: - cmp al, 3 - setz al - ret + cmp al, 3 + setz al + ret hotkey_test3: - cmp al, 1 - setz al - ret + cmp al, 1 + setz al + ret hotkey_test4: - cmp al, 2 - setz al - ret + cmp al, 2 + setz al + ret hotkey_do_test: - 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 + 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 .fail: - stc - pop eax - ret + stc + pop eax + ret align 4 irq1: @@ -120,14 +120,14 @@ irq1: cmp al,0xE1 jne .normal_code @@: - mov bh, 2 - mov [ext_code], al - jmp .writekey + mov bh, 2 + mov [ext_code], al + jmp .writekey .normal_code: - mov cl, 0 - xchg cl, [ext_code] + mov cl, 0 + xchg cl, [ext_code] and al,0x7F - mov bh, 1 + mov bh, 1 @@: cmp al,0x2A jne @f cmp cl,0xE0 @@ -142,21 +142,21 @@ irq1: jmp .modifier @@: cmp al,0x38 jne @f - mov eax, VKEY_LALT - test cl, cl - jz .modifier - mov al, VKEY_RALT - jmp .modifier + mov eax, VKEY_LALT + test cl, cl + jz .modifier + mov al, VKEY_RALT + jmp .modifier @@: cmp al,0x1D jne @f - mov eax, VKEY_LCONTROL - test cl, cl - jz .modifier - mov al, VKEY_RCONTROL - cmp cl, 0xE0 - jz .modifier - mov [ext_code], cl - jmp .writekey + mov eax, VKEY_LCONTROL + test cl, cl + jz .modifier + mov al, VKEY_RCONTROL + cmp cl, 0xE0 + jz .modifier + mov [ext_code], cl + jmp .writekey @@: cmp al,0x3A jne @f mov bl,4 @@ -164,8 +164,8 @@ irq1: jmp .no_key.xor @@: cmp al,0x45 jne @f - test cl, cl - jnz .writekey + test cl, cl + jnz .writekey mov bl,2 mov eax,VKEY_NUMLOCK jmp .no_key.xor @@ -177,10 +177,10 @@ irq1: @@: test ch,ch js .writekey - movzx eax,ch ; plain key + movzx eax,ch ; plain key mov bl,[keymap+eax] mov edx,[kb_state] - test dl,VKEY_CONTROL ; ctrl alt del + test dl,VKEY_CONTROL ; ctrl alt del jz .noctrlaltdel test dl,VKEY_ALT jz .noctrlaltdel @@ -188,92 +188,113 @@ irq1: jne .noctrlaltdel mov [ctrl_alt_del],1 .noctrlaltdel: - test dl,VKEY_CONTROL ; ctrl on ? + test dl,VKEY_CONTROL ; ctrl on ? jz @f sub bl,0x60 - @@: test dl,VKEY_SHIFT ; shift on ? + @@: test dl,VKEY_SHIFT ; shift on ? jz @f mov bl,[keymap_shift+eax] - @@: test dl,VKEY_ALT ; alt on ? + @@: test dl,VKEY_ALT ; alt on ? jz @f mov bl,[keymap_alt+eax] @@: - mov bh, 0 - jmp .writekey + mov bh, 0 + jmp .writekey .modifier: - test ch, ch - js .modifier.up - or [kb_state], eax - jmp .writekey + test ch, ch + js .modifier.up + or [kb_state], eax + jmp .writekey .modifier.up: - not eax - and [kb_state], eax - jmp .writekey + not eax + and [kb_state], eax + jmp .writekey .no_key.xor: - mov bh, 0 - test ch, ch - js .writekey - xor [kb_state], eax - xor [kb_lights], bl - call set_lights + mov bh, 0 + test ch, ch + js .writekey + xor [kb_state], eax + xor [kb_lights], bl + call set_lights .writekey: ; test for system hotkeys - movzx eax, ch - cmp bh, 1 - ja .nohotkey - jb @f - xor eax, eax + movzx eax, ch + cmp bh, 1 + ja .nohotkey + jb @f + xor eax, eax @@: - mov eax, [hotkey_scancodes + eax*4] + mov eax, [hotkey_scancodes + eax*4] .hotkey_loop: - 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 + 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 .hotkey_cont: - mov eax, [eax] - jmp .hotkey_loop + mov eax, [eax] + jmp .hotkey_loop .hotkey_found: - mov eax, [eax+8] + mov eax, [eax+8] ; put key in buffer for process in slot eax - mov edi, hotkey_buffer + mov edi, hotkey_buffer @@: - cmp dword [edi], 0 - jz .found_free - add edi, 8 - cmp edi, hotkey_buffer+120*8 - jb @b + cmp dword [edi], 0 + jz .found_free + add edi, 8 + cmp edi, hotkey_buffer+120*8 + jb @b ; no free space - replace first entry - mov edi, hotkey_buffer + mov edi, hotkey_buffer .found_free: - mov [edi], eax - movzx eax, ch - cmp bh, 1 - jnz @f - xor eax, eax + mov [edi], eax + movzx eax, ch + cmp bh, 1 + jnz @f + xor eax, eax @@: - mov [edi+4], ax - mov eax, [kb_state] - mov [edi+6], ax - jmp .exit.irq1 + mov [edi+4], ax + mov eax, [kb_state] + mov [edi+6], ax + jmp .exit.irq1 .nohotkey: cmp [keyboard_mode],0 ; return from keymap jne .scancode - test bh, bh - jnz .exit.irq1 - test bl, bl - jz .exit.irq1 - jmp .dowrite + 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 + + cmp ch, 55 + jnz @f + mov bl, 0x2A ;* + jmp .dowrite + @@: + cmp ch, 71 + jb .dowrite + cmp ch, 83 + ja .dowrite + push eax + movzx eax, ch + mov bl, [numlock_map + eax - 71] + pop eax + +;.........................Part1 End................................................. + + jmp .dowrite .scancode: - mov bl, ch + mov bl, ch .dowrite: movzx eax,byte[KEY_COUNT] cmp al,120 @@ -290,7 +311,7 @@ irq1: ; restore_ring3_context ; iret - ret + ret set_lights: mov al,0xED @@ -300,3 +321,19 @@ set_lights: ret ;// mike.dld ] +;..........................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................................................ \ No newline at end of file