Skip to main content

pyPS4Controller

PyPI version shields.io PyPI pyversions Downloads

pyPS4Controller is a light module designed to provide hooks for PS4 Controller using Python on Linux.

Installation

pip install pyPS4Controller

Usage

from pyPS4Controller.controller import Controller

class MyController(Controller):  # create a custom class for your controller and subclass Controller
    """
    If we want to bind an action to the X button on the controller, we need to override its respective methods.

    Some of the buttons have a binary On/Off state. For example the X, Circle, Square, and Triangle buttons.
    When overriding their respective methods there are no args in the function signature.

    Some controls like the L2, L3, R2 and R3 have a variable On state.
    When overriding their respective method, there is a value argument in the function signature 
    which indicates the degree of the input.
    """    
    def on_x_press(self):
        # Input any code that you want to run when X is pressed
        print("X pressed!")

    def on_x_release(self):
        # Input any code that you want to run when X is released
        print("X released!")

    def on_L3_up(self, value):
        # Input any code that you want to run when left joystick (L3) is pushed up
        # value will indicate the degree of how far the joystick is pushed
        print(f"L3 pushed up: {value}")

    def on_L3_release(self):
        # Input any code that you want to run when left joystick (L3) is back to its resting state
        print("L3 at rest!")

# now make sure the controller is paired over the Bluetooth and turn on the listener
MyController(interface="/dev/input/js0").listen()

Pair PS4 Controller with the Raspberry Pi

See detailed instructions here

Metadata

Release files for pyPS4Controller 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyPS4Controller 1.0.3
File Size Uploaded
pyPS4Controller-1.0.3.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyPS4Controller 1.0.3
File Interpreter ABI Platform
pyPS4Controller-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / pyPS4Controller-1.0.3.tar.gz

Download URL pyPS4Controller-1.0.3.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6988bb138959dc8d012ab78e3213d8bb1bb49539b406eba45189c7d708a8292b
BLAKE2b-256 checksum
How to use checksums
646ebecb4843cdb18cf43e0ebdac5647df97c9ab8151862d43c8a888b30c800e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

Release files / pyPS4Controller-1.0.3-py3-none-any.whl

Download URL pyPS4Controller-1.0.3-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfcc06f03583260dcf7a354e5c3a37db2416c2730fc05a13a24dc829ea6351cb
BLAKE2b-256 checksum
How to use checksums
307f6fc3916306b95265b912ba4be8a232fac89ae73fe252360d59784e937e36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

Release history Release notifications | RSS feed

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page