forked from KolibriOS/kolibrios
USBHID: support for USB tablet (absolute coordinates).
git-svn-id: svn://kolibrios.org@4529 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
91ae4fdcf8
commit
40cbd60db3
@ -32,6 +32,13 @@ ends
|
|||||||
; in: ebx -> device_data from USB layer, edi -> collection
|
; in: ebx -> device_data from USB layer, edi -> collection
|
||||||
; out: eax = device-specific data or NULL on error
|
; out: eax = device-specific data or NULL on error
|
||||||
proc mouse_driver_add_device
|
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.
|
; Just allocate memory; no initialization needed.
|
||||||
movi eax, sizeof.mouse_device_data
|
movi eax, sizeof.mouse_device_data
|
||||||
call Kmalloc
|
call Kmalloc
|
||||||
@ -111,7 +118,7 @@ end if
|
|||||||
; 3. This is x moving. For relative fields, store the value in the state.
|
; 3. This is x moving. For relative fields, store the value in the state.
|
||||||
; Pass absolute field to the default handler.
|
; Pass absolute field to the default handler.
|
||||||
test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
|
test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
|
||||||
jz .unclaimed
|
jz .relative_x
|
||||||
mov [edi+mouse_device_data.dx], edx
|
mov [edi+mouse_device_data.dx], edx
|
||||||
ret
|
ret
|
||||||
.y:
|
.y:
|
||||||
@ -121,7 +128,7 @@ end if
|
|||||||
; increasing from top to bottom.
|
; increasing from top to bottom.
|
||||||
; Pass absolute fields to the default handler.
|
; Pass absolute fields to the default handler.
|
||||||
test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
|
test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
|
||||||
jz .unclaimed
|
jz .relative_y
|
||||||
neg edx
|
neg edx
|
||||||
mov [edi+mouse_device_data.dy], edx
|
mov [edi+mouse_device_data.dy], edx
|
||||||
ret
|
ret
|
||||||
@ -138,6 +145,26 @@ end if
|
|||||||
jz .unclaimed
|
jz .unclaimed
|
||||||
mov [edi+mouse_device_data.hwheel], edx
|
mov [edi+mouse_device_data.hwheel], edx
|
||||||
ret
|
ret
|
||||||
|
.relative_x:
|
||||||
|
push ebx
|
||||||
|
mov eax, [screen_x]
|
||||||
|
mul edx
|
||||||
|
mov ebx, 0x8000
|
||||||
|
div ebx
|
||||||
|
mov [edi+mouse_device_data.dx], eax
|
||||||
|
or [edi+mouse_device_data.buttons], 0x80000000
|
||||||
|
pop ebx
|
||||||
|
ret
|
||||||
|
.relative_y:
|
||||||
|
push ebx
|
||||||
|
mov eax, [screen_y]
|
||||||
|
mul edx
|
||||||
|
mov ebx, 0x8000
|
||||||
|
div ebx
|
||||||
|
mov [edi+mouse_device_data.dy], eax
|
||||||
|
or [edi+mouse_device_data.buttons], 0x40000000
|
||||||
|
pop ebx
|
||||||
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
; This procedure is called when HID layer ends processing a new input packet
|
; This procedure is called when HID layer ends processing a new input packet
|
||||||
|
@ -534,6 +534,9 @@ disconnectmsg db 'K : USB HID device disconnected',13,10,0
|
|||||||
invalid_report_msg db 'K : report descriptor is invalid',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
|
delimiter_note db 'K : note: alternate usage ignored',13,10,0
|
||||||
|
|
||||||
|
screen_x dd ?
|
||||||
|
screen_y dd ?
|
||||||
|
|
||||||
; Exported variable: kernel API version.
|
; Exported variable: kernel API version.
|
||||||
align 4
|
align 4
|
||||||
version dd 50005h
|
version dd 50005h
|
||||||
|
@ -482,9 +482,12 @@ align 4
|
|||||||
proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
|
proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
|
||||||
|
|
||||||
mov eax, [BtnState]
|
mov eax, [BtnState]
|
||||||
|
and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements
|
||||||
mov [BTN_DOWN], eax
|
mov [BTN_DOWN], eax
|
||||||
|
|
||||||
mov eax, [XMoving]
|
mov eax, [XMoving]
|
||||||
|
test [BtnState], 0x80000000
|
||||||
|
jnz @@M1
|
||||||
call mouse_acceleration
|
call mouse_acceleration
|
||||||
add ax, [MOUSE_X];[XCoordinate]
|
add ax, [MOUSE_X];[XCoordinate]
|
||||||
cmp ax, 0
|
cmp ax, 0
|
||||||
@ -503,6 +506,8 @@ align 4
|
|||||||
mov [MOUSE_X], ax;[XCoordinate]
|
mov [MOUSE_X], ax;[XCoordinate]
|
||||||
|
|
||||||
mov eax, [YMoving]
|
mov eax, [YMoving]
|
||||||
|
test [BtnState], 0x40000000
|
||||||
|
jnz @@M3
|
||||||
neg eax
|
neg eax
|
||||||
call mouse_acceleration
|
call mouse_acceleration
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user