pygameControls 0.1.13__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.
Files changed (28) hide show
  1. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/PKG-INFO +1 -1
  2. pygamecontrols-0.2.0/pygameControls/controller.py +21 -0
  3. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/dualsense_controller.py +2 -0
  4. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/dualsense_edge_controller.py +2 -0
  5. pygamecontrols-0.2.0/pygameControls/enums.py +12 -0
  6. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/generic_controller.py +1 -0
  7. pygamecontrols-0.2.0/pygameControls/globals.py +207 -0
  8. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/logitech_dual_action_controller.py +1 -14
  9. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/logitech_f310_controller.py +1 -14
  10. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/logitech_f510_controller.py +7 -37
  11. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/logitech_f710_controller.py +5 -37
  12. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/playstation3_controller.py +2 -0
  13. pygamecontrols-0.2.0/pygameControls/playstation4_controller.py +72 -0
  14. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/sony_playstation3_controller.py +2 -0
  15. pygamecontrols-0.2.0/pygameControls/sony_playstation4_controller.py +72 -0
  16. pygamecontrols-0.2.0/pygameControls/xbox_360_controller.py +69 -0
  17. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/xbox_series_x_controller.py +2 -0
  18. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls.egg-info/PKG-INFO +1 -1
  19. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls.egg-info/SOURCES.txt +5 -0
  20. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/setup.py +1 -1
  21. pygamecontrols-0.1.13/pygameControls/controller.py +0 -35
  22. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/LICENSE +0 -0
  23. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/README.md +0 -0
  24. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/__init__.py +0 -0
  25. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls/controlsbase.py +0 -0
  26. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls.egg-info/dependency_links.txt +0 -0
  27. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/pygameControls.egg-info/top_level.txt +0 -0
  28. {pygamecontrols-0.1.13 → pygamecontrols-0.2.0}/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.0
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.0"
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"]
@@ -1,4 +1,5 @@
1
1
  from pygameControls.controlsbase import ControlsBase
2
+ from .enums import ConnectionType
2
3
  from pydualsense import *
3
4
 
4
5
  BATTERY_STATE = {
@@ -15,6 +16,7 @@ class DualSenseController(ControlsBase):
15
16
  self.device = pydualsense()
16
17
  self.device.init()
17
18
  self.name = self.device.device.get_product_string()
19
+ self.guid = self.device.get_guid()
18
20
  self.powerlevel = self.device.battery.Level
19
21
  self.batterystate = BATTERY_STATE[str(self.device.battery.State)]
20
22
  self.set_player_id(PlayerID.PLAYER_1)
@@ -1,4 +1,5 @@
1
1
  from pygameControls.controlsbase import ControlsBase
2
+ from enums import ConnectionType
2
3
  from pydualsense import *
3
4
 
4
5
 
@@ -7,6 +8,7 @@ class DualSenseEdgeController(ControlsBase):
7
8
  self.device = pydualsense()
8
9
  self.device.init()
9
10
  self.name = self.device.device.get_product_string()
11
+ self.guid = self.device.get_guid()
10
12
  self.powerlevel = self.device.battery.Level
11
13
  self.batterystate = BATTERY_STATE[str(self.device.battery.State)]
12
14
  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
@@ -1,5 +1,6 @@
1
1
  import pygame
2
2
  from pygameControls.controlsbase import ControlsBase
3
+ from enums import ConnectionType
3
4
 
4
5
  class GenericController(ControlsBase):
5
6
  def __init__(self, joy):
@@ -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,8 @@ 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
17
+ from enums import ConnectionType
18
18
 
19
- class InputMode(Enum):
20
- DirectInput = 1
21
- XInput = 2
22
-
23
19
  class LogitechDualActionController(ControlsBase):
24
20
  def __init__(self, joy):
25
21
  self.device = joy
@@ -33,7 +29,6 @@ class LogitechDualActionController(ControlsBase):
33
29
  self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
34
30
  self.numbuttons: int = self.device.get_numbuttons()
35
31
  self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
36
- self.input_mode = InputMode.DirectInput
37
32
  self.mapping = {
38
33
  "r2 trigger": 7,
39
34
  "l2 trigger": 6,
@@ -85,12 +80,4 @@ class LogitechDualActionController(ControlsBase):
85
80
  @name.setter
86
81
  def name(self, name: str) -> None:
87
82
  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
83
 
@@ -14,12 +14,8 @@ 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
17
+ from enums import ConnectionType
18
18
 
19
- class InputMode(Enum):
20
- DirectInput = 1
21
- XInput = 2
22
-
23
19
  class LogitechF310Controller(ControlsBase):
24
20
  def __init__(self, joy):
25
21
  self.device = joy
@@ -33,7 +29,6 @@ class LogitechF310Controller(ControlsBase):
33
29
  self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
34
30
  self.numbuttons: int = self.device.get_numbuttons()
35
31
  self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
36
- self.input_mode = InputMode.XInput
37
32
  self.mapping = {
38
33
  "l1 button": 4,
39
34
  "r1 button": 5,
@@ -83,12 +78,4 @@ class LogitechF310Controller(ControlsBase):
83
78
  @name.setter
84
79
  def name(self, name: str) -> None:
85
80
  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
81
 
@@ -1,41 +1,26 @@
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
10
+ from enums import ConnectionType
22
11
 
23
- class ConnectionType(Enum):
24
- WIRED = 1
25
- WIRELESS = 2
26
-
27
12
  class LogitechF510Controller(ControlsBase):
28
13
  def __init__(self, joy):
29
14
  self.device = joy
30
15
  self.instance_id: int = self.device.get_instance_id()
31
16
  self.name = self.device.get_name()
17
+ self.guid = self.device.get_guid()
32
18
  self.numaxis: int = self.device.get_numaxis()
33
19
  self.axis: list = []
34
20
  self.numhats: int = self.device.get_numhats()
35
21
  self.hats: list = []
36
22
  self.numbuttons: int = self.device.get_numbuttons()
37
23
  self.buttons: list = []
38
- self.input_mode: InputMode.DirectInput
39
24
  self.mapping = {
40
25
  "l1 button": 4,
41
26
  "r1 button": 5,
@@ -109,19 +94,4 @@ class LogitechF510Controller(ControlsBase):
109
94
  @buttons.setter
110
95
  def buttons(self) -> None:
111
96
  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
97
+
@@ -1,41 +1,24 @@
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
8
+ from enums import ConnectionType
22
9
 
23
- class ConnectionType(Enum):
24
- WIRED = 1
25
- WIRELESS = 2
26
-
27
10
  class LogitechF710Controller(ControlsBase):
28
11
  def __init__(self, joy):
29
12
  self.device = joy
30
13
  self.instance_id: int = self.device.get_instance_id()
31
14
  self.name = self.device.get_name()
15
+ self.guid = self.device.get_guid()
32
16
  self.numaxis: int = self.device.get_numaxis()
33
17
  self.axis: list = []
34
18
  self.numhats: int = self.device.get_numhats()
35
19
  self.hats: list = []
36
20
  self.numbuttons: int = self.device.get_numbuttons()
37
21
  self.buttons: list = []
38
- self.input_mode: InputMode.DirectInput
39
22
  self.mapping = {
40
23
  "l1 button": 4,
41
24
  "r1 button": 5,
@@ -109,19 +92,4 @@ class LogitechF710Controller(ControlsBase):
109
92
  @buttons.setter
110
93
  def buttons(self) -> None:
111
94
  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
95
+
@@ -1,4 +1,6 @@
1
1
  from pygameControls.controlsbase import ControlsBase
2
+ from enums import ConnectionType
3
+ import pygame
2
4
 
3
5
  class PlayStation3Controller(ControlsBase):
4
6
  def __init__(self, joy):
@@ -0,0 +1,72 @@
1
+ from pygameControls.controlsbase import ControlsBase
2
+ from enums import ConnectionType
3
+ import pygame
4
+
5
+ class PlayStation4Controller(ControlsBase):
6
+ def __init__(self, joy):
7
+ self.device = joy
8
+ self.instance_id: int = self.device.get_instance_id()
9
+ self.name = self.device.get_name()
10
+ self.guid = self.device.get_guid()
11
+ self.numaxis: int = self.device.get_numaxes()
12
+ self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)]
13
+ self.numhats: int = self.device.get_numhats()
14
+ self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
15
+ self.numbuttons: int = self.device.get_numbuttons()
16
+ self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
17
+ self.mapping = {
18
+ "l1 button": 4,
19
+ "r1 button": 5,
20
+ "cross button": 0,
21
+ "triangle button": 2,
22
+ "circle button": 1,
23
+ "square button": 3,
24
+ "left stick button": 11,
25
+ "right stick button": 12,
26
+ "logo button": 10,
27
+ "select button": 8,
28
+ "start button": 9,
29
+ "down button": 14,
30
+ "up button": 13,
31
+ "left button": 15,
32
+ "right button": 16
33
+ }
34
+ print(f"{self.name} connected.")
35
+
36
+ def close(self):
37
+ self.device.quit()
38
+
39
+ def handle_input(self, event):
40
+ pass
41
+
42
+ def left(self):
43
+ pass
44
+
45
+ def right(self):
46
+ pass
47
+
48
+ def up(self):
49
+ pass
50
+
51
+ def down(self):
52
+ pass
53
+
54
+ def pause(self):
55
+ pass
56
+
57
+ def rumble(self, left, right, duration=0):
58
+ if not left in range(256) or not right in range(256):
59
+ raise ValueError("left and right values must be in the range 0 - 255")
60
+ self.device.rumble(left / 255, right / 255, duration)
61
+
62
+ def stop_rumble(self):
63
+ self.device.stop_rumble()
64
+
65
+ @property
66
+ def name(self) -> str:
67
+ return self._name
68
+
69
+ @name.setter
70
+ def name(self, name: str) -> None:
71
+ self._name = name
72
+
@@ -1,4 +1,6 @@
1
1
  from pygameControls.controlsbase import ControlsBase
2
+ from enums import ConnectionType
3
+ import pygame
2
4
 
3
5
  class SonyPlayStation3Controller(ControlsBase):
4
6
  def __init__(self, joy):
@@ -0,0 +1,72 @@
1
+ from pygameControls.controlsbase import ControlsBase
2
+ from enums import ConnectionType
3
+ import pygame
4
+
5
+ class SonyPlayStation4Controller(ControlsBase):
6
+ def __init__(self, joy):
7
+ self.device = joy
8
+ self.instance_id: int = self.device.get_instance_id()
9
+ self.name = self.device.get_name()
10
+ self.guid = self.device.get_guid()
11
+ self.numaxis: int = self.device.get_numaxes()
12
+ self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)]
13
+ self.numhats: int = self.device.get_numhats()
14
+ self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
15
+ self.numbuttons: int = self.device.get_numbuttons()
16
+ self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
17
+ self.mapping = {
18
+ "l1 button": 4,
19
+ "r1 button": 5,
20
+ "cross button": 0,
21
+ "triangle button": 2,
22
+ "circle button": 1,
23
+ "square button": 3,
24
+ "left stick button": 11,
25
+ "right stick button": 12,
26
+ "logo button": 10,
27
+ "select button": 8,
28
+ "start button": 9,
29
+ "down button": 14,
30
+ "up button": 13,
31
+ "left button": 15,
32
+ "right button": 16
33
+ }
34
+ print(f"{self.name} connected.")
35
+
36
+ def close(self):
37
+ self.device.quit()
38
+
39
+ def handle_input(self, event):
40
+ pass
41
+
42
+ def left(self):
43
+ pass
44
+
45
+ def right(self):
46
+ pass
47
+
48
+ def up(self):
49
+ pass
50
+
51
+ def down(self):
52
+ pass
53
+
54
+ def pause(self):
55
+ pass
56
+
57
+ def rumble(self, left, right, duration=0):
58
+ if not left in range(256) or not right in range(256):
59
+ raise ValueError("left and right values must be in the range 0 - 255")
60
+ self.device.rumble(left / 255, right / 255, duration)
61
+
62
+ def stop_rumble(self):
63
+ self.device.stop_rumble()
64
+
65
+ @property
66
+ def name(self) -> str:
67
+ return self._name
68
+
69
+ @name.setter
70
+ def name(self, name: str) -> None:
71
+ self._name = name
72
+
@@ -0,0 +1,69 @@
1
+ from pygameControls.controlsbase import ControlsBase
2
+ from enums import ConnectionType, InputType
3
+ import pygame
4
+
5
+ class Xbox360Controller(ControlsBase):
6
+ def __init__(self, joy):
7
+ self.device = joy
8
+ self.instance_id: int = self.device.get_instance_id()
9
+ self.name = self.device.get_name()
10
+ self.guid = self.device.get_guid()
11
+ self.numaxis: int = self.device.get_numaxes()
12
+ self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)]
13
+ self.numhats: int = self.device.get_numhats()
14
+ self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
15
+ self.numbuttons: int = self.device.get_numbuttons()
16
+ self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
17
+ self.mapping = {
18
+ "l1 button": 6,
19
+ "r1 button": 7,
20
+ "X button": 3,
21
+ "Y button": 4,
22
+ "A button": 0,
23
+ "B button": 1,
24
+ "left stick button": 13,
25
+ "right stick button": 14,
26
+ "logo button": 12,
27
+ "share button": 15,
28
+ "list button": 11,
29
+ "copy button": 10
30
+ }
31
+ print(f"{self.name} connected.")
32
+
33
+ def close(self):
34
+ self.device.quit()
35
+
36
+ def handle_input(self, event):
37
+ pass
38
+
39
+ def left(self):
40
+ pass
41
+
42
+ def right(self):
43
+ pass
44
+
45
+ def up(self):
46
+ pass
47
+
48
+ def down(self):
49
+ pass
50
+
51
+ def pause(self):
52
+ pass
53
+
54
+ def rumble(self, left, right, duration=0):
55
+ if not left in range(256) or not right in range(256):
56
+ raise ValueError("left and right values must be in the range 0 - 255")
57
+ self.device.rumble(left / 255, right / 255, duration)
58
+
59
+ def stop_rumble(self):
60
+ self.device.stop_rumble()
61
+
62
+ @property
63
+ def name(self) -> str:
64
+ return self._name
65
+
66
+ @name.setter
67
+ def name(self, name: str) -> None:
68
+ self._name = name
69
+
@@ -1,4 +1,6 @@
1
1
  from pygameControls.controlsbase import ControlsBase
2
+ from enums import ConnectionType
3
+ import pygame
2
4
 
3
5
  class XboxSeriesXController(ControlsBase):
4
6
  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.0
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.0',
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