The script is as-is and was in general just for personal use, I set this git up so others who stumble upon might find it useful too. I personally have no experience in python and the script was made by 99% with ChatGPT (with a few hours of troubleshooting and feeding it with outputs). So expect a spaghetti code... sorry.
I wanted a tool that works systemwide for any game so I don't always have to rely on SteamInput/Bottles/Lutris. Works wired and via Bluetooth. Works for PS4 and PS5 controller.
It in general reads the raw input from the PS controllers and sends it as a virtual controller in uinput (xinput), which I needed especially in older games which don't support DirectInput at all.
It only works for one active controller!
Download the files manually or clone
git clone https://github.com/sera-ina/DualShock-uinput.git
- python3
- python3-dev
- python3-venv
- python_uinput
- evdev
- bluetoothctl
- if desired to be able to disconnect the controller via (PS + Start) combination
Once you installed python on your system, create a virtual enviroment (for example ".venv" in your home folder)
python3 -m venv ~/.venv
Update pip
~/.venv/bin/pip install --upgrade pip setuptools wheel
When it is done, install the dependencies manually or with the requirements.txt file
~/.venv/bin/pip install -r requirements.txt
Create udev rules file
sudo nano /etc/udev/rules.d/99-psinput.rules
and add
KERNEL=="uinput", MODE="0660", GROUP="input"
Add user to input group
sudo usermod -aG input $USER
Load uinput module
sudo modprobe uinput
Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm trigger
In the config.py file you can change the deadzone of each stick, the name of the controller and if you want to be able to use the (PS + Start) combo to disconnect the controller.
Connect you PS4/PS5 controller first via USB or Bluetooth, then run the script
~/.venv/bin/python ds4input.py
as the script looks for the controller directly on start else the script will just stop with an error.
- No vibration / force feedback
- The PS button is a separate button that you can map, for example in AntiMicroX