13 Commits

Author SHA1 Message Date
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
19 changed files with 70 additions and 24 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.3-blue)

View File

@@ -1,7 +1,7 @@
import pygame
from . import globals
__version__ = "0.2.0"
__version__ = "0.2.3"
class Controllers:
def __init__(self, joy):

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"]
}
],

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.3',
packages=find_packages(),
install_requires=[],
author='Jan Lerking',