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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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