Subversion Repositories Kolibri OS

Rev

Rev 6754 | Rev 7051 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. // Mouse Configuration Utility ver 1.4
  2.  
  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.h"
  13. #include "..\lib\obj\box_lib.h"
  14. #include "..\lib\obj\libini.h"
  15. #include "..\lib\patterns\restart_process.h"
  16.  
  17. #ifdef LANG_RUS
  18.         ?define WINDOW_TITLE "à®¢¥àª  ¨ ­ áâனª  ¯ à ¬¥â஢ ¬ëè¨"
  19.         ?define CHECK_MOUSE_1 " ¦¬¨â¥ ­  í⮩ ®¡« áâ¨"
  20.         ?define CHECK_MOUSE_2 "¤«ï ¯à®¢¥àª¨ ª­®¯®ª ¬ëè¨"
  21.         ?define POINTER_SPEED "„¥«¨â¥«ì ᪮à®á⨠㪠§ â¥«ï ¬ëè¨"
  22.         ?define ACCELERATION_TEXT "—ã¢á⢨⥫쭮áâì 㪠§ â¥«ï ¬ëè¨"
  23.         ?define DOUBLE_CLICK_TEXT "‡ ¤¥à¦ª  ¤¢®©­®£® ª«¨ª  ¬ëèìî"
  24.         ?define MOUSE_EMULATION "“¯à ¢«¥­¨¥ 㪠§ â¥«¥¬ ¬ëè¨ ç¥à¥§ ª« ¢¨ âãàã"
  25.         ?define MADMOUSE "‘ª¢®§­ë¥ ¤«ï ªãàá®à  áâ®à®­ë íªà ­ "
  26. #else
  27.         ?define WINDOW_TITLE "Mouse testing and configuration"
  28.         ?define CHECK_MOUSE_1 "Click on this area to"
  29.         ?define CHECK_MOUSE_2 "check your mouse buttons"
  30.         ?define POINTER_SPEED "Mouse pointer speed divider"
  31.         ?define ACCELERATION_TEXT "Mouse pointer sensitivity"
  32.         ?define DOUBLE_CLICK_TEXT "Mouse double click delay"
  33.         ?define MOUSE_EMULATION "Enable mouse emulation using keyboard NumPad"
  34.         ?define MADMOUSE "Through screen sides for pointer"
  35.         #endif
  36.  
  37. proc_info Form;
  38. frame mouse_frame = { 0, 000, 14, 130, 14, 0x000111, 0xFFFfff, 0, 0, 0, 0, 6, 0x000111, 0xCCCccc };
  39. char pos_x = 22;
  40.  
  41. unsigned char panels_img_data[] = FROM "mouse_image.raw";
  42. raw_image panels_img = { 59, 101, #panels_img_data };
  43.  
  44. char system_ini_path[] = "/sys/settings/system.ini";
  45. char mouse_category[] = "mouse";
  46.  
  47.  
  48. struct _mouse_cfg {
  49.         char pointer_speed,
  50.         acceleration,
  51.         emulation,
  52.         madmouse,
  53.         button_clicked;
  54.         word double_click_delay;
  55. } mouse_cfg;
  56.  
  57.  
  58. void main() {
  59.         char id, old_button_clicked;
  60.  
  61.         load_dll(libini, #lib_init,1);
  62.         load_dll(boxlib, #box_lib_init,0);
  63.  
  64.         LoadCfg();
  65.  
  66.         SetEventMask(0x27);
  67.         loop() switch(WaitEvent())
  68.         {
  69.                 case evMouse:
  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;
  73.                                 old_button_clicked = mouse_cfg.button_clicked;
  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;
  77.                                 else mouse_cfg.button_clicked=0;
  78.                                 if (mouse_cfg.button_clicked != old_button_clicked) DrawMouseImage();
  79.                                 break;
  80.  
  81.                 case evButton:
  82.                                 id=GetButtonID();
  83.                                 if (id==1)
  84.                                 {
  85.                                         ExitApp();
  86.                                 }
  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.                                 }
  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.acceleration++;
  118.                                         SetMouseAcceleration(mouse_cfg.acceleration);
  119.                                 }
  120.                                 if (id==123) && (mouse_cfg.acceleration>0)
  121.                                 {
  122.                                         mouse_cfg.acceleration--;
  123.                                         SetMouseAcceleration(mouse_cfg.acceleration);
  124.                                 }
  125.                                 if (id==124)
  126.                                 {
  127.                                         mouse_cfg.double_click_delay+=8;
  128.                                         SetMouseDoubleClickDelay(mouse_cfg.double_click_delay);
  129.                                 }
  130.                                 if (id==125) && (mouse_cfg.double_click_delay>0)
  131.                                 {
  132.                                         mouse_cfg.double_click_delay-=8;
  133.                                         SetMouseDoubleClickDelay(mouse_cfg.double_click_delay);
  134.                                 }
  135.                                 DrawControls();
  136.                                 break;
  137.                                
  138.                 case evKey:
  139.                                 if (GetKey()==27) ExitApp();
  140.                                 break;
  141.                        
  142.                 case evReDraw:
  143.                                 system.color.get();
  144.                                 DefineAndDrawWindow(430, 150, 424, 310+GetSkinHeight(),0x34,system.color.work,WINDOW_TITLE,0);
  145.                                 GetProcessInfo(#Form, SelfInfo);
  146.                                 if (Form.status_window>2) break;
  147.                                 SetFrameColors();
  148.                                 DefineButton(mouse_frame.start_x+2, mouse_frame.start_y+2, mouse_frame.size_x-4,
  149.                                         mouse_frame.size_y-4, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image
  150.                                 frame_draw stdcall (#mouse_frame);
  151.                                 WriteText(pos_x + 110, mouse_frame.start_y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1);
  152.                                 WriteText(pos_x + 110, mouse_frame.start_y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2);
  153.                                 DrawMouseImage();
  154.                                 DrawControls();
  155.         }
  156. }
  157.  
  158.  
  159. void DrawMouseImage() {
  160.         _PutImage(mouse_frame.start_x+30, mouse_frame.start_y + 15,  panels_img.w, panels_img.h,
  161.                 mouse_cfg.button_clicked * panels_img.w * panels_img.h * 3 + panels_img.data);
  162. }
  163.  
  164. void DrawControls() {
  165.         MoreLessBox(pos_x, mouse_frame.start_y + 142, 120, 121, mouse_cfg.pointer_speed, POINTER_SPEED);
  166.         MoreLessBox(pos_x, mouse_frame.start_y + 172, 122, 123, mouse_cfg.acceleration, ACCELERATION_TEXT);
  167.         MoreLessBox(pos_x, mouse_frame.start_y + 202, 124, 125, mouse_cfg.double_click_delay, DOUBLE_CLICK_TEXT);
  168.         CheckBox(pos_x, mouse_frame.start_y + 236, 100, MOUSE_EMULATION, mouse_cfg.emulation);
  169.         CheckBox(pos_x, mouse_frame.start_y + 262, 101, MADMOUSE, mouse_cfg.madmouse);
  170. }
  171.  
  172. void SetFrameColors() {
  173.         mouse_frame.size_x = - mouse_frame.start_x * 2 + Form.cwidth;
  174.         mouse_frame.font_color = system.color.work_text;
  175.         mouse_frame.font_backgr_color = system.color.work;
  176.         mouse_frame.ext_col = system.color.work_graph;
  177. }
  178.  
  179. void LoadCfg() {
  180.         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, "speed", GetMouseSpeed());   mouse_cfg.pointer_speed = EAX;
  182.         ini_get_int stdcall (#system_ini_path, #mouse_category, "double_click_delay", GetMouseDoubleClickDelay());   mouse_cfg.double_click_delay = EAX;
  183.         mouse_cfg.madmouse = CheckProcessExists("MADMOUSE");
  184.         mouse_cfg.emulation = CheckProcessExists("MOUSEMUL");
  185. }
  186.  
  187. void ExitApp() {
  188.         ini_set_int stdcall (#system_ini_path, #mouse_category, "acceleration", mouse_cfg.acceleration);
  189.         ini_set_int stdcall (#system_ini_path, #mouse_category, "speed", mouse_cfg.pointer_speed);
  190.         ini_set_int stdcall (#system_ini_path, #mouse_category, "double_click_delay", mouse_cfg.double_click_delay);
  191.         ExitProcess();
  192. }
  193.  
  194.  
  195.  
  196. stop: