blob: fb49765a0dc8e20fdf256060286d00d4a08c59d6 (
plain)
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
|
#!/usr/bin/python3
import inputs,os,pygame
print(inputs.devices.gamepads)
pads = inputs.devices.gamepads
select=0
start=0
disable_pad=False
pygame.init()
enable=pygame.mixer.Sound('enable.wav')
disable=pygame.mixer.Sound('disable.wav')
while True:
events = inputs.get_gamepad()
for event in events:
#print(event.ev_type, event.code, event.state)
if event.code == 'ABS_Y' and event.state == 255:
#print("down")
if not disable_pad:
os.system("xte 'key Down'")
elif event.code == 'ABS_Y' and event.state == 0:
#print("up")
if not disable_pad:
os.system("xte 'key Up'")
elif event.code == 'ABS_X' and event.state == 255:
#print("right")
if not disable_pad:
os.system("xte 'key Right'")
elif event.code == 'ABS_X' and event.state == 0:
#print("left")
if not disable_pad:
os.system("xte 'key Left'")
elif event.code == 'BTN_TRIGGER' and event.state == 1:
#print("B")
if not disable_pad:
os.system("xte 'key Escape'")
start=1
elif event.code == 'BTN_TRIGGER' and event.state == 0:
#print("B")
start=0
elif event.code == 'BTN_THUMB' and event.state == 1:
#print("A")
if not disable_pad:
os.system("xte 'key Return'")
select=1
elif event.code == 'BTN_THUMB' and event.state == 0:
#print("select")
select=0
elif event.code == 'BTN_BASE3' and event.state == 1:
#print("select")
if not disable_pad:
os.system("xte 'keydown Meta_L' 'key F4' 'keyup Meta_L'")
elif event.code == 'BTN_BASE4' and event.state == 1:
#print("start")
if not disable_pad:
os.system("xte 'key Super_L'")
if start == 1 and select == 1:
print("toggle disable pad")
disable_pad=not disable_pad
if disable_pad:
disable.play()
else:
enable.play()
select=0
start=0
|