21 Commits
v0.2.0 ... main

Author SHA1 Message Date
0a3042b93c Merge pull request 'Added Logitech Rumblepad 2. /JL' (#30) from 0.2.7 into main
Reviewed-on: #30
2025-05-13 14:01:21 +02:00
73fecc1904 Added Logitech Rumblepad 2. /JL
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-13 14:01:01 +02:00
ed252a6548 Merge pull request 'Added Logitech F710 gamepad. /JL' (#29) from 0.2.6 into main
Reviewed-on: #29
2025-05-13 13:57:42 +02:00
ad3214dd23 Added Logitech F710 gamepad. /JL
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-13 13:57:10 +02:00
311b047bf5 Merge pull request 'Removed debuging prints. /JL' (#28) from 0.2.5 into main
Reviewed-on: #28
2025-05-07 21:46:57 +02:00
13901aeb50 Removed debuging prints. /JL
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-07 21:44:07 +02:00
5f3f25cc8c Merge pull request 'Updated initialization code. /JL' (#27) from 0.2.4 into main
Reviewed-on: #27
2025-05-07 21:41:01 +02:00
96ae8860d5 Updated initialization code. /JL
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-07 21:40:40 +02:00
8a8f6deb89 Merge pull request 'Updated DualShock4 support. /JL' (#26) from 0.2.3 into main
Reviewed-on: #26
2025-05-07 21:34:21 +02:00
79230bfef3 Updated DualShock4 support. /JL
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-07 21:33:46 +02:00
063af49887 Merge pull request '0.2.2' (#25) from 0.2.2 into main
Reviewed-on: #25
2025-05-07 16:49:36 +02:00
21da6857b0 Updated. /JL
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-07 16:48:39 +02:00
0a892386ae Update README.md
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-07 07:30:05 +02:00
83d7177a78 Update README.md
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-07 07:21:12 +02:00
cc8afa8519 Update README.md
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-07 07:20:11 +02:00
4cf83ce9d1 Update README.md
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-07 07:19:22 +02:00
30379bd8e3 Add .gitea/workflows/test.yml
Some checks failed
Run Controller Tests / test (push) Has been cancelled
2025-05-07 07:10:10 +02:00
a6b4964e80 Update pygameControls/tests/test_controller.py 2025-05-07 06:49:57 +02:00
98ea8ef5b9 Add pygameControls/tests/test_controller.py 2025-05-07 06:29:41 +02:00
985e6a769d Merge pull request 'Cleanup code. /JL' (#24) from 0.2.1 into main
Reviewed-on: #24
2025-05-06 20:58:28 +02:00
b0d364b15e Cleanup code. /JL 2025-05-06 20:57:58 +02:00
20 changed files with 76 additions and 32 deletions

29
.gitea/workflows/test.yml Normal file
View File

@@ -0,0 +1,29 @@
name: Run Controller Tests
on:
push:
branches-ignore: [ main ]
pull-request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/setup-python@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Dependencies
run:
python -m pip install --upgrade pip
pip install pygame
- name: Run Unit Tests
run:
python -m unittest discover tests

View File

@@ -1,3 +1,6 @@
# PyGame-Controller
Small module to make it easy to add controller support.
Small module to make it easy to add controller support.
![Tests](https://gitpot-lerking.servehttp.com/api/v1/badges/CodingPirates/PyGame-Controller/workflows/test.yml)
![Version](https://img.shields.io/badge/version-0.2.5-blue)

View File

@@ -4,7 +4,6 @@ from pygameControls import globals
if __name__ == "__main__":
pygame.init()
globals.init()
done = False

View File

@@ -1,20 +1,18 @@
import pygame
from . import globals
__version__ = "0.2.0"
__version__ = "0.2.7"
class Controllers:
def __init__(self, joy):
globals.init()
self.controllers = []
cont = self.detect_controller(joy.get_guid())
print(cont)
self.controllers.append(cont(joy))
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"]

View File

@@ -1,5 +1,4 @@
from pygameControls.controlsbase import ControlsBase
from .enums import ConnectionType
from pydualsense import *
BATTERY_STATE = {

View File

@@ -1,5 +1,4 @@
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
from pydualsense import *

View File

@@ -1,6 +1,5 @@
import pygame
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
class GenericController(ControlsBase):
def __init__(self, joy):

View File

@@ -126,10 +126,10 @@ def init():
},
{
"vidpid": "054c:09cc",
"guid": "",
"guid": "05009b514c050000cc09000000810000",
"connection": ConnectionType.BLUETOOTH,
"input": InputType.DirectInput,
"name": ["DualShock 4 v2 Controller"],
"name": ["Wireless Controller"],
"class": CONTROLLERS["Sony PLAYSTATION(R)4 Controller"]
}
],
@@ -183,7 +183,7 @@ def init():
},
{
"vidpid": "046d:c21d",
"guid": "",
"guid": "0333443e6d0400001fc2000005030000",
"connection": ConnectionType.USB,
"input": InputType.XInput,
"name": [
@@ -194,14 +194,15 @@ def init():
},
{
"vidpid": "046d:c216",
"guid": "",
"guid": "03005d8e6d04000019c2000011010000",
"connection": ConnectionType.USB,
"input": InputType.DirectInput,
"name": [
"Logitech, Inc. F710 Gamepad [DirectInput Mode]",
"Logitech Dual Action"
"Logitech Dual Action",
"Logitech Cordless Rumblepad 2"
],
"class": CONTROLLERS["Logitech Dual Action"]
"class": CONTROLLERS["Logitech Rumblepad 2"]
}
]
}

View File

@@ -14,7 +14,6 @@ This controller is a usb controller, with the following features.
import pygame
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
class LogitechDualActionController(ControlsBase):
def __init__(self, joy):

View File

@@ -14,7 +14,6 @@ This controller is a usb controller, with the following features.
import pygame
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
class LogitechF310Controller(ControlsBase):
def __init__(self, joy):

View File

@@ -7,7 +7,6 @@ Subsequent updates will be done, based on updates for the F310.
import pygame
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
class LogitechF510Controller(ControlsBase):
def __init__(self, joy):

View File

@@ -5,7 +5,6 @@ This controller is a usb/wireless controller.
import pygame
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
class LogitechF710Controller(ControlsBase):
def __init__(self, joy):

View File

@@ -1,5 +1,4 @@
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
import pygame
class PlayStation3Controller(ControlsBase):

View File

@@ -1,5 +1,4 @@
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
import pygame
class PlayStation4Controller(ControlsBase):

View File

@@ -1,5 +1,4 @@
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
import pygame
class SonyPlayStation3Controller(ControlsBase):

View File

@@ -1,5 +1,4 @@
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
import pygame
class SonyPlayStation4Controller(ControlsBase):
@@ -24,12 +23,8 @@ class SonyPlayStation4Controller(ControlsBase):
"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
"share button": 8,
"options button": 9
}
print(f"{self.name} connected.")

View File

@@ -0,0 +1,31 @@
import unittest
from unittest.mock import MagicMock
from pygameControls import Controller
class TestController(unittest.TestCase):
def setUp(self):
self.mock_js = MagicMock()
self.mock_js.get_button.side_effect = lambda i: 1 if i == 0 else 0
self.mock_js.get_axis.side_effect = lambda i: 0.5 if i == 1 else 0.0
self.mock_js.get_name.return_value = "DualSense Wireless Controller"
self.mock_js.get_guid.return_value = "030000004c0500000c0e000011010000"
self.controller = Controller(self.mock_js)
def test_button_press(self):
self.assertEqual(self.controller.get_button(0), 1)
self.assertEqual(self.controller.get_button(1), 0)
def test_axis_reading(self):
self.assertAlmostEqual(self.controller.get_axis(1), 0.5)
def test_profile_mapping(self):
self.assertEqual(self.controller.get_mapping(), "Sony DualSense")
def test_custom_config(self):
cfg = self.controller.get_custom_config()
self.assertIn("cross", cfg)
self.assertEqual(cfg["cross"], 0)
if __name__ == "__main__":
unittest.main()

View File

@@ -1,5 +1,4 @@
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType, InputType
import pygame
class Xbox360Controller(ControlsBase):

View File

@@ -1,5 +1,4 @@
from pygameControls.controlsbase import ControlsBase
from enums import ConnectionType
import pygame
class XboxSeriesXController(ControlsBase):

View File

@@ -3,7 +3,7 @@ if __name__ == "__main__":
setup(
name='pygameControls',
version='0.2.0',
version='0.2.7',
packages=find_packages(),
install_requires=[],
author='Jan Lerking',