Rev 9930 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
9941 | Doczom | 3 | ;; Copyright (C) KolibriOS team 2004-2023. All rights reserved. ;; |
2288 | clevermous | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
8 | $Revision: 9941 $ |
||
9 | |||
10 | |||
11 | ; check mouse |
||
12 | ; |
||
13 | ; |
||
14 | ; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y |
||
15 | ; FB10 -> FB17 mouse color mem |
||
16 | ; FB21 x move |
||
17 | ; FB22 y move |
||
18 | ; FB30 color temp |
||
19 | ; FB28 high bits temp |
||
20 | ; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under |
||
21 | ; FC00 -> FCFE com1/ps2 buffer |
||
22 | ; FCFF com1/ps2 buffer count starting from FC00 |
||
23 | |||
24 | uglobal |
||
2430 | mario79 | 25 | ;-------------------------------------- |
26 | align 4 |
||
5154 | hidnplayr | 27 | mousecount dd ? |
28 | mousedata dd ? |
||
29 | Y_UNDER_sub_CUR_hot_y_add_curh dw ? |
||
30 | Y_UNDER_subtraction_CUR_hot_y dw ? |
||
31 | X_UNDER_sub_CUR_hot_x_add_curh dw ? |
||
32 | X_UNDER_subtraction_CUR_hot_x dw ? |
||
2288 | clevermous | 33 | endg |
34 | |||
35 | iglobal |
||
2430 | mario79 | 36 | ;-------------------------------------- |
37 | align 4 |
||
6230 | pathoswith | 38 | mouse_speed_factor dw 4 |
39 | mouse_delay db 3 |
||
5851 | pathoswith | 40 | mouse_doubleclick_delay db 64 |
2288 | clevermous | 41 | endg |
5154 | hidnplayr | 42 | |
2430 | mario79 | 43 | ;----------------------------------------------------------------------------- |
5154 | hidnplayr | 44 | |
2430 | mario79 | 45 | align 4 |
2288 | clevermous | 46 | draw_mouse_under: |
5154 | hidnplayr | 47 | |
2288 | clevermous | 48 | ; return old picture |
49 | cmp [_display.restore_cursor], 0 |
||
50 | je @F |
||
51 | |||
52 | pushad |
||
53 | movzx eax, word [X_UNDER] |
||
54 | movzx ebx, word [Y_UNDER] |
||
55 | stdcall [_display.restore_cursor], eax, ebx |
||
56 | popad |
||
9941 | Doczom | 57 | @@: |
2288 | clevermous | 58 | ret |
5154 | hidnplayr | 59 | |
2430 | mario79 | 60 | ;----------------------------------------------------------------------------- |
5154 | hidnplayr | 61 | |
2430 | mario79 | 62 | align 4 |
2288 | clevermous | 63 | save_draw_mouse: |
64 | cmp [_display.move_cursor], 0 |
||
9941 | Doczom | 65 | je .exit |
2288 | clevermous | 66 | pushad |
67 | |||
68 | mov [X_UNDER], ax |
||
69 | mov [Y_UNDER], bx |
||
70 | movzx eax, word [MOUSE_Y] |
||
71 | movzx ebx, word [MOUSE_X] |
||
72 | push eax |
||
73 | push ebx |
||
74 | |||
2446 | mario79 | 75 | mov eax, [d_width_calc_area + eax*4] |
76 | |||
5351 | serge | 77 | add eax, [_display.win_map] |
9715 | Doczom | 78 | movzx edx, byte [ebx + eax] |
9930 | Doczom | 79 | shl edx, BSF sizeof.WDATA |
9848 | rgimad | 80 | ; edx - thread slot of window under cursor |
9930 | Doczom | 81 | mov esi, [window_data + edx + WDATA.cursor] ; cursor of window under cursor |
2288 | clevermous | 82 | |
9848 | rgimad | 83 | ; if cursor of window under cursor already equal to the |
84 | ; current_cursor then just draw it |
||
2288 | clevermous | 85 | cmp esi, [current_cursor] |
86 | je .draw |
||
87 | |||
9848 | rgimad | 88 | ; eax = thread slot of current active window |
8866 | rgimad | 89 | mov eax, [thread_count] |
9715 | Doczom | 90 | movzx eax, word [WIN_POS + eax*2] |
9930 | Doczom | 91 | shl eax, BSF sizeof.WDATA |
3069 | serge | 92 | |
9848 | rgimad | 93 | ; window under cursor == active window ? |
3069 | serge | 94 | cmp eax, edx |
9850 | rgimad | 95 | je @f |
3069 | serge | 96 | |
9850 | rgimad | 97 | ; check whether active window is being resized now: |
9848 | rgimad | 98 | mov bl, [mouse.active_sys_window.action] |
99 | and bl, mouse.WINDOW_RESIZE_S_FLAG or mouse.WINDOW_RESIZE_W_FLAG or mouse.WINDOW_RESIZE_E_FLAG |
||
100 | test bl, bl |
||
9850 | rgimad | 101 | jz .active_isnt_resizing |
9930 | Doczom | 102 | mov esi, [window_data + eax + WDATA.cursor] ; esi = cursor of active window, it is resizing cursor |
9850 | rgimad | 103 | jmp @f |
104 | .active_isnt_resizing: |
||
9848 | rgimad | 105 | |
9850 | rgimad | 106 | ; if cursor of window under the cursor is resizing cursor then draw it. |
107 | cmp esi, [def_cursor_hresize] |
||
108 | je @f |
||
109 | cmp esi, [def_cursor_vresize] |
||
110 | je @f |
||
111 | cmp esi, [def_cursor_dresize1] |
||
112 | je @f |
||
113 | cmp esi, [def_cursor_dresize2] |
||
114 | je @f |
||
9848 | rgimad | 115 | |
9850 | rgimad | 116 | ; set cursor of window under cursor |
9930 | Doczom | 117 | mov esi, [window_data + edx + WDATA.cursor] |
3069 | serge | 118 | cmp esi, [current_cursor] |
119 | je .draw |
||
120 | |||
121 | @@: |
||
9941 | Doczom | 122 | cmp [_display.select_cursor], 0 |
123 | jz .error |
||
124 | |||
125 | stdcall [_display.select_cursor], esi |
||
2288 | clevermous | 126 | mov [current_cursor], esi |
2430 | mario79 | 127 | ;-------------------------------------- |
128 | align 4 |
||
2288 | clevermous | 129 | .draw: |
130 | stdcall [_display.move_cursor], esi |
||
131 | popad |
||
132 | ret |
||
2430 | mario79 | 133 | ;-------------------------------------- |
134 | ;align 4 |
||
135 | ;.fail: |
||
136 | ; mov ecx, [def_cursor] |
||
9930 | Doczom | 137 | ; mov [window_data + edx + WDATA.cursor], ecx |
2430 | mario79 | 138 | ; stdcall [_display.move_cursor], ecx ; stdcall: [esp]=ebx,eax |
139 | ; popad |
||
140 | ; ret |
||
141 | ;-------------------------------------- |
||
142 | align 4 |
||
9941 | Doczom | 143 | .error: |
2288 | clevermous | 144 | popad |
9941 | Doczom | 145 | .exit: |
2288 | clevermous | 146 | ret |
5154 | hidnplayr | 147 | |
2430 | mario79 | 148 | ;----------------------------------------------------------------------------- |
5154 | hidnplayr | 149 | |
2430 | mario79 | 150 | align 4 |
151 | __sys_draw_pointer: |
||
2288 | clevermous | 152 | pushad |
153 | movzx ecx, word [X_UNDER] |
||
154 | movzx edx, word [Y_UNDER] |
||
155 | movzx ebx, word [MOUSE_Y] |
||
156 | movzx eax, word [MOUSE_X] |
||
2450 | mario79 | 157 | cmp [redrawmouse_unconditional], 0 |
158 | je @f |
||
159 | mov [redrawmouse_unconditional], 0 |
||
9941 | Doczom | 160 | jmp .redrawmouse |
5154 | hidnplayr | 161 | @@: |
2288 | clevermous | 162 | cmp eax, ecx |
9941 | Doczom | 163 | jne .redrawmouse |
2288 | clevermous | 164 | cmp ebx, edx |
9941 | Doczom | 165 | je .nodmp |
5154 | hidnplayr | 166 | |
2430 | mario79 | 167 | ;-------------------------------------- |
5154 | hidnplayr | 168 | |
2430 | mario79 | 169 | align 4 |
9941 | Doczom | 170 | .redrawmouse: |
2288 | clevermous | 171 | pushfd |
172 | cli |
||
173 | call draw_mouse_under |
||
174 | call save_draw_mouse |
||
2430 | mario79 | 175 | |
2448 | mario79 | 176 | cmp [_display.select_cursor], select_cursor |
177 | jne @f |
||
2430 | mario79 | 178 | |
179 | xor eax, eax |
||
180 | mov esi, [current_cursor] |
||
181 | |||
182 | mov ax, [Y_UNDER] |
||
9715 | Doczom | 183 | sub eax, [esi + CURSOR.hot_y] |
2575 | mario79 | 184 | mov [Y_UNDER_subtraction_CUR_hot_y], ax |
2430 | mario79 | 185 | add eax, [cur.h] |
2575 | mario79 | 186 | mov [Y_UNDER_sub_CUR_hot_y_add_curh], ax |
2430 | mario79 | 187 | |
188 | mov ax, [X_UNDER] |
||
9715 | Doczom | 189 | sub eax, [esi + CURSOR.hot_x] |
2575 | mario79 | 190 | mov [X_UNDER_subtraction_CUR_hot_x], ax |
2430 | mario79 | 191 | add eax, [cur.w] |
2575 | mario79 | 192 | mov [X_UNDER_sub_CUR_hot_x_add_curh], ax |
5154 | hidnplayr | 193 | @@: |
2288 | clevermous | 194 | popfd |
9941 | Doczom | 195 | .nodmp: |
2288 | clevermous | 196 | popad |
197 | ret |
||
5154 | hidnplayr | 198 | |
2430 | mario79 | 199 | ;----------------------------------------------------------------------------- |
5154 | hidnplayr | 200 | |
2430 | mario79 | 201 | align 4 |
6230 | pathoswith | 202 | proc set_mouse_data stdcall uses ecx edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword |
2288 | clevermous | 203 | |
204 | mov eax, [BtnState] |
||
5154 | hidnplayr | 205 | and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements |
2288 | clevermous | 206 | mov [BTN_DOWN], eax |
4592 | hidnplayr | 207 | ;-------------------------------------- |
2288 | clevermous | 208 | mov eax, [XMoving] |
4529 | hidnplayr | 209 | test [BtnState], 0x80000000 |
4592 | hidnplayr | 210 | jnz .absolute_x |
5853 | pathoswith | 211 | test eax, eax |
212 | jz @f |
||
2288 | clevermous | 213 | call mouse_acceleration |
4592 | hidnplayr | 214 | add ax, [MOUSE_X] |
5853 | pathoswith | 215 | jns .check_x |
216 | xor eax, eax |
||
4592 | hidnplayr | 217 | jmp .set_x |
218 | .absolute_x: |
||
219 | mov edx, [_display.width] |
||
220 | mul edx |
||
221 | shr eax, 15 |
||
222 | .check_x: |
||
5350 | serge | 223 | cmp ax, word[_display.width] |
4592 | hidnplayr | 224 | jl .set_x |
5350 | serge | 225 | mov ax, word[_display.width] |
226 | dec ax |
||
4592 | hidnplayr | 227 | .set_x: |
228 | mov [MOUSE_X], ax |
||
2430 | mario79 | 229 | ;-------------------------------------- |
5853 | pathoswith | 230 | @@: |
2288 | clevermous | 231 | mov eax, [YMoving] |
4529 | hidnplayr | 232 | test [BtnState], 0x40000000 |
4592 | hidnplayr | 233 | jnz .absolute_y |
5853 | pathoswith | 234 | test eax, eax |
235 | jz @f |
||
2288 | clevermous | 236 | neg eax |
237 | call mouse_acceleration |
||
4592 | hidnplayr | 238 | add ax, [MOUSE_Y] |
5853 | pathoswith | 239 | jns .check_y |
240 | xor eax, eax |
||
4592 | hidnplayr | 241 | jmp .set_y |
242 | .absolute_y: |
||
243 | mov edx, [_display.height] |
||
244 | mul edx |
||
245 | shr eax, 15 |
||
246 | .check_y: |
||
5350 | serge | 247 | cmp ax, word[_display.height] |
4592 | hidnplayr | 248 | jl .set_y |
5350 | serge | 249 | mov ax, word[_display.height] |
250 | dec ax |
||
4592 | hidnplayr | 251 | .set_y: |
252 | mov [MOUSE_Y], ax |
||
2430 | mario79 | 253 | ;-------------------------------------- |
5853 | pathoswith | 254 | @@: |
2288 | clevermous | 255 | mov eax, [VScroll] |
5851 | pathoswith | 256 | test eax, eax |
257 | jz @f |
||
2288 | clevermous | 258 | add [MOUSE_SCROLL_V], ax |
5851 | pathoswith | 259 | bts word [BTN_DOWN], 15 |
260 | @@: |
||
2288 | clevermous | 261 | mov eax, [HScroll] |
5851 | pathoswith | 262 | test eax, eax |
263 | jz @f |
||
2288 | clevermous | 264 | add [MOUSE_SCROLL_H], ax |
5851 | pathoswith | 265 | bts dword [BTN_DOWN], 23 |
266 | @@: |
||
2288 | clevermous | 267 | mov [mouse_active], 1 |
3534 | clevermous | 268 | call wakeup_osloop |
2288 | clevermous | 269 | ret |
270 | endp |
||
5154 | hidnplayr | 271 | |
2430 | mario79 | 272 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 273 | mouse_acceleration: |
6230 | pathoswith | 274 | neg ax |
275 | jl mouse_acceleration |
||
276 | add al, [mouse_delay] |
||
277 | mul al |
||
278 | mov cx, [mouse_speed_factor] |
||
279 | dec ax |
||
280 | shr ax, cl |
||
281 | inc ax |
||
282 | test eax, eax |
||
283 | jns @f |
||
284 | neg ax |
||
5853 | pathoswith | 285 | @@: |
2288 | clevermous | 286 | ret |