-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlPs3.py
53 lines (37 loc) · 970 Bytes
/
ControlPs3.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
import pygame, sys, time, os
pygame.init()
joystick = pygame.joystick.Joystick(0)
joystick.init()
screen = pygame.display.set_mode((400,300))
interval = 0.1
try:
run = True
while run:
events = pygame.event.get()
for event in events:
# Check if one of the joysticks has moved
if event.type == pygame.JOYAXISMOTION:
if event.axis == 1:
print "event.axis == 1"
if event.axis == 2:
print "event.axis == 2"
if event.axis == 3:
print "event.axis == 3"
if event.type == pygame.JOYBUTTONDOWN:
if event.button == 0: #select
run = False
if event.button == 3: #start
reset()
if event.button == 12: #triangle
sc.setAngle(grip, 90)
if event.button == 14: #X
sc.setAngle(grip, 30)
else:
print event.button
time.sleep(interval)
except KeyboardInterrupt:
pass
except Exception as e:
print e
pass
sc.clean_up()