Subversion Repositories Kolibri OS

Rev

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

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