Added Playstation 3 controller. /JL #22
@@ -6,11 +6,12 @@ from .logitech_f310_controller import LogitechF310Controller
|
||||
from .logitech_f510_controller import LogitechF510Controller
|
||||
from .logitech_f710_controller import LogitechF710Controller
|
||||
from .xbox_series_x_controller import XboxSeriesXController
|
||||
from .dualshock3_controller import DualShock3Controller
|
||||
from .sony_playstation3_controller import SonyPlayStation3Controller
|
||||
from .playstation3_controller import PlayStation3Controller
|
||||
from .generic_controller import GenericController
|
||||
from .logitech_dual_action_controller import LogitechDualActionController
|
||||
|
||||
__version__ = "0.1.12"
|
||||
__version__ = "0.1.13"
|
||||
|
||||
CONTROLLERS = {
|
||||
"DualSense Wireless Controller": DualSenseController,
|
||||
@@ -20,7 +21,8 @@ CONTROLLERS = {
|
||||
"Logitech Gamepad F710": LogitechF710Controller,
|
||||
"Logitech Dual Action": LogitechDualActionController,
|
||||
"Xbox Series X Controller": XboxSeriesXController,
|
||||
"PLAYSTATION(R)3 Controller": DualShock3Controller
|
||||
"Sony PLAYSTATION(R)3 Controller": SonyPlayStation3Controller,
|
||||
"PLAYSTATION(R)3 Controller": PlayStation3Controller
|
||||
}
|
||||
|
||||
class Controllers:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
from pygameControls.controlsbase import ControlsBase
|
||||
|
||||
class DualShock3Controller(ControlsBase):
|
||||
class PlayStation3Controller(ControlsBase):
|
||||
def __init__(self, joy):
|
||||
self.device = joy
|
||||
self.instance_id: int = self.device.get_instance_id()
|
70
pygameControls/sony_playstation3_controller.py
Normal file
70
pygameControls/sony_playstation3_controller.py
Normal file
@@ -0,0 +1,70 @@
|
||||
from pygameControls.controlsbase import ControlsBase
|
||||
|
||||
class SonyPlayStation3Controller(ControlsBase):
|
||||
def __init__(self, joy):
|
||||
self.device = joy
|
||||
self.instance_id: int = self.device.get_instance_id()
|
||||
self.name = self.device.get_name()
|
||||
self.guid = self.device.get_guid()
|
||||
self.numaxis: int = self.device.get_numaxes()
|
||||
self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)]
|
||||
self.numhats: int = self.device.get_numhats()
|
||||
self.hats: list = [self.device.get_hat(h) for h in range(self.numhats)]
|
||||
self.numbuttons: int = self.device.get_numbuttons()
|
||||
self.buttons: list = [self.device.get_button(b) for b in range(self.numbuttons)]
|
||||
self.mapping = {
|
||||
"l1 button": 4,
|
||||
"r1 button": 5,
|
||||
"cross button": 0,
|
||||
"triangle button": 2,
|
||||
"circle button": 1,
|
||||
"square button": 3,
|
||||
"left stick button": 11,
|
||||
"right stick button": 12,
|
||||
"logo button": 10,
|
||||
"select button": 8,
|
||||
"start button": 9,
|
||||
"down button": 14,
|
||||
"up button": 13,
|
||||
"left button": 15,
|
||||
"right button": 16
|
||||
}
|
||||
print(f"{self.name} connected.")
|
||||
|
||||
def close(self):
|
||||
self.device.quit()
|
||||
|
||||
def handle_input(self, event):
|
||||
pass
|
||||
|
||||
def left(self):
|
||||
pass
|
||||
|
||||
def right(self):
|
||||
pass
|
||||
|
||||
def up(self):
|
||||
pass
|
||||
|
||||
def down(self):
|
||||
pass
|
||||
|
||||
def pause(self):
|
||||
pass
|
||||
|
||||
def rumble(self, left, right, duration=0):
|
||||
if not left in range(256) or not right in range(256):
|
||||
raise ValueError("left and right values must be in the range 0 - 255")
|
||||
self.device.rumble(left / 255, right / 255, duration)
|
||||
|
||||
def stop_rumble(self):
|
||||
self.device.stop_rumble()
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, name: str) -> None:
|
||||
self._name = name
|
||||
|
Reference in New Issue
Block a user