kolibrios/kernel/trunk/drivers/ps2m_irqh.inc
kastigar 510a108c5d 1)ps2 mouse driver(removed from kernel)
2)new 2 modes for ps2-mouse (scrolling mouse and 5-button mouse)
3) added function 37.7 for mouse scrolling data

git-svn-id: svn://kolibrios.org@479 a494cfbc-eb01-0410-851d-a64ba20cac60
2007-05-08 11:32:58 +00:00

121 lines
2.9 KiB
PHP

;**************************************
;* ÎÁÐÀÁÎÒ×ÈÊ ÏÐÅÐÛÂÀÍÈß ÎÒ ÌÛØÈ PS/2 *
;**************************************
proc irq_handler
call Wait8042BufferEmpty ;î÷èñòêà áóôåðà
in al,0x60 ;ïîëó÷èòü ñêýí-êîä
cmp [mouse_byte],0
je .byte1
cmp [mouse_byte],1
je .byte2
cmp [mouse_byte],2
je .byte3
cmp [mouse_byte],3
je .byte4
jmp .error
.byte1:
test al,1000b ;ïåðâûé áàéò ïîñûëêè?
jz .error ;ñáîé ñèíõðîíèçàöèè
mov [first_byte],al
inc [mouse_byte]
jmp .exit
.byte2:
mov [second_byte],al
inc [mouse_byte]
jmp .exit
.byte3:
mov [third_byte],al
cmp [MouseType],MT_3B
je .full_packet
inc [mouse_byte]
jmp .exit
.byte4:
mov [fourth_byte],al
.full_packet:
mov [mouse_byte],0
mov al,byte [first_byte]
and eax,7
mov byte [ButtonState],al
cmp [MouseType],MT_3B
je .xy_moving
mov al,[fourth_byte]
cmp [MouseType],MT_3BScroll
je .z_moving
mov ah,al
and ah,00110000b
shr ah,1
or byte [ButtonState],ah
and al,00001111b
bt eax,3
jnc .z_moving
or al,11110000b
.z_moving:
movsx eax,al
mov [ZMoving],eax
.xy_moving:
mov ah,0 ;äóáëèðóåì çíàê âî âñå ðàçðÿäû AH
mov al,[first_byte]
test al,10000b
jz @f
mov ah,0FFh
@@:
mov al,[second_byte]
cwd
mov [XMoving],eax
mov ah,0 ;äóáëèðóåì çíàê âî âñå ðàçðÿäû AH
mov al,[first_byte]
test al,100000b
jz @f
mov ah,0FFh
@@:
mov al,[third_byte]
cwd
@@:
mov [YMoving],eax
stdcall SetMouseData, [ButtonState], [XMoving], [YMoving], [ZMoving], 0
jmp .exit
.error:
mov [mouse_byte],0
.exit:
ret
endp
;***********************************************
;* ÎÆÈÄÀÍÈÅ Î×ÈÑÒÊÈ ÂÕÎÄÍÎÃÎ ÁÓÔÅÐÀ I8042 *
;* Ïðè âûõîäå èç ïðîöåäóðû: *
;* ôëàã ZF óñòàíîâëåí - íîðìàëüíîå çàâåðøåíèå, *
;* ôëàã ZF ñáðîøåí - îøèáêà òàéì-àóòà. *
;***********************************************
Wait8042BufferEmpty:
push ecx
xor ecx,ecx
@@:
in al,64h
test al,00000010b
loopnz @b
pop ecx
ret ;âîçâðàò â ïîäïðîãðàììó