Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
5970 leency 1
// Mouse Configuration Utility ver 1.4
5857 leency 2
 
5622 leency 3
#ifndef AUTOBUILD
4
#include "lang.h--"
5
#endif
6
 
7
#define MEMSIZE 0x23E80
8
#include "..\lib\strings.h"
9
#include "..\lib\mem.h"
10
#include "..\lib\file_system.h"
11
#include "..\lib\gui.h"
12
#include "..\lib\obj\libio_lib.h"
13
#include "..\lib\obj\box_lib.h"
5857 leency 14
#include "..\lib\obj\libini.h"
5622 leency 15
#include "..\lib\patterns\restart_process.h"
16
 
5630 leency 17
#include "kos_mouse_functions.h"
5622 leency 18
 
5630 leency 19
#ifdef LANG_RUS
20
	?define WINDOW_TITLE "Проверка и настройка параметров мыши"
21
	?define CHECK_MOUSE_1 "Нажмите на этой области"
22
	?define CHECK_MOUSE_2 "для проверки кнопок мыши"
23
	?define POINTER_SPEED "Скорость указателя мыши"
5970 leency 24
	?define ACCELERATION_TEXT "Ускорение указателя мыши"
25
	?define DOUBLE_CLICK_TEXT "Задержка двойного клика мышью"
5630 leency 26
	?define MOUSE_EMULATION "Эмуляция управления указателем через клавиатуру"
5654 leency 27
	?define MADMOUSE "Сквозные для курсора стороны экрана"
5630 leency 28
#else
29
	?define WINDOW_TITLE "Mouse testing and configuration"
30
	?define CHECK_MOUSE_1 "Click on this area to"
31
	?define CHECK_MOUSE_2 "check your mouse buttons"
32
	?define POINTER_SPEED "Mouse pointer speed"
5970 leency 33
	?define ACCELERATION_TEXT "Mouse pointer acceleration"
34
	?define DOUBLE_CLICK_TEXT "Mouse double click delay"
5630 leency 35
	?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad"
36
	?define MADMOUSE "Through screen sides for pointer"
5674 pavelyakov 37
	#endif
5622 leency 38
 
5970 leency 39
proc_info Form;
5630 leency 40
frame mouse_frame = { 0, 000, 14, 130, 14, 0x000111, 0xFFFfff, 0, 0, 0, 0, 6, 0x000111, 0xCCCccc };
5642 leency 41
char pos_x = 22;
5622 leency 42
 
5630 leency 43
unsigned char panels_img_data[] = FROM "mouse_image.raw";
44
raw_image panels_img = { 59, 101, #panels_img_data };
5970 leency 45
 
5857 leency 46
char system_ini_path[] = "/sys/settings/system.ini";
47
char mouse_category[] = "mouse";
5630 leency 48
 
5622 leency 49
 
5970 leency 50
struct _mouse_cfg {
5630 leency 51
	char pointer_speed,
5970 leency 52
	acceleration,
5630 leency 53
	emulation,
54
	madmouse,
55
	button_clicked;
5970 leency 56
	word double_click_delay;
5622 leency 57
} mouse_cfg;
58
 
59
 
60
void main() {
5630 leency 61
	char id, old_button_clicked;
5622 leency 62
 
5857 leency 63
	load_dll(libini, #lib_init,1);
5626 leency 64
	load_dll(boxlib, #box_lib_init,0);
5622 leency 65
 
66
	LoadCfg();
67
 
5630 leency 68
	SetEventMask(0x27);
5622 leency 69
	loop() switch(WaitEvent())
70
	{
5630 leency 71
		case evMouse:
5640 pavelyakov 72
				mouse.get();
73
				if (mouse.y <= mouse_frame.start_y) || (mouse.y >= mouse_frame.start_y + mouse_frame.size_y)
74
				|| (mouse.x >= mouse_frame.start_x + mouse_frame.size_x) || (mouse.x <= mouse_frame.start_x) break;
5630 leency 75
				old_button_clicked = mouse_cfg.button_clicked;
5640 pavelyakov 76
				if (mouse.lkm) mouse_cfg.button_clicked=1;
77
				else if (mouse.pkm) mouse_cfg.button_clicked=2;
78
				else if (mouse.mkm) mouse_cfg.button_clicked=3;
5630 leency 79
				else mouse_cfg.button_clicked=0;
80
				if (mouse_cfg.button_clicked != old_button_clicked) DrawMouseImage();
81
				break;
82
 
5622 leency 83
		case evButton:
84
				id=GetButtonID();
5630 leency 85
				if (id==1)
5622 leency 86
				{
5857 leency 87
					ExitApp();
5622 leency 88
				}
5630 leency 89
				if (id==99)
90
				{
91
					mouse_cfg.button_clicked=0;
92
					DrawMouseImage();
93
					break;
94
				}
95
				if (id==100)
96
				{
97
					if (mouse_cfg.emulation==true) KillProcessByName("mousemul", SINGLE);
98
					else RunProgram("/sys/mousemul", 0);
99
					mouse_cfg.emulation ^= 1;
100
				}
101
				if (id==101)
102
				{
103
					if (mouse_cfg.madmouse==true) KillProcessByName("madmouse", SINGLE);
104
					else RunProgram("/sys/madmouse", 0);
105
					mouse_cfg.madmouse ^= 1;
106
				}
107
				if (id==120)
108
				{
109
					mouse_cfg.pointer_speed++;
110
					SetMouseSpeed(mouse_cfg.pointer_speed);
111
				}
5631 pavelyakov 112
				if (id==121) && (mouse_cfg.pointer_speed>1)
5630 leency 113
				{
114
					mouse_cfg.pointer_speed--;
115
					SetMouseSpeed(mouse_cfg.pointer_speed);
116
				}
5970 leency 117
				if (id==122) && (mouse_cfg.acceleration<3)
5630 leency 118
				{
5970 leency 119
					mouse_cfg.acceleration++;
120
					SetMouseAcceleration(mouse_cfg.acceleration);
5630 leency 121
				}
5970 leency 122
				if (id==123) && (mouse_cfg.acceleration>0)
5630 leency 123
				{
5970 leency 124
					mouse_cfg.acceleration--;
125
					SetMouseAcceleration(mouse_cfg.acceleration);
5630 leency 126
				}
5970 leency 127
				if (id==124)
128
				{
129
					mouse_cfg.double_click_delay+=10;
130
					SetMouseDoubleClickDelay(mouse_cfg.double_click_delay);
131
				}
132
				if (id==125) && (mouse_cfg.double_click_delay>0)
133
				{
134
					mouse_cfg.double_click_delay-=10;
135
					SetMouseDoubleClickDelay(mouse_cfg.double_click_delay);
136
				}
5642 leency 137
				DrawControls();
5622 leency 138
				break;
139
 
140
		case evKey:
5857 leency 141
				if (GetKey()==27) ExitApp();
5622 leency 142
				break;
143
 
144
		case evReDraw:
5674 pavelyakov 145
				system.color.get();
5970 leency 146
				DefineAndDrawWindow(430, 150, 360, 300+GetSkinHeight(),0x34,system.color.work,WINDOW_TITLE);
5622 leency 147
				GetProcessInfo(#Form, SelfInfo);
148
				if (Form.status_window>2) break;
5642 leency 149
				SetFrameColors();
150
				DefineButton(mouse_frame.start_x+2, mouse_frame.start_y+2, mouse_frame.size_x-4,
151
					mouse_frame.size_y-4, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image
152
				frame_draw stdcall (#mouse_frame);
5857 leency 153
				WriteText(pos_x + 110, mouse_frame.start_y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1);
154
				WriteText(pos_x + 110, mouse_frame.start_y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2);
5642 leency 155
				DrawMouseImage();
156
				DrawControls();
5622 leency 157
	}
158
}
159
 
160
 
5630 leency 161
void DrawMouseImage() {
5642 leency 162
	_PutImage(mouse_frame.start_x+30, mouse_frame.start_y + 15,  panels_img.w, panels_img.h,
163
		mouse_cfg.button_clicked * panels_img.w * panels_img.h * 3 + panels_img.data);
5630 leency 164
}
5622 leency 165
 
5642 leency 166
void DrawControls() {
5857 leency 167
	DrawBar(pos_x, mouse_frame.start_y + 142, Form.cwidth - pos_x, 120, system.color.work);
5642 leency 168
	PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 142, 120, 121, mouse_cfg.pointer_speed, POINTER_SPEED);
5970 leency 169
	PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 170, 122, 123, mouse_cfg.acceleration, ACCELERATION_TEXT);
170
	PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 198, 124, 125, mouse_cfg.double_click_delay, DOUBLE_CLICK_TEXT);
171
	PanelCfg_CheckBox(pos_x, mouse_frame.start_y + 230, 100, MOUSE_EMULATION, mouse_cfg.emulation);
172
	PanelCfg_CheckBox(pos_x, mouse_frame.start_y + 254, 101, MADMOUSE, mouse_cfg.madmouse);
5642 leency 173
}
174
 
175
void SetFrameColors() {
176
	mouse_frame.size_x = - mouse_frame.start_x * 2 + Form.cwidth;
5674 pavelyakov 177
	mouse_frame.font_color = system.color.work_text;
178
	mouse_frame.font_backgr_color = system.color.work;
179
	mouse_frame.ext_col = system.color.work_graph;
5642 leency 180
}
181
 
5622 leency 182
void LoadCfg() {
5970 leency 183
	ini_get_int stdcall (#system_ini_path, #mouse_category, "acceleration", GetMouseAcceleration());   mouse_cfg.acceleration = EAX;
5857 leency 184
	ini_get_int stdcall (#system_ini_path, #mouse_category, "speed", GetMouseSpeed());   mouse_cfg.pointer_speed = EAX;
5970 leency 185
	ini_get_int stdcall (#system_ini_path, #mouse_category, "double_click_delay", GetMouseDoubleClickDelay());   mouse_cfg.double_click_delay = EAX;
5630 leency 186
	mouse_cfg.madmouse = CheckProcessExists("MADMOUSE");
187
	mouse_cfg.emulation = CheckProcessExists("MOUSEMUL");
5622 leency 188
}
189
 
5857 leency 190
void ExitApp() {
5970 leency 191
	ini_set_int stdcall (#system_ini_path, #mouse_category, "acceleration", mouse_cfg.acceleration);
5857 leency 192
	ini_set_int stdcall (#system_ini_path, #mouse_category, "speed", mouse_cfg.pointer_speed);
5970 leency 193
	ini_set_int stdcall (#system_ini_path, #mouse_category, "double_click_delay", mouse_cfg.double_click_delay);
5857 leency 194
	ExitProcess();
195
}
5630 leency 196
 
197
 
5970 leency 198
void PanelCfg_CheckBox(dword x, y, id, text, byte value) {
199
	CheckBox(x, y, 14, 14, id, text, system.color.work_graph, system.color.work_text, value);
200
}
5857 leency 201
 
5970 leency 202
void PanelCfg_MoreLessBox(dword x, y, id_more, id_less; word value; dword text) {
203
	MoreLessBox(x, y, 18, id_more, id_less, #system.color, value, text);
204
}
205
 
206
 
207
 
208
 
5622 leency 209
stop: