JoyIT-WLGamepad 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- joyit_wlgamepad-1.0.0/JoyIT_WLGamepad.egg-info/PKG-INFO +45 -0
- joyit_wlgamepad-1.0.0/JoyIT_WLGamepad.egg-info/SOURCES.txt +12 -0
- joyit_wlgamepad-1.0.0/JoyIT_WLGamepad.egg-info/dependency_links.txt +1 -0
- joyit_wlgamepad-1.0.0/JoyIT_WLGamepad.egg-info/not-zip-safe +1 -0
- joyit_wlgamepad-1.0.0/JoyIT_WLGamepad.egg-info/requires.txt +1 -0
- joyit_wlgamepad-1.0.0/JoyIT_WLGamepad.egg-info/top_level.txt +1 -0
- joyit_wlgamepad-1.0.0/LICENSE +21 -0
- joyit_wlgamepad-1.0.0/PKG-INFO +45 -0
- joyit_wlgamepad-1.0.0/README.md +25 -0
- joyit_wlgamepad-1.0.0/pyproject.toml +22 -0
- joyit_wlgamepad-1.0.0/setup.cfg +4 -0
- joyit_wlgamepad-1.0.0/setup.py +20 -0
- joyit_wlgamepad-1.0.0/wlgamepad/__init__.py +3 -0
- joyit_wlgamepad-1.0.0/wlgamepad/wlgamepad.py +110 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: JoyIT_WLGamepad
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Library to use the SBC-WLGamepad with the Raspberry Pi
|
|
5
|
+
Home-page: https://github.com/joy-it/JoyIT_WLGamepad
|
|
6
|
+
Author: Joy-IT
|
|
7
|
+
Author-email: Joy-IT <service@joy-it.net>
|
|
8
|
+
Project-URL: Homepage, https://github.com/joy-it/JoyIT_WLGamepad
|
|
9
|
+
Project-URL: Issues, https://github.com/joy-it/JoyIT_WLGamepad/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: RPi.GPIO>=0.7.0
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: home-page
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
|
|
21
|
+
# JoyIT_WLGamepad
|
|
22
|
+
Library to use the SBC-WLGamepad with the Raspberry Pi
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
You can install this library from PyPI.
|
|
26
|
+
To install it for the current user on your Raspberry Pi, use the following command:
|
|
27
|
+
```
|
|
28
|
+
pip install JoyIT_WLGamepad
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
You need to clone this repository on your Raspberry Pi to be able to execute the example code.
|
|
33
|
+
```
|
|
34
|
+
git clone https://github.com/joy-it/JoyIT_WLGamepad
|
|
35
|
+
```
|
|
36
|
+
Afterward, you need to move into the directory and activate the virtual environment with the following commands.
|
|
37
|
+
```
|
|
38
|
+
cd JoyIT_WLGamepad
|
|
39
|
+
python -m venv --system-site-packages env
|
|
40
|
+
source env/bin/activate
|
|
41
|
+
```
|
|
42
|
+
Then you can execute the example with the following command.
|
|
43
|
+
```
|
|
44
|
+
python3 examples/example.py
|
|
45
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
JoyIT_WLGamepad.egg-info/PKG-INFO
|
|
6
|
+
JoyIT_WLGamepad.egg-info/SOURCES.txt
|
|
7
|
+
JoyIT_WLGamepad.egg-info/dependency_links.txt
|
|
8
|
+
JoyIT_WLGamepad.egg-info/not-zip-safe
|
|
9
|
+
JoyIT_WLGamepad.egg-info/requires.txt
|
|
10
|
+
JoyIT_WLGamepad.egg-info/top_level.txt
|
|
11
|
+
wlgamepad/__init__.py
|
|
12
|
+
wlgamepad/wlgamepad.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
RPi.GPIO>=0.7.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wlgamepad
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Joy-IT
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: JoyIT_WLGamepad
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Library to use the SBC-WLGamepad with the Raspberry Pi
|
|
5
|
+
Home-page: https://github.com/joy-it/JoyIT_WLGamepad
|
|
6
|
+
Author: Joy-IT
|
|
7
|
+
Author-email: Joy-IT <service@joy-it.net>
|
|
8
|
+
Project-URL: Homepage, https://github.com/joy-it/JoyIT_WLGamepad
|
|
9
|
+
Project-URL: Issues, https://github.com/joy-it/JoyIT_WLGamepad/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: RPi.GPIO>=0.7.0
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: home-page
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
|
|
21
|
+
# JoyIT_WLGamepad
|
|
22
|
+
Library to use the SBC-WLGamepad with the Raspberry Pi
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
You can install this library from PyPI.
|
|
26
|
+
To install it for the current user on your Raspberry Pi, use the following command:
|
|
27
|
+
```
|
|
28
|
+
pip install JoyIT_WLGamepad
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
You need to clone this repository on your Raspberry Pi to be able to execute the example code.
|
|
33
|
+
```
|
|
34
|
+
git clone https://github.com/joy-it/JoyIT_WLGamepad
|
|
35
|
+
```
|
|
36
|
+
Afterward, you need to move into the directory and activate the virtual environment with the following commands.
|
|
37
|
+
```
|
|
38
|
+
cd JoyIT_WLGamepad
|
|
39
|
+
python -m venv --system-site-packages env
|
|
40
|
+
source env/bin/activate
|
|
41
|
+
```
|
|
42
|
+
Then you can execute the example with the following command.
|
|
43
|
+
```
|
|
44
|
+
python3 examples/example.py
|
|
45
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# JoyIT_WLGamepad
|
|
2
|
+
Library to use the SBC-WLGamepad with the Raspberry Pi
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
You can install this library from PyPI.
|
|
6
|
+
To install it for the current user on your Raspberry Pi, use the following command:
|
|
7
|
+
```
|
|
8
|
+
pip install JoyIT_WLGamepad
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
You need to clone this repository on your Raspberry Pi to be able to execute the example code.
|
|
13
|
+
```
|
|
14
|
+
git clone https://github.com/joy-it/JoyIT_WLGamepad
|
|
15
|
+
```
|
|
16
|
+
Afterward, you need to move into the directory and activate the virtual environment with the following commands.
|
|
17
|
+
```
|
|
18
|
+
cd JoyIT_WLGamepad
|
|
19
|
+
python -m venv --system-site-packages env
|
|
20
|
+
source env/bin/activate
|
|
21
|
+
```
|
|
22
|
+
Then you can execute the example with the following command.
|
|
23
|
+
```
|
|
24
|
+
python3 examples/example.py
|
|
25
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "JoyIT_WLGamepad"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
dependencies = ['RPi.GPIO>=0.7.0']
|
|
9
|
+
authors = [
|
|
10
|
+
{ name="Joy-IT", email="service@joy-it.net" },
|
|
11
|
+
]
|
|
12
|
+
description = "Library to use the SBC-WLGamepad with the Raspberry Pi"
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
requires-python = ">=3.8"
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/joy-it/JoyIT_WLGamepad"
|
|
22
|
+
Issues = "https://github.com/joy-it/JoyIT_WLGamepad/issues"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="JoyIT_WLGamepad",
|
|
5
|
+
version="1.0.0",
|
|
6
|
+
description="Library to use the SBC-WLGamepad with the Raspberry Pi",
|
|
7
|
+
author="Joy-IT",
|
|
8
|
+
author_email="service@joy-it.net",
|
|
9
|
+
packages=find_packages(),
|
|
10
|
+
long_description=open('README.md').read(),
|
|
11
|
+
long_description_content_type='text/markdown',
|
|
12
|
+
url='https://github.com/joy-it/JoyIT_WLGamepad',
|
|
13
|
+
classifiers=[
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
'License :: OSI Approved :: MIT License',
|
|
16
|
+
'Operating System :: OS Independent',
|
|
17
|
+
],
|
|
18
|
+
python_requires='>=3.7',
|
|
19
|
+
zip_safe=False,
|
|
20
|
+
)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import RPi.GPIO as GPIO
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
class WLGamepad:
|
|
5
|
+
# define name of buttons
|
|
6
|
+
BUTTONS = [
|
|
7
|
+
"Select", "L3", "R3", "Start",
|
|
8
|
+
"Up", "Right", "Down", "Left",
|
|
9
|
+
"L2", "R2", "L1", "R1",
|
|
10
|
+
"Triangle", "Circle", "Cross", "Square"
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
def __init__(self, ATT = 17, CLK = 18 , CMD = 27 , DATA = 22 ):
|
|
14
|
+
"""
|
|
15
|
+
method to initilize controller with default pins
|
|
16
|
+
"""
|
|
17
|
+
# set pins with the communication
|
|
18
|
+
self.ATT = ATT
|
|
19
|
+
self.CLK = CLK
|
|
20
|
+
self.CMD = CMD
|
|
21
|
+
self.DATA = DATA
|
|
22
|
+
|
|
23
|
+
# initilize pins
|
|
24
|
+
GPIO.setmode(GPIO.BCM)
|
|
25
|
+
GPIO.setup(ATT, GPIO.OUT, initial=1)
|
|
26
|
+
GPIO.setup(CLK, GPIO.OUT, initial=1)
|
|
27
|
+
GPIO.setup(CMD, GPIO.OUT, initial=1)
|
|
28
|
+
GPIO.setup(DATA, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
|
29
|
+
|
|
30
|
+
def _transfer(self,data):
|
|
31
|
+
"""
|
|
32
|
+
method to transfer data to controller
|
|
33
|
+
"""
|
|
34
|
+
value = 0
|
|
35
|
+
for i in range(8):
|
|
36
|
+
GPIO.output(self.CMD, (data >> i) & 1)
|
|
37
|
+
GPIO.output(self.CLK, 0)
|
|
38
|
+
if GPIO.input(self.DATA) == 1:
|
|
39
|
+
value |= (1 << i)
|
|
40
|
+
GPIO.output(self.CLK, 1)
|
|
41
|
+
return value
|
|
42
|
+
|
|
43
|
+
def _enter_config_mode(self):
|
|
44
|
+
"""
|
|
45
|
+
method to enter configuration mode of controller
|
|
46
|
+
"""
|
|
47
|
+
GPIO.output(self.ATT, 0)
|
|
48
|
+
for b in [0x01, 0x43, 0x00, 0x01, 0x00]:
|
|
49
|
+
self._transfer(b)
|
|
50
|
+
GPIO.output(self.ATT, 1)
|
|
51
|
+
time.sleep(0.01)
|
|
52
|
+
|
|
53
|
+
def _enable_analog(self):
|
|
54
|
+
"""
|
|
55
|
+
method to enable analog keys (joysticks)
|
|
56
|
+
"""
|
|
57
|
+
GPIO.output(self.ATT, 0)
|
|
58
|
+
for b in [0x01, 0x44, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00]:
|
|
59
|
+
self._transfer(b)
|
|
60
|
+
GPIO.output(self.ATT, 1)
|
|
61
|
+
time.sleep(0.01)
|
|
62
|
+
|
|
63
|
+
def _exit_config_mode(self):
|
|
64
|
+
"""
|
|
65
|
+
method to exit configuration mode of controller
|
|
66
|
+
"""
|
|
67
|
+
GPIO.output(self.ATT, 0)
|
|
68
|
+
for b in [0x01, 0x43, 0x00, 0x00, 0x5A]:
|
|
69
|
+
self._transfer(b)
|
|
70
|
+
GPIO.output(self.ATT, 1)
|
|
71
|
+
time.sleep(0.05)
|
|
72
|
+
|
|
73
|
+
def read_controller(self):
|
|
74
|
+
"""
|
|
75
|
+
method which returns all controller values
|
|
76
|
+
"""
|
|
77
|
+
# setup reading of controller
|
|
78
|
+
GPIO.output(self.ATT, 0)
|
|
79
|
+
resp = [self._transfer(0x01), self._transfer(0x42), self._transfer(0x00)]
|
|
80
|
+
btn_low = self._transfer(0x00)
|
|
81
|
+
btn_high = self._transfer(0x00)
|
|
82
|
+
axes = [self._transfer(0x00) for _ in range(4)]
|
|
83
|
+
GPIO.output(self.ATT, 1)
|
|
84
|
+
|
|
85
|
+
# read which buttons are pressed
|
|
86
|
+
buttons = []
|
|
87
|
+
btn_word = (btn_high << 8) | btn_low
|
|
88
|
+
for i in range(16):
|
|
89
|
+
if not (btn_word & (1 << i)):
|
|
90
|
+
buttons.append(self.BUTTONS[i])
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
"id": resp[1], # Controller ID
|
|
94
|
+
"buttons": buttons, # pressed buttons
|
|
95
|
+
"sticks": {
|
|
96
|
+
"LX": axes[2],
|
|
97
|
+
"LY": axes[3],
|
|
98
|
+
"RX": axes[0],
|
|
99
|
+
"RY": axes[1] # analog values 0-255 of joystick axes
|
|
100
|
+
},
|
|
101
|
+
"raw": [f"{b:02X}" for b in resp + [btn_low, btn_high] + axes] # raw values
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
def setup_controller(self):
|
|
105
|
+
"""
|
|
106
|
+
method to setup communication with controller
|
|
107
|
+
"""
|
|
108
|
+
self._enter_config_mode()
|
|
109
|
+
self._enable_analog()
|
|
110
|
+
self._exit_config_mode()
|