pygameControls 0.1.13__tar.gz → 0.2.1__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.
Files changed (28) hide show
  1. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/PKG-INFO +1 -1
  2. pygamecontrols-0.2.1/pygameControls/controller.py +21 -0
  3. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/dualsense_controller.py +1 -0
  4. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/dualsense_edge_controller.py +1 -0
  5. pygamecontrols-0.2.1/pygameControls/enums.py +12 -0
  6. pygamecontrols-0.2.1/pygameControls/globals.py +207 -0
  7. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/logitech_dual_action_controller.py +0 -14
  8. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/logitech_f310_controller.py +0 -14
  9. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/logitech_f510_controller.py +6 -37
  10. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/logitech_f710_controller.py +4 -37
  11. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/playstation3_controller.py +1 -0
  12. pygamecontrols-0.2.1/pygameControls/playstation4_controller.py +71 -0
  13. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/sony_playstation3_controller.py +1 -0
  14. pygamecontrols-0.2.1/pygameControls/sony_playstation4_controller.py +71 -0
  15. pygamecontrols-0.2.1/pygameControls/xbox_360_controller.py +68 -0
  16. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/xbox_series_x_controller.py +1 -0
  17. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls.egg-info/PKG-INFO +1 -1
  18. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls.egg-info/SOURCES.txt +5 -0
  19. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/setup.py +1 -1
  20. pygamecontrols-0.1.13/pygameControls/controller.py +0 -35
  21. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/LICENSE +0 -0
  22. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/README.md +0 -0
  23. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/__init__.py +0 -0
  24. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/controlsbase.py +0 -0
  25. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls/generic_controller.py +0 -0
  26. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls.egg-info/dependency_links.txt +0 -0
  27. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/pygameControls.egg-info/top_level.txt +0 -0
  28. {pygamecontrols-0.1.13 → pygamecontrols-0.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygameControls
3
- Version: 0.1.13
3
+ Version: 0.2.1
4
4
  Summary: A simple controller class for pygame.
5
5
  Home-page:
6
6
  Author: Jan Lerking
@@ -0,0 +1,21 @@
1
+ import pygame
2
+ from . import globals
3
+
4
+ __version__ = "0.2.1"
5
+
6
+ class Controllers:
7
+ def __init__(self, joy):
8
+ self.controllers = []
9
+ cont = self.detect_controller(joy.get_guid())
10
+ print(cont)
11
+ self.controllers.append(cont(joy))
12
+
13
+ def detect_controller(self, guid):
14
+ for gp in globals.GAMEPADS:
15
+ print(gp)
16
+ for p in globals.GAMEPADS[gp]:
17
+ print(p)
18
+ if p["guid"] != guid:
19
+ continue
20
+ return p["class"]
21
+ return globals.CONTROLLERS["Generic Controller"]
@@ -15,6 +15,7 @@ class DualSenseController(ControlsBase):
15
15
  self.device = pydualsense()
16
16
  self.device.init()
17
17
  self.name = self.device.device.get_product_string()
18
+ self.guid = self.device.get_guid()
18
19
  self.powerlevel = self.device.battery.Level
19
20
  self.batterystate = BATTERY_STATE[str(self.device.battery.State)]
20
21
  self.set_player_id(PlayerID.PLAYER_1)
@@ -7,6 +7,7 @@ class DualSenseEdgeController(ControlsBase):
7
7
  self.device = pydualsense()
8
8
  self.device.init()
9
9
  self.name = self.device.device.get_product_string()
10
+ self.guid = self.device.get_guid()
10
11
  self.powerlevel = self.device.battery.Level
11
12
  self.batterystate = BATTERY_STATE[str(self.device.battery.State)]
12
13
  self.set_player_id(PlayerID.PLAYER_1)
@@ -0,0 +1,12 @@
1
+ from enum import Enum
2
+
3
+ class ConnectionType(Enum):
4
+ USB = 1
5
+ BLUETOOTH = 2
6
+ WIRELESS = 3
7
+ Unknown = -1
8
+
9
+ class InputType(Enum):
10
+ DirectInput = 1
11
+ XInput = 2
12
+ Unknown = -1
@@ -0,0 +1,207 @@
1
+ from .enums import ConnectionType, InputType
2
+
3
+ from .controlsbase import ControlsBase
4
+ from .dualsense_controller import DualSenseController
5
+ from .dualsense_edge_controller import DualSenseEdgeController
6
+ from .logitech_f310_controller import LogitechF310Controller
7
+ from .logitech_f510_controller import LogitechF510Controller
8
+ from .logitech_f710_controller import LogitechF710Controller
9
+ from .xbox_series_x_controller import XboxSeriesXController
10
+ from .sony_playstation3_controller import SonyPlayStation3Controller
11
+ from .playstation3_controller import PlayStation3Controller
12
+ from .sony_playstation4_controller import SonyPlayStation4Controller
13
+ from .playstation4_controller import PlayStation4Controller
14
+ from .generic_controller import GenericController
15
+ from .logitech_dual_action_controller import LogitechDualActionController
16
+
17
+ def init():
18
+ global VID_PID
19
+ VID_PID = {
20
+ "046d:c216": "Logitech Gamepad F310",
21
+ "046d:c21d": "Microsoft X-Box 360 pad",
22
+ "046d:c21d": "Logitech Dual Action",
23
+ "045e:0b12": "Xbox Series X Controller",
24
+ "045e:0b13": "Xbox Series X Controller",
25
+ "045e:0b20": "Xbox Series X Controller",
26
+ "045e:0b21": "Xbox Series X Controller",
27
+ "054c:0ce6": "DualSense Wireless Controller",
28
+ "054c:0df2": "DualSense Wireless Controller",
29
+ }
30
+ global CONTROLLERS
31
+ CONTROLLERS = {
32
+ "DualSense Wireless Controller": DualSenseController,
33
+ "DualSense Edge Wireless Controller": DualSenseEdgeController,
34
+ "Logitech Gamepad F310": LogitechF310Controller,
35
+ "Logitech Gamepad F510": LogitechF510Controller,
36
+ "Logitech Gamepad F710": LogitechF710Controller,
37
+ "Logitech Dual Action": LogitechDualActionController,
38
+ "Microsoft X-Box 360 pad": LogitechDualActionController,
39
+ "Xbox Series X Controller": XboxSeriesXController,
40
+ "Sony PLAYSTATION(R)3 Controller": SonyPlayStation3Controller,
41
+ "PLAYSTATION(R)3 Controller": PlayStation3Controller,
42
+ "Sony PLAYSTATION(R)4 Controller": SonyPlayStation4Controller,
43
+ "PLAYSTATION(R)4 Controller": PlayStation4Controller,
44
+ "Generic Controller": GenericController
45
+ }
46
+ global GAMEPADS
47
+ GAMEPADS = {
48
+ "Sony Controller": [
49
+ {
50
+ "vidpid": "054c:0ce6",
51
+ "guid": "0300fd574c050000e60c000011810000",
52
+ "connection": ConnectionType.USB,
53
+ "input": InputType.DirectInput,
54
+ "name": [
55
+ "Sony Interactive Entertainment DualSense Wireless Controller",
56
+ "Sony Corp. DualSense wireless controller (PS5)",
57
+ "DualSense Wireless Controller"
58
+ ],
59
+ "class": CONTROLLERS["DualSense Wireless Controller"]
60
+ },
61
+ {
62
+ "vidpid": "054c:0df2",
63
+ "guid": "050057564c050000e60c000000810000",
64
+ "connection": ConnectionType.BLUETOOTH,
65
+ "input": InputType.DirectInput,
66
+ "name": [
67
+ "DualSense Wireless Controller"
68
+ ],
69
+ "class": CONTROLLERS["DualSense Wireless Controller"]
70
+ },
71
+ {
72
+ "vidpid": "054c:0dfc",
73
+ "guid": "",
74
+ "connection": ConnectionType.USB,
75
+ "input": InputType.DirectInput,
76
+ "name": ["DualSense Edge Wireless Controller"],
77
+ "class": CONTROLLERS["DualSense Edge Wireless Controller"]
78
+ },
79
+ {
80
+ "vidpid": "054c:0dfc",
81
+ "guid": "",
82
+ "connection": ConnectionType.BLUETOOTH,
83
+ "input": InputType.DirectInput,
84
+ "name": ["DualSense Edge Wireless Controller"],
85
+ "class": CONTROLLERS["DualSense Edge Wireless Controller"]
86
+ },
87
+ {
88
+ "vidpid": "054c:0268",
89
+ "guid": "0300afd34c0500006802000011810000",
90
+ "connection": ConnectionType.USB,
91
+ "input": InputType.DirectInput,
92
+ "name": ["Sony PLAYSTATION(R)3 Controller"],
93
+ "class": CONTROLLERS["Sony PLAYSTATION(R)3 Controller"]
94
+ },
95
+ {
96
+ "vidpid": "",
97
+ "guid": "0500f9d24c0500006802000000800000",
98
+ "connection": ConnectionType.BLUETOOTH,
99
+ "input": InputType.DirectInput,
100
+ "name": ["PLAYSTATION(R)3 Controller"],
101
+ "class": CONTROLLERS["PLAYSTATION(R)3 Controller"]
102
+ },
103
+ {
104
+ "vidpid": "054c:05c4",
105
+ "guid": "",
106
+ "connection": ConnectionType.USB,
107
+ "input": InputType.DirectInput,
108
+ "name": ["DualShock 4 v1 Controller"],
109
+ "class": CONTROLLERS["PLAYSTATION(R)4 Controller"]
110
+ },
111
+ {
112
+ "vidpid": "054c:05c4",
113
+ "guid": "",
114
+ "connection": ConnectionType.BLUETOOTH,
115
+ "input": InputType.DirectInput,
116
+ "name": ["DualShock 4 v1 Controller"],
117
+ "class": CONTROLLERS["Sony PLAYSTATION(R)4 Controller"]
118
+ },
119
+ {
120
+ "vidpid": "054c:09cc",
121
+ "guid": "",
122
+ "connection": ConnectionType.USB,
123
+ "input": InputType.DirectInput,
124
+ "name": ["DualShock 4 v2 Controller"],
125
+ "class": CONTROLLERS["PLAYSTATION(R)4 Controller"]
126
+ },
127
+ {
128
+ "vidpid": "054c:09cc",
129
+ "guid": "",
130
+ "connection": ConnectionType.BLUETOOTH,
131
+ "input": InputType.DirectInput,
132
+ "name": ["DualShock 4 v2 Controller"],
133
+ "class": CONTROLLERS["Sony PLAYSTATION(R)4 Controller"]
134
+ }
135
+ ],
136
+ "Microsoft Controller": [
137
+ {
138
+ "vidpid": "045e:0b12",
139
+ "guid": "0300509d5e040000120b000017050000",
140
+ "connection": ConnectionType.USB,
141
+ "input": InputType.XInput,
142
+ "name": [
143
+ "Xbox Series X Controller",
144
+ "Microsoft Corp. Xbox Controller"
145
+ ],
146
+ "class": CONTROLLERS["Xbox Series X Controller"]
147
+ },
148
+ {
149
+ "vidpid": "045e:0b13",
150
+ "guid": "0500509d5e040000130b000023050000",
151
+ "connection": ConnectionType.BLUETOOTH,
152
+ "input": InputType.XInput,
153
+ "name": [
154
+ "Xbox Series X Controller",
155
+ "Xbox Wireless Controller"
156
+ ],
157
+ "class": CONTROLLERS["Xbox Series X Controller"]
158
+ }
159
+ ],
160
+ "Logitech Controller": [
161
+ {
162
+ "vidpid": "046d:c21d",
163
+ "guid": "030005ff6d0400001dc2000014400000",
164
+ "connection": ConnectionType.USB,
165
+ "input": InputType.XInput,
166
+ "name": [
167
+ "Logitech, Inc. F310 Gamepad [XInput Mode]",
168
+ "Logitech Gamepad F310"
169
+ ],
170
+ "class": CONTROLLERS["Logitech Gamepad F310"]
171
+ },
172
+ {
173
+ "vidpid": "046d:c216",
174
+ "guid": "0300040e6d04000016c2000011010000",
175
+ "connection": ConnectionType.USB,
176
+ "input": InputType.DirectInput,
177
+ "name": [
178
+ "Logitech, Inc. F310 Gamepad [DirectInput Mode]",
179
+ "Logitech Dual Action",
180
+ "Logitech Logitech Dual Action"
181
+ ],
182
+ "class": CONTROLLERS["Logitech Dual Action"]
183
+ },
184
+ {
185
+ "vidpid": "046d:c21d",
186
+ "guid": "",
187
+ "connection": ConnectionType.USB,
188
+ "input": InputType.XInput,
189
+ "name": [
190
+ "Logitech, Inc. F710 Gamepad [XInput Mode]",
191
+ "Logitech Gamepad F710"
192
+ ],
193
+ "class": CONTROLLERS["Logitech Gamepad F710"]
194
+ },
195
+ {
196
+ "vidpid": "046d:c216",
197
+ "guid": "",
198
+ "connection": ConnectionType.USB,
199
+ "input": InputType.DirectInput,
200
+ "name": [
201
+ "Logitech, Inc. F710 Gamepad [DirectInput Mode]",
202
+ "Logitech Dual Action"
203
+ ],
204
+ "class": CONTROLLERS["Logitech Dual Action"]
205
+ }
206
+ ]
207
+ }
@@ -14,12 +14,7 @@ This controller is a usb controller, with the following features.
14
14
 
15
15
  import pygame
16
16
  from pygameControls.controlsbase import ControlsBase
17
- from enum import Enum
18
17
 
19
- class InputMode(Enum):
20
- DirectInput = 1
21
- XInput = 2
22
-
23
18
  class LogitechDualActionController(ControlsBase):
24
19
  def __init__(self, joy):
25
20
  self.device = joy
@@ -33,7 +28,6 @@ class LogitechDualActionController(ControlsBase):
33
28
  self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
34
29
  self.numbuttons: int = self.device.get_numbuttons()
35
30
  self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
36
- self.input_mode = InputMode.DirectInput
37
31
  self.mapping = {
38
32
  "r2 trigger": 7,
39
33
  "l2 trigger": 6,
@@ -85,12 +79,4 @@ class LogitechDualActionController(ControlsBase):
85
79
  @name.setter
86
80
  def name(self, name: str) -> None:
87
81
  self._name = name
88
-
89
- @property
90
- def input_mode(self) -> int:
91
- return self._inputmode
92
-
93
- @input_mode.setter
94
- def input_mode(self, mode: int) -> None:
95
- self._inputmode = mode
96
82
 
@@ -14,12 +14,7 @@ This controller is a usb controller, with the following features.
14
14
 
15
15
  import pygame
16
16
  from pygameControls.controlsbase import ControlsBase
17
- from enum import Enum
18
17
 
19
- class InputMode(Enum):
20
- DirectInput = 1
21
- XInput = 2
22
-
23
18
  class LogitechF310Controller(ControlsBase):
24
19
  def __init__(self, joy):
25
20
  self.device = joy
@@ -33,7 +28,6 @@ class LogitechF310Controller(ControlsBase):
33
28
  self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
34
29
  self.numbuttons: int = self.device.get_numbuttons()
35
30
  self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
36
- self.input_mode = InputMode.XInput
37
31
  self.mapping = {
38
32
  "l1 button": 4,
39
33
  "r1 button": 5,
@@ -83,12 +77,4 @@ class LogitechF310Controller(ControlsBase):
83
77
  @name.setter
84
78
  def name(self, name: str) -> None:
85
79
  self._name = name
86
-
87
- @property
88
- def input_mode(self) -> int:
89
- return self._inputmode
90
-
91
- @input_mode.setter
92
- def input_mode(self, mode: int) -> None:
93
- self._inputmode = mode
94
80
 
@@ -1,41 +1,25 @@
1
1
  """
2
- Logitech F310 Controller class.
3
- This controller is a usb controller, with the following features.
4
- (XInput mode)
5
- 6 axis
6
- 11 buttons
7
- 1 hat
8
-
9
- (DirectInput mode)
10
- 4 axis
11
- 12 buttons
12
- 1 hat
2
+ Logitech F510 Controller class.
3
+ This controller should have the same setup as the F310, but with the addition of rumble effect.
4
+ I don't have this controller, so I haven't been able to verify the workings!
5
+ Subsequent updates will be done, based on updates for the F310.
13
6
  """
14
7
 
15
8
  import pygame
16
9
  from pygameControls.controlsbase import ControlsBase
17
- from enum import Enum
18
-
19
- class InputMode(Enum):
20
- DirectInput = 1
21
- XInput = 2
22
10
 
23
- class ConnectionType(Enum):
24
- WIRED = 1
25
- WIRELESS = 2
26
-
27
11
  class LogitechF510Controller(ControlsBase):
28
12
  def __init__(self, joy):
29
13
  self.device = joy
30
14
  self.instance_id: int = self.device.get_instance_id()
31
15
  self.name = self.device.get_name()
16
+ self.guid = self.device.get_guid()
32
17
  self.numaxis: int = self.device.get_numaxis()
33
18
  self.axis: list = []
34
19
  self.numhats: int = self.device.get_numhats()
35
20
  self.hats: list = []
36
21
  self.numbuttons: int = self.device.get_numbuttons()
37
22
  self.buttons: list = []
38
- self.input_mode: InputMode.DirectInput
39
23
  self.mapping = {
40
24
  "l1 button": 4,
41
25
  "r1 button": 5,
@@ -109,19 +93,4 @@ class LogitechF510Controller(ControlsBase):
109
93
  @buttons.setter
110
94
  def buttons(self) -> None:
111
95
  self._buttons = [self.device.get_buttons(b) for b in range(self.numbuttons)]
112
-
113
- @property
114
- def input_mode(self) -> int:
115
- return self._inputmode
116
-
117
- @input_mode.setter
118
- def input_mode(self, mode: int) -> None:
119
- self._inputmode = mode
120
-
121
- @property
122
- def input_connection(self) -> int:
123
- return self._input_connection
124
-
125
- @input_connection.setter
126
- def input_connection(self, conn: int) -> None:
127
- self._input_connection = conn
96
+
@@ -1,41 +1,23 @@
1
1
  """
2
- Logitech F310 Controller class.
3
- This controller is a usb controller, with the following features.
4
- (XInput mode)
5
- 6 axis
6
- 11 buttons
7
- 1 hat
8
-
9
- (DirectInput mode)
10
- 4 axis
11
- 12 buttons
12
- 1 hat
2
+ Logitech F710 Controller class.
3
+ This controller is a usb/wireless controller.
13
4
  """
14
5
 
15
6
  import pygame
16
7
  from pygameControls.controlsbase import ControlsBase
17
- from enum import Enum
18
-
19
- class InputMode(Enum):
20
- DirectInput = 1
21
- XInput = 2
22
8
 
23
- class ConnectionType(Enum):
24
- WIRED = 1
25
- WIRELESS = 2
26
-
27
9
  class LogitechF710Controller(ControlsBase):
28
10
  def __init__(self, joy):
29
11
  self.device = joy
30
12
  self.instance_id: int = self.device.get_instance_id()
31
13
  self.name = self.device.get_name()
14
+ self.guid = self.device.get_guid()
32
15
  self.numaxis: int = self.device.get_numaxis()
33
16
  self.axis: list = []
34
17
  self.numhats: int = self.device.get_numhats()
35
18
  self.hats: list = []
36
19
  self.numbuttons: int = self.device.get_numbuttons()
37
20
  self.buttons: list = []
38
- self.input_mode: InputMode.DirectInput
39
21
  self.mapping = {
40
22
  "l1 button": 4,
41
23
  "r1 button": 5,
@@ -109,19 +91,4 @@ class LogitechF710Controller(ControlsBase):
109
91
  @buttons.setter
110
92
  def buttons(self) -> None:
111
93
  self._buttons = [self.device.get_buttons(b) for b in range(self.numbuttons)]
112
-
113
- @property
114
- def input_mode(self) -> int:
115
- return self._inputmode
116
-
117
- @input_mode.setter
118
- def input_mode(self, mode: int) -> None:
119
- self._inputmode = mode
120
-
121
- @property
122
- def input_connection(self) -> int:
123
- return self._input_connection
124
-
125
- @input_connection.setter
126
- def input_connection(self, conn: int) -> None:
127
- self._input_connection = conn
94
+
@@ -1,4 +1,5 @@
1
1
  from pygameControls.controlsbase import ControlsBase
2
+ import pygame
2
3
 
3
4
  class PlayStation3Controller(ControlsBase):
4
5
  def __init__(self, joy):
@@ -0,0 +1,71 @@
1
+ from pygameControls.controlsbase import ControlsBase
2
+ import pygame
3
+
4
+ class PlayStation4Controller(ControlsBase):
5
+ def __init__(self, joy):
6
+ self.device = joy
7
+ self.instance_id: int = self.device.get_instance_id()
8
+ self.name = self.device.get_name()
9
+ self.guid = self.device.get_guid()
10
+ self.numaxis: int = self.device.get_numaxes()
11
+ self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)]
12
+ self.numhats: int = self.device.get_numhats()
13
+ self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
14
+ self.numbuttons: int = self.device.get_numbuttons()
15
+ self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
16
+ self.mapping = {
17
+ "l1 button": 4,
18
+ "r1 button": 5,
19
+ "cross button": 0,
20
+ "triangle button": 2,
21
+ "circle button": 1,
22
+ "square button": 3,
23
+ "left stick button": 11,
24
+ "right stick button": 12,
25
+ "logo button": 10,
26
+ "select button": 8,
27
+ "start button": 9,
28
+ "down button": 14,
29
+ "up button": 13,
30
+ "left button": 15,
31
+ "right button": 16
32
+ }
33
+ print(f"{self.name} connected.")
34
+
35
+ def close(self):
36
+ self.device.quit()
37
+
38
+ def handle_input(self, event):
39
+ pass
40
+
41
+ def left(self):
42
+ pass
43
+
44
+ def right(self):
45
+ pass
46
+
47
+ def up(self):
48
+ pass
49
+
50
+ def down(self):
51
+ pass
52
+
53
+ def pause(self):
54
+ pass
55
+
56
+ def rumble(self, left, right, duration=0):
57
+ if not left in range(256) or not right in range(256):
58
+ raise ValueError("left and right values must be in the range 0 - 255")
59
+ self.device.rumble(left / 255, right / 255, duration)
60
+
61
+ def stop_rumble(self):
62
+ self.device.stop_rumble()
63
+
64
+ @property
65
+ def name(self) -> str:
66
+ return self._name
67
+
68
+ @name.setter
69
+ def name(self, name: str) -> None:
70
+ self._name = name
71
+
@@ -1,4 +1,5 @@
1
1
  from pygameControls.controlsbase import ControlsBase
2
+ import pygame
2
3
 
3
4
  class SonyPlayStation3Controller(ControlsBase):
4
5
  def __init__(self, joy):
@@ -0,0 +1,71 @@
1
+ from pygameControls.controlsbase import ControlsBase
2
+ import pygame
3
+
4
+ class SonyPlayStation4Controller(ControlsBase):
5
+ def __init__(self, joy):
6
+ self.device = joy
7
+ self.instance_id: int = self.device.get_instance_id()
8
+ self.name = self.device.get_name()
9
+ self.guid = self.device.get_guid()
10
+ self.numaxis: int = self.device.get_numaxes()
11
+ self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)]
12
+ self.numhats: int = self.device.get_numhats()
13
+ self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
14
+ self.numbuttons: int = self.device.get_numbuttons()
15
+ self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
16
+ self.mapping = {
17
+ "l1 button": 4,
18
+ "r1 button": 5,
19
+ "cross button": 0,
20
+ "triangle button": 2,
21
+ "circle button": 1,
22
+ "square button": 3,
23
+ "left stick button": 11,
24
+ "right stick button": 12,
25
+ "logo button": 10,
26
+ "select button": 8,
27
+ "start button": 9,
28
+ "down button": 14,
29
+ "up button": 13,
30
+ "left button": 15,
31
+ "right button": 16
32
+ }
33
+ print(f"{self.name} connected.")
34
+
35
+ def close(self):
36
+ self.device.quit()
37
+
38
+ def handle_input(self, event):
39
+ pass
40
+
41
+ def left(self):
42
+ pass
43
+
44
+ def right(self):
45
+ pass
46
+
47
+ def up(self):
48
+ pass
49
+
50
+ def down(self):
51
+ pass
52
+
53
+ def pause(self):
54
+ pass
55
+
56
+ def rumble(self, left, right, duration=0):
57
+ if not left in range(256) or not right in range(256):
58
+ raise ValueError("left and right values must be in the range 0 - 255")
59
+ self.device.rumble(left / 255, right / 255, duration)
60
+
61
+ def stop_rumble(self):
62
+ self.device.stop_rumble()
63
+
64
+ @property
65
+ def name(self) -> str:
66
+ return self._name
67
+
68
+ @name.setter
69
+ def name(self, name: str) -> None:
70
+ self._name = name
71
+
@@ -0,0 +1,68 @@
1
+ from pygameControls.controlsbase import ControlsBase
2
+ import pygame
3
+
4
+ class Xbox360Controller(ControlsBase):
5
+ def __init__(self, joy):
6
+ self.device = joy
7
+ self.instance_id: int = self.device.get_instance_id()
8
+ self.name = self.device.get_name()
9
+ self.guid = self.device.get_guid()
10
+ self.numaxis: int = self.device.get_numaxes()
11
+ self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)]
12
+ self.numhats: int = self.device.get_numhats()
13
+ self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
14
+ self.numbuttons: int = self.device.get_numbuttons()
15
+ self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
16
+ self.mapping = {
17
+ "l1 button": 6,
18
+ "r1 button": 7,
19
+ "X button": 3,
20
+ "Y button": 4,
21
+ "A button": 0,
22
+ "B button": 1,
23
+ "left stick button": 13,
24
+ "right stick button": 14,
25
+ "logo button": 12,
26
+ "share button": 15,
27
+ "list button": 11,
28
+ "copy button": 10
29
+ }
30
+ print(f"{self.name} connected.")
31
+
32
+ def close(self):
33
+ self.device.quit()
34
+
35
+ def handle_input(self, event):
36
+ pass
37
+
38
+ def left(self):
39
+ pass
40
+
41
+ def right(self):
42
+ pass
43
+
44
+ def up(self):
45
+ pass
46
+
47
+ def down(self):
48
+ pass
49
+
50
+ def pause(self):
51
+ pass
52
+
53
+ def rumble(self, left, right, duration=0):
54
+ if not left in range(256) or not right in range(256):
55
+ raise ValueError("left and right values must be in the range 0 - 255")
56
+ self.device.rumble(left / 255, right / 255, duration)
57
+
58
+ def stop_rumble(self):
59
+ self.device.stop_rumble()
60
+
61
+ @property
62
+ def name(self) -> str:
63
+ return self._name
64
+
65
+ @name.setter
66
+ def name(self, name: str) -> None:
67
+ self._name = name
68
+
@@ -1,4 +1,5 @@
1
1
  from pygameControls.controlsbase import ControlsBase
2
+ import pygame
2
3
 
3
4
  class XboxSeriesXController(ControlsBase):
4
5
  def __init__(self, joy):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygameControls
3
- Version: 0.1.13
3
+ Version: 0.2.1
4
4
  Summary: A simple controller class for pygame.
5
5
  Home-page:
6
6
  Author: Jan Lerking
@@ -6,13 +6,18 @@ pygameControls/controller.py
6
6
  pygameControls/controlsbase.py
7
7
  pygameControls/dualsense_controller.py
8
8
  pygameControls/dualsense_edge_controller.py
9
+ pygameControls/enums.py
9
10
  pygameControls/generic_controller.py
11
+ pygameControls/globals.py
10
12
  pygameControls/logitech_dual_action_controller.py
11
13
  pygameControls/logitech_f310_controller.py
12
14
  pygameControls/logitech_f510_controller.py
13
15
  pygameControls/logitech_f710_controller.py
14
16
  pygameControls/playstation3_controller.py
17
+ pygameControls/playstation4_controller.py
15
18
  pygameControls/sony_playstation3_controller.py
19
+ pygameControls/sony_playstation4_controller.py
20
+ pygameControls/xbox_360_controller.py
16
21
  pygameControls/xbox_series_x_controller.py
17
22
  pygameControls.egg-info/PKG-INFO
18
23
  pygameControls.egg-info/SOURCES.txt
@@ -3,7 +3,7 @@ if __name__ == "__main__":
3
3
 
4
4
  setup(
5
5
  name='pygameControls',
6
- version='0.1.13',
6
+ version='0.2.1',
7
7
  packages=find_packages(),
8
8
  install_requires=[],
9
9
  author='Jan Lerking',
@@ -1,35 +0,0 @@
1
- import pygame
2
- from .controlsbase import ControlsBase
3
- from .dualsense_controller import DualSenseController
4
- from .dualsense_edge_controller import DualSenseEdgeController
5
- from .logitech_f310_controller import LogitechF310Controller
6
- from .logitech_f510_controller import LogitechF510Controller
7
- from .logitech_f710_controller import LogitechF710Controller
8
- from .xbox_series_x_controller import XboxSeriesXController
9
- from .sony_playstation3_controller import SonyPlayStation3Controller
10
- from .playstation3_controller import PlayStation3Controller
11
- from .generic_controller import GenericController
12
- from .logitech_dual_action_controller import LogitechDualActionController
13
-
14
- __version__ = "0.1.13"
15
-
16
- CONTROLLERS = {
17
- "DualSense Wireless Controller": DualSenseController,
18
- "DualSense Edge Wireless Controller": DualSenseEdgeController,
19
- "Logitech Gamepad F310": LogitechF310Controller,
20
- "Logitech Gamepad F510": LogitechF510Controller,
21
- "Logitech Gamepad F710": LogitechF710Controller,
22
- "Logitech Dual Action": LogitechDualActionController,
23
- "Xbox Series X Controller": XboxSeriesXController,
24
- "Sony PLAYSTATION(R)3 Controller": SonyPlayStation3Controller,
25
- "PLAYSTATION(R)3 Controller": PlayStation3Controller
26
- }
27
-
28
- class Controllers:
29
- def __init__(self, joy):
30
- self.controllers = []
31
- if not joy.get_name() in CONTROLLERS:
32
- self.controllers.append(GenericController(joy))
33
- else:
34
- self.controllers.append(CONTROLLERS[joy.get_name()](joy))
35
-
File without changes