Subversion Repositories Kolibri OS

Rev

Rev 3741 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3741 Rev 4529
Line 30... Line 30...
30
 
30
 
31
; This procedure is called when HID layer detects a new mouse.
31
; This procedure is called when HID layer detects a new mouse.
32
; in: ebx -> device_data from USB layer, edi -> collection
32
; in: ebx -> device_data from USB layer, edi -> collection
33
; out: eax = device-specific data or NULL on error
33
; out: eax = device-specific data or NULL on error
-
 
34
proc mouse_driver_add_device
-
 
35
; Get screen resolution so we can calculate absolute coordinates.
-
 
36
        mov     eax, 14
-
 
37
        int     0x40
-
 
38
        mov     [screen_y], eax
-
 
39
        and     [screen_y], 0xffff
-
 
40
        shr     eax, 16
34
proc mouse_driver_add_device
41
        mov     [screen_x], eax
35
; Just allocate memory; no initialization needed.
42
; Just allocate memory; no initialization needed.
36
        movi    eax, sizeof.mouse_device_data
43
        movi    eax, sizeof.mouse_device_data
37
        call    Kmalloc
44
        call    Kmalloc
38
        ret
45
        ret
Line 109... Line 116...
109
end if
116
end if
110
.x:
117
.x:
111
; 3. This is x moving. For relative fields, store the value in the state.
118
; 3. This is x moving. For relative fields, store the value in the state.
112
; Pass absolute field to the default handler.
119
; Pass absolute field to the default handler.
113
        test    byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
120
        test    byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
114
        jz      .unclaimed
121
        jz      .relative_x
115
        mov     [edi+mouse_device_data.dx], edx
122
        mov     [edi+mouse_device_data.dx], edx
116
        ret
123
        ret
117
.y:
124
.y:
118
; 4. This is y moving. For relative fields, store the value in the state,
125
; 4. This is y moving. For relative fields, store the value in the state,
119
; changing the sign: HID uses "mathematics" scheme with Y axis increasing from
126
; changing the sign: HID uses "mathematics" scheme with Y axis increasing from
120
; bottom to top, the kernel expects "programming" PS/2-style with Y axis
127
; bottom to top, the kernel expects "programming" PS/2-style with Y axis
121
; increasing from top to bottom.
128
; increasing from top to bottom.
122
; Pass absolute fields to the default handler.
129
; Pass absolute fields to the default handler.
123
        test    byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
130
        test    byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
124
        jz      .unclaimed
131
        jz      .relative_y
125
        neg     edx
132
        neg     edx
126
        mov     [edi+mouse_device_data.dy], edx
133
        mov     [edi+mouse_device_data.dy], edx
127
        ret
134
        ret
128
.wheel:
135
.wheel:
129
; 5. This is wheel event. For relative fields, store the value in the state,
136
; 5. This is wheel event. For relative fields, store the value in the state,
Line 136... Line 143...
136
.hwheel:
143
.hwheel:
137
        test    byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
144
        test    byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
138
        jz      .unclaimed
145
        jz      .unclaimed
139
        mov     [edi+mouse_device_data.hwheel], edx
146
        mov     [edi+mouse_device_data.hwheel], edx
140
        ret
147
        ret
-
 
148
.relative_x:
-
 
149
        push    ebx
-
 
150
        mov     eax, [screen_x]
-
 
151
        mul     edx
-
 
152
        mov     ebx, 0x8000
-
 
153
        div     ebx
-
 
154
        mov     [edi+mouse_device_data.dx], eax
-
 
155
        or      [edi+mouse_device_data.buttons], 0x80000000
-
 
156
        pop     ebx
-
 
157
        ret
-
 
158
.relative_y:
-
 
159
        push    ebx
-
 
160
        mov     eax, [screen_y]
-
 
161
        mul     edx
-
 
162
        mov     ebx, 0x8000
-
 
163
        div     ebx
-
 
164
        mov     [edi+mouse_device_data.dy], eax
-
 
165
        or      [edi+mouse_device_data.buttons], 0x40000000
-
 
166
        pop     ebx
-
 
167
        ret
141
endp
168
endp
Line 142... Line 169...
142
 
169
 
143
; This procedure is called when HID layer ends processing a new input packet
170
; This procedure is called when HID layer ends processing a new input packet
144
; from a mouse.
171
; from a mouse.