Skip to content

Commit b0917cf

Browse files
committed
find the device by name
1 parent 6652808 commit b0917cf

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

fixes/raw_ps4/README

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Playstation DualShock4 controller hw_version=0x0000b418 fw_version=0x0000a00b
44
I could not get Dpad to work with this API but the Sticks works.
55
I use the Dpad only around edges but can play without it.
66
This is just a way to take the kernel RAW when everything else is not working
7-
You might just need to replace this line.
8-
device = evdev.InputDevice('/dev/input/event21') # Replace X with the correct number
97

108
The quick way:
119
sudo modprobe uinput

fixes/raw_ps4/controller.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
from evdev import UInput, ecodes as e
33

44
# Open your PS4 controller device
5-
device = evdev.InputDevice('/dev/input/by-id/usb-Sony_Interactive_Entertainment_Wireless_Controller-if03-event-joystick') # Replace
5+
controller_names = (
6+
"Wireless Controller",
7+
"Sony Interactive Entertainment Wireless Controller"
8+
)
9+
10+
for device_path in evdev.list_devices():
11+
device = evdev.InputDevice(device_path)
12+
13+
if any(name in device.name for name in controller_names):
14+
device = evdev.InputDevice(device.path)
15+
break
616

717
# Create a virtual keyboard
818
ui = UInput()

0 commit comments

Comments
 (0)