Skip to main content

Python Gamepad

Project description


PyPad2

PyPad2 is simple and easy to use wrapper around evdev to read gamepad input from XBOX/PS4 controller

License:

License

Python & Pypi:

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-0.0.9.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

pypad2-0.0.9-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file pypad2-0.0.9.tar.gz.

File metadata

  • Download URL: pypad2-0.0.9.tar.gz
  • Upload date:
  • Size: 16.1 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

Hashes for pypad2-0.0.9.tar.gz
Algorithm Hash digest
SHA256 6fc5697f5f3eaa95bd36d7e000136b9c1547061c88c3be96c34685553a4e641b
MD5 4227820e2eb3c43a298c41b0362f9ba3
BLAKE2b-256 a45b7aa6a80c5f2a57d4ed180ea2c4117852a77d2ab8e68e25e45e43f56922af

See more details on using hashes here.

File details

Details for the file pypad2-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: pypad2-0.0.9-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

Hashes for pypad2-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 28e056953a7ac44c2a89e0b84c196ed6f05d74e7dbaf25b9e31398046b56aece
MD5 059abd5b12eba5d3feb12d5fbde6a192
BLAKE2b-256 7718432faeb4bf7a292c54ba544d718290bd10534ff848f9a8143651fdee3b80

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page