Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
7227 leency 1
// Mouse Configuration Utility ver 1.5
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"
7219 leency 10
#include "..\lib\fs.h"
5622 leency 11
#include "..\lib\gui.h"
7049 leency 12
#include "..\lib\obj\libio.h"
5622 leency 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
 
7051 leency 17
// Translatiions
5630 leency 18
#ifdef LANG_RUS
19
	?define WINDOW_TITLE "Проверка и настройка параметров мыши"
20
	?define CHECK_MOUSE_1 "Нажмите на этой области"
21
	?define CHECK_MOUSE_2 "для проверки кнопок мыши"
6231 pathoswith 22
	?define POINTER_SPEED "Делитель скорости указателя мыши"
23
	?define ACCELERATION_TEXT "Чувствительность указателя мыши"
5970 leency 24
	?define DOUBLE_CLICK_TEXT "Задержка двойного клика мышью"
6197 leency 25
	?define MOUSE_EMULATION "Управление указателем мыши через клавиатуру"
5654 leency 26
	?define MADMOUSE "Сквозные для курсора стороны экрана"
5630 leency 27
#else
28
	?define WINDOW_TITLE "Mouse testing and configuration"
29
	?define CHECK_MOUSE_1 "Click on this area to"
30
	?define CHECK_MOUSE_2 "check your mouse buttons"
6231 pathoswith 31
	?define POINTER_SPEED "Mouse pointer speed divider"
32
	?define ACCELERATION_TEXT "Mouse pointer sensitivity"
5970 leency 33
	?define DOUBLE_CLICK_TEXT "Mouse double click delay"
5630 leency 34
	?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad"
35
	?define MADMOUSE "Through screen sides for pointer"
7227 leency 36
#endif
5970 leency 37
proc_info Form;
5622 leency 38
 
7244 leency 39
block mouse_frame = { 18, 18, NULL, 130 };
7243 leency 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 };
7244 leency 43
checkbox emulation = { MOUSE_EMULATION, NULL };
44
checkbox madmouse = { MADMOUSE, NULL };
45
 
5630 leency 46
unsigned char panels_img_data[] = FROM "mouse_image.raw";
47
raw_image panels_img = { 59, 101, #panels_img_data };
5970 leency 48
 
7051 leency 49
_ini ini = { "/sys/settings/system.ini", "mouse" };
5630 leency 50
 
7248 leency 51
dword click_status;
5622 leency 52
 
53
 
7244 leency 54
 
5622 leency 55
void main() {
7249 leency 56
	int id;
7051 leency 57
 
5857 leency 58
	load_dll(libini, #lib_init,1);
5626 leency 59
	load_dll(boxlib, #box_lib_init,0);
7051 leency 60
 
5622 leency 61
	LoadCfg();
62
 
7051 leency 63
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
64
 
5622 leency 65
	loop() switch(WaitEvent())
66
	{
5630 leency 67
		case evMouse:
5640 pavelyakov 68
				mouse.get();
7244 leency 69
				if (mouse.down) && (click_status==0) && (mouse_frame.hovered()) {
70
					if (mouse.key&MOUSE_LEFT) click_status = 1;
71
					if (mouse.key&MOUSE_RIGHT) click_status = 2;
72
					if (mouse.key&MOUSE_CENTER) click_status = 3;
7248 leency 73
					DrawMouseImage();
7227 leency 74
				}
75
				if (mouse.up) {
7244 leency 76
					click_status=0;
7248 leency 77
					DrawMouseImage();
7227 leency 78
				}
5630 leency 79
				break;
80
 
5622 leency 81
		case evButton:
7227 leency 82
				id = GetButtonID();
7371 pavelyakov 83
				if (id == 1) ExitApp();
84
				else if (pointer_speed.click(id)) ApplyCfg();
85
				else if (acceleration.click(id)) ApplyCfg();
86
				else if (double_click_delay.click(id)) ApplyCfg();
87
				else if (emulation.click(id)) {
88
					if (emulation.checked == true) RunProgram("/sys/mousemul", 0);
89
					else KillProcessByName("mousemul", SINGLE);
90
					break;
5622 leency 91
				}
7371 pavelyakov 92
				else if (madmouse.click(id)) {
93
					if (madmouse.checked == true) RunProgram("/sys/madmouse", 0);
94
					else KillProcessByName("madmouse", SINGLE);
95
					break;
7244 leency 96
				}
5622 leency 97
				break;
7051 leency 98
 
5622 leency 99
		case evKey:
7051 leency 100
				GetKeys();
101
				if (key_scancode == SCAN_CODE_ESC) ExitApp();
5622 leency 102
				break;
103
 
104
		case evReDraw:
5674 pavelyakov 105
				system.color.get();
7051 leency 106
				DefineAndDrawWindow(430, 150, 424, 310+skin_height,0x34,system.color.work,WINDOW_TITLE,0);
5622 leency 107
				GetProcessInfo(#Form, SelfInfo);
108
				if (Form.status_window>2) break;
7227 leency 109
				mouse_frame.w = - mouse_frame.x * 2 + Form.cwidth;
110
				DefineButton(mouse_frame.x, mouse_frame.y, mouse_frame.w,
111
					mouse_frame.h, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image
112
				WriteText(mouse_frame.x + 110, mouse_frame.y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1);
113
				WriteText(mouse_frame.x + 110, mouse_frame.y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2);
5642 leency 114
				DrawMouseImage();
115
				DrawControls();
5622 leency 116
	}
117
}
118
 
119
 
7248 leency 120
void DrawMouseImage() {
7227 leency 121
	_PutImage(mouse_frame.x+30, mouse_frame.y + 15,  panels_img.w, panels_img.h,
7248 leency 122
		click_status * panels_img.w * panels_img.h * 3 + panels_img.data);
5630 leency 123
}
5622 leency 124
 
5642 leency 125
void DrawControls() {
7244 leency 126
	incn y;
127
	y.n = mouse_frame.y+115;
7248 leency 128
	pointer_speed.draw(mouse_frame.x, y.inc(30));
129
	acceleration.draw(mouse_frame.x, y.inc(30));
130
	double_click_delay.draw(mouse_frame.x, y.inc(30));
131
	emulation.draw(mouse_frame.x, y.inc(33));
132
	madmouse.draw(mouse_frame.x, y.inc(27));
5642 leency 133
}
134
 
5622 leency 135
void LoadCfg() {
7227 leency 136
	acceleration.value = ini.GetInt("acceleration", GetMouseAcceleration());
137
	pointer_speed.value = ini.GetInt("speed", GetMouseSpeed());
138
	double_click_delay.value = ini.GetInt("double_click_delay", GetMouseDoubleClickDelay());
7244 leency 139
	madmouse.checked = CheckProcessExists("MADMOUSE");
140
	emulation.checked = CheckProcessExists("MOUSEMUL");
5622 leency 141
}
142
 
5857 leency 143
void ExitApp() {
7227 leency 144
	ini.SetInt("acceleration", acceleration.value);
145
	ini.SetInt("speed", pointer_speed.value);
146
	ini.SetInt("double_click_delay", double_click_delay.value);
5857 leency 147
	ExitProcess();
148
}
5630 leency 149
 
7051 leency 150
void ApplyCfg() {
7227 leency 151
	SetMouseSpeed(pointer_speed.value);
152
	SetMouseAcceleration(acceleration.value);
153
	SetMouseDoubleClickDelay(double_click_delay.value);
7051 leency 154
}
5630 leency 155
 
5622 leency 156
stop: