Rev 5970 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5970 | Rev 5996 | ||
---|---|---|---|
1 | // Mouse Configuration Utility ver 1.4 |
1 | // Mouse Configuration Utility ver 1.4 |
2 | 2 | ||
3 | #ifndef AUTOBUILD |
3 | #ifndef AUTOBUILD |
4 | #include "lang.h--" |
4 | #include "lang.h--" |
5 | #endif |
5 | #endif |
6 | 6 | ||
7 | #define MEMSIZE 0x23E80 |
7 | #define MEMSIZE 0x23E80 |
8 | #include "..\lib\strings.h" |
8 | #include "..\lib\strings.h" |
9 | #include "..\lib\mem.h" |
9 | #include "..\lib\mem.h" |
10 | #include "..\lib\file_system.h" |
10 | #include "..\lib\file_system.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\obj\libini.h" |
14 | #include "..\lib\obj\libini.h" |
15 | #include "..\lib\patterns\restart_process.h" |
15 | #include "..\lib\patterns\restart_process.h" |
16 | - | ||
17 | #include "kos_mouse_functions.h" |
- | |
18 | 16 | ||
19 | #ifdef LANG_RUS |
17 | #ifdef LANG_RUS |
20 | ?define WINDOW_TITLE "஢¥àª ¨ áâனª ¯ à ¬¥â஢ ¬ëè¨" |
18 | ?define WINDOW_TITLE "஢¥àª ¨ áâனª ¯ à ¬¥â஢ ¬ëè¨" |
21 | ?define CHECK_MOUSE_1 " ¦¬¨â¥ í⮩ ®¡« áâ¨" |
19 | ?define CHECK_MOUSE_1 " ¦¬¨â¥ í⮩ ®¡« áâ¨" |
22 | ?define CHECK_MOUSE_2 "¤«ï ¯à®¢¥àª¨ ª®¯®ª ¬ëè¨" |
20 | ?define CHECK_MOUSE_2 "¤«ï ¯à®¢¥àª¨ ª®¯®ª ¬ëè¨" |
23 | ?define POINTER_SPEED "ª®à®áâì 㪠§ â¥«ï ¬ëè¨" |
21 | ?define POINTER_SPEED "ª®à®áâì 㪠§ â¥«ï ¬ëè¨" |
24 | ?define ACCELERATION_TEXT "᪮२¥ 㪠§ â¥«ï ¬ëè¨" |
22 | ?define ACCELERATION_TEXT "᪮२¥ 㪠§ â¥«ï ¬ëè¨" |
25 | ?define DOUBLE_CLICK_TEXT " ¤¥à¦ª ¤¢®©®£® ª«¨ª ¬ëèìî" |
23 | ?define DOUBLE_CLICK_TEXT " ¤¥à¦ª ¤¢®©®£® ª«¨ª ¬ëèìî" |
26 | ?define MOUSE_EMULATION "¬ã«ïæ¨ï ã¯à ¢«¥¨ï 㪠§ ⥫¥¬ ç¥à¥§ ª« ¢¨ âãàã" |
24 | ?define MOUSE_EMULATION "¬ã«ïæ¨ï ã¯à ¢«¥¨ï 㪠§ ⥫¥¬ ç¥à¥§ ª« ¢¨ âãàã" |
27 | ?define MADMOUSE "ª¢®§ë¥ ¤«ï ªãàá®à áâ®à®ë íªà " |
25 | ?define MADMOUSE "ª¢®§ë¥ ¤«ï ªãàá®à áâ®à®ë íªà " |
28 | #else |
26 | #else |
29 | ?define WINDOW_TITLE "Mouse testing and configuration" |
27 | ?define WINDOW_TITLE "Mouse testing and configuration" |
30 | ?define CHECK_MOUSE_1 "Click on this area to" |
28 | ?define CHECK_MOUSE_1 "Click on this area to" |
31 | ?define CHECK_MOUSE_2 "check your mouse buttons" |
29 | ?define CHECK_MOUSE_2 "check your mouse buttons" |
32 | ?define POINTER_SPEED "Mouse pointer speed" |
30 | ?define POINTER_SPEED "Mouse pointer speed" |
33 | ?define ACCELERATION_TEXT "Mouse pointer acceleration" |
31 | ?define ACCELERATION_TEXT "Mouse pointer acceleration" |
34 | ?define DOUBLE_CLICK_TEXT "Mouse double click delay" |
32 | ?define DOUBLE_CLICK_TEXT "Mouse double click delay" |
35 | ?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad" |
33 | ?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad" |
36 | ?define MADMOUSE "Through screen sides for pointer" |
34 | ?define MADMOUSE "Through screen sides for pointer" |
37 | #endif |
35 | #endif |
38 | 36 | ||
39 | proc_info Form; |
37 | proc_info Form; |
40 | frame mouse_frame = { 0, 000, 14, 130, 14, 0x000111, 0xFFFfff, 0, 0, 0, 0, 6, 0x000111, 0xCCCccc }; |
38 | frame mouse_frame = { 0, 000, 14, 130, 14, 0x000111, 0xFFFfff, 0, 0, 0, 0, 6, 0x000111, 0xCCCccc }; |
41 | char pos_x = 22; |
39 | char pos_x = 22; |
42 | 40 | ||
43 | unsigned char panels_img_data[] = FROM "mouse_image.raw"; |
41 | unsigned char panels_img_data[] = FROM "mouse_image.raw"; |
44 | raw_image panels_img = { 59, 101, #panels_img_data }; |
42 | raw_image panels_img = { 59, 101, #panels_img_data }; |
45 | 43 | ||
46 | char system_ini_path[] = "/sys/settings/system.ini"; |
44 | char system_ini_path[] = "/sys/settings/system.ini"; |
47 | char mouse_category[] = "mouse"; |
45 | char mouse_category[] = "mouse"; |
48 | 46 | ||
49 | 47 | ||
50 | struct _mouse_cfg { |
48 | struct _mouse_cfg { |
51 | char pointer_speed, |
49 | char pointer_speed, |
52 | acceleration, |
50 | acceleration, |
53 | emulation, |
51 | emulation, |
54 | madmouse, |
52 | madmouse, |
55 | button_clicked; |
53 | button_clicked; |
56 | word double_click_delay; |
54 | word double_click_delay; |
57 | } mouse_cfg; |
55 | } mouse_cfg; |
58 | 56 | ||
59 | 57 | ||
60 | void main() { |
58 | void main() { |
61 | char id, old_button_clicked; |
59 | char id, old_button_clicked; |
62 | 60 | ||
63 | load_dll(libini, #lib_init,1); |
61 | load_dll(libini, #lib_init,1); |
64 | load_dll(boxlib, #box_lib_init,0); |
62 | load_dll(boxlib, #box_lib_init,0); |
65 | 63 | ||
66 | LoadCfg(); |
64 | LoadCfg(); |
67 | 65 | ||
68 | SetEventMask(0x27); |
66 | SetEventMask(0x27); |
69 | loop() switch(WaitEvent()) |
67 | loop() switch(WaitEvent()) |
70 | { |
68 | { |
71 | case evMouse: |
69 | case evMouse: |
72 | mouse.get(); |
70 | mouse.get(); |
73 | if (mouse.y <= mouse_frame.start_y) || (mouse.y >= mouse_frame.start_y + mouse_frame.size_y) |
71 | if (mouse.y <= mouse_frame.start_y) || (mouse.y >= mouse_frame.start_y + mouse_frame.size_y) |
74 | || (mouse.x >= mouse_frame.start_x + mouse_frame.size_x) || (mouse.x <= mouse_frame.start_x) break; |
72 | || (mouse.x >= mouse_frame.start_x + mouse_frame.size_x) || (mouse.x <= mouse_frame.start_x) break; |
75 | old_button_clicked = mouse_cfg.button_clicked; |
73 | old_button_clicked = mouse_cfg.button_clicked; |
76 | if (mouse.lkm) mouse_cfg.button_clicked=1; |
74 | if (mouse.lkm) mouse_cfg.button_clicked=1; |
77 | else if (mouse.pkm) mouse_cfg.button_clicked=2; |
75 | else if (mouse.pkm) mouse_cfg.button_clicked=2; |
78 | else if (mouse.mkm) mouse_cfg.button_clicked=3; |
76 | else if (mouse.mkm) mouse_cfg.button_clicked=3; |
79 | else mouse_cfg.button_clicked=0; |
77 | else mouse_cfg.button_clicked=0; |
80 | if (mouse_cfg.button_clicked != old_button_clicked) DrawMouseImage(); |
78 | if (mouse_cfg.button_clicked != old_button_clicked) DrawMouseImage(); |
81 | break; |
79 | break; |
82 | 80 | ||
83 | case evButton: |
81 | case evButton: |
84 | id=GetButtonID(); |
82 | id=GetButtonID(); |
85 | if (id==1) |
83 | if (id==1) |
86 | { |
84 | { |
87 | ExitApp(); |
85 | ExitApp(); |
88 | } |
86 | } |
89 | if (id==99) |
87 | if (id==99) |
90 | { |
88 | { |
91 | mouse_cfg.button_clicked=0; |
89 | mouse_cfg.button_clicked=0; |
92 | DrawMouseImage(); |
90 | DrawMouseImage(); |
93 | break; |
91 | break; |
94 | } |
92 | } |
95 | if (id==100) |
93 | if (id==100) |
96 | { |
94 | { |
97 | if (mouse_cfg.emulation==true) KillProcessByName("mousemul", SINGLE); |
95 | if (mouse_cfg.emulation==true) KillProcessByName("mousemul", SINGLE); |
98 | else RunProgram("/sys/mousemul", 0); |
96 | else RunProgram("/sys/mousemul", 0); |
99 | mouse_cfg.emulation ^= 1; |
97 | mouse_cfg.emulation ^= 1; |
100 | } |
98 | } |
101 | if (id==101) |
99 | if (id==101) |
102 | { |
100 | { |
103 | if (mouse_cfg.madmouse==true) KillProcessByName("madmouse", SINGLE); |
101 | if (mouse_cfg.madmouse==true) KillProcessByName("madmouse", SINGLE); |
104 | else RunProgram("/sys/madmouse", 0); |
102 | else RunProgram("/sys/madmouse", 0); |
105 | mouse_cfg.madmouse ^= 1; |
103 | mouse_cfg.madmouse ^= 1; |
106 | } |
104 | } |
107 | if (id==120) |
105 | if (id==120) |
108 | { |
106 | { |
109 | mouse_cfg.pointer_speed++; |
107 | mouse_cfg.pointer_speed++; |
110 | SetMouseSpeed(mouse_cfg.pointer_speed); |
108 | SetMouseSpeed(mouse_cfg.pointer_speed); |
111 | } |
109 | } |
112 | if (id==121) && (mouse_cfg.pointer_speed>1) |
110 | if (id==121) && (mouse_cfg.pointer_speed>1) |
113 | { |
111 | { |
114 | mouse_cfg.pointer_speed--; |
112 | mouse_cfg.pointer_speed--; |
115 | SetMouseSpeed(mouse_cfg.pointer_speed); |
113 | SetMouseSpeed(mouse_cfg.pointer_speed); |
116 | } |
114 | } |
117 | if (id==122) && (mouse_cfg.acceleration<3) |
115 | if (id==122) && (mouse_cfg.acceleration<3) |
118 | { |
116 | { |
119 | mouse_cfg.acceleration++; |
117 | mouse_cfg.acceleration++; |
120 | SetMouseAcceleration(mouse_cfg.acceleration); |
118 | SetMouseAcceleration(mouse_cfg.acceleration); |
121 | } |
119 | } |
122 | if (id==123) && (mouse_cfg.acceleration>0) |
120 | if (id==123) && (mouse_cfg.acceleration>0) |
123 | { |
121 | { |
124 | mouse_cfg.acceleration--; |
122 | mouse_cfg.acceleration--; |
125 | SetMouseAcceleration(mouse_cfg.acceleration); |
123 | SetMouseAcceleration(mouse_cfg.acceleration); |
126 | } |
124 | } |
127 | if (id==124) |
125 | if (id==124) |
128 | { |
126 | { |
129 | mouse_cfg.double_click_delay+=10; |
127 | mouse_cfg.double_click_delay+=10; |
130 | SetMouseDoubleClickDelay(mouse_cfg.double_click_delay); |
128 | SetMouseDoubleClickDelay(mouse_cfg.double_click_delay); |
131 | } |
129 | } |
132 | if (id==125) && (mouse_cfg.double_click_delay>0) |
130 | if (id==125) && (mouse_cfg.double_click_delay>0) |
133 | { |
131 | { |
134 | mouse_cfg.double_click_delay-=10; |
132 | mouse_cfg.double_click_delay-=10; |
135 | SetMouseDoubleClickDelay(mouse_cfg.double_click_delay); |
133 | SetMouseDoubleClickDelay(mouse_cfg.double_click_delay); |
136 | } |
134 | } |
137 | DrawControls(); |
135 | DrawControls(); |
138 | break; |
136 | break; |
139 | 137 | ||
140 | case evKey: |
138 | case evKey: |
141 | if (GetKey()==27) ExitApp(); |
139 | if (GetKey()==27) ExitApp(); |
142 | break; |
140 | break; |
143 | 141 | ||
144 | case evReDraw: |
142 | case evReDraw: |
145 | system.color.get(); |
143 | system.color.get(); |
146 | DefineAndDrawWindow(430, 150, 360, 300+GetSkinHeight(),0x34,system.color.work,WINDOW_TITLE); |
144 | DefineAndDrawWindow(430, 150, 360, 300+GetSkinHeight(),0x34,system.color.work,WINDOW_TITLE); |
147 | GetProcessInfo(#Form, SelfInfo); |
145 | GetProcessInfo(#Form, SelfInfo); |
148 | if (Form.status_window>2) break; |
146 | if (Form.status_window>2) break; |
149 | SetFrameColors(); |
147 | SetFrameColors(); |
150 | DefineButton(mouse_frame.start_x+2, mouse_frame.start_y+2, mouse_frame.size_x-4, |
148 | DefineButton(mouse_frame.start_x+2, mouse_frame.start_y+2, mouse_frame.size_x-4, |
151 | mouse_frame.size_y-4, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image |
149 | mouse_frame.size_y-4, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image |
152 | frame_draw stdcall (#mouse_frame); |
150 | frame_draw stdcall (#mouse_frame); |
153 | WriteText(pos_x + 110, mouse_frame.start_y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1); |
151 | WriteText(pos_x + 110, mouse_frame.start_y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1); |
154 | WriteText(pos_x + 110, mouse_frame.start_y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2); |
152 | WriteText(pos_x + 110, mouse_frame.start_y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2); |
155 | DrawMouseImage(); |
153 | DrawMouseImage(); |
156 | DrawControls(); |
154 | DrawControls(); |
157 | } |
155 | } |
158 | } |
156 | } |
159 | 157 | ||
160 | 158 | ||
161 | void DrawMouseImage() { |
159 | void DrawMouseImage() { |
162 | _PutImage(mouse_frame.start_x+30, mouse_frame.start_y + 15, panels_img.w, panels_img.h, |
160 | _PutImage(mouse_frame.start_x+30, mouse_frame.start_y + 15, panels_img.w, panels_img.h, |
163 | mouse_cfg.button_clicked * panels_img.w * panels_img.h * 3 + panels_img.data); |
161 | mouse_cfg.button_clicked * panels_img.w * panels_img.h * 3 + panels_img.data); |
164 | } |
162 | } |
165 | 163 | ||
166 | void DrawControls() { |
164 | void DrawControls() { |
167 | DrawBar(pos_x, mouse_frame.start_y + 142, Form.cwidth - pos_x, 120, system.color.work); |
165 | DrawBar(pos_x, mouse_frame.start_y + 142, Form.cwidth - pos_x, 120, system.color.work); |
168 | PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 142, 120, 121, mouse_cfg.pointer_speed, POINTER_SPEED); |
166 | PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 142, 120, 121, mouse_cfg.pointer_speed, POINTER_SPEED); |
169 | PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 170, 122, 123, mouse_cfg.acceleration, ACCELERATION_TEXT); |
167 | PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 170, 122, 123, mouse_cfg.acceleration, ACCELERATION_TEXT); |
170 | PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 198, 124, 125, mouse_cfg.double_click_delay, DOUBLE_CLICK_TEXT); |
168 | PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 198, 124, 125, mouse_cfg.double_click_delay, DOUBLE_CLICK_TEXT); |
171 | PanelCfg_CheckBox(pos_x, mouse_frame.start_y + 230, 100, MOUSE_EMULATION, mouse_cfg.emulation); |
169 | PanelCfg_CheckBox(pos_x, mouse_frame.start_y + 230, 100, MOUSE_EMULATION, mouse_cfg.emulation); |
172 | PanelCfg_CheckBox(pos_x, mouse_frame.start_y + 254, 101, MADMOUSE, mouse_cfg.madmouse); |
170 | PanelCfg_CheckBox(pos_x, mouse_frame.start_y + 254, 101, MADMOUSE, mouse_cfg.madmouse); |
173 | } |
171 | } |
174 | 172 | ||
175 | void SetFrameColors() { |
173 | void SetFrameColors() { |
176 | mouse_frame.size_x = - mouse_frame.start_x * 2 + Form.cwidth; |
174 | mouse_frame.size_x = - mouse_frame.start_x * 2 + Form.cwidth; |
177 | mouse_frame.font_color = system.color.work_text; |
175 | mouse_frame.font_color = system.color.work_text; |
178 | mouse_frame.font_backgr_color = system.color.work; |
176 | mouse_frame.font_backgr_color = system.color.work; |
179 | mouse_frame.ext_col = system.color.work_graph; |
177 | mouse_frame.ext_col = system.color.work_graph; |
180 | } |
178 | } |
181 | 179 | ||
182 | void LoadCfg() { |
180 | void LoadCfg() { |
183 | ini_get_int stdcall (#system_ini_path, #mouse_category, "acceleration", GetMouseAcceleration()); mouse_cfg.acceleration = EAX; |
181 | ini_get_int stdcall (#system_ini_path, #mouse_category, "acceleration", GetMouseAcceleration()); mouse_cfg.acceleration = EAX; |
184 | ini_get_int stdcall (#system_ini_path, #mouse_category, "speed", GetMouseSpeed()); mouse_cfg.pointer_speed = EAX; |
182 | ini_get_int stdcall (#system_ini_path, #mouse_category, "speed", GetMouseSpeed()); mouse_cfg.pointer_speed = EAX; |
185 | ini_get_int stdcall (#system_ini_path, #mouse_category, "double_click_delay", GetMouseDoubleClickDelay()); mouse_cfg.double_click_delay = EAX; |
183 | ini_get_int stdcall (#system_ini_path, #mouse_category, "double_click_delay", GetMouseDoubleClickDelay()); mouse_cfg.double_click_delay = EAX; |
186 | mouse_cfg.madmouse = CheckProcessExists("MADMOUSE"); |
184 | mouse_cfg.madmouse = CheckProcessExists("MADMOUSE"); |
187 | mouse_cfg.emulation = CheckProcessExists("MOUSEMUL"); |
185 | mouse_cfg.emulation = CheckProcessExists("MOUSEMUL"); |
188 | } |
186 | } |
189 | 187 | ||
190 | void ExitApp() { |
188 | void ExitApp() { |
191 | ini_set_int stdcall (#system_ini_path, #mouse_category, "acceleration", mouse_cfg.acceleration); |
189 | ini_set_int stdcall (#system_ini_path, #mouse_category, "acceleration", mouse_cfg.acceleration); |
192 | ini_set_int stdcall (#system_ini_path, #mouse_category, "speed", mouse_cfg.pointer_speed); |
190 | ini_set_int stdcall (#system_ini_path, #mouse_category, "speed", mouse_cfg.pointer_speed); |
193 | ini_set_int stdcall (#system_ini_path, #mouse_category, "double_click_delay", mouse_cfg.double_click_delay); |
191 | ini_set_int stdcall (#system_ini_path, #mouse_category, "double_click_delay", mouse_cfg.double_click_delay); |
194 | ExitProcess(); |
192 | ExitProcess(); |
195 | } |
193 | } |
196 | 194 | ||
197 | 195 | ||
198 | void PanelCfg_CheckBox(dword x, y, id, text, byte value) { |
196 | void PanelCfg_CheckBox(dword x, y, id, text, byte value) { |
199 | CheckBox(x, y, 14, 14, id, text, system.color.work_graph, system.color.work_text, value); |
197 | CheckBox(x, y, 14, 14, id, text, system.color.work_graph, system.color.work_text, value); |
200 | } |
198 | } |
201 | 199 | ||
202 | void PanelCfg_MoreLessBox(dword x, y, id_more, id_less; word value; dword text) { |
200 | void PanelCfg_MoreLessBox(dword x, y, id_more, id_less; word value; dword text) { |
203 | MoreLessBox(x, y, 18, id_more, id_less, #system.color, value, text); |
201 | MoreLessBox(x, y, 18, id_more, id_less, #system.color, value, text); |
204 | } |
202 | } |
205 | 203 | ||
206 | 204 | ||
207 | 205 | ||
208 | 206 | ||
209 | stop:3) |
207 | stop:3) |
210 | >=>=> |
208 | >=>=> |