Nonliniear mouse control option

git-svn-id: svn://kolibrios.org@5853 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2015-10-20 23:01:43 +00:00
parent 4054b22aaa
commit cb95c307f3
2 changed files with 46 additions and 23 deletions

View File

@ -35,10 +35,8 @@ endg
iglobal iglobal
;-------------------------------------- ;--------------------------------------
align 4 align 4
mouse_delay dd 10 mouse_speed_factor dw 1
mouse_speed_factor: mouse_delay db 1
dd 3
mouse_timer_ticks dd 0
mouse_doubleclick_delay db 64 mouse_doubleclick_delay db 64
endg endg
@ -491,11 +489,12 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
mov eax, [XMoving] mov eax, [XMoving]
test [BtnState], 0x80000000 test [BtnState], 0x80000000
jnz .absolute_x jnz .absolute_x
test eax, eax
jz @f
call mouse_acceleration call mouse_acceleration
add ax, [MOUSE_X] add ax, [MOUSE_X]
cmp ax, 0 jns .check_x
jge .check_x xor eax, eax
mov eax, 0
jmp .set_x jmp .set_x
.absolute_x: .absolute_x:
mov edx, [_display.width] mov edx, [_display.width]
@ -509,15 +508,17 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
.set_x: .set_x:
mov [MOUSE_X], ax mov [MOUSE_X], ax
;-------------------------------------- ;--------------------------------------
@@:
mov eax, [YMoving] mov eax, [YMoving]
test [BtnState], 0x40000000 test [BtnState], 0x40000000
jnz .absolute_y jnz .absolute_y
test eax, eax
jz @f
neg eax neg eax
call mouse_acceleration call mouse_acceleration
add ax, [MOUSE_Y] add ax, [MOUSE_Y]
cmp ax, 0 jns .check_y
jge .check_y xor eax, eax
mov ax, 0
jmp .set_y jmp .set_y
.absolute_y: .absolute_y:
mov edx, [_display.height] mov edx, [_display.height]
@ -531,6 +532,7 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
.set_y: .set_y:
mov [MOUSE_Y], ax mov [MOUSE_Y], ax
;-------------------------------------- ;--------------------------------------
@@:
mov eax, [VScroll] mov eax, [VScroll]
test eax, eax test eax, eax
jz @f jz @f
@ -544,8 +546,6 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
bts dword [BTN_DOWN], 23 bts dword [BTN_DOWN], 23
@@: @@:
mov [mouse_active], 1 mov [mouse_active], 1
mov eax, [timer_ticks]
mov [mouse_timer_ticks], eax
call wakeup_osloop call wakeup_osloop
ret ret
endp endp
@ -554,14 +554,36 @@ endp
align 4 align 4
mouse_acceleration: mouse_acceleration:
cmp [mouse_delay], 1
jz .slight
jc .end
push eax push eax
mov eax, [timer_ticks] @@:
sub eax, [mouse_timer_ticks] neg eax
cmp eax, [mouse_delay] jl @b
pop eax mov edx, eax
ja @f shr edx, 1
;push edx jc @f
imul eax, [mouse_speed_factor] mul dl
;pop edx add eax, edx
@@: jmp .next
@@:
inc edx
mul dl
.next:
pop edx
test edx, edx
jns .end
neg eax
jmp .end
;--------------------------------------
.slight:
shl eax, 1
js @f
dec eax
jmp .end
@@:
inc eax
.end:
imul [mouse_speed_factor]
ret ret

View File

@ -2571,11 +2571,12 @@ sysfn_mouse_acceleration: ; 18.19 = set/get mouse features
mov [mouse_speed_factor], dx mov [mouse_speed_factor], dx
ret ret
.get_mouse_delay: .get_mouse_delay:
mov eax, [mouse_delay] xor eax, eax
mov al, [mouse_delay]
mov [esp+32], eax mov [esp+32], eax
ret ret
.set_mouse_delay: .set_mouse_delay:
mov [mouse_delay], edx mov [mouse_delay], dl
@@: @@:
ret ret
.set_pointer_position: .set_pointer_position: