From 2a9746d510fddeccd3a394e6a95d90f6a69e86f7 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 08:30:54 +0200 Subject: [PATCH 01/57] Update pygameControls/controller.py Added support for getting connection type of controller. /JL --- pygameControls/controller.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pygameControls/controller.py b/pygameControls/controller.py index a2c74f9..305585d 100644 --- a/pygameControls/controller.py +++ b/pygameControls/controller.py @@ -1,4 +1,5 @@ import pygame +from evdev import InputDevice, list_devices from .controlsbase import ControlsBase from .dualsense_controller import DualSenseController from .dualsense_edge_controller import DualSenseEdgeController @@ -11,7 +12,7 @@ from .playstation3_controller import PlayStation3Controller from .generic_controller import GenericController from .logitech_dual_action_controller import LogitechDualActionController -__version__ = "0.1.13" +__version__ = "0.2.0" CONTROLLERS = { "DualSense Wireless Controller": DualSenseController, @@ -29,7 +30,23 @@ class Controllers: def __init__(self, joy): self.controllers = [] if not joy.get_name() in CONTROLLERS: + self.get_connection_type(joy.get_name()) self.controllers.append(GenericController(joy)) else: + self.get_connection_type(joy.get_name()) self.controllers.append(CONTROLLERS[joy.get_name()](joy)) + + def get_connection_type(self, controller_name): + for path in list_devices() + device = InputDevice(path) + name = device.name.lower() + if name != controller_name.lower(): + continue + + if 'usb' in device.phys.lower(): + return 'usb' + elif 'bluetooth' in device.phys.lower(): + return 'bluetooth' + elif 'rf' in device.phys.lower() or 'wireless' in name: + return 'wireless' \ No newline at end of file From d26316d273a8914200e200a3f027933fd44f8d67 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:02:09 +0200 Subject: [PATCH 02/57] Update pygameControls/controller.py Added connection type to class init. /JL --- pygameControls/controller.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pygameControls/controller.py b/pygameControls/controller.py index 305585d..8530310 100644 --- a/pygameControls/controller.py +++ b/pygameControls/controller.py @@ -30,11 +30,9 @@ class Controllers: def __init__(self, joy): self.controllers = [] if not joy.get_name() in CONTROLLERS: - self.get_connection_type(joy.get_name()) - self.controllers.append(GenericController(joy)) + self.controllers.append(GenericController(joy, self.get_connection_type(joy.get_name()))) else: - self.get_connection_type(joy.get_name()) - self.controllers.append(CONTROLLERS[joy.get_name()](joy)) + self.controllers.append(CONTROLLERS[joy.get_name()](joy, self.get_connection_type(joy.get_name()))) def get_connection_type(self, controller_name): for path in list_devices() From 7d4037a748753c9efc940477f68b92047f633927 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:03:32 +0200 Subject: [PATCH 03/57] Update pygameControls/dualsense_controller.py Added connection_type. /JL --- pygameControls/dualsense_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/dualsense_controller.py b/pygameControls/dualsense_controller.py index a9de40d..742fdd0 100644 --- a/pygameControls/dualsense_controller.py +++ b/pygameControls/dualsense_controller.py @@ -11,10 +11,11 @@ BATTERY_STATE = { } class DualSenseController(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = pydualsense() self.device.init() self.name = self.device.device.get_product_string() + self.connection_type = connection_type self.powerlevel = self.device.battery.Level self.batterystate = BATTERY_STATE[str(self.device.battery.State)] self.set_player_id(PlayerID.PLAYER_1) From 7b2641f17478d9543ffc85c72ffb58ef0cb0b9a0 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:03:55 +0200 Subject: [PATCH 04/57] Update pygameControls/dualsense_edge_controller.py --- pygameControls/dualsense_edge_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/dualsense_edge_controller.py b/pygameControls/dualsense_edge_controller.py index 15e3179..5ace8af 100644 --- a/pygameControls/dualsense_edge_controller.py +++ b/pygameControls/dualsense_edge_controller.py @@ -3,10 +3,11 @@ from pydualsense import * class DualSenseEdgeController(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = pydualsense() self.device.init() self.name = self.device.device.get_product_string() + self.connection_type = connection_type self.powerlevel = self.device.battery.Level self.batterystate = BATTERY_STATE[str(self.device.battery.State)] self.set_player_id(PlayerID.PLAYER_1) From cefd61a97a6eb0f24e9ef4675b0f86fdf6b779b0 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:04:23 +0200 Subject: [PATCH 05/57] Update pygameControls/generic_controller.py --- pygameControls/generic_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/generic_controller.py b/pygameControls/generic_controller.py index ebdfc9e..76fe57b 100644 --- a/pygameControls/generic_controller.py +++ b/pygameControls/generic_controller.py @@ -2,10 +2,11 @@ import pygame from pygameControls.controlsbase import ControlsBase class GenericController(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() + self.connection_type = connection_type 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)] From 1342f281d7dd48f9b3600bf695ee0239fec8dd3d Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:04:50 +0200 Subject: [PATCH 06/57] Update pygameControls/logitech_dual_action_controller.py --- pygameControls/logitech_dual_action_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/logitech_dual_action_controller.py b/pygameControls/logitech_dual_action_controller.py index 6ae0c51..ab6ae12 100644 --- a/pygameControls/logitech_dual_action_controller.py +++ b/pygameControls/logitech_dual_action_controller.py @@ -21,10 +21,11 @@ class InputMode(Enum): XInput = 2 class LogitechDualActionController(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() + self.connection_type = connection_type self.guid = self.device.get_guid() self.powerlevel = self.device.get_power_level() self.numaxis: int = self.device.get_numaxes() From baa36754063a59deb790b43d8b48e06572af705b Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:05:13 +0200 Subject: [PATCH 07/57] Update pygameControls/logitech_f310_controller.py --- pygameControls/logitech_f310_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/logitech_f310_controller.py b/pygameControls/logitech_f310_controller.py index d22ad97..40f0454 100644 --- a/pygameControls/logitech_f310_controller.py +++ b/pygameControls/logitech_f310_controller.py @@ -21,10 +21,11 @@ class InputMode(Enum): XInput = 2 class LogitechF310Controller(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() + self.connection_type = connection_type self.guid = self.device.get_guid() self.powerlevel = self.device.get_power_level() self.numaxis: int = self.device.get_numaxes() From 4c4aed6fa8ade4889fdbe5dd7c3cb2ca699aa44c Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:05:34 +0200 Subject: [PATCH 08/57] Update pygameControls/logitech_f510_controller.py --- pygameControls/logitech_f510_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/logitech_f510_controller.py b/pygameControls/logitech_f510_controller.py index fe26fe2..aed0d84 100644 --- a/pygameControls/logitech_f510_controller.py +++ b/pygameControls/logitech_f510_controller.py @@ -25,10 +25,11 @@ class ConnectionType(Enum): WIRELESS = 2 class LogitechF510Controller(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() + self.connection_type = connection_type self.numaxis: int = self.device.get_numaxis() self.axis: list = [] self.numhats: int = self.device.get_numhats() From d5790b538ced3f181deb093b27855799ff1d7ad1 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:06:02 +0200 Subject: [PATCH 09/57] Update pygameControls/logitech_f710_controller.py --- pygameControls/logitech_f710_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/logitech_f710_controller.py b/pygameControls/logitech_f710_controller.py index 8cabfa5..29345cc 100644 --- a/pygameControls/logitech_f710_controller.py +++ b/pygameControls/logitech_f710_controller.py @@ -25,10 +25,11 @@ class ConnectionType(Enum): WIRELESS = 2 class LogitechF710Controller(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() + self.connection_type = connection_type self.numaxis: int = self.device.get_numaxis() self.axis: list = [] self.numhats: int = self.device.get_numhats() From 50fa5106a397c6f1d9519e3a064e283a41e9b79d Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:06:24 +0200 Subject: [PATCH 10/57] Update pygameControls/playstation3_controller.py --- pygameControls/playstation3_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/playstation3_controller.py b/pygameControls/playstation3_controller.py index d79af23..86018f3 100644 --- a/pygameControls/playstation3_controller.py +++ b/pygameControls/playstation3_controller.py @@ -1,10 +1,11 @@ from pygameControls.controlsbase import ControlsBase class PlayStation3Controller(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() + self.connection_type = connection_type 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)] From 8c2fff3be104a84db3de545d3bbea13dcc58f00b Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:07:15 +0200 Subject: [PATCH 11/57] Update pygameControls/sony_playstation3_controller.py --- pygameControls/sony_playstation3_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/sony_playstation3_controller.py b/pygameControls/sony_playstation3_controller.py index d70b22e..e703428 100644 --- a/pygameControls/sony_playstation3_controller.py +++ b/pygameControls/sony_playstation3_controller.py @@ -1,10 +1,11 @@ from pygameControls.controlsbase import ControlsBase class SonyPlayStation3Controller(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() + self.connection_type = connection_type 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)] From e5a1ff1bbdc6e454298560e4e1cbf5337fb9a01e Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:07:42 +0200 Subject: [PATCH 12/57] Update pygameControls/xbox_series_x_controller.py --- pygameControls/xbox_series_x_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/xbox_series_x_controller.py b/pygameControls/xbox_series_x_controller.py index 0a96842..5da1347 100644 --- a/pygameControls/xbox_series_x_controller.py +++ b/pygameControls/xbox_series_x_controller.py @@ -1,10 +1,11 @@ from pygameControls.controlsbase import ControlsBase class XboxSeriesXController(ControlsBase): - def __init__(self, joy): + def __init__(self, joy, connection_type): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() + self.connection_type = connection_type 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)] From 124c961ff08d3a8e6d2c1f0d0f44dfa72b75613b Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:07:56 +0200 Subject: [PATCH 13/57] Update pygameControls/logitech_f710_controller.py --- pygameControls/logitech_f710_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygameControls/logitech_f710_controller.py b/pygameControls/logitech_f710_controller.py index 29345cc..9a3ff37 100644 --- a/pygameControls/logitech_f710_controller.py +++ b/pygameControls/logitech_f710_controller.py @@ -29,6 +29,7 @@ class LogitechF710Controller(ControlsBase): 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.connection_type = connection_type self.numaxis: int = self.device.get_numaxis() self.axis: list = [] From 7791e1de0b0feeae5ad5ce0f808b44e94def4eae Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:08:07 +0200 Subject: [PATCH 14/57] Update pygameControls/logitech_f510_controller.py --- pygameControls/logitech_f510_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygameControls/logitech_f510_controller.py b/pygameControls/logitech_f510_controller.py index aed0d84..c1a0df2 100644 --- a/pygameControls/logitech_f510_controller.py +++ b/pygameControls/logitech_f510_controller.py @@ -29,6 +29,7 @@ class LogitechF510Controller(ControlsBase): 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.connection_type = connection_type self.numaxis: int = self.device.get_numaxis() self.axis: list = [] From ff6f5ffa13427f3ff2d89daeb467362fd0171e7f Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:09:24 +0200 Subject: [PATCH 15/57] Update pygameControls/dualsense_edge_controller.py --- pygameControls/dualsense_edge_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygameControls/dualsense_edge_controller.py b/pygameControls/dualsense_edge_controller.py index 5ace8af..cf1765f 100644 --- a/pygameControls/dualsense_edge_controller.py +++ b/pygameControls/dualsense_edge_controller.py @@ -7,6 +7,7 @@ class DualSenseEdgeController(ControlsBase): self.device = pydualsense() self.device.init() self.name = self.device.device.get_product_string() + self.guid = self.device.get_guid() self.connection_type = connection_type self.powerlevel = self.device.battery.Level self.batterystate = BATTERY_STATE[str(self.device.battery.State)] From 148205d27a7e9da6c8502b3f72e670214b270543 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:09:42 +0200 Subject: [PATCH 16/57] Update pygameControls/dualsense_controller.py --- pygameControls/dualsense_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygameControls/dualsense_controller.py b/pygameControls/dualsense_controller.py index 742fdd0..bf0c010 100644 --- a/pygameControls/dualsense_controller.py +++ b/pygameControls/dualsense_controller.py @@ -15,6 +15,7 @@ class DualSenseController(ControlsBase): self.device = pydualsense() self.device.init() self.name = self.device.device.get_product_string() + self.guid = self.device.get_guid() self.connection_type = connection_type self.powerlevel = self.device.battery.Level self.batterystate = BATTERY_STATE[str(self.device.battery.State)] From f1a6f6e21da0e933614f824411fa144f2d4661a4 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:10:00 +0200 Subject: [PATCH 17/57] Update pygameControls/generic_controller.py --- pygameControls/generic_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygameControls/generic_controller.py b/pygameControls/generic_controller.py index 76fe57b..40fd9ac 100644 --- a/pygameControls/generic_controller.py +++ b/pygameControls/generic_controller.py @@ -6,8 +6,8 @@ class GenericController(ControlsBase): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() - self.connection_type = connection_type self.guid = self.device.get_guid() + self.connection_type = connection_type 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() From 6eb50802d41813f62268d6f97f181bddc7a21e01 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:10:17 +0200 Subject: [PATCH 18/57] Update pygameControls/logitech_dual_action_controller.py --- pygameControls/logitech_dual_action_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygameControls/logitech_dual_action_controller.py b/pygameControls/logitech_dual_action_controller.py index ab6ae12..be3f64d 100644 --- a/pygameControls/logitech_dual_action_controller.py +++ b/pygameControls/logitech_dual_action_controller.py @@ -25,8 +25,8 @@ class LogitechDualActionController(ControlsBase): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() - self.connection_type = connection_type self.guid = self.device.get_guid() + self.connection_type = connection_type self.powerlevel = self.device.get_power_level() self.numaxis: int = self.device.get_numaxes() self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)] From 95170bcd0d39037da612769d3f8af3046bd5e4ea Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:10:32 +0200 Subject: [PATCH 19/57] Update pygameControls/logitech_f310_controller.py --- pygameControls/logitech_f310_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygameControls/logitech_f310_controller.py b/pygameControls/logitech_f310_controller.py index 40f0454..678b9e9 100644 --- a/pygameControls/logitech_f310_controller.py +++ b/pygameControls/logitech_f310_controller.py @@ -25,8 +25,8 @@ class LogitechF310Controller(ControlsBase): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() - self.connection_type = connection_type self.guid = self.device.get_guid() + self.connection_type = connection_type self.powerlevel = self.device.get_power_level() self.numaxis: int = self.device.get_numaxes() self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)] From a5bf138ea5cc675b0fe4ef928509eaed5bfb0bed Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:11:00 +0200 Subject: [PATCH 20/57] Update pygameControls/playstation3_controller.py --- pygameControls/playstation3_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygameControls/playstation3_controller.py b/pygameControls/playstation3_controller.py index 86018f3..9e1fa1f 100644 --- a/pygameControls/playstation3_controller.py +++ b/pygameControls/playstation3_controller.py @@ -5,8 +5,8 @@ class PlayStation3Controller(ControlsBase): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() - self.connection_type = connection_type self.guid = self.device.get_guid() + self.connection_type = connection_type 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() From d9d604318caaaab04d8c53c499b500236fa913c3 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:11:15 +0200 Subject: [PATCH 21/57] Update pygameControls/sony_playstation3_controller.py --- pygameControls/sony_playstation3_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygameControls/sony_playstation3_controller.py b/pygameControls/sony_playstation3_controller.py index e703428..5c31981 100644 --- a/pygameControls/sony_playstation3_controller.py +++ b/pygameControls/sony_playstation3_controller.py @@ -5,8 +5,8 @@ class SonyPlayStation3Controller(ControlsBase): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() - self.connection_type = connection_type self.guid = self.device.get_guid() + self.connection_type = connection_type 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() From b78cc61b21ad0105c9d316624de2119526b50c34 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:11:29 +0200 Subject: [PATCH 22/57] Update pygameControls/xbox_series_x_controller.py --- pygameControls/xbox_series_x_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygameControls/xbox_series_x_controller.py b/pygameControls/xbox_series_x_controller.py index 5da1347..b64a631 100644 --- a/pygameControls/xbox_series_x_controller.py +++ b/pygameControls/xbox_series_x_controller.py @@ -5,8 +5,8 @@ class XboxSeriesXController(ControlsBase): self.device = joy self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() - self.connection_type = connection_type self.guid = self.device.get_guid() + self.connection_type = connection_type 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() From 88c5208aea38c9201feaf13b650bf515244dbacb Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:13:06 +0200 Subject: [PATCH 23/57] Add pygameControls/enums.py --- pygameControls/enums.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 pygameControls/enums.py diff --git a/pygameControls/enums.py b/pygameControls/enums.py new file mode 100644 index 0000000..3049da0 --- /dev/null +++ b/pygameControls/enums.py @@ -0,0 +1 @@ +from enums import Enum \ No newline at end of file From f2ea6a014b643a9cf3e6ca0528bd09c4d380612c Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:14:57 +0200 Subject: [PATCH 24/57] Update pygameControls/enums.py --- pygameControls/enums.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pygameControls/enums.py b/pygameControls/enums.py index 3049da0..447a2ec 100644 --- a/pygameControls/enums.py +++ b/pygameControls/enums.py @@ -1 +1,7 @@ -from enums import Enum \ No newline at end of file +from enum import Enum + +class ConnectionType(Enum): + 'usb' = 1 + 'bluetooth' = 2 + 'wireless' = 3 + 'unknown' = -1 \ No newline at end of file From 3b898462e08de0420a85adeb4e7daac58b1ae2cc Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:18:27 +0200 Subject: [PATCH 25/57] Update pygameControls/dualsense_controller.py --- pygameControls/dualsense_controller.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygameControls/dualsense_controller.py b/pygameControls/dualsense_controller.py index bf0c010..f419f26 100644 --- a/pygameControls/dualsense_controller.py +++ b/pygameControls/dualsense_controller.py @@ -1,4 +1,5 @@ from pygameControls.controlsbase import ControlsBase +from enums import ConnectionType from pydualsense import * BATTERY_STATE = { @@ -16,7 +17,7 @@ class DualSenseController(ControlsBase): self.device.init() self.name = self.device.device.get_product_string() self.guid = self.device.get_guid() - self.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) self.powerlevel = self.device.battery.Level self.batterystate = BATTERY_STATE[str(self.device.battery.State)] self.set_player_id(PlayerID.PLAYER_1) @@ -42,6 +43,7 @@ class DualSenseController(ControlsBase): print(f"{self.name} connected") print(f"Power level: {self.powerlevel}") print(f"Battery state: {self.batterystate}") + print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.close() From 3cccc1d1c7fc1c8e6443831778a21d0cd1dfb377 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:20:02 +0200 Subject: [PATCH 26/57] Update pygameControls/dualsense_edge_controller.py --- pygameControls/dualsense_edge_controller.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygameControls/dualsense_edge_controller.py b/pygameControls/dualsense_edge_controller.py index cf1765f..a380853 100644 --- a/pygameControls/dualsense_edge_controller.py +++ b/pygameControls/dualsense_edge_controller.py @@ -1,4 +1,5 @@ from pygameControls.controlsbase import ControlsBase +from enums import ConnectionType from pydualsense import * @@ -8,7 +9,7 @@ class DualSenseEdgeController(ControlsBase): self.device.init() self.name = self.device.device.get_product_string() self.guid = self.device.get_guid() - self.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) self.powerlevel = self.device.battery.Level self.batterystate = BATTERY_STATE[str(self.device.battery.State)] self.set_player_id(PlayerID.PLAYER_1) @@ -42,6 +43,7 @@ class DualSenseEdgeController(ControlsBase): print(f"{self.name} connected") print(f"Power level: {self.powerlevel}") print(f"Battery state: {self.batterystate}") + print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.close() From 1c2565cf39f4f6ca3b5d7ba0f137ffcbc065197a Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:22:33 +0200 Subject: [PATCH 27/57] Update pygameControls/generic_controller.py --- pygameControls/generic_controller.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygameControls/generic_controller.py b/pygameControls/generic_controller.py index 40fd9ac..04f3ea0 100644 --- a/pygameControls/generic_controller.py +++ b/pygameControls/generic_controller.py @@ -1,5 +1,6 @@ import pygame from pygameControls.controlsbase import ControlsBase +from enums import ConnectionType class GenericController(ControlsBase): def __init__(self, joy, connection_type): @@ -7,7 +8,7 @@ class GenericController(ControlsBase): self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() self.guid = self.device.get_guid() - self.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) 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() @@ -30,6 +31,7 @@ class GenericController(ControlsBase): "logo button": None } print(f"{self.name} connected.") + print(f"Connection type: {connection_type.capitalize()}") def close(self): pass From 8ac6883f17afaba70c98fdd5b30ba1f0b48fdcc4 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:23:59 +0200 Subject: [PATCH 28/57] Update pygameControls/logitech_dual_action_controller.py --- pygameControls/logitech_dual_action_controller.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pygameControls/logitech_dual_action_controller.py b/pygameControls/logitech_dual_action_controller.py index be3f64d..597b82d 100644 --- a/pygameControls/logitech_dual_action_controller.py +++ b/pygameControls/logitech_dual_action_controller.py @@ -14,19 +14,15 @@ This controller is a usb controller, with the following features. import pygame from pygameControls.controlsbase import ControlsBase -from enum import Enum +from enums import ConnectionType -class InputMode(Enum): - DirectInput = 1 - XInput = 2 - class LogitechDualActionController(ControlsBase): def __init__(self, joy, connection_type): 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.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) self.powerlevel = self.device.get_power_level() self.numaxis: int = self.device.get_numaxes() self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)] @@ -34,7 +30,6 @@ class LogitechDualActionController(ControlsBase): 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.input_mode = InputMode.DirectInput self.mapping = { "r2 trigger": 7, "l2 trigger": 6, @@ -51,6 +46,7 @@ class LogitechDualActionController(ControlsBase): "logo button": None } print(f"{self.name} connected.") + print(f"Connection type: {connection_type.capitalize()}") def close(self): pass From b356ce2d9f8dc9c5adffecc25a54e9468c490088 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:24:46 +0200 Subject: [PATCH 29/57] Update pygameControls/logitech_f310_controller.py --- pygameControls/logitech_f310_controller.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pygameControls/logitech_f310_controller.py b/pygameControls/logitech_f310_controller.py index 678b9e9..3a80d95 100644 --- a/pygameControls/logitech_f310_controller.py +++ b/pygameControls/logitech_f310_controller.py @@ -14,19 +14,15 @@ This controller is a usb controller, with the following features. import pygame from pygameControls.controlsbase import ControlsBase -from enum import Enum +from enums import ConnectionType -class InputMode(Enum): - DirectInput = 1 - XInput = 2 - class LogitechF310Controller(ControlsBase): def __init__(self, joy, connection_type): 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.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) self.powerlevel = self.device.get_power_level() self.numaxis: int = self.device.get_numaxes() self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)] @@ -49,6 +45,7 @@ class LogitechF310Controller(ControlsBase): "logo button": 8 } print(f"{self.name} connected.") + print(f"Connection type: {connection_type.capitalize()}") def close(self): pass From 9dea5d4c10e46247c4bfc703c6d1b5f55dd985af Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:26:03 +0200 Subject: [PATCH 30/57] Update pygameControls/logitech_f510_controller.py --- pygameControls/logitech_f510_controller.py | 31 +++------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/pygameControls/logitech_f510_controller.py b/pygameControls/logitech_f510_controller.py index c1a0df2..a723399 100644 --- a/pygameControls/logitech_f510_controller.py +++ b/pygameControls/logitech_f510_controller.py @@ -14,30 +14,21 @@ This controller is a usb controller, with the following features. import pygame from pygameControls.controlsbase import ControlsBase -from enum import Enum +from enums import ConnectionType -class InputMode(Enum): - DirectInput = 1 - XInput = 2 - -class ConnectionType(Enum): - WIRED = 1 - WIRELESS = 2 - class LogitechF510Controller(ControlsBase): def __init__(self, joy, connection_type): 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.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) self.numaxis: int = self.device.get_numaxis() self.axis: list = [] self.numhats: int = self.device.get_numhats() self.hats: list = [] self.numbuttons: int = self.device.get_numbuttons() self.buttons: list = [] - self.input_mode: InputMode.DirectInput self.mapping = { "l1 button": 4, "r1 button": 5, @@ -52,6 +43,7 @@ class LogitechF510Controller(ControlsBase): "logo button": 8 } print(f"{self.name} connected.") + print(f"Connection type: {connection_type.capitalize()}") def close(self): pass @@ -111,19 +103,4 @@ class LogitechF510Controller(ControlsBase): @buttons.setter def buttons(self) -> None: self._buttons = [self.device.get_buttons(b) for b in range(self.numbuttons)] - - @property - def input_mode(self) -> int: - return self._inputmode - - @input_mode.setter - def input_mode(self, mode: int) -> None: - self._inputmode = mode - - @property - def input_connection(self) -> int: - return self._input_connection - - @input_connection.setter - def input_connection(self, conn: int) -> None: - self._input_connection = conn \ No newline at end of file + \ No newline at end of file From b3603680d84cbe4737390cf7ee085b8843821644 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:26:25 +0200 Subject: [PATCH 31/57] Update pygameControls/logitech_f310_controller.py --- pygameControls/logitech_f310_controller.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pygameControls/logitech_f310_controller.py b/pygameControls/logitech_f310_controller.py index 3a80d95..1805ca6 100644 --- a/pygameControls/logitech_f310_controller.py +++ b/pygameControls/logitech_f310_controller.py @@ -30,7 +30,6 @@ class LogitechF310Controller(ControlsBase): 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.input_mode = InputMode.XInput self.mapping = { "l1 button": 4, "r1 button": 5, @@ -81,12 +80,4 @@ class LogitechF310Controller(ControlsBase): @name.setter def name(self, name: str) -> None: self._name = name - - @property - def input_mode(self) -> int: - return self._inputmode - - @input_mode.setter - def input_mode(self, mode: int) -> None: - self._inputmode = mode \ No newline at end of file From 40c6af15efcc1032b5589c88b00054054cbced39 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:26:43 +0200 Subject: [PATCH 32/57] Update pygameControls/logitech_dual_action_controller.py --- pygameControls/logitech_dual_action_controller.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pygameControls/logitech_dual_action_controller.py b/pygameControls/logitech_dual_action_controller.py index 597b82d..8f2896a 100644 --- a/pygameControls/logitech_dual_action_controller.py +++ b/pygameControls/logitech_dual_action_controller.py @@ -82,12 +82,4 @@ class LogitechDualActionController(ControlsBase): @name.setter def name(self, name: str) -> None: self._name = name - - @property - def input_mode(self) -> int: - return self._inputmode - - @input_mode.setter - def input_mode(self, mode: int) -> None: - self._inputmode = mode \ No newline at end of file From 94564057b9cc018cb84ff98e3811524471009440 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:27:49 +0200 Subject: [PATCH 33/57] Update pygameControls/logitech_f710_controller.py --- pygameControls/logitech_f710_controller.py | 31 +++------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/pygameControls/logitech_f710_controller.py b/pygameControls/logitech_f710_controller.py index 9a3ff37..b2284ae 100644 --- a/pygameControls/logitech_f710_controller.py +++ b/pygameControls/logitech_f710_controller.py @@ -14,30 +14,21 @@ This controller is a usb controller, with the following features. import pygame from pygameControls.controlsbase import ControlsBase -from enum import Enum +from enums import ConnectionType -class InputMode(Enum): - DirectInput = 1 - XInput = 2 - -class ConnectionType(Enum): - WIRED = 1 - WIRELESS = 2 - class LogitechF710Controller(ControlsBase): def __init__(self, joy, connection_type): 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.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) self.numaxis: int = self.device.get_numaxis() self.axis: list = [] self.numhats: int = self.device.get_numhats() self.hats: list = [] self.numbuttons: int = self.device.get_numbuttons() self.buttons: list = [] - self.input_mode: InputMode.DirectInput self.mapping = { "l1 button": 4, "r1 button": 5, @@ -52,6 +43,7 @@ class LogitechF710Controller(ControlsBase): "logo button": 8 } print(f"{self.name} connected.") + print(f"Connection type: {connection_type.capitalize()}") def close(self): pass @@ -111,19 +103,4 @@ class LogitechF710Controller(ControlsBase): @buttons.setter def buttons(self) -> None: self._buttons = [self.device.get_buttons(b) for b in range(self.numbuttons)] - - @property - def input_mode(self) -> int: - return self._inputmode - - @input_mode.setter - def input_mode(self, mode: int) -> None: - self._inputmode = mode - - @property - def input_connection(self) -> int: - return self._input_connection - - @input_connection.setter - def input_connection(self, conn: int) -> None: - self._input_connection = conn \ No newline at end of file + \ No newline at end of file From 82f908ae0a1cb5604e29cd24cb13bbcb1f270902 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:29:57 +0200 Subject: [PATCH 34/57] Update pygameControls/playstation3_controller.py --- pygameControls/playstation3_controller.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pygameControls/playstation3_controller.py b/pygameControls/playstation3_controller.py index 9e1fa1f..fb2a40a 100644 --- a/pygameControls/playstation3_controller.py +++ b/pygameControls/playstation3_controller.py @@ -1,4 +1,6 @@ from pygameControls.controlsbase import ControlsBase +from enums import ConnectionType +import pygame class PlayStation3Controller(ControlsBase): def __init__(self, joy, connection_type): @@ -6,7 +8,7 @@ class PlayStation3Controller(ControlsBase): self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() self.guid = self.device.get_guid() - self.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) 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() @@ -31,6 +33,7 @@ class PlayStation3Controller(ControlsBase): "right button": 16 } print(f"{self.name} connected.") + print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.quit() From 803df7e08763fadf36a16f9885535eef5a89ee62 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:30:54 +0200 Subject: [PATCH 35/57] Update pygameControls/xbox_series_x_controller.py --- pygameControls/xbox_series_x_controller.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pygameControls/xbox_series_x_controller.py b/pygameControls/xbox_series_x_controller.py index b64a631..29d7d5e 100644 --- a/pygameControls/xbox_series_x_controller.py +++ b/pygameControls/xbox_series_x_controller.py @@ -1,4 +1,6 @@ from pygameControls.controlsbase import ControlsBase +from enums import ConnectionType +import pygame class XboxSeriesXController(ControlsBase): def __init__(self, joy, connection_type): @@ -6,7 +8,7 @@ class XboxSeriesXController(ControlsBase): self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() self.guid = self.device.get_guid() - self.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) 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() @@ -28,6 +30,7 @@ class XboxSeriesXController(ControlsBase): "copy button": 10 } print(f"{self.name} connected.") + print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.quit() From 3f9dfec4132a0ab819522d1bb846991f72d4e4f9 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:31:48 +0200 Subject: [PATCH 36/57] Update pygameControls/sony_playstation3_controller.py --- pygameControls/sony_playstation3_controller.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pygameControls/sony_playstation3_controller.py b/pygameControls/sony_playstation3_controller.py index 5c31981..e61f8e9 100644 --- a/pygameControls/sony_playstation3_controller.py +++ b/pygameControls/sony_playstation3_controller.py @@ -1,4 +1,6 @@ from pygameControls.controlsbase import ControlsBase +from enums import ConnectionType +import pygame class SonyPlayStation3Controller(ControlsBase): def __init__(self, joy, connection_type): @@ -6,7 +8,7 @@ class SonyPlayStation3Controller(ControlsBase): self.instance_id: int = self.device.get_instance_id() self.name = self.device.get_name() self.guid = self.device.get_guid() - self.connection_type = connection_type + self.connection_type = ConnectionType(connection_type.values()) 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() @@ -31,6 +33,7 @@ class SonyPlayStation3Controller(ControlsBase): "right button": 16 } print(f"{self.name} connected.") + print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.quit() From 86b7e5dd132c594d2f26717e7b599c1f752eb7e4 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:33:28 +0200 Subject: [PATCH 37/57] Add pygameControls/playstation4_controller.py --- pygameControls/playstation4_controller.py | 74 +++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 pygameControls/playstation4_controller.py diff --git a/pygameControls/playstation4_controller.py b/pygameControls/playstation4_controller.py new file mode 100644 index 0000000..d44366d --- /dev/null +++ b/pygameControls/playstation4_controller.py @@ -0,0 +1,74 @@ +from pygameControls.controlsbase import ControlsBase +from enums import ConnectionType +import pygame + +class PlayStation4Controller(ControlsBase): + def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) + 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.") + print(f"Connection type: {connection_type.capitalize()}") + + 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 + \ No newline at end of file From 7c6275db4587427d402bd324b44cbb8cce5f31a5 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 09:34:10 +0200 Subject: [PATCH 38/57] Add pygameControls/sony_playstation4_controller.py --- .../sony_playstation4_controller.py | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 pygameControls/sony_playstation4_controller.py diff --git a/pygameControls/sony_playstation4_controller.py b/pygameControls/sony_playstation4_controller.py new file mode 100644 index 0000000..2080d47 --- /dev/null +++ b/pygameControls/sony_playstation4_controller.py @@ -0,0 +1,74 @@ +from pygameControls.controlsbase import ControlsBase +from enums import ConnectionType +import pygame + +class SonyPlayStation4Controller(ControlsBase): + def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) + 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.") + print(f"Connection type: {connection_type.capitalize()}") + + 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 + \ No newline at end of file From 4e8af089a0be38c5af07fc5066632a93038e2bc4 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 10:59:35 +0200 Subject: [PATCH 39/57] Update pygameControls/controller.py --- pygameControls/controller.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pygameControls/controller.py b/pygameControls/controller.py index 8530310..be018cb 100644 --- a/pygameControls/controller.py +++ b/pygameControls/controller.py @@ -9,6 +9,8 @@ from .logitech_f710_controller import LogitechF710Controller from .xbox_series_x_controller import XboxSeriesXController from .sony_playstation3_controller import SonyPlayStation3Controller from .playstation3_controller import PlayStation3Controller +from .sony_playstation4_controller import SonyPlayStation4Controller +from .playstation4_controller import PlayStation4Controller from .generic_controller import GenericController from .logitech_dual_action_controller import LogitechDualActionController @@ -23,7 +25,9 @@ CONTROLLERS = { "Logitech Dual Action": LogitechDualActionController, "Xbox Series X Controller": XboxSeriesXController, "Sony PLAYSTATION(R)3 Controller": SonyPlayStation3Controller, - "PLAYSTATION(R)3 Controller": PlayStation3Controller + "PLAYSTATION(R)3 Controller": PlayStation3Controller, + "Sony PLAYSTATION(R)4 Controller": SonyPlayStation4Controller, + "PLAYSTATION(R)4 Controller": PlayStation4Controller } class Controllers: From 480411b50ffcbdfd51a637a49a30e395e420759d Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 11:00:27 +0200 Subject: [PATCH 40/57] Add pygameControls/xbox_360_controller.py --- pygameControls/xbox_360_controller.py | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 pygameControls/xbox_360_controller.py diff --git a/pygameControls/xbox_360_controller.py b/pygameControls/xbox_360_controller.py new file mode 100644 index 0000000..de72303 --- /dev/null +++ b/pygameControls/xbox_360_controller.py @@ -0,0 +1,71 @@ +from pygameControls.controlsbase import ControlsBase +from enums import ConnectionType +import pygame + +class Xbox360Controller(ControlsBase): + def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) + 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": 6, + "r1 button": 7, + "X button": 3, + "Y button": 4, + "A button": 0, + "B button": 1, + "left stick button": 13, + "right stick button": 14, + "logo button": 12, + "share button": 15, + "list button": 11, + "copy button": 10 + } + print(f"{self.name} connected.") + print(f"Connection type: {connection_type.capitalize()}") + + 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 + \ No newline at end of file From d2bf9a8a1e0c9bbf1b526858827c32fd8a4017b3 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 11:26:55 +0200 Subject: [PATCH 41/57] Update pygameControls/enums.py --- pygameControls/enums.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pygameControls/enums.py b/pygameControls/enums.py index 447a2ec..8250bec 100644 --- a/pygameControls/enums.py +++ b/pygameControls/enums.py @@ -4,4 +4,9 @@ class ConnectionType(Enum): 'usb' = 1 'bluetooth' = 2 'wireless' = 3 + 'unknown' = -1 + +class InputType(Enum): + 'directinput' = 1 + 'xinput' = 2 'unknown' = -1 \ No newline at end of file From 74f2665a2fd5c8503fdec70367d9880c7b6c7af1 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 11:29:44 +0200 Subject: [PATCH 42/57] Update pygameControls/xbox_360_controller.py --- pygameControls/xbox_360_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/xbox_360_controller.py b/pygameControls/xbox_360_controller.py index de72303..ce79160 100644 --- a/pygameControls/xbox_360_controller.py +++ b/pygameControls/xbox_360_controller.py @@ -1,5 +1,5 @@ from pygameControls.controlsbase import ControlsBase -from enums import ConnectionType +from enums import ConnectionType, InputType import pygame class Xbox360Controller(ControlsBase): @@ -9,6 +9,7 @@ class Xbox360Controller(ControlsBase): self.name = self.device.get_name() self.guid = self.device.get_guid() self.connection_type = ConnectionType(connection_type.values()) + self.input_type = InputType.XInput 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() From e5f6d5697b3c830e5372a60b29e68dbb7a69c571 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 11:31:23 +0200 Subject: [PATCH 43/57] Update pygameControls/enums.py --- pygameControls/enums.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pygameControls/enums.py b/pygameControls/enums.py index 8250bec..394dd52 100644 --- a/pygameControls/enums.py +++ b/pygameControls/enums.py @@ -1,12 +1,12 @@ from enum import Enum class ConnectionType(Enum): - 'usb' = 1 - 'bluetooth' = 2 - 'wireless' = 3 - 'unknown' = -1 + USB = 1 + BLUETOOTH = 2 + WIRELESS = 3 + Unknown = -1 class InputType(Enum): - 'directinput' = 1 - 'xinput' = 2 - 'unknown' = -1 \ No newline at end of file + DirectInput = 1 + XInput = 2 + Unknown = -1 \ No newline at end of file From 263853da7f9d2d7c55cd339c5fedc6f075aecf14 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 11:49:42 +0200 Subject: [PATCH 44/57] Update pygameControls/xbox_series_x_controller.py --- pygameControls/xbox_series_x_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygameControls/xbox_series_x_controller.py b/pygameControls/xbox_series_x_controller.py index 29d7d5e..bf986d8 100644 --- a/pygameControls/xbox_series_x_controller.py +++ b/pygameControls/xbox_series_x_controller.py @@ -9,6 +9,7 @@ class XboxSeriesXController(ControlsBase): self.name = self.device.get_name() self.guid = self.device.get_guid() self.connection_type = ConnectionType(connection_type.values()) + self.input_type = InputType.XInput 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() From 9954e3c308bc2b70f988a7adc4f8ba0c7614a74a Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 12:48:01 +0200 Subject: [PATCH 45/57] Update pygameControls/controller.py --- pygameControls/controller.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygameControls/controller.py b/pygameControls/controller.py index be018cb..fe4b81f 100644 --- a/pygameControls/controller.py +++ b/pygameControls/controller.py @@ -13,6 +13,7 @@ from .sony_playstation4_controller import SonyPlayStation4Controller from .playstation4_controller import PlayStation4Controller from .generic_controller import GenericController from .logitech_dual_action_controller import LogitechDualActionController +from enums import InputType __version__ = "0.2.0" @@ -23,6 +24,7 @@ CONTROLLERS = { "Logitech Gamepad F510": LogitechF510Controller, "Logitech Gamepad F710": LogitechF710Controller, "Logitech Dual Action": LogitechDualActionController, + "Microsoft X-Box 360 pad": LogitechDualActionController "Xbox Series X Controller": XboxSeriesXController, "Sony PLAYSTATION(R)3 Controller": SonyPlayStation3Controller, "PLAYSTATION(R)3 Controller": PlayStation3Controller, From ae528e516b5c654b330b69afa36823f574f681a9 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 13:00:12 +0200 Subject: [PATCH 46/57] Add pygameControls/globals.py --- pygameControls/globals.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pygameControls/globals.py diff --git a/pygameControls/globals.py b/pygameControls/globals.py new file mode 100644 index 0000000..839c9a0 --- /dev/null +++ b/pygameControls/globals.py @@ -0,0 +1,36 @@ +from .enums import ConnectionType, InputType + +CONNECTIONS = { + "046d:c216": ConnectionType.USB, + "046d:c21d": ConnectionType.USB, + "045e:0b12": ConnectionType.USB, + "045e:0b13": ConnectionType.BLUETOOTH, + "045e:0b20": ConnectionType.BLUETOOTH, + "045e:0b21": ConnectionType.BLUETOOTH, + "054c:0ce6": ConnectionType.USB, + "054c:0df2"; ConnectionType.BLUETOOTH, + +} + +INPUTS = { + "046d:c216": InputType.DirectInput, + "046d:c21d": InputType.XInput, + "045e:0b12": InputType.XInput, + "045e:0b13": InputType.XInput, + "045e:0b20": InputType.XInput, + "045e:0b21": InputType.XInput, + "054c:0ce6": InputType.DirectInput, + "054c:0df2": InputType.DirectInput, +} + +VID_PID = { + "046d:c216": "Logitech Gamepad F310", + "046d:c21d": "Microsoft X-Box 360 pad", + "046d:c21d": "Logitech Dual Action", + "045e:0b12": "Xbox Series X Controller", + "045e:0b13": "Xbox Series X Controller", + "045e:0b20": "Xbox Series X Controller", + "045e:0b21": "Xbox Series X Controller", + "054c:0ce6": "Dualsense Controller", + "054c:0df2": "Dualsense Controller", +} \ No newline at end of file From 422cb858acfb1d6e302849b844c1e2b8995489d7 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 13:05:17 +0200 Subject: [PATCH 47/57] Update pygameControls/globals.py --- pygameControls/globals.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygameControls/globals.py b/pygameControls/globals.py index 839c9a0..0f6631b 100644 --- a/pygameControls/globals.py +++ b/pygameControls/globals.py @@ -31,6 +31,6 @@ VID_PID = { "045e:0b13": "Xbox Series X Controller", "045e:0b20": "Xbox Series X Controller", "045e:0b21": "Xbox Series X Controller", - "054c:0ce6": "Dualsense Controller", - "054c:0df2": "Dualsense Controller", + "054c:0ce6": "DualSense Wireless Controller", + "054c:0df2": "DualSense Wireless Controller", } \ No newline at end of file From 1004d0fef564a118dec588940d446595bb07a4c1 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 13:06:33 +0200 Subject: [PATCH 48/57] Update pygameControls/controller.py --- pygameControls/controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygameControls/controller.py b/pygameControls/controller.py index fe4b81f..c9fdb48 100644 --- a/pygameControls/controller.py +++ b/pygameControls/controller.py @@ -1,4 +1,5 @@ import pygame +from .globals import * from evdev import InputDevice, list_devices from .controlsbase import ControlsBase from .dualsense_controller import DualSenseController @@ -13,7 +14,7 @@ from .sony_playstation4_controller import SonyPlayStation4Controller from .playstation4_controller import PlayStation4Controller from .generic_controller import GenericController from .logitech_dual_action_controller import LogitechDualActionController -from enums import InputType +from .enums import InputType __version__ = "0.2.0" From 97908392f64e9a6c50e89327e94e3aff136e0e9c Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 13:28:39 +0200 Subject: [PATCH 49/57] Update pygameControls/globals.py --- pygameControls/globals.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pygameControls/globals.py b/pygameControls/globals.py index 0f6631b..c1d0456 100644 --- a/pygameControls/globals.py +++ b/pygameControls/globals.py @@ -33,4 +33,8 @@ VID_PID = { "045e:0b21": "Xbox Series X Controller", "054c:0ce6": "DualSense Wireless Controller", "054c:0df2": "DualSense Wireless Controller", +} + +SONY_GAMEPADS = { + } \ No newline at end of file From b236be16b75e665b62a6f542049756eef6c58cb7 Mon Sep 17 00:00:00 2001 From: Lerking Date: Mon, 5 May 2025 13:57:38 +0200 Subject: [PATCH 50/57] Update pygameControls/globals.py --- pygameControls/globals.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/pygameControls/globals.py b/pygameControls/globals.py index c1d0456..293db76 100644 --- a/pygameControls/globals.py +++ b/pygameControls/globals.py @@ -35,6 +35,34 @@ VID_PID = { "054c:0df2": "DualSense Wireless Controller", } -SONY_GAMEPADS = { - +GAMEPADS = { + "Sony DualSense (PS5)": { + [ + "vidpid": "054c:0ce6", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": ["DualSense Wireless Controller"] + ], + [ + "vidpid": "054c:0df2", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name" ["DualSense Wireless Controller"] + ] + }, + "Sony DualSense Edge (PS5)": { + [ + "vidhid": "054c:0dfc", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name" ["DualSense Edge Wireless Controller"] + ], + [ + "vidhid": "054c:0dfc", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name": ["DualSense Edge Wireless Controller"] + ] + }, + "" } \ No newline at end of file From 53b3dc3761dc3d3c5b6223604fc6190c202d481d Mon Sep 17 00:00:00 2001 From: Lerking Date: Tue, 6 May 2025 07:04:22 +0200 Subject: [PATCH 51/57] Update pygameControls/logitech_f510_controller.py --- pygameControls/logitech_f510_controller.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pygameControls/logitech_f510_controller.py b/pygameControls/logitech_f510_controller.py index a723399..e35bf55 100644 --- a/pygameControls/logitech_f510_controller.py +++ b/pygameControls/logitech_f510_controller.py @@ -1,15 +1,8 @@ """ -Logitech F310 Controller class. -This controller is a usb controller, with the following features. -(XInput mode) -6 axis -11 buttons -1 hat - -(DirectInput mode) -4 axis -12 buttons -1 hat +Logitech F510 Controller class. +This controller should have the same setup as the F310, but with the addition of rumble effect. +I don't have this controller, so I haven't been able to verify the workings! +Subsequent updates will be done, based on updates for the F310. """ import pygame From 8acc3666dca0e9c40f76794c1b09419b536ae3ee Mon Sep 17 00:00:00 2001 From: Lerking Date: Tue, 6 May 2025 07:05:22 +0200 Subject: [PATCH 52/57] Update pygameControls/logitech_f710_controller.py --- pygameControls/logitech_f710_controller.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/pygameControls/logitech_f710_controller.py b/pygameControls/logitech_f710_controller.py index b2284ae..df01aee 100644 --- a/pygameControls/logitech_f710_controller.py +++ b/pygameControls/logitech_f710_controller.py @@ -1,15 +1,6 @@ """ -Logitech F310 Controller class. -This controller is a usb controller, with the following features. -(XInput mode) -6 axis -11 buttons -1 hat - -(DirectInput mode) -4 axis -12 buttons -1 hat +Logitech F710 Controller class. +This controller is a usb/wireless controller. """ import pygame From 25794ce68c6f9b1aef165fa8af1facbfef1015af Mon Sep 17 00:00:00 2001 From: Lerking Date: Tue, 6 May 2025 07:08:07 +0200 Subject: [PATCH 53/57] Update pygameControls/globals.py --- pygameControls/globals.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pygameControls/globals.py b/pygameControls/globals.py index 293db76..62f4bc7 100644 --- a/pygameControls/globals.py +++ b/pygameControls/globals.py @@ -41,13 +41,15 @@ GAMEPADS = { "vidpid": "054c:0ce6", "connection": ConnectionType.USB, "input": InputType.DirectInput, - "name": ["DualSense Wireless Controller"] + "name": ["DualSense Wireless Controller"], + "class": "DualSenseController" ], [ "vidpid": "054c:0df2", "connection": ConnectionType.BLUETOOTH, "input": InputType.DirectInput, - "name" ["DualSense Wireless Controller"] + "name" ["DualSense Wireless Controller"], + "class": "DualSenseController" ] }, "Sony DualSense Edge (PS5)": { @@ -55,13 +57,15 @@ GAMEPADS = { "vidhid": "054c:0dfc", "connection": ConnectionType.USB, "input": InputType.DirectInput, - "name" ["DualSense Edge Wireless Controller"] + "name" ["DualSense Edge Wireless Controller"], + "class": "DualSenseEdgeController" ], [ "vidhid": "054c:0dfc", "connection": ConnectionType.BLUETOOTH, "input": InputType.DirectInput, - "name": ["DualSense Edge Wireless Controller"] + "name": ["DualSense Edge Wireless Controller"], + "class": "DualSenseEdgeController" ] }, "" From 52264dc7cf62cb30a6bca3d1827552b5036d4bf6 Mon Sep 17 00:00:00 2001 From: Lerking Date: Tue, 6 May 2025 07:21:39 +0200 Subject: [PATCH 54/57] Update pygameControls/globals.py --- pygameControls/globals.py | 46 ++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/pygameControls/globals.py b/pygameControls/globals.py index 62f4bc7..85e6220 100644 --- a/pygameControls/globals.py +++ b/pygameControls/globals.py @@ -35,6 +35,21 @@ VID_PID = { "054c:0df2": "DualSense Wireless Controller", } +CONTROLLERS = { + "DualSense Wireless Controller": DualSenseController, + "DualSense Edge Wireless Controller": DualSenseEdgeController, + "Logitech Gamepad F310": LogitechF310Controller, + "Logitech Gamepad F510": LogitechF510Controller, + "Logitech Gamepad F710": LogitechF710Controller, + "Logitech Dual Action": LogitechDualActionController, + "Microsoft X-Box 360 pad": LogitechDualActionController + "Xbox Series X Controller": XboxSeriesXController, + "Sony PLAYSTATION(R)3 Controller": SonyPlayStation3Controller, + "PLAYSTATION(R)3 Controller": PlayStation3Controller, + "Sony PLAYSTATION(R)4 Controller": SonyPlayStation4Controller, + "PLAYSTATION(R)4 Controller": PlayStation4Controller + } + GAMEPADS = { "Sony DualSense (PS5)": { [ @@ -42,14 +57,14 @@ GAMEPADS = { "connection": ConnectionType.USB, "input": InputType.DirectInput, "name": ["DualSense Wireless Controller"], - "class": "DualSenseController" + "class": CONTROLLERS[DualSenseController] ], [ "vidpid": "054c:0df2", "connection": ConnectionType.BLUETOOTH, "input": InputType.DirectInput, "name" ["DualSense Wireless Controller"], - "class": "DualSenseController" + "class": CONTROLLERS[DualSenseController] ] }, "Sony DualSense Edge (PS5)": { @@ -58,15 +73,36 @@ GAMEPADS = { "connection": ConnectionType.USB, "input": InputType.DirectInput, "name" ["DualSense Edge Wireless Controller"], - "class": "DualSenseEdgeController" + "class": CONTROLLERS[DualSenseEdgeController] ], [ "vidhid": "054c:0dfc", "connection": ConnectionType.BLUETOOTH, "input": InputType.DirectInput, "name": ["DualSense Edge Wireless Controller"], - "class": "DualSenseEdgeController" + "class": CONTROLLERS[DualSenseEdgeController] ] }, - "" + "Sony DualShock 3 (PS3)": { + [ + "vidhid": "054c:0268", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": ["PLAYSTATION(R) 3 Controller"], + "class": CONTROLLERS[PlayStation3Controller] + ], + [ + "vidhid": None, + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name": ["Sony PLAYSTATION(R) 3 Controller"], + "class": CONTROLLERS[SonyPlayStation3Controller] + ] + }, + "Sony DualShock 4 v1 (PS4)": { + + }, + "Sony DualShock 4 v2 (PS4)": { + + } } \ No newline at end of file From 074bff27d65ecf484c525f696f59ec0f1ca34c21 Mon Sep 17 00:00:00 2001 From: Lerking Date: Tue, 6 May 2025 08:07:35 +0200 Subject: [PATCH 55/57] Update pygameControls/globals.py --- pygameControls/globals.py | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/pygameControls/globals.py b/pygameControls/globals.py index 85e6220..31ce0ae 100644 --- a/pygameControls/globals.py +++ b/pygameControls/globals.py @@ -54,6 +54,7 @@ GAMEPADS = { "Sony DualSense (PS5)": { [ "vidpid": "054c:0ce6", + "guid": "030000004c0500000c0e000011010000", "connection": ConnectionType.USB, "input": InputType.DirectInput, "name": ["DualSense Wireless Controller"], @@ -61,6 +62,7 @@ GAMEPADS = { ], [ "vidpid": "054c:0df2", + "guid": "030000004c0500000c0e000011010000", "connection": ConnectionType.BLUETOOTH, "input": InputType.DirectInput, "name" ["DualSense Wireless Controller"], @@ -100,9 +102,39 @@ GAMEPADS = { ] }, "Sony DualShock 4 v1 (PS4)": { - + [ + "vidhid": "054c:05c4", + "guid": "", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": ["DualShock 4 v1 Controller"], + "class": CONTROLLERS["PLAYSTATION(R)4 Controller"] + ], + [ + "vidhid": "054c:05c4", + "guid": "", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name": ["DualShock 4 v1 Controller"], + "class": CONTROLLERS["Sony PLAYSTATION(R)4 Controller"] + ] }, "Sony DualShock 4 v2 (PS4)": { - + [ + "vidhid": "054c:09cc", + "guid": "", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": ["DualShock 4 v2 Controller"], + "class": CONTROLLERS["PLAYSTATION(R)4 Controller"] + ], + [ + "vidhid": "054c:09cc", + "guid": "", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name": ["DualShock 4 v2 Controller"], + "class": CONTROLLERS["Sony PLAYSTATION(R)4 Controller"] + ] } } \ No newline at end of file From e99f8f761c466305134120cae8c2c4c3b03120a7 Mon Sep 17 00:00:00 2001 From: Lerking Date: Tue, 6 May 2025 08:13:16 +0200 Subject: [PATCH 56/57] Update pygameControls/globals.py --- pygameControls/globals.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/pygameControls/globals.py b/pygameControls/globals.py index 31ce0ae..8f3b231 100644 --- a/pygameControls/globals.py +++ b/pygameControls/globals.py @@ -1,28 +1,5 @@ from .enums import ConnectionType, InputType -CONNECTIONS = { - "046d:c216": ConnectionType.USB, - "046d:c21d": ConnectionType.USB, - "045e:0b12": ConnectionType.USB, - "045e:0b13": ConnectionType.BLUETOOTH, - "045e:0b20": ConnectionType.BLUETOOTH, - "045e:0b21": ConnectionType.BLUETOOTH, - "054c:0ce6": ConnectionType.USB, - "054c:0df2"; ConnectionType.BLUETOOTH, - -} - -INPUTS = { - "046d:c216": InputType.DirectInput, - "046d:c21d": InputType.XInput, - "045e:0b12": InputType.XInput, - "045e:0b13": InputType.XInput, - "045e:0b20": InputType.XInput, - "045e:0b21": InputType.XInput, - "054c:0ce6": InputType.DirectInput, - "054c:0df2": InputType.DirectInput, -} - VID_PID = { "046d:c216": "Logitech Gamepad F310", "046d:c21d": "Microsoft X-Box 360 pad", From e02148c9372e9555a8e8a8257421ce410b78638a Mon Sep 17 00:00:00 2001 From: Jan Lerking Date: Tue, 6 May 2025 20:47:01 +0200 Subject: [PATCH 57/57] GUID identification used to determine gamepad. /JL --- joystick.py | 2 +- joystick_debug.py | 55 ++++ main.py | 2 + pygameControls/controller.py | 62 +--- pygameControls/dualsense_controller.py | 6 +- pygameControls/dualsense_edge_controller.py | 4 +- pygameControls/generic_controller.py | 4 +- pygameControls/globals.py | 310 +++++++++++------- .../logitech_dual_action_controller.py | 4 +- pygameControls/logitech_f310_controller.py | 4 +- pygameControls/logitech_f510_controller.py | 4 +- pygameControls/logitech_f710_controller.py | 4 +- pygameControls/playstation3_controller.py | 4 +- pygameControls/playstation4_controller.py | 4 +- .../sony_playstation3_controller.py | 4 +- .../sony_playstation4_controller.py | 4 +- pygameControls/xbox_360_controller.py | 5 +- pygameControls/xbox_series_x_controller.py | 5 +- requirements.txt | 2 +- setup.py | 2 +- 20 files changed, 287 insertions(+), 204 deletions(-) create mode 100644 joystick_debug.py diff --git a/joystick.py b/joystick.py index 7e31275..75dee31 100644 --- a/joystick.py +++ b/joystick.py @@ -30,7 +30,7 @@ class TextPrint: def main(): # Set the width and height of the screen (width, height), and name the window. - screen = pygame.display.set_mode((500, 700)) + screen = pygame.display.set_mode((800, 700)) pygame.display.set_caption("Joystick example") # Used to manage how fast the screen updates. diff --git a/joystick_debug.py b/joystick_debug.py new file mode 100644 index 0000000..0315d82 --- /dev/null +++ b/joystick_debug.py @@ -0,0 +1,55 @@ +import os +import pygame +from evdev import InputDevice, list_devices + +def format_vidpid(info): + return f"{info.vendor:04x}:{info.product:04x}" + +def get_evdev_devices(): + evdev_devices = {} + for path in list_devices(): + try: + dev = InputDevice(path) + evdev_devices[os.path.basename(path)] = { + 'name': dev.name, + 'phys': dev.phys, + 'vidpid': format_vidpid(dev.info), + 'path': path + } + except Exception: + pass + return evdev_devices + +def match_evdev_to_pygame(): + pygame.init() + pygame.joystick.init() + + evdev_devices = get_evdev_devices() + + for i in range(pygame.joystick.get_count()): + js = pygame.joystick.Joystick(i) + js.init() + name = js.get_name() + guid = js.get_guid() + + # Try to guess the matching evdev device based on name + matched = None + for ev in evdev_devices.values(): + if name.lower() in ev['name'].lower() or ev['name'].lower() in name.lower(): + matched = ev + break + + print(f"Joystick {i}:") + print(f" pygame name : {name}") + print(f" pygame guid : {guid}") + if matched: + print(f" evdev name : {matched['name']}") + print(f" path : {matched['path']}") + print(f" phys : {matched['phys']}") + print(f" VID:PID : {matched['vidpid']}") + else: + print(f" evdev info : [not matched]") + print("-" * 40) + +if __name__ == "__main__": + match_evdev_to_pygame() diff --git a/main.py b/main.py index ff43ce7..ea05694 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,10 @@ import pygame import pygameControls as PC +from pygameControls import globals if __name__ == "__main__": pygame.init() + globals.init() done = False diff --git a/pygameControls/controller.py b/pygameControls/controller.py index c9fdb48..a1171cf 100644 --- a/pygameControls/controller.py +++ b/pygameControls/controller.py @@ -1,57 +1,21 @@ import pygame -from .globals import * -from evdev import InputDevice, list_devices -from .controlsbase import ControlsBase -from .dualsense_controller import DualSenseController -from .dualsense_edge_controller import DualSenseEdgeController -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 .sony_playstation3_controller import SonyPlayStation3Controller -from .playstation3_controller import PlayStation3Controller -from .sony_playstation4_controller import SonyPlayStation4Controller -from .playstation4_controller import PlayStation4Controller -from .generic_controller import GenericController -from .logitech_dual_action_controller import LogitechDualActionController -from .enums import InputType +from . import globals __version__ = "0.2.0" -CONTROLLERS = { - "DualSense Wireless Controller": DualSenseController, - "DualSense Edge Wireless Controller": DualSenseEdgeController, - "Logitech Gamepad F310": LogitechF310Controller, - "Logitech Gamepad F510": LogitechF510Controller, - "Logitech Gamepad F710": LogitechF710Controller, - "Logitech Dual Action": LogitechDualActionController, - "Microsoft X-Box 360 pad": LogitechDualActionController - "Xbox Series X Controller": XboxSeriesXController, - "Sony PLAYSTATION(R)3 Controller": SonyPlayStation3Controller, - "PLAYSTATION(R)3 Controller": PlayStation3Controller, - "Sony PLAYSTATION(R)4 Controller": SonyPlayStation4Controller, - "PLAYSTATION(R)4 Controller": PlayStation4Controller - } - class Controllers: def __init__(self, joy): self.controllers = [] - if not joy.get_name() in CONTROLLERS: - self.controllers.append(GenericController(joy, self.get_connection_type(joy.get_name()))) - else: - self.controllers.append(CONTROLLERS[joy.get_name()](joy, self.get_connection_type(joy.get_name()))) + cont = self.detect_controller(joy.get_guid()) + print(cont) + self.controllers.append(cont(joy)) - def get_connection_type(self, controller_name): - for path in list_devices() - device = InputDevice(path) - name = device.name.lower() - if name != controller_name.lower(): - continue - - if 'usb' in device.phys.lower(): - return 'usb' - elif 'bluetooth' in device.phys.lower(): - return 'bluetooth' - elif 'rf' in device.phys.lower() or 'wireless' in name: - return 'wireless' - \ No newline at end of file + def detect_controller(self, guid): + for gp in globals.GAMEPADS: + print(gp) + for p in globals.GAMEPADS[gp]: + print(p) + if p["guid"] != guid: + continue + return p["class"] + return globals.CONTROLLERS["Generic Controller"] \ No newline at end of file diff --git a/pygameControls/dualsense_controller.py b/pygameControls/dualsense_controller.py index f419f26..b8a063d 100644 --- a/pygameControls/dualsense_controller.py +++ b/pygameControls/dualsense_controller.py @@ -1,5 +1,5 @@ from pygameControls.controlsbase import ControlsBase -from enums import ConnectionType +from .enums import ConnectionType from pydualsense import * BATTERY_STATE = { @@ -12,12 +12,11 @@ BATTERY_STATE = { } class DualSenseController(ControlsBase): - def __init__(self, joy, connection_type): + def __init__(self, joy): self.device = pydualsense() self.device.init() self.name = self.device.device.get_product_string() self.guid = self.device.get_guid() - self.connection_type = ConnectionType(connection_type.values()) self.powerlevel = self.device.battery.Level self.batterystate = BATTERY_STATE[str(self.device.battery.State)] self.set_player_id(PlayerID.PLAYER_1) @@ -43,7 +42,6 @@ class DualSenseController(ControlsBase): print(f"{self.name} connected") print(f"Power level: {self.powerlevel}") print(f"Battery state: {self.batterystate}") - print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.close() diff --git a/pygameControls/dualsense_edge_controller.py b/pygameControls/dualsense_edge_controller.py index a380853..1d6287d 100644 --- a/pygameControls/dualsense_edge_controller.py +++ b/pygameControls/dualsense_edge_controller.py @@ -4,12 +4,11 @@ from pydualsense import * class DualSenseEdgeController(ControlsBase): - def __init__(self, joy, connection_type): + def __init__(self, joy): self.device = pydualsense() self.device.init() self.name = self.device.device.get_product_string() self.guid = self.device.get_guid() - self.connection_type = ConnectionType(connection_type.values()) self.powerlevel = self.device.battery.Level self.batterystate = BATTERY_STATE[str(self.device.battery.State)] self.set_player_id(PlayerID.PLAYER_1) @@ -43,7 +42,6 @@ class DualSenseEdgeController(ControlsBase): print(f"{self.name} connected") print(f"Power level: {self.powerlevel}") print(f"Battery state: {self.batterystate}") - print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.close() diff --git a/pygameControls/generic_controller.py b/pygameControls/generic_controller.py index 04f3ea0..0498ce9 100644 --- a/pygameControls/generic_controller.py +++ b/pygameControls/generic_controller.py @@ -3,12 +3,11 @@ from pygameControls.controlsbase import ControlsBase from enums import ConnectionType class GenericController(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) 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() @@ -31,7 +30,6 @@ class GenericController(ControlsBase): "logo button": None } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): pass diff --git a/pygameControls/globals.py b/pygameControls/globals.py index 8f3b231..cff0263 100644 --- a/pygameControls/globals.py +++ b/pygameControls/globals.py @@ -1,117 +1,207 @@ from .enums import ConnectionType, InputType -VID_PID = { - "046d:c216": "Logitech Gamepad F310", - "046d:c21d": "Microsoft X-Box 360 pad", - "046d:c21d": "Logitech Dual Action", - "045e:0b12": "Xbox Series X Controller", - "045e:0b13": "Xbox Series X Controller", - "045e:0b20": "Xbox Series X Controller", - "045e:0b21": "Xbox Series X Controller", - "054c:0ce6": "DualSense Wireless Controller", - "054c:0df2": "DualSense Wireless Controller", -} +from .controlsbase import ControlsBase +from .dualsense_controller import DualSenseController +from .dualsense_edge_controller import DualSenseEdgeController +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 .sony_playstation3_controller import SonyPlayStation3Controller +from .playstation3_controller import PlayStation3Controller +from .sony_playstation4_controller import SonyPlayStation4Controller +from .playstation4_controller import PlayStation4Controller +from .generic_controller import GenericController +from .logitech_dual_action_controller import LogitechDualActionController -CONTROLLERS = { - "DualSense Wireless Controller": DualSenseController, - "DualSense Edge Wireless Controller": DualSenseEdgeController, - "Logitech Gamepad F310": LogitechF310Controller, - "Logitech Gamepad F510": LogitechF510Controller, - "Logitech Gamepad F710": LogitechF710Controller, - "Logitech Dual Action": LogitechDualActionController, - "Microsoft X-Box 360 pad": LogitechDualActionController - "Xbox Series X Controller": XboxSeriesXController, - "Sony PLAYSTATION(R)3 Controller": SonyPlayStation3Controller, - "PLAYSTATION(R)3 Controller": PlayStation3Controller, - "Sony PLAYSTATION(R)4 Controller": SonyPlayStation4Controller, - "PLAYSTATION(R)4 Controller": PlayStation4Controller +def init(): + global VID_PID + VID_PID = { + "046d:c216": "Logitech Gamepad F310", + "046d:c21d": "Microsoft X-Box 360 pad", + "046d:c21d": "Logitech Dual Action", + "045e:0b12": "Xbox Series X Controller", + "045e:0b13": "Xbox Series X Controller", + "045e:0b20": "Xbox Series X Controller", + "045e:0b21": "Xbox Series X Controller", + "054c:0ce6": "DualSense Wireless Controller", + "054c:0df2": "DualSense Wireless Controller", } - -GAMEPADS = { - "Sony DualSense (PS5)": { - [ - "vidpid": "054c:0ce6", - "guid": "030000004c0500000c0e000011010000", - "connection": ConnectionType.USB, - "input": InputType.DirectInput, - "name": ["DualSense Wireless Controller"], - "class": CONTROLLERS[DualSenseController] + global CONTROLLERS + CONTROLLERS = { + "DualSense Wireless Controller": DualSenseController, + "DualSense Edge Wireless Controller": DualSenseEdgeController, + "Logitech Gamepad F310": LogitechF310Controller, + "Logitech Gamepad F510": LogitechF510Controller, + "Logitech Gamepad F710": LogitechF710Controller, + "Logitech Dual Action": LogitechDualActionController, + "Microsoft X-Box 360 pad": LogitechDualActionController, + "Xbox Series X Controller": XboxSeriesXController, + "Sony PLAYSTATION(R)3 Controller": SonyPlayStation3Controller, + "PLAYSTATION(R)3 Controller": PlayStation3Controller, + "Sony PLAYSTATION(R)4 Controller": SonyPlayStation4Controller, + "PLAYSTATION(R)4 Controller": PlayStation4Controller, + "Generic Controller": GenericController + } + global GAMEPADS + GAMEPADS = { + "Sony Controller": [ + { + "vidpid": "054c:0ce6", + "guid": "0300fd574c050000e60c000011810000", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": [ + "Sony Interactive Entertainment DualSense Wireless Controller", + "Sony Corp. DualSense wireless controller (PS5)", + "DualSense Wireless Controller" + ], + "class": CONTROLLERS["DualSense Wireless Controller"] + }, + { + "vidpid": "054c:0df2", + "guid": "050057564c050000e60c000000810000", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name": [ + "DualSense Wireless Controller" + ], + "class": CONTROLLERS["DualSense Wireless Controller"] + }, + { + "vidpid": "054c:0dfc", + "guid": "", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": ["DualSense Edge Wireless Controller"], + "class": CONTROLLERS["DualSense Edge Wireless Controller"] + }, + { + "vidpid": "054c:0dfc", + "guid": "", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name": ["DualSense Edge Wireless Controller"], + "class": CONTROLLERS["DualSense Edge Wireless Controller"] + }, + { + "vidpid": "054c:0268", + "guid": "0300afd34c0500006802000011810000", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": ["Sony PLAYSTATION(R)3 Controller"], + "class": CONTROLLERS["Sony PLAYSTATION(R)3 Controller"] + }, + { + "vidpid": "", + "guid": "0500f9d24c0500006802000000800000", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name": ["PLAYSTATION(R)3 Controller"], + "class": CONTROLLERS["PLAYSTATION(R)3 Controller"] + }, + { + "vidpid": "054c:05c4", + "guid": "", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": ["DualShock 4 v1 Controller"], + "class": CONTROLLERS["PLAYSTATION(R)4 Controller"] + }, + { + "vidpid": "054c:05c4", + "guid": "", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name": ["DualShock 4 v1 Controller"], + "class": CONTROLLERS["Sony PLAYSTATION(R)4 Controller"] + }, + { + "vidpid": "054c:09cc", + "guid": "", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": ["DualShock 4 v2 Controller"], + "class": CONTROLLERS["PLAYSTATION(R)4 Controller"] + }, + { + "vidpid": "054c:09cc", + "guid": "", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.DirectInput, + "name": ["DualShock 4 v2 Controller"], + "class": CONTROLLERS["Sony PLAYSTATION(R)4 Controller"] + } ], - [ - "vidpid": "054c:0df2", - "guid": "030000004c0500000c0e000011010000", - "connection": ConnectionType.BLUETOOTH, - "input": InputType.DirectInput, - "name" ["DualSense Wireless Controller"], - "class": CONTROLLERS[DualSenseController] - ] - }, - "Sony DualSense Edge (PS5)": { - [ - "vidhid": "054c:0dfc", - "connection": ConnectionType.USB, - "input": InputType.DirectInput, - "name" ["DualSense Edge Wireless Controller"], - "class": CONTROLLERS[DualSenseEdgeController] + "Microsoft Controller": [ + { + "vidpid": "045e:0b12", + "guid": "0300509d5e040000120b000017050000", + "connection": ConnectionType.USB, + "input": InputType.XInput, + "name": [ + "Xbox Series X Controller", + "Microsoft Corp. Xbox Controller" + ], + "class": CONTROLLERS["Xbox Series X Controller"] + }, + { + "vidpid": "045e:0b13", + "guid": "0500509d5e040000130b000023050000", + "connection": ConnectionType.BLUETOOTH, + "input": InputType.XInput, + "name": [ + "Xbox Series X Controller", + "Xbox Wireless Controller" + ], + "class": CONTROLLERS["Xbox Series X Controller"] + } ], - [ - "vidhid": "054c:0dfc", - "connection": ConnectionType.BLUETOOTH, - "input": InputType.DirectInput, - "name": ["DualSense Edge Wireless Controller"], - "class": CONTROLLERS[DualSenseEdgeController] + "Logitech Controller": [ + { + "vidpid": "046d:c21d", + "guid": "030005ff6d0400001dc2000014400000", + "connection": ConnectionType.USB, + "input": InputType.XInput, + "name": [ + "Logitech, Inc. F310 Gamepad [XInput Mode]", + "Logitech Gamepad F310" + ], + "class": CONTROLLERS["Logitech Gamepad F310"] + }, + { + "vidpid": "046d:c216", + "guid": "0300040e6d04000016c2000011010000", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": [ + "Logitech, Inc. F310 Gamepad [DirectInput Mode]", + "Logitech Dual Action", + "Logitech Logitech Dual Action" + ], + "class": CONTROLLERS["Logitech Dual Action"] + }, + { + "vidpid": "046d:c21d", + "guid": "", + "connection": ConnectionType.USB, + "input": InputType.XInput, + "name": [ + "Logitech, Inc. F710 Gamepad [XInput Mode]", + "Logitech Gamepad F710" + ], + "class": CONTROLLERS["Logitech Gamepad F710"] + }, + { + "vidpid": "046d:c216", + "guid": "", + "connection": ConnectionType.USB, + "input": InputType.DirectInput, + "name": [ + "Logitech, Inc. F710 Gamepad [DirectInput Mode]", + "Logitech Dual Action" + ], + "class": CONTROLLERS["Logitech Dual Action"] + } ] - }, - "Sony DualShock 3 (PS3)": { - [ - "vidhid": "054c:0268", - "connection": ConnectionType.USB, - "input": InputType.DirectInput, - "name": ["PLAYSTATION(R) 3 Controller"], - "class": CONTROLLERS[PlayStation3Controller] - ], - [ - "vidhid": None, - "connection": ConnectionType.BLUETOOTH, - "input": InputType.DirectInput, - "name": ["Sony PLAYSTATION(R) 3 Controller"], - "class": CONTROLLERS[SonyPlayStation3Controller] - ] - }, - "Sony DualShock 4 v1 (PS4)": { - [ - "vidhid": "054c:05c4", - "guid": "", - "connection": ConnectionType.USB, - "input": InputType.DirectInput, - "name": ["DualShock 4 v1 Controller"], - "class": CONTROLLERS["PLAYSTATION(R)4 Controller"] - ], - [ - "vidhid": "054c:05c4", - "guid": "", - "connection": ConnectionType.BLUETOOTH, - "input": InputType.DirectInput, - "name": ["DualShock 4 v1 Controller"], - "class": CONTROLLERS["Sony PLAYSTATION(R)4 Controller"] - ] - }, - "Sony DualShock 4 v2 (PS4)": { - [ - "vidhid": "054c:09cc", - "guid": "", - "connection": ConnectionType.USB, - "input": InputType.DirectInput, - "name": ["DualShock 4 v2 Controller"], - "class": CONTROLLERS["PLAYSTATION(R)4 Controller"] - ], - [ - "vidhid": "054c:09cc", - "guid": "", - "connection": ConnectionType.BLUETOOTH, - "input": InputType.DirectInput, - "name": ["DualShock 4 v2 Controller"], - "class": CONTROLLERS["Sony PLAYSTATION(R)4 Controller"] - ] - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/pygameControls/logitech_dual_action_controller.py b/pygameControls/logitech_dual_action_controller.py index 8f2896a..8848236 100644 --- a/pygameControls/logitech_dual_action_controller.py +++ b/pygameControls/logitech_dual_action_controller.py @@ -17,12 +17,11 @@ from pygameControls.controlsbase import ControlsBase from enums import ConnectionType class LogitechDualActionController(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) self.powerlevel = self.device.get_power_level() self.numaxis: int = self.device.get_numaxes() self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)] @@ -46,7 +45,6 @@ class LogitechDualActionController(ControlsBase): "logo button": None } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): pass diff --git a/pygameControls/logitech_f310_controller.py b/pygameControls/logitech_f310_controller.py index 1805ca6..cd6cffb 100644 --- a/pygameControls/logitech_f310_controller.py +++ b/pygameControls/logitech_f310_controller.py @@ -17,12 +17,11 @@ from pygameControls.controlsbase import ControlsBase from enums import ConnectionType class LogitechF310Controller(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) self.powerlevel = self.device.get_power_level() self.numaxis: int = self.device.get_numaxes() self.axis: list = [self.device.get_axis(a) for a in range(self.numaxis)] @@ -44,7 +43,6 @@ class LogitechF310Controller(ControlsBase): "logo button": 8 } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): pass diff --git a/pygameControls/logitech_f510_controller.py b/pygameControls/logitech_f510_controller.py index e35bf55..344e41b 100644 --- a/pygameControls/logitech_f510_controller.py +++ b/pygameControls/logitech_f510_controller.py @@ -10,12 +10,11 @@ from pygameControls.controlsbase import ControlsBase from enums import ConnectionType class LogitechF510Controller(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) self.numaxis: int = self.device.get_numaxis() self.axis: list = [] self.numhats: int = self.device.get_numhats() @@ -36,7 +35,6 @@ class LogitechF510Controller(ControlsBase): "logo button": 8 } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): pass diff --git a/pygameControls/logitech_f710_controller.py b/pygameControls/logitech_f710_controller.py index df01aee..c743931 100644 --- a/pygameControls/logitech_f710_controller.py +++ b/pygameControls/logitech_f710_controller.py @@ -8,12 +8,11 @@ from pygameControls.controlsbase import ControlsBase from enums import ConnectionType class LogitechF710Controller(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) self.numaxis: int = self.device.get_numaxis() self.axis: list = [] self.numhats: int = self.device.get_numhats() @@ -34,7 +33,6 @@ class LogitechF710Controller(ControlsBase): "logo button": 8 } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): pass diff --git a/pygameControls/playstation3_controller.py b/pygameControls/playstation3_controller.py index fb2a40a..6a02782 100644 --- a/pygameControls/playstation3_controller.py +++ b/pygameControls/playstation3_controller.py @@ -3,12 +3,11 @@ from enums import ConnectionType import pygame class PlayStation3Controller(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) 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() @@ -33,7 +32,6 @@ class PlayStation3Controller(ControlsBase): "right button": 16 } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.quit() diff --git a/pygameControls/playstation4_controller.py b/pygameControls/playstation4_controller.py index d44366d..d667f4f 100644 --- a/pygameControls/playstation4_controller.py +++ b/pygameControls/playstation4_controller.py @@ -3,12 +3,11 @@ from enums import ConnectionType import pygame class PlayStation4Controller(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) 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() @@ -33,7 +32,6 @@ class PlayStation4Controller(ControlsBase): "right button": 16 } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.quit() diff --git a/pygameControls/sony_playstation3_controller.py b/pygameControls/sony_playstation3_controller.py index e61f8e9..b272b1b 100644 --- a/pygameControls/sony_playstation3_controller.py +++ b/pygameControls/sony_playstation3_controller.py @@ -3,12 +3,11 @@ from enums import ConnectionType import pygame class SonyPlayStation3Controller(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) 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() @@ -33,7 +32,6 @@ class SonyPlayStation3Controller(ControlsBase): "right button": 16 } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.quit() diff --git a/pygameControls/sony_playstation4_controller.py b/pygameControls/sony_playstation4_controller.py index 2080d47..316e972 100644 --- a/pygameControls/sony_playstation4_controller.py +++ b/pygameControls/sony_playstation4_controller.py @@ -3,12 +3,11 @@ from enums import ConnectionType import pygame class SonyPlayStation4Controller(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) 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() @@ -33,7 +32,6 @@ class SonyPlayStation4Controller(ControlsBase): "right button": 16 } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.quit() diff --git a/pygameControls/xbox_360_controller.py b/pygameControls/xbox_360_controller.py index ce79160..3d9aaf5 100644 --- a/pygameControls/xbox_360_controller.py +++ b/pygameControls/xbox_360_controller.py @@ -3,13 +3,11 @@ from enums import ConnectionType, InputType import pygame class Xbox360Controller(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) - self.input_type = InputType.XInput 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() @@ -31,7 +29,6 @@ class Xbox360Controller(ControlsBase): "copy button": 10 } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.quit() diff --git a/pygameControls/xbox_series_x_controller.py b/pygameControls/xbox_series_x_controller.py index bf986d8..a735fca 100644 --- a/pygameControls/xbox_series_x_controller.py +++ b/pygameControls/xbox_series_x_controller.py @@ -3,13 +3,11 @@ from enums import ConnectionType import pygame class XboxSeriesXController(ControlsBase): - def __init__(self, joy, connection_type): + 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.connection_type = ConnectionType(connection_type.values()) - self.input_type = InputType.XInput 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() @@ -31,7 +29,6 @@ class XboxSeriesXController(ControlsBase): "copy button": 10 } print(f"{self.name} connected.") - print(f"Connection type: {connection_type.capitalize()}") def close(self): self.device.quit() diff --git a/requirements.txt b/requirements.txt index 78b8367..3b1f5f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ pulsectl==24.12.0 pydualsense==0.7.3 pygame==2.6.1 setuptools==68.2.2 -sounddevice==0.5.1 +sounddevice==0.5.1 \ No newline at end of file diff --git a/setup.py b/setup.py index d6fde79..03c5b1a 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ if __name__ == "__main__": setup( name='pygameControls', - version='0.1.13', + version='0.2.0', packages=find_packages(), install_requires=[], author='Jan Lerking',