Python Gamepad
Project description
PyPad2
PyPad2
is simple and easy to use wrapper around evdev
to read gamepad input from XBOX/PS4 controller
License:
Python & Pypi:
Install & Upgrade:
# install via pypi
pip3 install pypad2
# upgrade
pip3 install --upgrade pypad2
Import:
from pypad2 import Gamepad, KeymapType, KeymapsPS
Usage:
Examples:
from pypad2 import Gamepad, KeymapsPS
# read button's and Axe's
def on_keys(keys):
if KeymapsPS.AXE_L2 in keys:
print(keys[KeymapsPS.AXE_L2])
if KeymapsPS.AXE_R2 in keys:
print(keys[KeymapsPS.AXE_R2])
# callback on successfully established connection
def on_begin():
print('controller connected & ready')
# callback on error
def on_error(error):
print(f"error: {error}")
gamepad = Gamepad() # create instance
gamepad.on_begin(callback=on_begin) # assign callback
gamepad.on_keys(callback=on_keys) # assign callback
gamepad.on_error(callback=on_error) # assign callback
gamepad.start() # read input | this is non-blocking, uses own thread
Author:
👨🏼💻 Vinzenz Weist
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pypad2-1.0.0.tar.gz
(16.2 kB
view details)
Built Distribution
pypad2-1.0.0-py3-none-any.whl
(16.9 kB
view details)
File details
Details for the file pypad2-1.0.0.tar.gz
.
File metadata
- Download URL: pypad2-1.0.0.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3d02898f9d70b1fa806ee9b5914bf140bb2bd1bf1818cf854b3005985a66d68 |
|
MD5 | 86bff17472bf05503d48ad3e1e390c26 |
|
BLAKE2b-256 | f455fc3f86278d2696fb7d85da793fee5ecbb30e7a064b4a77d94e2e2d845b07 |
File details
Details for the file pypad2-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pypad2-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73ec434a68b35d1709d036fad7f8e167d647a414f01b2eca90f40c06110cbb97 |
|
MD5 | f143ca666d6e4834c98f18480db7710a |
|
BLAKE2b-256 | 81fda9344d667fdab1cb59c7deb872d1288ca3ab4c00c1d99d168c73b1cb7305 |