Subversion Repositories Kolibri OS

Rev

Rev 2705 | Rev 3326 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1601 mario79 1
; <--- description --->
2
; compiler:     FASM 1.67.23
3
; name:         Mouse Emulation For KolibriOS
4
;-----------------------------------------------------------------------------
2710 mario79 5
; version:	1.2
6
; last update:  01/06/2012
7
; written by:   Marat Zakiyanov aka Mario79, aka Mario
8
; changes:      using new functions 66.6 and 66.7
9
;-----------------------------------------------------------------------------
2687 leency 10
; version:	1.1
11
; last update:  26/05/2012
12
; written by:   Lipatov Kirill aka Leency
13
; changes:      shows notify with instructions, while opening program
14
;-----------------------------------------------------------------------------
1601 mario79 15
; version:	1.0
16
; last update:  04/09/2010
17
; written by:   Marat Zakiyanov aka Mario79, aka Mario
18
; changes:      total optimization of code,
19
;               different events for Up and Down of key Num 5
20
;               advansed acceleration mode
21
;-----------------------------------------------------------------------------
22
; version:      0.8
23
; last update:  03/10/2007
24
; written by:   Zlobny_Gluk
25
; e-mail:       umbrosia@land.ru
26
;-----------------------------------------------------------------------------
27
; <--- include all KolibriOS stuff --->
2687 leency 28
include "lang.inc"
1601 mario79 29
include '../../../macros.inc'
30
 
31
; <--- start of KolibriOS application --->
32
MEOS_APP_START
33
 
34
; <--- start of code --->
35
CODE
36
;-----------------------------------------------------------------------------
37
start:
2710 mario79 38
	mcall	70,notifyapp
2687 leency 39
 
2705 leency 40
start1:
1601 mario79 41
	xor	ebx,ebx
42
	mcall	40
43
@@:
44
	mcall	23,10
45
 
46
	mcall	66,3
2710 mario79 47
	test	eax,0x80	;NumLock status
1601 mario79 48
	jz	@r
49
 
50
	mov	ebx,4
51
	call	hotkeys_common
52
 
53
	mcall	40,10b
54
still:
55
	mcall	10
56
 
57
	cmp	eax,2		; if event == 2
58
	jne	still
59
;-----------------------------------------------------------------------------
60
key:				   ; key event handler
61
	call	mouse_acceleration
62
 
63
	mcall	2		   ; get key code
64
 
65
	push	eax
66
	mcall	66,3
2710 mario79 67
	test	eax,0x80	;NumLock status
1601 mario79 68
	pop	eax
69
	jnz	@f
70
	mov	ebx,5
2710 mario79 71
	call	hotkeys_common
2705 leency 72
	jmp	start1
1601 mario79 73
@@:
74
	cmp	al,2
75
	jne	still
76
 
77
	xor	edx,edx
78
 
79
	cmp	ah,80	; Down Num 2
80
	je	keytwo
81
	cmp	ah,81	; Down Num 3
82
	je	keythree
83
	cmp	ah,75	; Down Num 4
84
	je	keyfour
85
	cmp	ah,77	; Down Num 6
86
	je	keysix
87
	cmp	ah,71	; Down Num 7
88
	je	keyseven
89
	cmp	ah,72	; Down Num 8
90
	je	keyeight
91
	cmp	ah,73	; Down Num 9
92
	je	keynine
93
	cmp	ah,76	; Down Num 5
94
	je	keyfive
95
	cmp	ah,204	; Up Num 5
96
	je	keyfive_1
97
	cmp	ah,79	; Down Num 1
98
	jne	still
99
;-----------------------------------------------------------------------------
100
keyone:
101
	call	down
102
keyfour:
103
	call	left
104
	jmp	mouseread
105
;-----------------------------------------------------------------------------
106
keythree:
107
	call	right
108
keytwo:
109
	call	down
110
	jmp	mouseread
111
;-----------------------------------------------------------------------------
112
keyseven:
113
	call	left
114
keyeight:
115
	call	up
116
	jmp	mouseread
117
;-----------------------------------------------------------------------------
118
keynine:
119
	call	up
120
keysix:
121
	call	right
122
	jmp	mouseread
123
;-----------------------------------------------------------------------------
124
keyfive:
125
	inc	edx
126
keyfive_1:
127
	mcall	18,19,5
128
	jmp	still
129
;-----------------------------------------------------------------------------
130
left:
131
	mov	eax,esi
132
	shl	eax,16
133
	sub	edx,eax
134
	ret
135
;-----------------------------------------------------------------------------
136
right:
137
	mov	eax,esi
138
	shl	eax,16
139
	add	edx,eax
140
	ret
141
;-----------------------------------------------------------------------------
142
down:
143
	add	edx,esi
144
	ret
145
;-----------------------------------------------------------------------------
146
up:
147
	sub	edx,esi
148
	ret
149
;-----------------------------------------------------------------------------
150
mouseread:
151
	xor	ebx,ebx
152
	mcall	37
153
	add	edx,eax
154
 
155
sravn:
156
	xor	ebx,ebx
157
	xor	edi,edi
158
 
159
real:
160
	mov	ebx,edx
161
	mov	edi,ebx
162
	shr	ebx,16 ; get x1
163
;	shl	edi,16 ; get y1
164
;	shr	edi,16
165
	and	edi,0xffff
166
 
167
nullli:
168
	add	ebx,16
169
	cmp	ebx,65535
170
	jg	xmin
171
	sub	ebx,15
172
 
173
	add	edi,16
174
	cmp	edi,65535
175
	jg	ymin
176
	sub	edi,15
177
 
178
razr:
179
	mcall	14
180
 
181
	mov	ecx,eax
182
	shr	eax,16 ; get x2
183
;	shl	ecx,16 ; get y2
184
;	shr	ecx,16
185
	and	ecx,0xffff
186
 
187
rightdownli:
188
	cmp	eax,ebx
189
	jl	xmax
190
	cmp	ecx,edi
191
	jl	ymax
192
 
193
mousewrite:
194
	mcall	18,19,4
195
	mcall	26,9
196
	mov	[mouse_timer_ticks],eax
197
	jmp	still
198
;-----------------------------------------------------------------------------
199
mouse_acceleration:
200
	xor	esi,esi
201
	inc	esi
202
	mcall	18,19,2
203
	mov	ecx,eax
204
	mcall	26,9
205
	sub	eax,[mouse_timer_ticks]
206
	cmp	eax,ecx  ; mouse_delay
207
	ja	@f
208
	xor	ecx,ecx
209
	mcall	18,19	; checkspeed
210
	mov	esi,eax
211
	shl	esi,2
212
@@:
213
	ret
214
;-----------------------------------------------------------------------------
215
xmax:
216
	dec	eax
217
	dec	ebx
218
	dec	edi
219
	shl	eax,16
220
	add	edi,eax
221
	mov	edx,edi
222
	jmp	sravn
223
;-----------------------------------------------------------------------------
224
xmin:
225
	mov	edx,edi
226
	jmp	sravn
227
;-----------------------------------------------------------------------------
228
ymax:
229
	dec	ecx
230
	dec	ebx
231
 
232
	shl	ebx,16
233
	mov	edi,ebx
234
	add	edi,ecx
235
	mov	edx,edi
236
	jmp	sravn
237
;-----------------------------------------------------------------------------
238
ymin:
239
	shl	ebx,16
240
	mov	edx,ebx
241
	shr	ebx,16
242
	jmp	sravn
243
;-----------------------------------------------------------------------------
244
hotkeys_common:
245
	xor	ecx,ecx
246
	xor	edx,edx
247
	mov	cl,79	; Down Num 1
248
	mcall	66
249
 
250
	mov	cl,80	; Down Num 2
251
	mcall	66
252
 
253
	mov	cl,81	; Down Num 3
254
	mcall	66
255
 
256
	mov	cl,75	; Down Num 4
257
	mcall	66
258
 
259
	mov	cl,76	; Down Num 5
260
	mcall	66
261
 
262
	mov	cl,204 ; Up Num 5
263
	mcall	66
264
 
265
	mov	cl,77	; Down Num 6
266
	mcall	66
267
 
268
	mov	cl,71	; Down Num 7
269
	mcall	66
270
 
271
	mov	cl,72	; Down Num 8
272
	mcall	66
273
 
274
	mov	cl,73	; Down Num 9
275
	mcall	66
2710 mario79 276
; disable/enable input, work only hotkeys (f.66.6,66.7)
277
	add	ebx,2
278
	mcall	66
1601 mario79 279
	ret
280
;-----------------------------------------------------------------------------
281
; <--- initialised data --->
282
DATA
283
;-----------------------------------------------------------------------------
284
; <--- uninitialised data --->
285
UDATA
286
mouse_timer_ticks	dd 0
287
;-----------------------------------------------------------------------------
2687 leency 288
if lang eq ru
2710 mario79 289
ud_user_message db 'NumLock вкл/выкл эмулятор мыши. Управление Numpad',0
2687 leency 290
else
291
ud_user_message db 'NumLock - on/off mouse emul. Numpad - move cursor',0
292
end if
293
 
294
notifyapp:
2710 mario79 295
	dd 7
296
	dd 0
297
	dd ud_user_message
298
	dd 0
299
	dd 0
300
	db '@notify',0
2687 leency 301
;-----------------------------------------------------------------------------
1601 mario79 302
MEOS_APP_END
303
; <--- end of KolibriOS application --->
304
; ZG