Subversion Repositories Kolibri OS

Rev

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