Subversion Repositories Kolibri OS

Rev

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

  1. ; <--- description --->
  2. ; compiler:     FASM 1.67.23
  3. ; name:         Mouse Emulation For KolibriOS
  4. ;-----------------------------------------------------------------------------
  5. ; version:      1.1
  6. ; last update:  26/05/2012
  7. ; written by:   Lipatov Kirill aka Leency
  8. ; changes:      shows notify with instructions, while opening program
  9. ;-----------------------------------------------------------------------------
  10. ; version:      1.0
  11. ; last update:  04/09/2010
  12. ; written by:   Marat Zakiyanov aka Mario79, aka Mario
  13. ; changes:      total optimization of code,
  14. ;               different events for Up and Down of key Num 5
  15. ;               advansed acceleration mode
  16. ;-----------------------------------------------------------------------------
  17. ; version:      0.8
  18. ; last update:  03/10/2007
  19. ; written by:   Zlobny_Gluk
  20. ; e-mail:       umbrosia@land.ru
  21. ;-----------------------------------------------------------------------------
  22. ; <--- include all KolibriOS stuff --->
  23. include "lang.inc"
  24. include '../../../macros.inc'
  25.  
  26. ; <--- start of KolibriOS application --->
  27. MEOS_APP_START
  28.  
  29. ; <--- start of code --->
  30. CODE
  31. ;-----------------------------------------------------------------------------
  32. start:
  33.     mov eax,70
  34.     mov ebx,notifyapp
  35.     mcall
  36.        
  37.         xor     ebx,ebx
  38.         mcall   40
  39. @@:
  40.         mcall   23,10  
  41.  
  42.         mcall   66,3
  43.         test    eax,0x80
  44.         jz      @r
  45.  
  46.         mov     ebx,4
  47.         call    hotkeys_common
  48.  
  49.         mcall   40,10b
  50. still:
  51.         mcall   10
  52.        
  53.         cmp     eax,2           ; if event == 2
  54.         jne     still
  55. ;-----------------------------------------------------------------------------
  56. key:                               ; key event handler
  57.         call    mouse_acceleration
  58.  
  59.         mcall   2                  ; get key code
  60.        
  61.         push    eax
  62.         mcall   66,3
  63.         test    eax,0x80
  64.         pop     eax
  65.         jnz     @f
  66.         mov     ebx,5
  67.         call    hotkeys_common 
  68.         jmp     start
  69. @@:
  70.         cmp     al,2
  71.         jne     still
  72.  
  73.         xor     edx,edx
  74.  
  75.         cmp     ah,80   ; Down Num 2
  76.         je      keytwo
  77.         cmp     ah,81   ; Down Num 3
  78.         je      keythree
  79.         cmp     ah,75   ; Down Num 4
  80.         je      keyfour
  81.         cmp     ah,77   ; Down Num 6
  82.         je      keysix
  83.         cmp     ah,71   ; Down Num 7
  84.         je      keyseven
  85.         cmp     ah,72   ; Down Num 8
  86.         je      keyeight
  87.         cmp     ah,73   ; Down Num 9
  88.         je      keynine
  89.         cmp     ah,76   ; Down Num 5
  90.         je      keyfive
  91.         cmp     ah,204  ; Up Num 5
  92.         je      keyfive_1
  93.         cmp     ah,79   ; Down Num 1
  94.         jne     still
  95. ;-----------------------------------------------------------------------------
  96. keyone:
  97.         call    down
  98. keyfour:
  99.         call    left
  100.         jmp     mouseread
  101. ;-----------------------------------------------------------------------------
  102. keythree:
  103.         call    right
  104. keytwo:
  105.         call    down
  106.         jmp     mouseread
  107. ;-----------------------------------------------------------------------------
  108. keyseven:
  109.         call    left
  110. keyeight:
  111.         call    up
  112.         jmp     mouseread
  113. ;-----------------------------------------------------------------------------
  114. keynine:
  115.         call    up
  116. keysix:
  117.         call    right
  118.         jmp     mouseread
  119. ;-----------------------------------------------------------------------------
  120. keyfive:
  121.         inc     edx
  122. keyfive_1:
  123.         mcall   18,19,5
  124.         jmp     still
  125. ;-----------------------------------------------------------------------------
  126. left:
  127.         mov     eax,esi
  128.         shl     eax,16
  129.         sub     edx,eax
  130.         ret
  131. ;-----------------------------------------------------------------------------
  132. right:
  133.         mov     eax,esi
  134.         shl     eax,16
  135.         add     edx,eax
  136.         ret
  137. ;-----------------------------------------------------------------------------
  138. down:
  139.         add     edx,esi
  140.         ret
  141. ;-----------------------------------------------------------------------------
  142. up:
  143.         sub     edx,esi
  144.         ret
  145. ;-----------------------------------------------------------------------------
  146. mouseread:
  147.         xor     ebx,ebx
  148.         mcall   37
  149.         add     edx,eax
  150.  
  151. sravn:
  152.         xor     ebx,ebx
  153.         xor     edi,edi
  154.  
  155. real:
  156.         mov     ebx,edx
  157.         mov     edi,ebx
  158.         shr     ebx,16 ; get x1
  159. ;       shl     edi,16 ; get y1
  160. ;       shr     edi,16
  161.         and     edi,0xffff
  162.  
  163. nullli:
  164.         add     ebx,16
  165.         cmp     ebx,65535
  166.         jg      xmin
  167.         sub     ebx,15
  168.  
  169.         add     edi,16
  170.         cmp     edi,65535
  171.         jg      ymin
  172.         sub     edi,15
  173.  
  174. razr:
  175.         mcall   14
  176.  
  177.         mov     ecx,eax
  178.         shr     eax,16 ; get x2
  179. ;       shl     ecx,16 ; get y2
  180. ;       shr     ecx,16
  181.         and     ecx,0xffff
  182.  
  183. rightdownli:
  184.         cmp     eax,ebx
  185.         jl      xmax
  186.         cmp     ecx,edi
  187.         jl      ymax
  188.  
  189. mousewrite:
  190.         mcall   18,19,4
  191.         mcall   26,9
  192.         mov     [mouse_timer_ticks],eax
  193.         jmp     still
  194. ;-----------------------------------------------------------------------------
  195. mouse_acceleration:
  196.         xor     esi,esi
  197.         inc     esi
  198.         mcall   18,19,2
  199.         mov     ecx,eax
  200.         mcall   26,9
  201.         sub     eax,[mouse_timer_ticks]
  202.         cmp     eax,ecx  ; mouse_delay
  203.         ja      @f
  204.         xor     ecx,ecx
  205.         mcall   18,19   ; checkspeed
  206.         mov     esi,eax
  207.         shl     esi,2
  208. @@:
  209.         ret
  210. ;-----------------------------------------------------------------------------
  211. xmax:
  212.         dec     eax
  213.         dec     ebx
  214.         dec     edi
  215.         shl     eax,16
  216.         add     edi,eax
  217.         mov     edx,edi
  218.         jmp     sravn
  219. ;-----------------------------------------------------------------------------
  220. xmin:
  221.         mov     edx,edi
  222.         jmp     sravn
  223. ;-----------------------------------------------------------------------------
  224. ymax:
  225.         dec     ecx
  226.         dec     ebx
  227.  
  228.         shl     ebx,16
  229.         mov     edi,ebx
  230.         add     edi,ecx
  231.         mov     edx,edi
  232.         jmp     sravn
  233. ;-----------------------------------------------------------------------------
  234. ymin:
  235.         shl     ebx,16
  236.         mov     edx,ebx
  237.         shr     ebx,16
  238.         jmp     sravn
  239. ;-----------------------------------------------------------------------------
  240. hotkeys_common:
  241.         xor     ecx,ecx
  242.         xor     edx,edx
  243.         mov     cl,79   ; Down Num 1
  244.         mcall   66
  245.  
  246.         mov     cl,80   ; Down Num 2
  247.         mcall   66
  248.  
  249.         mov     cl,81   ; Down Num 3
  250.         mcall   66
  251.  
  252.         mov     cl,75   ; Down Num 4
  253.         mcall   66
  254.  
  255.         mov     cl,76   ; Down Num 5
  256.         mcall   66
  257.  
  258.         mov     cl,204 ; Up Num 5
  259.         mcall   66
  260.  
  261.         mov     cl,77   ; Down Num 6
  262.         mcall   66
  263.  
  264.         mov     cl,71   ; Down Num 7
  265.         mcall   66
  266.  
  267.         mov     cl,72   ; Down Num 8
  268.         mcall   66
  269.  
  270.         mov     cl,73   ; Down Num 9
  271.         mcall   66
  272.         ret
  273. ;-----------------------------------------------------------------------------
  274. ; <--- initialised data --->
  275. DATA
  276. ;-----------------------------------------------------------------------------
  277. ; <--- uninitialised data --->
  278. UDATA
  279. mouse_timer_ticks       dd 0
  280. ;-----------------------------------------------------------------------------
  281. if lang eq ru
  282. ud_user_message db 'NumLock ¢ª«/¢ëª« í¬ã«ïâ®à ¬ëè¨. “¯à ¢«¥­¨¥ Numpad',0 ;㤠«¨âì áâà®çªã ¨§ å®â_ª¥©§
  283. else
  284. ud_user_message db 'NumLock - on/off mouse emul. Numpad - move cursor',0
  285. end if
  286.  
  287. notifyapp:
  288.         dd      7
  289.         dd      0
  290.         dd      ud_user_message
  291.         dd      0
  292.         dd      0
  293.         db      '@notify',0
  294. ;-----------------------------------------------------------------------------
  295.  
  296.  
  297.  
  298. MEOS_APP_END
  299. ; <--- end of KolibriOS application --->
  300. ; ZG