-
Notifications
You must be signed in to change notification settings - Fork 2
/
mouse.r
119 lines (102 loc) · 1.9 KB
/
mouse.r
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
file mouse - mouse maintenance
include rid:rider
include rid:imdef
include rid:fidef
include rid:rtrea
; %build
; @@its:mouse.inf
; !rider its:mouse/obj:itb:/nodel
; link itb:mouse/exe:itb:/map:itb:,itb:mouinf,lib:(crt,ridlib)/bot:2000
; copy itb:mouse.sav hd1:*.*
; %end
type moTevt
is Vbut : char
Vx : char
Vy : char
Vz : char
end
moLFT_ := 1
moMID_ := 2
moRGT_ := 4
type moTpos
is Vbut : WORD
Vx : word
Vy : word
Vz : word
end
type moTbuf
is Vcnt : char
Vtyp : char
Verr : char
Vrun : char
Aevt : [15] moTevt
end
func start
is fil : FILE
buf : moTbuf
cnt : int
evt : * moTevt
im_ini ("MOUSE")
fil = fi_opn ("MO:", "rb", "")
exit if fail
; mo_drw (fil)
repeat
rt_rea (fil, 0, &buf, 32, rtWAI)
; exit if fail
PUT("Cnt=%d Typ=%d Err=%d Rnt=%d ",
buf.Vcnt, buf.Vtyp, buf.Verr, buf.Vrun)
cnt = buf.Vcnt
evt = buf.Aevt
while cnt--
PUT("L") if evt->Vbut & moLFT_
PUT("M") if evt->Vbut & moMID_
PUT("R") if evt->Vbut & moRGT_
PUT(" X=%d", evt->Vx) if evt->Vx
PUT(" Y=%d", evt->Vy) if evt->Vy
PUT(" Z=%d", evt->Vz) if evt->Vz
PUT(" ")
++evt
end
PUT("\n")
end
end
end file
if !buf->Vcnt
while
fil : FILE
buf : moTbuf
cnt : int
evt : * moTevt
code mo_drw - draw mouse
func mo_drw
is pos : moTpos
str : [32] char
repeat
mo_pos (&pos)
ptr = str
*str++ = 033
st_cop ("[x
FMT(str, "[%d;%d;", pos.x, pos.y)
end
end
code mo_get - get next event
func mo_get
pos : * moTpos
is evt : * moTevt
pos : * moTpos
while !buf->Vcnt
moVnxt = 0
.. rt_rea (moPfil, 0, &moIbuf, 32, 0)
evt = moPevt = moIbuf.Aevt[moVnxt++]
mo_pos (evt, pos)
end
func mo_pos
evt : * moTevt
pos : * moTpos
is pos->Vx += evt->Vx
pos->Vy += evt->Vy
pos->Vx = 1 if pos->Vx lt
pos->Vx = 79 if pos->Vx ge 80
pos->Vy = 1 if pos->Vy lt
pos->Vx = 1 if pos->Vy ge 24
end