Subversion Repositories Kolibri OS

Rev

Rev 5631 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  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. #include "kos_mouse_functions.h"
  17.  
  18. #ifdef LANG_RUS
  19.         ?define WINDOW_TITLE "à®¢¥àª  ¨ ­ áâனª  ¯ à ¬¥â஢ ¬ëè¨"
  20.         ?define CHECK_MOUSE_1 " ¦¬¨â¥ ­  í⮩ ®¡« áâ¨"
  21.         ?define CHECK_MOUSE_2 "¤«ï ¯à®¢¥àª¨ ª­®¯®ª ¬ëè¨"
  22.         ?define POINTER_SPEED "‘ª®à®áâì 㪠§ â¥«ï ¬ëè¨"
  23.         ?define POINTER_DELAY "‡ ¤¥à¦ª  㪠§ â¥«ï ¬ëè¨"
  24.         ?define MOUSE_EMULATION "¬ã«ïæ¨ï ã¯à ¢«¥­¨ï 㪠§ â¥«¥¬ ç¥à¥§ ª« ¢¨ âãàã"
  25.         ?define MADMOUSE "‘ªà®§­ë¥ ¤«ï ªãàá®à  áâ®à®­ë íªà ­ "
  26.         //?define MADMOUSE_DESCRIPTION "'When cursor reaches screen side switch it to inverce side' -I"
  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"
  35.         //?define MADMOUSE_DESCRIPTION "'When cursor reaches screen side switch it to inverce side' -I"
  36. #endif
  37.  
  38. frame mouse_frame = { 0, 000, 14, 130, 14, 0x000111, 0xFFFfff, 0, 0, 0, 0, 6, 0x000111, 0xCCCccc };
  39.  
  40.  
  41. unsigned char panels_img_data[] = FROM "mouse_image.raw";
  42. raw_image panels_img = { 59, 101, #panels_img_data };
  43.  
  44. system_colors sc;
  45. proc_info Form;
  46.  
  47.  
  48. struct mouse_cfg1 {
  49.         char pointer_speed,
  50.         pointer_delay,
  51.         emulation,
  52.         madmouse,
  53.         button_clicked;
  54. } mouse_cfg;
  55.  
  56.  
  57. void main() {
  58.         char id, old_button_clicked;
  59.  
  60.         mem_Init();
  61.         load_dll(boxlib, #box_lib_init,0);
  62.  
  63.         LoadCfg();
  64.  
  65.         SetEventMask(0x27);
  66.         loop() switch(WaitEvent())
  67.         {
  68.                 case evMouse:
  69.                                 mouse.get();
  70.                                 if (mouse.y <= mouse_frame.start_y) || (mouse.y >= mouse_frame.start_y + mouse_frame.size_y)
  71.                                 || (mouse.x >= mouse_frame.start_x + mouse_frame.size_x) || (mouse.x <= mouse_frame.start_x) break;
  72.                                 old_button_clicked = mouse_cfg.button_clicked;
  73.                                 if (mouse.lkm) mouse_cfg.button_clicked=1;
  74.                                 else if (mouse.pkm) mouse_cfg.button_clicked=2;
  75.                                 else if (mouse.mkm) mouse_cfg.button_clicked=3;
  76.                                 else mouse_cfg.button_clicked=0;
  77.                                 if (mouse_cfg.button_clicked != old_button_clicked) DrawMouseImage();
  78.                                 break;
  79.  
  80.                 case evButton:
  81.                                 id=GetButtonID();
  82.                                 if (id==1)
  83.                                 {
  84.                                         ExitProcess();
  85.                                 }
  86.                                 if (id==99)
  87.                                 {
  88.                                         mouse_cfg.button_clicked=0;
  89.                                         DrawMouseImage();
  90.                                         break;
  91.                                 }
  92.                                 if (id==100)
  93.                                 {
  94.                                         if (mouse_cfg.emulation==true) KillProcessByName("mousemul", SINGLE);
  95.                                         else RunProgram("/sys/mousemul", 0);
  96.                                         mouse_cfg.emulation ^= 1;
  97.                                 }
  98.                                 if (id==101)
  99.                                 {
  100.                                         if (mouse_cfg.madmouse==true) KillProcessByName("madmouse", SINGLE);
  101.                                         else RunProgram("/sys/madmouse", 0);
  102.                                         mouse_cfg.madmouse ^= 1;
  103.                                 }
  104.                                 if (id==120)
  105.                                 {
  106.                                         mouse_cfg.pointer_speed++;
  107.                                         SetMouseSpeed(mouse_cfg.pointer_speed);
  108.                                 }
  109.                                 if (id==121) && (mouse_cfg.pointer_speed>1)
  110.                                 {
  111.                                         mouse_cfg.pointer_speed--;
  112.                                         SetMouseSpeed(mouse_cfg.pointer_speed);
  113.                                 }
  114.                                 if (id==122)
  115.                                 {
  116.                                         mouse_cfg.pointer_delay++;
  117.                                         SetMouseDelay(mouse_cfg.pointer_delay);
  118.                                 }
  119.                                 if (id==123) && (mouse_cfg.pointer_delay>0)
  120.                                 {
  121.                                         mouse_cfg.pointer_delay--;
  122.                                         SetMouseDelay(mouse_cfg.pointer_delay);
  123.                                 }
  124.                                 DrawWindowContent();
  125.                                 break;
  126.                                
  127.                 case evKey:
  128.                                 if (GetKey()==27) ExitProcess();
  129.                                 break;
  130.                        
  131.                 case evReDraw:
  132.                                 sc.get();
  133.                                 DefineAndDrawWindow(430, 150, 360, 280+GetSkinHeight(),0x34,sc.work,WINDOW_TITLE);
  134.                                 GetProcessInfo(#Form, SelfInfo);
  135.                                 if (Form.status_window>2) break;
  136.                                 mouse_frame.size_x = - mouse_frame.start_x * 2 + Form.cwidth;
  137.                                 mouse_frame.font_color = sc.work_text;
  138.                                 mouse_frame.font_backgr_color = sc.work;
  139.                                 mouse_frame.ext_col = sc.work_graph;
  140.                                 DrawWindowContent();
  141.         }
  142. }
  143.  
  144.  
  145. void DrawWindowContent() {
  146.         char pos_x = 22;
  147.  
  148.         DefineButton(mouse_frame.start_x, mouse_frame.start_y, mouse_frame.size_x, mouse_frame.size_y, 99+BT_NOFRAME, 0xF0F2F3); //needed to handle mouse_up and refresh mouse image
  149.         frame_draw stdcall (#mouse_frame);
  150.         DrawMouseImage();
  151.         WriteTextB(pos_x + 110, mouse_frame.start_y + 25, 0x90, 0x2C343C, CHECK_MOUSE_1);
  152.         WriteTextB(pos_x + 110, mouse_frame.start_y + 45, 0x90, 0x2C343C, CHECK_MOUSE_2);
  153.  
  154.         PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 142, 120, 121, mouse_cfg.pointer_speed, POINTER_SPEED);
  155.         PanelCfg_MoreLessBox(pos_x, mouse_frame.start_y + 170, 122, 123, mouse_cfg.pointer_delay, POINTER_DELAY);
  156.  
  157.         PanelCfg_CheckBox(pos_x, mouse_frame.start_y + 202, 100, MOUSE_EMULATION, mouse_cfg.emulation);
  158.         PanelCfg_CheckBox(pos_x, mouse_frame.start_y + 226, 101, MADMOUSE, mouse_cfg.madmouse);
  159. }
  160.  
  161.  
  162. void PanelCfg_CheckBox(dword x, y, id, text, byte value) {
  163.         CheckBox(x, y, 14, 14, id, text, sc.work_graph, sc.work_text, value);
  164. }
  165.  
  166.  
  167. void PanelCfg_MoreLessBox(dword x, y, id_more, id_less; byte value; dword text) {
  168.         MoreLessBox(x, y, 18, id_more, id_less, #sc, value, text);
  169. }
  170.  
  171. void DrawMouseImage() {
  172.         _PutImage(mouse_frame.start_x+30, mouse_frame.start_y + 15,  panels_img.w, panels_img.h, mouse_cfg.button_clicked * panels_img.w * panels_img.h * 3 + panels_img.data);
  173. }
  174.  
  175. void LoadCfg() {
  176.         mouse_cfg.pointer_delay = GetMouseDelay();
  177.         mouse_cfg.pointer_speed = GetMouseSpeed();
  178.         mouse_cfg.madmouse = CheckProcessExists("MADMOUSE");
  179.         mouse_cfg.emulation = CheckProcessExists("MOUSEMUL");
  180. }
  181.  
  182.  
  183.  
  184. stop: