-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmouse.bas
99 lines (75 loc) · 2.36 KB
/
mouse.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
' raton serie
static shared As Integer oldb=0
Sub mouse_serial_poll(x As Integer , y As Integer , b As Integer )
Dim As UByte mousedat(3) =Any
If (serial.ier And 1)=0 Then return
If (x=0) And (y=0) And (b=oldb) Then return
oldb=b
if (x>127) Then x=127
if (y>127) Then y=127
if (x<-128) Then x=-128
if (y<-128) Then y=-128
/'Use Microsoft format'/
mousedat(0) = &h40
mousedat(0) = mousedat(0) Or (((y Shr 6) And 3) Shl 2)
mousedat(0) = mousedat(0) Or ((x Shr 6) And 3)
if (b And 1) Then mousedat(0) = mousedat(0) Or &h20
if (b And 2) Then mousedat(0) = mousedat(0) Or &h10
mousedat(1)=x And &h3F
mousedat(2)=y And &h3F
if (serial.mctrl And &h10)=0 Then
serial_write_fifo(mousedat(0))
serial_write_fifo(mousedat(1))
serial_write_fifo(mousedat(2))
EndIf
'Locate 31,30:Print "mouse:";x,y,b
End Sub
Sub mouse_serial_rcr()
mousepos=-1
mousedelay=1000
End Sub
static shared As integer pollmouse_delay = 2
Sub mouse_poll()
Dim As integer x=any,y=any,mouse_b=any, relx=any, rely=any,xx=any,yy=Any
Static As Integer oldx=any,oldy=Any
pollmouse_delay-=1
if (pollmouse_delay) Then Return
pollmouse_delay = 2
'poll_mouse()
'get_mouse_mickeys(x,y)
GetMouse (x,y,,mouse_b)
' si se sale de la ventana
If x=-1 Or y=-1 Then
x=oldx
y=oldy
xx=0
yy=0
EndIf
If x<>oldx Or y<>oldy Then
relx=oldx-x
rely=oldy-y
xx=-relx
yy=-rely
oldx=x
oldy=y
Else
xx=0
yy=0
EndIf
'if (mouse_poll) Then
mouse_serial_poll(xx, yy, mouse_b)
'if (mousecapture) thenposition_mouse(64,64)
End Sub
Sub mousecallback()
if (mousepos = -1) Then
mousepos = 0
serial_fifo_read = 0
serial_fifo_write = 0
serial.linestat = serial.linestat And inv(1)
serial_write_fifo(Asc("M"))
ElseIf (serial_fifo_read <> serial_fifo_write) Then
serial.iir=4
serial.linestat = serial.linestat Or 1
if (serial.mctrl And 8) Then picint(&h10)
EndIf
End Sub