Subversion Repositories Kolibri OS

Rev

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

Rev 7612 Rev 7646
Line 1... Line 1...
1
// Mouse Configuration Utility ver 1.61
1
// Mouse Configuration Utility ver 1.62
Line 2... Line 2...
2
 
2
 
3
#ifndef AUTOBUILD
3
#ifndef AUTOBUILD
4
#include "lang.h--"
4
#include "lang.h--"
Line 23... Line 23...
23
	?define POINTER_SPEED "„¥«¨â¥«ì ᪮à®á⨠㪠§ â¥«ï ¬ëè¨"
23
	?define POINTER_SPEED "„¥«¨â¥«ì ᪮à®á⨠㪠§ â¥«ï ¬ëè¨"
24
	?define ACCELERATION_TEXT "—ã¢á⢨⥫쭮áâì 㪠§ â¥«ï ¬ëè¨"
24
	?define ACCELERATION_TEXT "—ã¢á⢨⥫쭮áâì 㪠§ â¥«ï ¬ëè¨"
25
	?define DOUBLE_CLICK_TEXT "‡ ¤¥à¦ª  ¤¢®©­®£® ª«¨ª  ¬ëèìî"
25
	?define DOUBLE_CLICK_TEXT "‡ ¤¥à¦ª  ¤¢®©­®£® ª«¨ª  ¬ëèìî"
26
	?define MOUSE_EMULATION "“¯à ¢«¥­¨¥ 㪠§ â¥«¥¬ ¬ëè¨ ç¥à¥§ ª« ¢¨ âãàã"
26
	?define MOUSE_EMULATION "“¯à ¢«¥­¨¥ 㪠§ â¥«¥¬ ¬ëè¨ ç¥à¥§ ª« ¢¨ âãàã"
27
	?define MADMOUSE "‘ª¢®§­ë¥ ¤«ï ªãàá®à  áâ®à®­ë íªà ­ "
27
	?define MADMOUSE "‘ª¢®§­ë¥ ¤«ï ªãàá®à  áâ®à®­ë íªà ­ "
-
 
28
	?define COMMOUSE "‡ £à㧨âì ¤à ©¢¥à ¬ëè¨ ¤«ï COM-¯®àâ  (F10)"
-
 
29
	?define COMMOUSE_LOADED "'„à ©¢¥à ¤«ï COM ¬ëè¨ ¡ë« § £à㦥­' -O"
-
 
30
	?define COMMOUSE_CAN_NOT_UNLOAD "'Žáâ ­®¢ª  ¤à ©¢¥à  ­¥¢®§¬®¦­ ' -W"
28
#else
31
#else
29
	?define WINDOW_TITLE "Mouse testing and configuration"
32
	?define WINDOW_TITLE "Mouse testing and configuration"
30
	?define CHECK_MOUSE_1 "Click on this area to"
33
	?define CHECK_MOUSE_1 "Click on this area to"
31
	?define CHECK_MOUSE_2 "check your mouse buttons"
34
	?define CHECK_MOUSE_2 "check your mouse buttons"
32
	?define POINTER_SPEED "Mouse pointer speed divider"
35
	?define POINTER_SPEED "Mouse pointer speed divider"
33
	?define ACCELERATION_TEXT "Mouse pointer sensitivity"
36
	?define ACCELERATION_TEXT "Mouse pointer sensitivity"
34
	?define DOUBLE_CLICK_TEXT "Mouse double click delay"
37
	?define DOUBLE_CLICK_TEXT "Mouse double click delay"
35
	?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad"
38
	?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad"
36
	?define MADMOUSE "Through screen sides for pointer"
39
	?define MADMOUSE "Through screen sides for pointer"
-
 
40
	?define COMMOUSE "Load mouse driver for COM-port (F10)"
-
 
41
	?define COMMOUSE_LOADED "'Driver for COM mouse loaded' -O"
-
 
42
	?define COMMOUSE_CAN_NOT_UNLOAD "'Driver stop is impossible' -W"
37
#endif
43
#endif
Line -... Line 44...
-
 
44
 
-
 
45
#define FRAME_X 18
38
 
46
#define FRAME_Y 18
39
:block mouse_frame = { 18, 18, NULL, 130 };
47
:block mouse_frame = { FRAME_X, FRAME_Y, NULL, 130 };
40
:more_less_box pointer_speed      = { NULL, 0, 64, POINTER_SPEED };
48
:more_less_box pointer_speed      = { NULL, 0, 64, POINTER_SPEED };
41
:more_less_box acceleration       = { NULL, 0, 64, ACCELERATION_TEXT };
49
:more_less_box acceleration       = { NULL, 0, 64, ACCELERATION_TEXT };
42
:more_less_box double_click_delay = { NULL, 0, 999, DOUBLE_CLICK_TEXT, 8 };
50
:more_less_box double_click_delay = { NULL, 0, 999, DOUBLE_CLICK_TEXT, 8 };
43
:checkbox emulation = { MOUSE_EMULATION, NULL };
51
:checkbox emulation = { MOUSE_EMULATION, NULL };
-
 
52
:checkbox madmouse = { MADMOUSE, NULL };
Line 44... Line 53...
44
:checkbox madmouse = { MADMOUSE, NULL };
53
:checkbox com_mouse = { COMMOUSE, NULL };
Line 45... Line 54...
45
 
54
 
46
_ini ini = { "/sys/settings/system.ini", "mouse" };
55
_ini ini = { "/sys/settings/system.ini", "loaded drivers" };
47
 
56
 
Line 68... Line 77...
68
				id = GetButtonID();
77
				id = GetButtonID();
69
				IF (1 == id) ExitApp();
78
				IF (1 == id) ExitApp();
70
				else IF (pointer_speed.click(id)) ApplyCfg();
79
				else IF (pointer_speed.click(id)) ApplyCfg();
71
				else IF (acceleration.click(id)) ApplyCfg();
80
				else IF (acceleration.click(id)) ApplyCfg();
72
				else IF (double_click_delay.click(id)) ApplyCfg();
81
				else IF (double_click_delay.click(id)) ApplyCfg();
73
				ELSE IF (emulation.click(id)) {
82
				else IF (emulation.click(id)) {
74
					IF (emulation.checked == true) RunProgram("/sys/mousemul", 0);
83
					IF (emulation.checked == true) RunProgram("/sys/mousemul", 0);
75
					ELSE KillProcessByName("mousemul", SINGLE);
84
					ELSE KillProcessByName("mousemul", SINGLE);
76
					break;
85
					break;
77
				}
86
				}
78
				ELSE IF (madmouse.click(id)) {						
87
				else IF (madmouse.click(id)) {						
79
					IF (madmouse.checked == true) RunProgram("/sys/madmouse", 0);
88
					IF (madmouse.checked == true) RunProgram("/sys/madmouse", 0);
80
					ELSE KillProcessByName("madmouse", SINGLE);
89
					ELSE KillProcessByName("madmouse", SINGLE);
81
					break;
90
					break;
82
				}
91
				}
-
 
92
				else IF (id == com_mouse.id) {
-
 
93
					EventClickComMouse();
-
 
94
				}
83
				break;
95
				break;
Line 84... Line 96...
84
 
96
 
85
		case evKey:
97
		case evKey:
86
				GetKeys();
98
				GetKeys();
-
 
99
				IF (key_scancode == SCAN_CODE_ESC) ExitApp();
87
				IF (key_scancode == SCAN_CODE_ESC) ExitApp();
100
				IF (key_scancode == SCAN_CODE_F10) EventClickComMouse();
Line 88... Line 101...
88
				break;
101
				break;
89
			
102
			
90
		case evReDraw:
103
		case evReDraw:
91
				system.color.get();
104
				system.color.get();
92
				DefineAndDrawWindow(430, 150, 424, 313+skin_height,0x34,system.color.work,WINDOW_TITLE,0);
105
				DefineAndDrawWindow(430, 150, 424, 343+skin_height,0x34,system.color.work,WINDOW_TITLE,0);
93
				GetProcessInfo(#Form, SelfInfo);
106
				GetProcessInfo(#Form, SelfInfo);
94
				if (Form.status_window>2) break;
107
				if (Form.status_window>2) break;
95
				mouse_frame.w = - mouse_frame.x * 2 + Form.cwidth;
108
				mouse_frame.w = - FRAME_X * 2 + Form.cwidth;
96
				DefineButton(mouse_frame.x, mouse_frame.y, mouse_frame.w, 
109
				DefineButton(FRAME_X, FRAME_Y, mouse_frame.w, 
97
					mouse_frame.h, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image
110
					mouse_frame.h, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image
98
				WriteText(mouse_frame.x + 110, mouse_frame.y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1);
111
				WriteText(FRAME_X + 110, FRAME_Y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1);
99
				WriteText(mouse_frame.x + 110, mouse_frame.y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2);
112
				WriteText(FRAME_X + 110, FRAME_Y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2);
100
				DrawMouseImage(0,0,0,0);
113
				DrawMouseImage(0,0,0,0);
101
				DrawControls();
114
				DrawControls();
Line 130... Line 143...
130
	}
143
	}
131
}
144
}
Line 132... Line 145...
132
 
145
 
133
void DrawControls() {
146
void DrawControls() {
134
	incn y;
147
	incn y;
135
	y.n = mouse_frame.y+115;
148
	y.n = FRAME_Y+115;
136
	pointer_speed.draw(mouse_frame.x, y.inc(30));
149
	pointer_speed.draw(FRAME_X, y.inc(30));
137
	acceleration.draw(mouse_frame.x, y.inc(30));
150
	acceleration.draw(FRAME_X, y.inc(30));
138
	double_click_delay.draw(mouse_frame.x, y.inc(30));
151
	double_click_delay.draw(FRAME_X, y.inc(30));
139
	emulation.draw(mouse_frame.x, y.inc(33));
152
	emulation.draw(FRAME_X, y.inc(33));
-
 
153
	madmouse.draw(FRAME_X, y.inc(27));
140
	madmouse.draw(mouse_frame.x, y.inc(27));
154
	com_mouse.draw(FRAME_X, y.inc(27));
Line 141... Line 155...
141
}
155
}
142
 
156
 
143
void LoadCfg() {
157
void LoadCfg() {
144
	acceleration.value = ini.GetInt("acceleration", GetMouseAcceleration());
158
	acceleration.value = GetMouseAcceleration();
-
 
159
	pointer_speed.value = GetMouseSpeed();
145
	pointer_speed.value = ini.GetInt("speed", GetMouseSpeed());
160
	double_click_delay.value = GetMouseDoubleClickDelay();
146
	double_click_delay.value = ini.GetInt("double_click_delay", GetMouseDoubleClickDelay());
161
	com_mouse.checked = ini.GetInt("com_mouse", 0);
147
	madmouse.checked = CheckProcessExists("MADMOUSE");
162
	madmouse.checked = CheckProcessExists("MADMOUSE");
Line 148... Line 163...
148
	emulation.checked = CheckProcessExists("MOUSEMUL");
163
	emulation.checked = CheckProcessExists("MOUSEMUL");
149
}
-
 
150
 
164
}
151
void ExitApp() {
-
 
152
	ini.SetInt("acceleration", acceleration.value);
165
 
153
	ini.SetInt("speed", pointer_speed.value);
166
void ExitApp() {
Line 154... Line 167...
154
	ini.SetInt("double_click_delay", double_click_delay.value);
167
	ini.SetInt("com_mouse", com_mouse.checked);
155
	ExitProcess();
168
	ExitProcess();
156
}
169
}
157
 
170
 
158
void ApplyCfg() {
171
void ApplyCfg() {
Line -... Line 172...
-
 
172
	SetMouseSpeed(pointer_speed.value);
-
 
173
	SetMouseAcceleration(acceleration.value);
-
 
174
	SetMouseDoubleClickDelay(double_click_delay.value);
-
 
175
}
-
 
176
 
-
 
177
void EventClickComMouse()
-
 
178
{
-
 
179
	if (!com_mouse.checked) 
-
 
180
	{
-
 
181
		if (RunProgram("/sys/loaddrv", "COMMOUSE")>=0) {
-
 
182
			notify(COMMOUSE_LOADED);
-
 
183
			com_mouse.click(com_mouse.id);
-
 
184
		}
-
 
185
		else {
-
 
186
			notify("'Error running LOADDRV' -E");
-
 
187
		}
-
 
188
	}
-
 
189
	else
159
	SetMouseSpeed(pointer_speed.value);
190
	{