Subversion Repositories Kolibri OS

Rev

Rev 5676 | Rev 7182 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5676 Rev 5996
1
#ifndef INCLUDE_MOUSE_H
1
#ifndef INCLUDE_MOUSE_H
2
#define INCLUDE_MOUSE_H
2
#define INCLUDE_MOUSE_H
3
#print "[include ]\n"
3
#print "[include ]\n"
4
 
4
 
5
//Button MOUSE
5
//Button MOUSE
6
#define MOUSE_LEFT   001b
6
#define MOUSE_LEFT   001b
7
#define MOUSE_RIGHT  010b
7
#define MOUSE_RIGHT  010b
8
#define MOUSE_LR     011b
8
#define MOUSE_LR     011b
9
#define MOUSE_CENTER 100b
9
#define MOUSE_CENTER 100b
10
 
10
 
11
/**
11
/**
12
 *  The structure of the MOUSE
12
 *  The structure of the MOUSE
13
 *  x - coordinate X
13
 *  x - coordinate X
14
 *  y - coordinate Y
14
 *  y - coordinate Y
15
 *  xx and yy - time coordinates
15
 *  xx and yy - time coordinates
16
 *  lkm - left MOUSE button
16
 *  lkm - left MOUSE button
17
 *  pkm - right MOUSE button
17
 *  pkm - right MOUSE button
18
 *  mkm - MOUSE wheel
18
 *  mkm - MOUSE wheel
19
 *  key - keycode button
19
 *  key - keycode button
20
 *  tmp - time keycode 
20
 *  tmp - time keycode 
21
 *  down - key event press
21
 *  down - key event press
22
 *  up - key release events
22
 *  up - key release events
23
 *  move - event MOUSE movements
23
 *  move - event MOUSE movements
24
 *  click - when clicked
24
 *  click - when clicked
25
 *  dblclick - double-click the default 50 (500 ms)
25
 *  dblclick - double-click get system value
26
 *  drag - drag the element event
26
 *  drag - drag the element event
27
 */
27
 */
28
 
28
 
29
:dword __TMP_TIME,MOUSE_TIME;
29
:dword __TMP_TIME,DOUBLE_CLICK_DELAY;
30
:struct MOUSE
30
:struct MOUSE
31
{
31
{
32
	signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick,drag,left,top;
32
	signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick,drag,left,top;
33
	dword handle,_;
33
	dword handle,_;
34
	byte cmd;
34
	byte cmd;
35
	void clearTime();
35
	void clearTime();
36
	void get();
36
	void get();
37
	void set();
37
	void set();
38
	void center();
38
	void center();
39
	dword hide();
39
	dword hide();
40
	void slider();
40
	void slider();
41
	void show();
41
	void show();
42
} mouse;
42
} mouse;
43
:void MOUSE::clearTime()
43
:void MOUSE::clearTime()
44
{
44
{
45
	tmp_time = GetStartTime()+MOUSE_TIME;
45
	tmp_time = GetStartTime()+DOUBLE_CLICK_DELAY;
46
}
46
}
47
:void MOUSE::show()
47
:void MOUSE::show()
48
{
48
{
49
	if(!handle)return;
49
	if(!handle)return;
50
	ECX = handle;
50
	ECX = handle;
51
	EAX = 37;
51
	EAX = 37;
52
	EBX = 5;
52
	EBX = 5;
53
	$int 0x40;
53
	$int 0x40;
54
}
54
}
55
:dword MOUSE::hide()
55
:dword MOUSE::hide()
56
{
56
{
57
	if(!_)
57
	if(!_)
58
	{
58
	{
59
		EAX = 68;
59
		EAX = 68;
60
		EBX = 12;
60
		EBX = 12;
61
		ECX = 32*32*4;
61
		ECX = 32*32*4;
62
		$int 0x40
62
		$int 0x40
63
		ECX = EAX;
63
		ECX = EAX;
64
		_ = EAX;
64
		_ = EAX;
65
	} else ECX = _;
65
	} else ECX = _;
66
	EAX = 37;
66
	EAX = 37;
67
	EBX = 4;
67
	EBX = 4;
68
	DX  = 2;
68
	DX  = 2;
69
	$int 0x40;
69
	$int 0x40;
70
	handle = EAX;
70
	handle = EAX;
71
	ECX = EAX;
71
	ECX = EAX;
72
	EAX = 37;
72
	EAX = 37;
73
	EBX = 5;
73
	EBX = 5;
74
	$int 0x40;
74
	$int 0x40;
75
	handle = EAX;
75
	handle = EAX;
76
}
76
}
77
 
77
 
78
//set new attributes MOUSE
78
//set new attributes MOUSE
79
:void MOUSE::set()
79
:void MOUSE::set()
80
{
80
{
81
	if((xx!=x)||(yy!=y))
81
	if((xx!=x)||(yy!=y))
82
	{
82
	{
83
		EAX = 18;
83
		EAX = 18;
84
		EBX = 19;
84
		EBX = 19;
85
		ECX = 4;
85
		ECX = 4;
86
		EDX = (x<<16)+y;
86
		EDX = (x<<16)+y;
87
		$int 0x40
87
		$int 0x40
88
		//move = true;
88
		//move = true;
89
	}
89
	}
90
	if((key)||(lkm|mkm|pkm))&&(down|up|click|dblclick|move)
90
	if((key)||(lkm|mkm|pkm))&&(down|up|click|dblclick|move)
91
	{
91
	{
92
		if(lkm|mkm|pkm)key=(lkm)|(pkm<<1)|(2<
92
		if(lkm|mkm|pkm)key=(lkm)|(pkm<<1)|(2<
93
		EAX = 18;
93
		EAX = 18;
94
		EBX = 19;
94
		EBX = 19;
95
		ECX = key;
95
		ECX = key;
96
		EDX = (x<<16)+y;
96
		EDX = (x<<16)+y;
97
		$int 0x40
97
		$int 0x40
98
	}
98
	}
99
}
99
}
100
 
100
 
101
:void MOUSE::center()
101
:void MOUSE::center()
102
{
102
{
103
	EAX = 18;
103
	EAX = 18;
104
	EBX = 15;
104
	EBX = 15;
105
	$int 0x40
105
	$int 0x40
106
}
106
}
107
 
107
 
108
//get new attributes MOUSE
108
//get new attributes MOUSE
109
:void MOUSE::get()
109
:void MOUSE::get()
110
{
110
{
111
	EAX = 37;
111
	EAX = 37;
112
	EBX = 1;
112
	EBX = 1;
113
	$int	0x40
113
	$int	0x40
114
	$mov	ebx, eax
114
	$mov	ebx, eax
115
	$shr	eax, 16
115
	$shr	eax, 16
116
	$and	ebx,0x0000FFFF
116
	$and	ebx,0x0000FFFF
117
	x = EAX;
117
	x = EAX;
118
	y = EBX;
118
	y = EBX;
119
	if (x>6000) x-=65535;
119
	if (x>6000) x-=65535;
120
	if (y>6000) y-=65535;
120
	if (y>6000) y-=65535;
121
	EAX = 37;
121
	EAX = 37;
122
	EBX = 2;
122
	EBX = 2;
123
	$int	0x40
123
	$int	0x40
124
	$mov	ebx, eax
124
	$mov	ebx, eax
125
	$mov	ecx, eax
125
	$mov	ecx, eax
126
	key = EAX;
126
	key = EAX;
127
	$and	eax, 0x00000001
127
	$and	eax, 0x00000001
128
	$shr	ebx, 1
128
	$shr	ebx, 1
129
	$and	ebx, 0x00000001
129
	$and	ebx, 0x00000001
130
	$shr	ecx, 2
130
	$shr	ecx, 2
131
	$and	ecx, 0x00000001
131
	$and	ecx, 0x00000001
132
	lkm = EAX;
132
	lkm = EAX;
133
	pkm = EBX;
133
	pkm = EBX;
134
	mkm = ECX;
134
	mkm = ECX;
135
	
135
	
136
	//when you release the MOUSE button
136
	//when you release the MOUSE button
137
	// Mouse Move Event
137
	// Mouse Move Event
138
	if(xx!=x)||(yy!=y)
138
	if(xx!=x)||(yy!=y)
139
	{
139
	{
140
		move = true;
140
		move = true;
141
		xx = x;
141
		xx = x;
142
		yy = y;
142
		yy = y;
143
	}
143
	}
144
	else move = false;
144
	else move = false;
145
	// Mouse Up Event
145
	// Mouse Up Event
146
	if(cmd)&&(!key){
146
	if(cmd)&&(!key){
147
		up   = true;
147
		up   = true;
148
		down = false;
148
		down = false;
149
		drag = false;
149
		drag = false;
150
		if(!move) click = true;
150
		if(!move) click = true;
151
		__TMP_TIME = GetStartTime();
151
		__TMP_TIME = GetStartTime();
152
		if(__TMP_TIME-tmp_time<=MOUSE_TIME)
152
		if(__TMP_TIME-tmp_time<=DOUBLE_CLICK_DELAY)
153
		{ 
153
		{ 
154
			dblclick = true;
154
			dblclick = true;
155
			click    = false; 
155
			click    = false; 
156
		}
156
		}
157
		tmp_time = __TMP_TIME;
157
		tmp_time = __TMP_TIME;
158
		//returns the key code
158
		//returns the key code
159
		key = tmp;
159
		key = tmp;
160
		lkm = 1&tmp;
160
		lkm = 1&tmp;
161
		pkm = 2&tmp;
161
		pkm = 2&tmp;
162
		pkm >>= 1;
162
		pkm >>= 1;
163
		mkm = 4&tmp;
163
		mkm = 4&tmp;
164
		mkm >>= 2;
164
		mkm >>= 2;
165
		cmd = false;
165
		cmd = false;
166
	}
166
	}
167
	
167
	
168
	//when you press the MOUSE button
168
	//when you press the MOUSE button
169
	// Mouse Down Event/Move Event
169
	// Mouse Down Event/Move Event
170
	else 
170
	else 
171
	{
171
	{
172
	    up       = false;
172
	    up       = false;
173
		click    = false;
173
		click    = false;
174
		dblclick = false;
174
		dblclick = false;
175
		down     = false;
175
		down     = false;
176
		// Mouse Move Event
176
		// Mouse Move Event
177
		if(key)if(!cmd) 
177
		if(key)if(!cmd) 
178
		{
178
		{
179
			down = true;
179
			down = true;
180
			if(move)drag = true;
180
			if(move)drag = true;
181
			cmd = true;
181
			cmd = true;
182
			tmp=key;
182
			tmp=key;
183
		}
183
		}
184
	}
184
	}
185
	
185
	
186
	//scroll
186
	//scroll
187
	EAX = 37;
187
	EAX = 37;
188
	EBX = 7;
188
	EBX = 7;
189
	$int	0x40
189
	$int	0x40
190
	$mov	ebx, eax
190
	$mov	ebx, eax
191
	$shr	eax, 16
191
	$shr	eax, 16
192
	$and	ebx,0x0000FFFF
192
	$and	ebx,0x0000FFFF
193
	//hor = EAX;
193
	//hor = EAX;
194
	vert = EBX;
194
	vert = EBX;
195
}
195
}
196
 
196
 
197
 
197
 
198
 
198
 
199
:void MOUSE::slider()
199
:void MOUSE::slider()
200
{
200
{
201
	signed _x,_y;
201
	signed _x,_y;
202
	if(!handle)hide();
202
	if(!handle)hide();
203
	get();
203
	get();
204
	_x = x;_y = y;
204
	_x = x;_y = y;
205
	pause(5);
205
	pause(5);
206
	get();
206
	get();
207
	left = _x - x;
207
	left = _x - x;
208
	top  = _y - y;
208
	top  = _y - y;
209
	center();
209
	center();
210
	get();
210
	get();
211
	_x = x;_y = y;
211
	_x = x;_y = y;
212
	pause(5);
212
	pause(5);
213
}
213
}
-
 
214
 
-
 
215
 
-
 
216
/*=====================================================================================
-
 
217
===========================                                 ===========================
-
 
218
===========================              SYSTEM             ===========================
-
 
219
===========================                                 ===========================
-
 
220
=====================================================================================*/
-
 
221
 
-
 
222
 
-
 
223
inline fastcall int GetMouseSpeed() {
-
 
224
	$mov eax,18
-
 
225
	$mov ebx,19
-
 
226
	$mov ecx,0
-
 
227
	$int 0x40
-
 
228
}
-
 
229
 
-
 
230
inline fastcall void SetMouseSpeed(EDX) {
-
 
231
	$mov eax,18
-
 
232
	$mov ebx,19
-
 
233
	$mov ecx,1
-
 
234
	$int 0x40
-
 
235
}
-
 
236
 
-
 
237
inline fastcall int GetMouseAcceleration() {
-
 
238
	$mov eax,18
-
 
239
	$mov ebx,19
-
 
240
	$mov ecx,2
-
 
241
	$int 0x40
-
 
242
}
-
 
243
 
-
 
244
inline fastcall void SetMouseAcceleration(EDX) {
-
 
245
	$mov eax,18
-
 
246
	$mov ebx,19
-
 
247
	$mov ecx,3
-
 
248
	$int 0x40
-
 
249
}
-
 
250
 
-
 
251
inline fastcall int GetMouseDoubleClickDelay() {
-
 
252
	$mov eax,18
-
 
253
	$mov ebx,19
-
 
254
	$mov ecx,6
-
 
255
	$int 0x40
-
 
256
}
-
 
257
 
-
 
258
inline fastcall void SetMouseDoubleClickDelay(DL) {
-
 
259
	$mov eax,18
-
 
260
	$mov ebx,19
-
 
261
	$mov ecx,7
-
 
262
	$int 0x40
-
 
263
}
214
 
264
 
215
#endif
265
#endif
216
>
266
>
217
>
267
>
218
>
268
>
219
>
269
>
220
>
270
>
221
>
271
>
222
>
272
>
223
>
273
>
224
>
274
>