-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouse.lua
46 lines (45 loc) · 1.01 KB
/
mouse.lua
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
mouse_x_offset = 2
mouse = {
-- mouse position
x,y,last_x,last_y,
-- mouse sensitivity
move_sens = 0.05,
-- button
button,
-- scrl
scroll,
-- init mouse input
init = function()
poke(0x5f2d, 1)
end,
--mouse cursor draw function
draw = function()
if mouse.button == 1 then
spr(1, mouse.x+mouse_x_offset, mouse.y)
else
spr(0, mouse.x+mouse_x_offset, mouse.y)
end
end,
-- return int:button [0..4]
-- 0 .. no button
-- 1 .. left
-- 2 .. right
-- 4 .. middle
get_button = function()
mouse.button=stat(34)
end,
-- return int:direction
-- 0 .. no scroll
-- 1 .. up scroll
-- -1 .. down scroll
wheel = function()
mouse.scroll=stat(36)
end,
-- return int:x, int:y, onscreen:bool
update = function()
mouse.last_x, mouse.last_y = mouse.x, mouse.y
mouse.x,mouse.y = stat(32)-1,stat(33)-1
mouse.get_button()
mouse.wheel()
end,
}