Subversion Repositories Kolibri OS

Rev

Rev 5626 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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