diff --git a/kernel/trunk/drivers/usbhid/mouse.inc b/kernel/trunk/drivers/usbhid/mouse.inc index 21101011a7..7cd6807b0c 100644 --- a/kernel/trunk/drivers/usbhid/mouse.inc +++ b/kernel/trunk/drivers/usbhid/mouse.inc @@ -32,13 +32,6 @@ ends ; in: ebx -> device_data from USB layer, edi -> collection ; out: eax = device-specific data or NULL on error proc mouse_driver_add_device -; Get screen resolution so we can calculate absolute coordinates. - mov eax, 14 - int 0x40 - mov [screen_y], eax - and [screen_y], 0xffff - shr eax, 16 - mov [screen_x], eax ; Just allocate memory; no initialization needed. movi eax, sizeof.mouse_device_data call Kmalloc @@ -146,24 +139,12 @@ end if mov [edi+mouse_device_data.hwheel], edx ret .absolute_x: - push ebx - mov eax, [screen_x] - mul edx - mov ebx, 0x8000 - div ebx - mov [edi+mouse_device_data.dx], eax + mov [edi+mouse_device_data.dx], edx or [edi+mouse_device_data.buttons], 0x80000000 - pop ebx ret .absolute_y: - push ebx - mov eax, [screen_y] - mul edx - mov ebx, 0x8000 - div ebx - mov [edi+mouse_device_data.dy], eax + mov [edi+mouse_device_data.dy], edx or [edi+mouse_device_data.buttons], 0x40000000 - pop ebx ret endp diff --git a/kernel/trunk/drivers/usbhid/usbhid.asm b/kernel/trunk/drivers/usbhid/usbhid.asm index 29ef502b02..0c4227131a 100644 --- a/kernel/trunk/drivers/usbhid/usbhid.asm +++ b/kernel/trunk/drivers/usbhid/usbhid.asm @@ -534,9 +534,6 @@ disconnectmsg db 'K : USB HID device disconnected',13,10,0 invalid_report_msg db 'K : report descriptor is invalid',13,10,0 delimiter_note db 'K : note: alternate usage ignored',13,10,0 -screen_x dd ? -screen_y dd ? - ; Exported variable: kernel API version. align 4 version dd 50005h diff --git a/kernel/trunk/hid/mousedrv.inc b/kernel/trunk/hid/mousedrv.inc index eb39227e22..cdc3b9c436 100644 --- a/kernel/trunk/hid/mousedrv.inc +++ b/kernel/trunk/hid/mousedrv.inc @@ -479,54 +479,53 @@ nodmp: ret ;----------------------------------------------------------------------------- align 4 -proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword +proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword mov eax, [BtnState] and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements mov [BTN_DOWN], eax - +;-------------------------------------- mov eax, [XMoving] test [BtnState], 0x80000000 - jnz @@M1 + jnz .absolute_x call mouse_acceleration - add ax, [MOUSE_X];[XCoordinate] + add ax, [MOUSE_X] cmp ax, 0 - jge @@M1 + jge .check_x mov eax, 0 - jmp @@M2 + jmp .set_x + .absolute_x: + mov edx, [_display.width] + mul edx + shr eax, 15 + .check_x: + cmp ax, word[Screen_Max_X] + jl .set_x + mov ax, word[Screen_Max_X] + .set_x: + mov [MOUSE_X], ax ;-------------------------------------- -align 4 -@@M1: - cmp ax, word [Screen_Max_X];ScreenLength - jl @@M2 - mov ax, word [Screen_Max_X];ScreenLength-1 -;-------------------------------------- -align 4 -@@M2: - mov [MOUSE_X], ax;[XCoordinate] - mov eax, [YMoving] test [BtnState], 0x40000000 - jnz @@M3 + jnz .absolute_y neg eax call mouse_acceleration - - add ax, [MOUSE_Y];[YCoordinate] + add ax, [MOUSE_Y] cmp ax, 0 - jge @@M3 + jge .check_y mov ax, 0 - jmp @@M4 + jmp .set_y + .absolute_y: + mov edx, [_display.height] + mul edx + shr eax, 15 + .check_y: + cmp ax, word[Screen_Max_Y] + jl .set_y + mov ax, word[Screen_Max_Y] + .set_y: + mov [MOUSE_Y], ax ;-------------------------------------- -align 4 -@@M3: - cmp ax, word [Screen_Max_Y];ScreenHeigth - jl @@M4 - mov ax, word [Screen_Max_Y];ScreenHeigth-1 -;-------------------------------------- -align 4 -@@M4: - mov [MOUSE_Y], ax;[YCoordinate] - mov eax, [VScroll] add [MOUSE_SCROLL_V], ax