-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmouse.py
63 lines (47 loc) · 1.14 KB
/
mouse.py
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
import sys, pygame, serial
pygame.init()
size = width, height = 1920, 1080
screen = pygame.display.set_mode(size)
ser = serial.Serial('/dev/ttyACM0', 57600, timeout=1)
lb = False
rb = False
#pygame.display.toggle_fullscreen()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
x, y = pygame.mouse.get_pos()
dx, dy = pygame.mouse.get_rel()
lbo = lb
rbo = rb
lb, mb, rb = pygame.mouse.get_pressed()
if lb and x==0 and y==0:
sys.exit()
#print dx, dy, lb
if dx<0:
ser.write("6\n")
print "dx-"
if dx>0:
ser.write("5\n")
print "dx+"
if dy>0:
ser.write("8\n")
print "dy-"
if dy<0:
ser.write("7\n")
print "dy+"
if lb and lb != lbo:
ser.write("1\n")
print "lb+"
else:
if lb != lbo:
ser.write("2\n")
print "lb-"
if rb and rb != rbo:
ser.write("3\n")
print "rb+"
else:
if rb != rbo:
ser.write("4\n")
print "rb-"
screen.fill((0,0,0))
pygame.display.flip()