Subversion Repositories Kolibri OS

Rev

Rev 5596 | Rev 6078 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5596 Rev 5984
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 5596 $
8
$Revision: 5984 $
9
 
9
 
10
 
10
 
Line 33... Line 33...
33
endg
33
endg
Line 34... Line 34...
34
 
34
 
35
iglobal
35
iglobal
36
;--------------------------------------
36
;--------------------------------------
37
align 4
-
 
38
mouse_delay             dd 10
37
align 4
39
mouse_speed_factor:
38
mouse_speed_factor      dw 1
40
                        dd 3
39
mouse_delay             db 1
41
mouse_timer_ticks       dd 0
40
mouse_doubleclick_delay db 64
Line 42... Line 41...
42
endg
41
endg
Line 43... Line 42...
43
 
42
 
Line 488... Line 487...
488
        mov     [BTN_DOWN], eax
487
        mov     [BTN_DOWN], eax
489
;--------------------------------------
488
;--------------------------------------
490
        mov     eax, [XMoving]
489
        mov     eax, [XMoving]
491
        test    [BtnState], 0x80000000
490
        test    [BtnState], 0x80000000
492
        jnz     .absolute_x
491
        jnz     .absolute_x
-
 
492
        test    eax, eax
-
 
493
        jz      @f
493
        call    mouse_acceleration
494
        call    mouse_acceleration
494
        add     ax, [MOUSE_X]
495
        add     ax, [MOUSE_X]
495
        cmp     ax, 0
-
 
496
        jge     .check_x
496
        jns     .check_x
497
        mov     eax, 0
497
        xor     eax, eax
498
        jmp     .set_x
498
        jmp     .set_x
499
 .absolute_x:
499
 .absolute_x:
500
        mov     edx, [_display.width]
500
        mov     edx, [_display.width]
501
        mul     edx
501
        mul     edx
502
        shr     eax, 15
502
        shr     eax, 15
Line 506... Line 506...
506
        mov     ax, word[_display.width]
506
        mov     ax, word[_display.width]
507
        dec     ax
507
        dec     ax
508
 .set_x:
508
 .set_x:
509
        mov     [MOUSE_X], ax
509
        mov     [MOUSE_X], ax
510
;--------------------------------------
510
;--------------------------------------
-
 
511
@@:
511
        mov     eax, [YMoving]
512
        mov     eax, [YMoving]
512
        test    [BtnState], 0x40000000
513
        test    [BtnState], 0x40000000
513
        jnz     .absolute_y
514
        jnz     .absolute_y
-
 
515
        test    eax, eax
-
 
516
        jz      @f
514
        neg     eax
517
        neg     eax
515
        call    mouse_acceleration
518
        call    mouse_acceleration
516
        add     ax, [MOUSE_Y]
519
        add     ax, [MOUSE_Y]
517
        cmp     ax, 0
-
 
518
        jge     .check_y
520
        jns     .check_y
519
        mov     ax, 0
521
        xor     eax, eax
520
        jmp     .set_y
522
        jmp     .set_y
521
 .absolute_y:
523
 .absolute_y:
522
        mov     edx, [_display.height]
524
        mov     edx, [_display.height]
523
        mul     edx
525
        mul     edx
524
        shr     eax, 15
526
        shr     eax, 15
Line 528... Line 530...
528
        mov     ax, word[_display.height]
530
        mov     ax, word[_display.height]
529
        dec     ax
531
        dec     ax
530
 .set_y:
532
 .set_y:
531
        mov     [MOUSE_Y], ax
533
        mov     [MOUSE_Y], ax
532
;--------------------------------------
534
;--------------------------------------
-
 
535
@@:
533
        mov     eax, [VScroll]
536
        mov     eax, [VScroll]
-
 
537
        test    eax, eax
-
 
538
        jz      @f
534
        add     [MOUSE_SCROLL_V], ax
539
        add     [MOUSE_SCROLL_V], ax
-
 
540
        bts     word [BTN_DOWN], 15
535
 
541
@@:
536
        mov     eax, [HScroll]
542
        mov     eax, [HScroll]
-
 
543
        test    eax, eax
-
 
544
        jz      @f
537
        add     [MOUSE_SCROLL_H], ax
545
        add     [MOUSE_SCROLL_H], ax
-
 
546
        bts     dword [BTN_DOWN], 23
538
 
547
@@:
539
        mov     [mouse_active], 1
548
        mov     [mouse_active], 1
540
        mov     eax, [timer_ticks]
-
 
541
        mov     [mouse_timer_ticks], eax
-
 
542
        call    wakeup_osloop
549
        call    wakeup_osloop
543
        ret
550
        ret
544
endp
551
endp
Line 545... Line 552...
545
 
552
 
546
;-----------------------------------------------------------------------------
553
;-----------------------------------------------------------------------------
-
 
554
; 3 = x^2 /2
-
 
555
; 2 = (x+1)^2 /4
547
 
556
; 1 = (x+2)^2 /8
548
align 4
557
align 4
-
 
558
mouse_acceleration:
-
 
559
        cmp     [mouse_delay], 0
549
mouse_acceleration:
560
        jz      .end
550
        push    eax
-
 
551
        mov     eax, [timer_ticks]
-
 
552
        sub     eax, [mouse_timer_ticks]
-
 
553
        cmp     eax, [mouse_delay]
-
 
554
        pop     eax
-
 
555
        ja      @f
-
 
556
        ;push  edx
-
 
557
        imul    eax, [mouse_speed_factor]
-
 
558
        ;pop   edx
561
        push    eax
-
 
562
@@:
-
 
563
        neg     eax
-
 
564
        jl      @b
-
 
565
        cmp     [mouse_delay], 3
-
 
566
        adc     eax, 0
-
 
567
        cmp     [mouse_delay], 2
-
 
568
        adc     eax, 0
-
 
569
        mul     al
-
 
570
        shr     eax, 1
-
 
571
        adc     eax, 0
-
 
572
        cmp     [mouse_delay], 2
-
 
573
        jz      .2
-
 
574
        jnc     .3
-
 
575
        shr     eax, 1
-
 
576
.2:
-
 
577
        shr     eax, 1
-
 
578
.3:
-
 
579
        pop     edx
-
 
580
        test    edx, edx
-
 
581
        jns     .end
-
 
582
        neg     eax
-
 
583
.end:
559
  @@:
584
        imul    [mouse_speed_factor]