Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
7437 leency 1
// Mouse Configuration Utility ver 1.61
5857 leency 2
 
5622 leency 3
#ifndef AUTOBUILD
4
#include "lang.h--"
5
#endif
6
 
7434 leency 7
#define MEMSIZE 4096*11
8
 
5622 leency 9
#include "..\lib\strings.h"
10
#include "..\lib\mem.h"
7219 leency 11
#include "..\lib\fs.h"
5622 leency 12
#include "..\lib\gui.h"
7049 leency 13
#include "..\lib\obj\libio.h"
5622 leency 14
#include "..\lib\obj\box_lib.h"
5857 leency 15
#include "..\lib\obj\libini.h"
5622 leency 16
#include "..\lib\patterns\restart_process.h"
17
 
7051 leency 18
// Translatiions
5630 leency 19
#ifdef LANG_RUS
20
	?define WINDOW_TITLE "Проверка и настройка параметров мыши"
21
	?define CHECK_MOUSE_1 "Нажмите на этой области"
22
	?define CHECK_MOUSE_2 "для проверки кнопок мыши"
6231 pathoswith 23
	?define POINTER_SPEED "Делитель скорости указателя мыши"
24
	?define ACCELERATION_TEXT "Чувствительность указателя мыши"
5970 leency 25
	?define DOUBLE_CLICK_TEXT "Задержка двойного клика мышью"
6197 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"
6231 pathoswith 32
	?define POINTER_SPEED "Mouse pointer speed divider"
33
	?define ACCELERATION_TEXT "Mouse pointer sensitivity"
5970 leency 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"
7227 leency 37
#endif
5622 leency 38
 
7434 leency 39
:block mouse_frame = { 18, 18, NULL, 130 };
40
:more_less_box pointer_speed      = { NULL, 0, 64, POINTER_SPEED };
41
:more_less_box acceleration       = { NULL, 0, 64, ACCELERATION_TEXT };
42
:more_less_box double_click_delay = { NULL, 0, 999, DOUBLE_CLICK_TEXT, 8 };
43
:checkbox emulation = { MOUSE_EMULATION, NULL };
44
:checkbox madmouse = { MADMOUSE, NULL };
7244 leency 45
 
7051 leency 46
_ini ini = { "/sys/settings/system.ini", "mouse" };
5630 leency 47
 
5622 leency 48
void main() {
7434 leency 49
	proc_info Form;
7249 leency 50
	int id;
7051 leency 51
 
5857 leency 52
	load_dll(libini, #lib_init,1);
5626 leency 53
	load_dll(boxlib, #box_lib_init,0);
7051 leency 54
 
5622 leency 55
	LoadCfg();
56
 
7051 leency 57
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
58
 
5622 leency 59
	loop() switch(WaitEvent())
60
	{
5630 leency 61
		case evMouse:
5640 pavelyakov 62
				mouse.get();
7437 leency 63
				IF (mouse_frame.hovered()) DrawMouseImage(mouse.lkm,mouse.pkm,mouse.mkm,mouse.vert);
7500 leency 64
				IF (mouse.click) || (mouse.up) DrawMouseImage(0,0,0,0);
5630 leency 65
				break;
66
 
7434 leency 67
		CASE evButton:
7227 leency 68
				id = GetButtonID();
7434 leency 69
				IF (1 == id) ExitApp();
70
				else IF (pointer_speed.click(id)) ApplyCfg();
71
				else IF (acceleration.click(id)) ApplyCfg();
72
				else IF (double_click_delay.click(id)) ApplyCfg();
73
				ELSE IF (emulation.click(id)) {
74
					IF (emulation.checked == true) RunProgram("/sys/mousemul", 0);
75
					ELSE KillProcessByName("/sys/mousemul", SINGLE);
7371 pavelyakov 76
					break;
5622 leency 77
				}
7434 leency 78
				ELSE IF (madmouse.click(id)) {
79
					IF (madmouse.checked == true) RunProgram("/sys/madmouse", 0);
80
					ELSE KillProcessByName("/sys/madmouse", SINGLE);
7371 pavelyakov 81
					break;
7244 leency 82
				}
5622 leency 83
				break;
7051 leency 84
 
5622 leency 85
		case evKey:
7051 leency 86
				GetKeys();
7434 leency 87
				IF (key_scancode == SCAN_CODE_ESC) ExitApp();
5622 leency 88
				break;
89
 
90
		case evReDraw:
5674 pavelyakov 91
				system.color.get();
7434 leency 92
				DefineAndDrawWindow(430, 150, 424, 313+skin_height,0x34,system.color.work,WINDOW_TITLE,0);
5622 leency 93
				GetProcessInfo(#Form, SelfInfo);
94
				if (Form.status_window>2) break;
7227 leency 95
				mouse_frame.w = - mouse_frame.x * 2 + Form.cwidth;
96
				DefineButton(mouse_frame.x, mouse_frame.y, mouse_frame.w,
97
					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);
99
				WriteText(mouse_frame.x + 110, mouse_frame.y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2);
7434 leency 100
				DrawMouseImage(0,0,0,0);
5642 leency 101
				DrawControls();
5622 leency 102
	}
103
}
104
 
7434 leency 105
:byte panels_img_data[] = FROM "mouse_image.raw";
5622 leency 106
 
7434 leency 107
#define red    0xff0000
108
#define yellow 0xfff600
109
#define white  0xffffff
110
#define dgrey  0x2d353d
111
 
7437 leency 112
:struct IMG_PAL{ dword back, shad1, contour, left,  right, middle, mwhite; }
113
         pal = { 0xF0F2F3,0xABB0B2, dgrey,   white, white, dgrey,  white  };
7434 leency 114
 
115
void DrawMouseImage(dword l,r,m,v) {
116
	#define IMG_W 59
117
	#define IMG_H 101
118
 
119
	IF (l) pal.left = red;
120
	IF (m) pal.middle = red;
121
	IF (r) pal.right = red;
122
	IF (v) pal.middle = yellow;
123
 
124
	PutPaletteImage(#panels_img_data,IMG_W,IMG_H,18+30,18+15,8,#pal);
125
	pal.left = pal.right = white;
126
	pal.middle = dgrey;
7437 leency 127
	IF (v) {
7434 leency 128
		pause(10);
7437 leency 129
		DrawMouseImage(l,r,m,0);
7434 leency 130
	}
5630 leency 131
}
5622 leency 132
 
5642 leency 133
void DrawControls() {
7244 leency 134
	incn y;
135
	y.n = mouse_frame.y+115;
7248 leency 136
	pointer_speed.draw(mouse_frame.x, y.inc(30));
137
	acceleration.draw(mouse_frame.x, y.inc(30));
138
	double_click_delay.draw(mouse_frame.x, y.inc(30));
139
	emulation.draw(mouse_frame.x, y.inc(33));
140
	madmouse.draw(mouse_frame.x, y.inc(27));
5642 leency 141
}
142
 
5622 leency 143
void LoadCfg() {
7227 leency 144
	acceleration.value = ini.GetInt("acceleration", GetMouseAcceleration());
145
	pointer_speed.value = ini.GetInt("speed", GetMouseSpeed());
146
	double_click_delay.value = ini.GetInt("double_click_delay", GetMouseDoubleClickDelay());
7244 leency 147
	madmouse.checked = CheckProcessExists("MADMOUSE");
148
	emulation.checked = CheckProcessExists("MOUSEMUL");
5622 leency 149
}
150
 
5857 leency 151
void ExitApp() {
7227 leency 152
	ini.SetInt("acceleration", acceleration.value);
153
	ini.SetInt("speed", pointer_speed.value);
154
	ini.SetInt("double_click_delay", double_click_delay.value);
5857 leency 155
	ExitProcess();
156
}
5630 leency 157
 
7051 leency 158
void ApplyCfg() {
7227 leency 159
	SetMouseSpeed(pointer_speed.value);
160
	SetMouseAcceleration(acceleration.value);
161
	SetMouseDoubleClickDelay(double_click_delay.value);
7051 leency 162
}
5630 leency 163
 
7434 leency 164
stop: