-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton_mapping.py
92 lines (87 loc) · 1.9 KB
/
button_mapping.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
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
import sys
darwin = {
0: "button square",
1: "button cross",
2: "button circle",
3: "button triangle",
4: "bumper left",
5: "bumper right",
6: "trigger left",
7: "trigger right",
8: "select",
9: "start",
10: "left stick",
11: "right stick",
12: "meta",
13: "touchpad",
"left": "dpad left",
"right": "dpad right",
"up": "dpad up",
"down": "dpad down",
"axis": {
0: ["stick left", "x"],
1: ["stick left", "y"],
2: ["stick right", "x"],
5: ["stick right", "y"]
}
}
linux = {
0: "button square",
1: "button cross",
2: "button circle",
3: "button triangle",
4: "bumper left",
5: "bumper right",
6: "trigger left",
7: "trigger right",
8: "select",
9: "start",
10: "left stick",
11: "right stick",
12: "meta",
13: "touchpad",
"left": "dpad left",
"right": "dpad right",
"up": "dpad up",
"down": "dpad down",
"axis": {
0: ["stick left", "x"],
1: ["stick left", "y"],
2: ["stick right", "x"],
5: ["stick right", "y"]
}
}
windows = {
0: "button cross",
1: "button circle",
2: "button square",
3: "button triangle",
4: "select",
5: "meta",
6: "start",
7: "stick left",
8: "stick right",
9: "bumper left",
10: "bumper right",
11: "dpad up",
12: "dpad down",
13: "dpad left",
14: "dpad right",
15: "touchpad",
"axis": {
0: ["stick left", "x"],
1: ["stick left", "y"],
2: ["stick right", "x"],
3: ["stick right", "y"],
4: ["trigger left", None],
5: ["trigger right", None]
}
}
def button_mapping(button_key):
platform = sys.platform
if "darwin" == platform:
return darwin[button_key]
elif "win32" == platform:
return windows[button_key]
else:
return linux[button_key]