Category PS4 CFW and Hacks       Thread starter PSXHAX       Start date Jan 28, 2020 at 3:38 PM       2,027       6            
Since we covered the PS4 Gentoo Linux Installation Guide, developer ArturSpirin shared pyPS4Controller on Github which is a light module designed to provide hooks for PlayStation 4 Controllers in homebrew development projects using Python with Raspberry Pi devices or on other Linux machines. šŸ§

Download: pyPS4Controller v1.0.8 / / GIT

From the pyPS4Controller

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

sudo pip install pyPS4Controller
  1. First, you have to make sure you can connect your PS4 controller with ds4drv. You can do it 1 of 2 ways.
    • Manually by following this instructions
    • Automatically by running py3ps4c init (if you are using python3) or py2ps4c init (if you are using python2) in your terminal.
  2. (Optional) connect your controller directly to the computer's Bluetooth module. Once successful, disconnect the controller. If you don't do this, in the next step you may see this error: Unable to connect to detected device: Failed to set operational mode: [Errno 107] Transport endpoint is not connected
  3. Now start sudo ds4drv and press SHARE + PS4 button on your controller. If pairing fails, you want to try in again, it should eventually connect.
  4. Copy the code bellow to a file, say
  5. Run it python
  6. Use your controller.
  7. Adjust logic in the code and integrate it with your RC needs!
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.

You can put any custom code inside the functions bellow. I have put print statements in there just so you
can copy/paste the code, connect controller, play with the inputs and see the result.

All of the functions that you can override are listed in this script.

def on_x_press(self):

def on_x_release(self):

def on_triangle_press(self):

def on_triangle_release(self):

def on_circle_press(self):

def on_circle_release(self):

def on_square_press(self):

def on_square_release(self):

def on_L1_press(self):

def on_L1_release(self):

def on_L2_press(self, value):
print("on_L2_press: ", value)

def on_L2_release(self):

def on_R1_press(self):

def on_R1_release(self):

def on_R2_press(self, value):
print("on_R2_press: ", value)

def on_R2_release(self):

def on_up_arrow_press(self):

def on_up_down_arrow_release(self):

def on_down_arrow_press(self):

def on_left_arrow_press(self):

def on_left_right_arrow_release(self):

def on_right_arrow_press(self):

def on_L3_up(self, value):
print("on_L3_up: ", value)

def on_L3_down(self, value):
print("on_L3_down: ", value)

def on_L3_left(self, value):
print("on_L3_left: ", value)

def on_L3_right(self, value):
print("on_L3_right: ", value)

def on_L3_release(self):

def on_R3_up(self, value):
print("on_R3_up: ", value)

def on_R3_down(self, value):
print("on_R3_down: ", value)

def on_R3_left(self, value):
print("on_R3_left: ", value)

def on_R3_right(self, value):
print("on_R3_right: ", value)

def on_R3_release(self):

def on_options_press(self):

def on_options_release(self):

# now make sure the controller is paired over the Bluetooth and turn on the listener
Known limitations at this time
  • L3/R3 button clicks are not detected
  • Mouse pad events and clicks are not detected
  • Share button clicks are not detected
  • PS button clicks are not detected
PyPS4Controller Module PS4 Controller Hooks via Python on Linux by ArturSpirin.jpg



Senior Member
Why use this over the existing alternatives? I forgot the names of both drivers, but I've used 1 for Kodi on Raspbian and another for retroarch on Arch... what is the point of this?


Staff Member
A lot of times devs make things for themselves, and then share with the community afterwards even if alternatives already exist.

Someone may think why bother giving people choice or options, but another may think if this is what the dev wants to spend their time working on that is their decision.

My motto is if it's free it's for me and I'll take three! :D


Senior Member
Android would be terrific but I think it came to Switch so soon because that scene is massive and a Switch is basically a glorified tablet. Almost every major component is off the shelf and therefore has drivers for it, etc. It's basically an Nvidia Shield and that's been hacked to death so... Switch!

Getting proper Android to work over a PS4 would be a tall task, based on Linux or Bumfartix or whatever. Sure, an x86 Android OS exists but PS4 is still more proprietary than Switch, despite being pretty off the shelf in comparison to past Playstations.

This is all a guess though. I could be wrong.
Recent Articles
Hunt: Showdown Brings Bounty Hunters to PlayStation 4 Next Week
Next week join the rugged bounty hunters of Hunt: Showdown as they rid the world from the savage, nightmarish monsters roaming the Louisiana swamps! :eek: Hunt's competitive, match-based gameplay...
Rainbow Six Siege: Operation Void Edge PS4 Updates and Reveal Trailer
Following the Tom Clancy's Rainbow Six Siege Operation Blood Orchid PS4 Trailer and Operation White Noise updates this weekend Ubisoft outlined the new Rainbow Six Siege: Operation Void Edge...
Mortal Kombat 11 DeepFake Celebrity Skin Demos by BabyZone
Game modder BabyZone recently shared some Mortal Kombat 11 DeepFake skin demos featuring popular celebrities including Keanu Reeves, Bruce Lee, Bruce Campbell, The Rock, Vandamme and Jackie Chan...
PlayStation 5 Price Affected by Costly PS5 Parts According to Reports
Business and Market news site reports that Sony is struggling on the PlayStation 5 Price due to costly parts (DRAM / NAND shortages) with current PS5 manufacturing costs around $450...