Skip to content

Commit 2a1ceff

Browse files
committed
make finding the device more exact
1 parent b0917cf commit 2a1ceff

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fixes/raw_ps4/controller.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import evdev
23
from evdev import UInput, ecodes as e
34

@@ -7,13 +8,17 @@
78
"Sony Interactive Entertainment Wireless Controller"
89
)
910

11+
device = None
1012
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)
13+
temp_device = evdev.InputDevice(device_path)
14+
if temp_device.name in controller_names:
15+
device = temp_device
1516
break
1617

18+
if device == None:
19+
print("No device found")
20+
sys.exit(1)
21+
1722
# Create a virtual keyboard
1823
ui = UInput()
1924

0 commit comments

Comments
 (0)