kolibrios-fun/kernel/trunk/hid/m_com.inc
Evgeny Grechnikov (Diamond) 441fcf143a * Unified COM1/COM2 mice handling.
* Corrected COM mouse detection.
* Mouse cursor can now be at right and bottom screen sides.
* Normal handling of "desktop background redraw" event.
  (Background redraw is faster now.)
* Fixed error in stretch background function for VESA 2.0.

git-svn-id: svn://kolibrios.org@473 a494cfbc-eb01-0410-851d-a64ba20cac60
2007-05-02 12:06:10 +00:00

142 lines
4.6 KiB
PHP

$Revision$
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
struc COM_MOUSE_DATA {
; Íîìåð ïðèíèìàåìîãî îò ìûøè áàéòà
.MouseByteNumber db ?
; Òðåõáàéòîâàÿ ñòðóêòóðà äàííûõ, ïåðåäàâàåìàÿ ìûøüþ
.FirstByte db ?
.SecondByte db ?
.ThirdByte db ?
.timer_ticks_com dd ?
}
virtual at 0
COM_MOUSE_DATA COM_MOUSE_DATA
end virtual
uglobal
com1_mouse COM_MOUSE_DATA
com2_mouse COM_MOUSE_DATA
endg
;***************************************
;* ÍÎÂÛÉ ÎÁÐÀÁÎÒ×ÈÊ ÏÐÅÐÛÂÀÍÈß ÎÒ ÌÛØÈ *
;***************************************
check_mouse_data_com:
; in: esi -> COM_MOUSE_DATA struc, dx = base port (xF8h)
add edx, 5 ; xFDh
in al, dx
test al, 1 ; Äàííûå ãîòîâû?
jz .Error
; Ââåñòè äàííûå
sub edx, 5
in al, dx
; Ñáðîñèòü ñòàðøèé íåçíà÷àùèé áèò
and al, 01111111b
; Îïðåäåëèòü ïîðÿäêîâûé íîìåð ïðèíèìàåìîãî áàéòà
cmp [esi+COM_MOUSE_DATA.MouseByteNumber], 2
ja .Error
jz .ThirdByte
jp .SecondByte
; Ñîõðàíèòü ïåðâûé áàéò äàííûõ
.FirstByte:
test al, 1000000b ; Ïåðâûé áàéò ïîñûëêè?
jz .Error
mov [esi+COM_MOUSE_DATA.FirstByte], al
inc [esi+COM_MOUSE_DATA.MouseByteNumber]
jmp .EndMouseInterrupt
; Ñîõðàíèòü âòîðîé áàéò äàííûõ
.SecondByte:
test al, 1000000b
jnz .Error
mov [esi+COM_MOUSE_DATA.SecondByte], al
inc [esi+COM_MOUSE_DATA.MouseByteNumber]
jmp .EndMouseInterrupt
; Ñîõðàíèòü òðåòèé áàéò äàííûõ
.ThirdByte:
test al, 1000000b
jnz .Error
mov [esi+COM_MOUSE_DATA.ThirdByte], al
mov [esi+COM_MOUSE_DATA.MouseByteNumber], 0
; (Ïàêåò äàííûõ îò ìûøè ïðèíÿò ïîëíîñòüþ).
; Çàïèñàòü íîâîå çíà÷åíèå ñîñòîÿíèÿ êíîïîê ìûøè
mov al, [esi+COM_MOUSE_DATA.FirstByte]
mov ah, al
shr al, 3
and al, 2
shr ah, 5
and ah, 1
add al, ah
mov [BTN_DOWN], al
mov [mouse_active], 1
; Ïðèáàâèòü ïåðåìåùåíèå ïî X ê êîîðäèíàòå X
mov al, [esi+COM_MOUSE_DATA.FirstByte]
shl al, 6
or al, [esi+COM_MOUSE_DATA.SecondByte]
call mouse_acceleration_com
; mouse acceleration
mov ecx, [timer_ticks]
sub ecx, [esi+COM_MOUSE_DATA.timer_ticks_com]
cmp ecx, [mouse_delay]
ja @f
imul ax, [mouse_speed_factor]
@@:
add ax, [MOUSE_X]
; Êóðñîð íå äîëæåí âûõîäèòü çà ëåâóþ èëè ïðàâóþ ãðàíèöó ýêðàíà
js .x1
cmp ax, [ScreenWidth]
jb .x2
; Óñòàíîâèòü êîîðäèíàòó X ïî ïðàâîé ãðàíèöå
mov ax, [ScreenWidth]
jmp .x2
.x1:
; Óñòàíîâèòü êîîðäèíàòó X ïî ëåâîé ãðàíèöå
xor eax, eax
.x2:
mov [MOUSE_X], ax
; Ïðèáàâèòü ïåðåìåùåíèå ïî Y ê êîîðäèíàòå Y
mov al, [esi+COM_MOUSE_DATA.FirstByte]
and al, 00001100b
shl al, 4
or al, [esi+COM_MOUSE_DATA.ThirdByte]
call mouse_acceleration_com
add ax, [MOUSE_Y]
; Êóðñîð íå äîëæåí âûõîäèòü çà âåðõíþþ èëè íèæíþþ ãðàíèöó ýêðàíà
js .y1
cmp ax, [ScreenHeight]
jb .y2
; Óñòàíîâèòü êîîðäèíàòó Y ïî íèæíåé ãðàíèöå
mov ax, [ScreenHeight]
jmp .y2
.y1:
; Óñòàíîâèòü êîîðäèíàòó Y ïî âåðõíåé ãðàíèöå
xor eax, eax
.y2:
mov [MOUSE_Y], ax
mov eax, [timer_ticks]
mov [esi+COM_MOUSE_DATA.timer_ticks_com], eax
jmp .EndMouseInterrupt
.Error:
; Ïðîèçîøåë ñáîé â ïîðÿäêå ïåðåäà÷è èíôîðìàöèè îò
; ìûøè, îáíóëèòü ñ÷åò÷èê áàéòîâ ïàêåòà äàííûõ
mov [esi+COM_MOUSE_DATA.MouseByteNumber],0
.EndMouseInterrupt:
jmp ready_for_next_irq
mouse_acceleration_com:
cbw
mov ecx, [timer_ticks]
sub ecx, [esi+COM_MOUSE_DATA.timer_ticks_com]
cmp ecx, [mouse_delay]
ja @f
imul ax, [mouse_speed_factor]
@@:
ret