Subversion Repositories Kolibri OS

Rev

Rev 5622 | 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
 
16
?define WINDOW_TITLE "Mouse configuration"
17
?define MOUSE_FRAME_T " Mouse "
18
?define KEYBOARD_FRAME_T " Keyboard "
19
?define CHECK_MOUSE "Click to check mouse"
20
?define POINTER_SPEED "Mouse pointer speed"
21
?define POINTER_DELAY "Mouse pointer delay"
22
?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad"
23
?define MADMOUSE "When cursor reaches screen side switch it to inverce side"
24
 
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 };
27
 
28
 
29
unsigned char panels_img_data[] = FROM "panels_image.raw";
30
raw_image panels_img = { 37, 27, #panels_img_data };
31
 
32
system_colors sc;
33
proc_info Form;
34
 
35
 
36
struct mouse_cfg1 {
37
	byte pointer_speed, pointer_delay, emulation, madmouse;
38
} mouse_cfg;
39
 
40
 
41
void main() {
42
	dword id;
43
 
44
	mem_Init();
5626 leency 45
	load_dll(boxlib, #box_lib_init,0);
5622 leency 46
 
47
	LoadCfg();
48
 
49
	loop() switch(WaitEvent())
50
	{
51
		case evButton:
52
				id=GetButtonID();
53
				if (id==1) ExitProcess();
54
 
55
				if (id>=100) && (id<200)
56
				{
57
					if (id==100) {
58
						if (mouse_cfg.emulation==true) KillProcessByName("mousemul", SINGLE);
59
						else RunProgram("/sys/mousemul", 0);
60
						mouse_cfg.emulation ^= 1;
61
					}
62
					if (id==101) {
63
						if (mouse_cfg.madmouse==true) KillProcessByName("madmouse", SINGLE);
64
						else RunProgram("/sys/madmouse", 0);
65
						mouse_cfg.madmouse ^= 1;
66
					}
67
					if (id==120) mouse_cfg.pointer_speed++;
68
					if (id==121) && (mouse_cfg.pointer_speed>0) mouse_cfg.pointer_speed--;
69
					if (id==122) mouse_cfg.pointer_delay++;
70
					if (id==123) && (mouse_cfg.pointer_delay>0) mouse_cfg.pointer_delay--;
71
					DrawWindowContent();
72
				}
73
				break;
74
 
75
		case evKey:
76
				if (GetKey()==27) ExitProcess();
77
				break;
78
 
79
		case evReDraw:
80
				sc.get();
81
				DefineAndDrawWindow(130, 150, 430, 200+GetSkinHeight(),0x34,sc.work,WINDOW_TITLE);
82
				GetProcessInfo(#Form, SelfInfo);
83
				if (Form.status_window>2) break;
84
				mouse_frame.size_x = keyboard_frame.size_x = - mouse_frame.start_x * 2 + Form.cwidth;
85
				mouse_frame.font_color = keyboard_frame.font_color = sc.work_text;
86
				mouse_frame.font_backgr_color = keyboard_frame.font_backgr_color = sc.work;
87
				mouse_frame.ext_col = keyboard_frame.ext_col = sc.work_graph;
88
				DrawWindowContent();
89
	}
90
}
91
 
92
 
93
void DrawWindowContent() {
94
	char pos_x = 22;
95
 
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);
101
 
102
	PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 50, 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);
104
 
105
	PanelCfg_CheckBox(pos_x, mouse_frame.start_y +  108,  100, MOUSE_EMULATION, mouse_cfg.emulation);
106
	PanelCfg_CheckBox(pos_x, mouse_frame.start_y +  130, 101, MADMOUSE, mouse_cfg.madmouse);
107
}
108
 
109
 
110
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);
112
}
113
 
114
 
115
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);
117
}
118
 
119
 
120
void LoadCfg() {
121
	mouse_cfg.pointer_delay = 10;
122
	mouse_cfg.pointer_speed = 2;
123
	//CheckProcessExists("MADMOUSE");
124
	mouse_cfg.madmouse = 0;
125
	//CheckProcessExists("MOUSEMUL");
126
	mouse_cfg.emulation = 0;
127
}
128
 
129
stop: