robot-xbox-controller 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/PKG-INFO +2 -2
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/README.rst +1 -1
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/pyproject.toml +1 -1
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/src/robot/xbox_controller.py +1 -1
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/src/robot/xbox_state.py +30 -0
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/tests/test_xbox_controller.py +15 -0
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/.gitignore +0 -0
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/.python-version +0 -0
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/LICENSE +0 -0
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/examples/xbox_controller_example.py +0 -0
- {robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/examples/xbox_controller_state_example.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: robot-xbox-controller
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Library for xbox controllers.
|
|
5
5
|
Project-URL: Documentation, https://github.com/fmorton/robot-python-xbox-controller#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/fmorton/robot-python-xbox-controller/issues
|
|
@@ -183,7 +183,7 @@ The following button constant values are available in XboxController:
|
|
|
183
183
|
BUTTON_Y = 3
|
|
184
184
|
BUTTON_VIEW = 4 # left middle button
|
|
185
185
|
BUTTON_XBOX = 5 # center middle button
|
|
186
|
-
|
|
186
|
+
BUTTON_MENU = 6 # right middle button
|
|
187
187
|
BUTTON_LEFT_JOYSTICK = 7
|
|
188
188
|
BUTTON_RIGHT_JOYSTICK = 8
|
|
189
189
|
BUTTON_LEFT_BUMPER = 9
|
|
@@ -149,7 +149,7 @@ The following button constant values are available in XboxController:
|
|
|
149
149
|
BUTTON_Y = 3
|
|
150
150
|
BUTTON_VIEW = 4 # left middle button
|
|
151
151
|
BUTTON_XBOX = 5 # center middle button
|
|
152
|
-
|
|
152
|
+
BUTTON_MENU = 6 # right middle button
|
|
153
153
|
BUTTON_LEFT_JOYSTICK = 7
|
|
154
154
|
BUTTON_RIGHT_JOYSTICK = 8
|
|
155
155
|
BUTTON_LEFT_BUMPER = 9
|
|
@@ -17,7 +17,7 @@ class XboxController:
|
|
|
17
17
|
BUTTON_Y = 3
|
|
18
18
|
BUTTON_VIEW = 4 # left middle button
|
|
19
19
|
BUTTON_XBOX = 5 # center middle button
|
|
20
|
-
|
|
20
|
+
BUTTON_MENU = 6 # right middle button
|
|
21
21
|
BUTTON_LEFT_JOYSTICK = 7
|
|
22
22
|
BUTTON_RIGHT_JOYSTICK = 8
|
|
23
23
|
BUTTON_LEFT_BUMPER = 9
|
|
@@ -53,6 +53,36 @@ class XboxState:
|
|
|
53
53
|
if debugging:
|
|
54
54
|
print(self.state_string())
|
|
55
55
|
|
|
56
|
+
def dictionary(self):
|
|
57
|
+
d = {}
|
|
58
|
+
d["left_x"] = self.left_x()
|
|
59
|
+
d["left_y"] = self.left_y()
|
|
60
|
+
d["right_x"] = self.right_x()
|
|
61
|
+
d["right_y"] = self.right_y()
|
|
62
|
+
d["left_trigger"] = self.left_trigger()
|
|
63
|
+
d["right_trigger"] = self.right_trigger()
|
|
64
|
+
|
|
65
|
+
for button in range(16):
|
|
66
|
+
d[str(button)] = self.button_down_milliseconds(button)
|
|
67
|
+
|
|
68
|
+
d["a_button"] = self.button_down_milliseconds(0)
|
|
69
|
+
d["b_button"] = self.button_down_milliseconds(1)
|
|
70
|
+
d["x_button"] = self.button_down_milliseconds(2)
|
|
71
|
+
d["y_button"] = self.button_down_milliseconds(3)
|
|
72
|
+
d["view_button"] = self.button_down_milliseconds(4)
|
|
73
|
+
d["xbox_button"] = self.button_down_milliseconds(5)
|
|
74
|
+
d["menu_button"] = self.button_down_milliseconds(6)
|
|
75
|
+
d["left_stick_click"] = self.button_down_milliseconds(7)
|
|
76
|
+
d["right_stick_click"] = self.button_down_milliseconds(8)
|
|
77
|
+
d["left_bumper"] = self.button_down_milliseconds(9)
|
|
78
|
+
d["right_bumper"] = self.button_down_milliseconds(10)
|
|
79
|
+
d["d_pad_up"] = self.button_down_milliseconds(11)
|
|
80
|
+
d["d_pad_down"] = self.button_down_milliseconds(12)
|
|
81
|
+
d["d_pad_left"] = self.button_down_milliseconds(13)
|
|
82
|
+
d["d_pad_right"] = self.button_down_milliseconds(14)
|
|
83
|
+
|
|
84
|
+
return d
|
|
85
|
+
|
|
56
86
|
def left_x(self):
|
|
57
87
|
return self.axis_value[0]
|
|
58
88
|
|
|
@@ -89,5 +89,20 @@ def test_run():
|
|
|
89
89
|
controller.run(runner)
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
def runner_dictionary(controller):
|
|
93
|
+
print("dictionary:", controller.state.dictionary())
|
|
94
|
+
|
|
95
|
+
sleep(XboxController.EVENT_LOOP_DELAY)
|
|
96
|
+
|
|
97
|
+
if controller.state.button_down_milliseconds(XboxController.BUTTON_XBOX):
|
|
98
|
+
return False
|
|
99
|
+
|
|
100
|
+
return True
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_run_dictionary():
|
|
104
|
+
controller.run(runner_dictionary)
|
|
105
|
+
|
|
106
|
+
|
|
92
107
|
def test_tick():
|
|
93
108
|
controller.tick(30)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{robot_xbox_controller-0.1.0 → robot_xbox_controller-0.2.0}/examples/xbox_controller_example.py
RENAMED
|
File without changes
|
|
File without changes
|