Rev 7646 | Rev 7806 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7646 | Rev 7804 | ||
---|---|---|---|
1 | // Mouse Configuration Utility ver 1.62 |
1 | // Mouse Configuration Utility ver 1.62 |
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 4096*11 |
7 | #define MEMSIZE 4096*11 |
8 | 8 | ||
9 | #include "..\lib\strings.h" |
9 | #include "..\lib\strings.h" |
10 | #include "..\lib\mem.h" |
10 | #include "..\lib\mem.h" |
11 | #include "..\lib\fs.h" |
11 | #include "..\lib\fs.h" |
12 | #include "..\lib\gui.h" |
12 | #include "..\lib\gui.h" |
13 | #include "..\lib\obj\libio.h" |
13 | #include "..\lib\obj\libio.h" |
14 | #include "..\lib\obj\box_lib.h" |
- | |
15 | #include "..\lib\obj\libini.h" |
14 | #include "..\lib\obj\libini.h" |
16 | #include "..\lib\patterns\restart_process.h" |
15 | #include "..\lib\patterns\restart_process.h" |
17 | 16 | ||
18 | // Translatiions |
17 | // Translatiions |
19 | #ifdef LANG_RUS |
18 | #ifdef LANG_RUS |
20 | ?define WINDOW_TITLE "஢¥àª ¨ áâனª ¯ à ¬¥â஢ ¬ëè¨" |
19 | ?define WINDOW_TITLE "஢¥àª ¨ áâனª ¯ à ¬¥â஢ ¬ëè¨" |
21 | ?define CHECK_MOUSE_1 " ¦¬¨â¥ í⮩ ®¡« áâ¨" |
20 | ?define CHECK_MOUSE_1 " ¦¬¨â¥ í⮩ ®¡« áâ¨" |
22 | ?define CHECK_MOUSE_2 "¤«ï ¯à®¢¥àª¨ ª®¯®ª ¬ëè¨" |
21 | ?define CHECK_MOUSE_2 "¤«ï ¯à®¢¥àª¨ ª®¯®ª ¬ëè¨" |
23 | ?define POINTER_SPEED "¥«¨â¥«ì ᪮à®á⨠㪠§ â¥«ï ¬ëè¨" |
22 | ?define POINTER_SPEED "¥«¨â¥«ì ᪮à®á⨠㪠§ â¥«ï ¬ëè¨" |
24 | ?define ACCELERATION_TEXT "ã¢á⢨⥫ì®áâì 㪠§ â¥«ï ¬ëè¨" |
23 | ?define ACCELERATION_TEXT "ã¢á⢨⥫ì®áâì 㪠§ â¥«ï ¬ëè¨" |
25 | ?define DOUBLE_CLICK_TEXT " ¤¥à¦ª ¤¢®©®£® ª«¨ª ¬ëèìî" |
24 | ?define DOUBLE_CLICK_TEXT " ¤¥à¦ª ¤¢®©®£® ª«¨ª ¬ëèìî" |
26 | ?define MOUSE_EMULATION "¯à ¢«¥¨¥ 㪠§ ⥫¥¬ ¬ëè¨ ç¥à¥§ ª« ¢¨ âãàã" |
25 | ?define MOUSE_EMULATION "¯à ¢«¥¨¥ 㪠§ ⥫¥¬ ¬ëè¨ ç¥à¥§ ª« ¢¨ âãàã" |
27 | ?define MADMOUSE "ª¢®§ë¥ ¤«ï ªãàá®à áâ®à®ë íªà " |
26 | ?define MADMOUSE "ª¢®§ë¥ ¤«ï ªãàá®à áâ®à®ë íªà " |
28 | ?define COMMOUSE " £à㧨âì ¤à ©¢¥à ¬ëè¨ ¤«ï COM-¯®àâ (F10)" |
27 | ?define COMMOUSE " £à㧨âì ¤à ©¢¥à ¬ëè¨ ¤«ï COM-¯®àâ (F10)" |
29 | ?define COMMOUSE_LOADED "'à ©¢¥à ¤«ï COM ¬ëè¨ ¡ë« § £à㦥' -O" |
28 | ?define COMMOUSE_LOADED "'à ©¢¥à ¤«ï COM ¬ëè¨ ¡ë« § £à㦥' -O" |
30 | ?define COMMOUSE_CAN_NOT_UNLOAD "'áâ ®¢ª ¤à ©¢¥à ¥¢®§¬®¦ ' -W" |
29 | ?define COMMOUSE_CAN_NOT_UNLOAD "'áâ ®¢ª ¤à ©¢¥à ¥¢®§¬®¦ ' -W" |
31 | #else |
30 | #else |
32 | ?define WINDOW_TITLE "Mouse testing and configuration" |
31 | ?define WINDOW_TITLE "Mouse testing and configuration" |
33 | ?define CHECK_MOUSE_1 "Click on this area to" |
32 | ?define CHECK_MOUSE_1 "Click on this area to" |
34 | ?define CHECK_MOUSE_2 "check your mouse buttons" |
33 | ?define CHECK_MOUSE_2 "check your mouse buttons" |
35 | ?define POINTER_SPEED "Mouse pointer speed divider" |
34 | ?define POINTER_SPEED "Mouse pointer speed divider" |
36 | ?define ACCELERATION_TEXT "Mouse pointer sensitivity" |
35 | ?define ACCELERATION_TEXT "Mouse pointer sensitivity" |
37 | ?define DOUBLE_CLICK_TEXT "Mouse double click delay" |
36 | ?define DOUBLE_CLICK_TEXT "Mouse double click delay" |
38 | ?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad" |
37 | ?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad" |
39 | ?define MADMOUSE "Through screen sides for pointer" |
38 | ?define MADMOUSE "Through screen sides for pointer" |
40 | ?define COMMOUSE "Load mouse driver for COM-port (F10)" |
39 | ?define COMMOUSE "Load mouse driver for COM-port (F10)" |
41 | ?define COMMOUSE_LOADED "'Driver for COM mouse loaded' -O" |
40 | ?define COMMOUSE_LOADED "'Driver for COM mouse loaded' -O" |
42 | ?define COMMOUSE_CAN_NOT_UNLOAD "'Driver stop is impossible' -W" |
41 | ?define COMMOUSE_CAN_NOT_UNLOAD "'Driver stop is impossible' -W" |
43 | #endif |
42 | #endif |
44 | 43 | ||
45 | #define FRAME_X 18 |
44 | #define FRAME_X 18 |
46 | #define FRAME_Y 18 |
45 | #define FRAME_Y 18 |
47 | :block mouse_frame = { FRAME_X, FRAME_Y, NULL, 130 }; |
46 | :block mouse_frame = { FRAME_X, FRAME_Y, NULL, 130 }; |
48 | :more_less_box pointer_speed = { NULL, 0, 64, POINTER_SPEED }; |
47 | :more_less_box pointer_speed = { NULL, 0, 64, POINTER_SPEED }; |
49 | :more_less_box acceleration = { NULL, 0, 64, ACCELERATION_TEXT }; |
48 | :more_less_box acceleration = { NULL, 0, 64, ACCELERATION_TEXT }; |
50 | :more_less_box double_click_delay = { NULL, 0, 999, DOUBLE_CLICK_TEXT, 8 }; |
49 | :more_less_box double_click_delay = { NULL, 0, 999, DOUBLE_CLICK_TEXT, 8 }; |
51 | :checkbox emulation = { MOUSE_EMULATION, NULL }; |
50 | :checkbox emulation = { MOUSE_EMULATION, NULL }; |
52 | :checkbox madmouse = { MADMOUSE, NULL }; |
51 | :checkbox madmouse = { MADMOUSE, NULL }; |
53 | :checkbox com_mouse = { COMMOUSE, NULL }; |
52 | :checkbox com_mouse = { COMMOUSE, NULL }; |
54 | 53 | ||
55 | _ini ini = { "/sys/settings/system.ini", "loaded drivers" }; |
54 | _ini ini = { "/sys/settings/system.ini", "loaded drivers" }; |
56 | 55 | ||
57 | void main() { |
56 | void main() { |
58 | proc_info Form; |
57 | proc_info Form; |
59 | int id; |
58 | int id; |
60 | 59 | ||
61 | load_dll(libini, #lib_init,1); |
60 | load_dll(libini, #lib_init,1); |
62 | load_dll(boxlib, #box_lib_init,0); |
- | |
63 | 61 | ||
64 | LoadCfg(); |
62 | LoadCfg(); |
65 | 63 | ||
66 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
64 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
67 | 65 | ||
68 | loop() switch(WaitEvent()) |
66 | loop() switch(WaitEvent()) |
69 | { |
67 | { |
70 | case evMouse: |
68 | case evMouse: |
71 | mouse.get(); |
69 | mouse.get(); |
72 | IF (mouse_frame.hovered()) DrawMouseImage(mouse.lkm,mouse.pkm,mouse.mkm,mouse.vert); |
70 | IF (mouse_frame.hovered()) DrawMouseImage(mouse.lkm,mouse.pkm,mouse.mkm,mouse.vert); |
73 | IF (mouse.click) || (mouse.up) DrawMouseImage(0,0,0,0); |
71 | IF (mouse.click) || (mouse.up) DrawMouseImage(0,0,0,0); |
74 | break; |
72 | break; |
75 | 73 | ||
76 | CASE evButton: |
74 | CASE evButton: |
77 | id = GetButtonID(); |
75 | id = GetButtonID(); |
78 | IF (1 == id) ExitApp(); |
76 | IF (1 == id) ExitApp(); |
79 | else IF (pointer_speed.click(id)) ApplyCfg(); |
77 | else IF (pointer_speed.click(id)) ApplyCfg(); |
80 | else IF (acceleration.click(id)) ApplyCfg(); |
78 | else IF (acceleration.click(id)) ApplyCfg(); |
81 | else IF (double_click_delay.click(id)) ApplyCfg(); |
79 | else IF (double_click_delay.click(id)) ApplyCfg(); |
82 | else IF (emulation.click(id)) { |
80 | else IF (emulation.click(id)) { |
83 | IF (emulation.checked == true) RunProgram("/sys/mousemul", 0); |
81 | IF (emulation.checked == true) RunProgram("/sys/mousemul", 0); |
84 | ELSE KillProcessByName("mousemul", SINGLE); |
82 | ELSE KillProcessByName("mousemul", SINGLE); |
85 | break; |
83 | break; |
86 | } |
84 | } |
87 | else IF (madmouse.click(id)) { |
85 | else IF (madmouse.click(id)) { |
88 | IF (madmouse.checked == true) RunProgram("/sys/madmouse", 0); |
86 | IF (madmouse.checked == true) RunProgram("/sys/madmouse", 0); |
89 | ELSE KillProcessByName("madmouse", SINGLE); |
87 | ELSE KillProcessByName("madmouse", SINGLE); |
90 | break; |
88 | break; |
91 | } |
89 | } |
92 | else IF (id == com_mouse.id) { |
90 | else IF (id == com_mouse.id) { |
93 | EventClickComMouse(); |
91 | EventClickComMouse(); |
94 | } |
92 | } |
95 | break; |
93 | break; |
96 | 94 | ||
97 | case evKey: |
95 | case evKey: |
98 | GetKeys(); |
96 | GetKeys(); |
99 | IF (key_scancode == SCAN_CODE_ESC) ExitApp(); |
97 | IF (key_scancode == SCAN_CODE_ESC) ExitApp(); |
100 | IF (key_scancode == SCAN_CODE_F10) EventClickComMouse(); |
98 | IF (key_scancode == SCAN_CODE_F10) EventClickComMouse(); |
101 | break; |
99 | break; |
102 | 100 | ||
103 | case evReDraw: |
101 | case evReDraw: |
104 | system.color.get(); |
102 | system.color.get(); |
105 | DefineAndDrawWindow(430, 150, 424, 343+skin_height,0x34,system.color.work,WINDOW_TITLE,0); |
103 | DefineAndDrawWindow(430, 150, 424, 343+skin_height,0x34,system.color.work,WINDOW_TITLE,0); |
106 | GetProcessInfo(#Form, SelfInfo); |
104 | GetProcessInfo(#Form, SelfInfo); |
107 | if (Form.status_window>2) break; |
105 | if (Form.status_window>2) break; |
108 | mouse_frame.w = - FRAME_X * 2 + Form.cwidth; |
106 | mouse_frame.w = - FRAME_X * 2 + Form.cwidth; |
109 | DefineButton(FRAME_X, FRAME_Y, mouse_frame.w, |
107 | DefineButton(FRAME_X, FRAME_Y, mouse_frame.w, |
110 | mouse_frame.h, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image |
108 | mouse_frame.h, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image |
111 | WriteText(FRAME_X + 110, FRAME_Y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1); |
109 | WriteText(FRAME_X + 110, FRAME_Y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1); |
112 | WriteText(FRAME_X + 110, FRAME_Y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2); |
110 | WriteText(FRAME_X + 110, FRAME_Y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2); |
113 | DrawMouseImage(0,0,0,0); |
111 | DrawMouseImage(0,0,0,0); |
114 | DrawControls(); |
112 | DrawControls(); |
115 | } |
113 | } |
116 | } |
114 | } |
117 | 115 | ||
118 | :byte panels_img_data[] = FROM "mouse_image.raw"; |
116 | :byte panels_img_data[] = FROM "mouse_image.raw"; |
119 | 117 | ||
120 | #define red 0xff0000 |
118 | #define red 0xff0000 |
121 | #define yellow 0xfff600 |
119 | #define yellow 0xfff600 |
122 | #define white 0xffffff |
120 | #define white 0xffffff |
123 | #define dgrey 0x2d353d |
121 | #define dgrey 0x2d353d |
124 | 122 | ||
125 | :struct IMG_PAL{ dword back, shad1, contour, left, right, middle, mwhite; } |
123 | :struct IMG_PAL{ dword back, shad1, contour, left, right, middle, mwhite; } |
126 | pal = { 0xF0F2F3,0xABB0B2, dgrey, white, white, dgrey, white }; |
124 | pal = { 0xF0F2F3,0xABB0B2, dgrey, white, white, dgrey, white }; |
127 | 125 | ||
128 | void DrawMouseImage(dword l,r,m,v) { |
126 | void DrawMouseImage(dword l,r,m,v) { |
129 | #define IMG_W 59 |
127 | #define IMG_W 59 |
130 | #define IMG_H 101 |
128 | #define IMG_H 101 |
131 | 129 | ||
132 | IF (l) pal.left = red; |
130 | IF (l) pal.left = red; |
133 | IF (m) pal.middle = red; |
131 | IF (m) pal.middle = red; |
134 | IF (r) pal.right = red; |
132 | IF (r) pal.right = red; |
135 | IF (v) pal.middle = yellow; |
133 | IF (v) pal.middle = yellow; |
136 | 134 | ||
137 | PutPaletteImage(#panels_img_data,IMG_W,IMG_H,18+30,18+15,8,#pal); |
135 | PutPaletteImage(#panels_img_data,IMG_W,IMG_H,18+30,18+15,8,#pal); |
138 | pal.left = pal.right = white; |
136 | pal.left = pal.right = white; |
139 | pal.middle = dgrey; |
137 | pal.middle = dgrey; |
140 | IF (v) { |
138 | IF (v) { |
141 | pause(10); |
139 | pause(10); |
142 | DrawMouseImage(l,r,m,0); |
140 | DrawMouseImage(l,r,m,0); |
143 | } |
141 | } |
144 | } |
142 | } |
145 | 143 | ||
146 | void DrawControls() { |
144 | void DrawControls() { |
147 | incn y; |
145 | incn y; |
148 | y.n = FRAME_Y+115; |
146 | y.n = FRAME_Y+115; |
149 | pointer_speed.draw(FRAME_X, y.inc(30)); |
147 | pointer_speed.draw(FRAME_X, y.inc(30)); |
150 | acceleration.draw(FRAME_X, y.inc(30)); |
148 | acceleration.draw(FRAME_X, y.inc(30)); |
151 | double_click_delay.draw(FRAME_X, y.inc(30)); |
149 | double_click_delay.draw(FRAME_X, y.inc(30)); |
152 | emulation.draw(FRAME_X, y.inc(33)); |
150 | emulation.draw(FRAME_X, y.inc(33)); |
153 | madmouse.draw(FRAME_X, y.inc(27)); |
151 | madmouse.draw(FRAME_X, y.inc(27)); |
154 | com_mouse.draw(FRAME_X, y.inc(27)); |
152 | com_mouse.draw(FRAME_X, y.inc(27)); |
155 | } |
153 | } |
156 | 154 | ||
157 | void LoadCfg() { |
155 | void LoadCfg() { |
158 | acceleration.value = GetMouseAcceleration(); |
156 | acceleration.value = GetMouseAcceleration(); |
159 | pointer_speed.value = GetMouseSpeed(); |
157 | pointer_speed.value = GetMouseSpeed(); |
160 | double_click_delay.value = GetMouseDoubleClickDelay(); |
158 | double_click_delay.value = GetMouseDoubleClickDelay(); |
161 | com_mouse.checked = ini.GetInt("com_mouse", 0); |
159 | com_mouse.checked = ini.GetInt("com_mouse", 0); |
162 | madmouse.checked = CheckProcessExists("MADMOUSE"); |
160 | madmouse.checked = CheckProcessExists("MADMOUSE"); |
163 | emulation.checked = CheckProcessExists("MOUSEMUL"); |
161 | emulation.checked = CheckProcessExists("MOUSEMUL"); |
164 | } |
162 | } |
165 | 163 | ||
166 | void ExitApp() { |
164 | void ExitApp() { |
167 | ini.SetInt("com_mouse", com_mouse.checked); |
165 | ini.SetInt("com_mouse", com_mouse.checked); |
168 | ExitProcess(); |
166 | ExitProcess(); |
169 | } |
167 | } |
170 | 168 | ||
171 | void ApplyCfg() { |
169 | void ApplyCfg() { |
172 | SetMouseSpeed(pointer_speed.value); |
170 | SetMouseSpeed(pointer_speed.value); |
173 | SetMouseAcceleration(acceleration.value); |
171 | SetMouseAcceleration(acceleration.value); |
174 | SetMouseDoubleClickDelay(double_click_delay.value); |
172 | SetMouseDoubleClickDelay(double_click_delay.value); |
175 | } |
173 | } |
176 | 174 | ||
177 | void EventClickComMouse() |
175 | void EventClickComMouse() |
178 | { |
176 | { |
179 | if (!com_mouse.checked) |
177 | if (!com_mouse.checked) |
180 | { |
178 | { |
181 | if (RunProgram("/sys/loaddrv", "COMMOUSE")>=0) { |
179 | if (RunProgram("/sys/loaddrv", "COMMOUSE")>=0) { |
182 | notify(COMMOUSE_LOADED); |
180 | notify(COMMOUSE_LOADED); |
183 | com_mouse.click(com_mouse.id); |
181 | com_mouse.click(com_mouse.id); |
184 | } |
182 | } |
185 | else { |
183 | else { |
186 | notify("'Error running LOADDRV' -E"); |
184 | notify("'Error running LOADDRV' -E"); |
187 | } |
185 | } |
188 | } |
186 | } |
189 | else |
187 | else |
190 | { |
188 | { |
191 | notify(COMMOUSE_CAN_NOT_UNLOAD); |
189 | notify(COMMOUSE_CAN_NOT_UNLOAD); |
192 | } |
190 | } |
193 | } |
191 | } |
194 | 192 | ||
195 | stop: |
193 | stop: |