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