You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-5Lines changed: 9 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# python-connect-ps4
2
-
Using Python to connect to a PS4 and a map of all identified events.
2
+
A basic snippet to use vanillia Python to react to a PS4 controller events.
3
3
4
4
This code was written to connect a LEGO EV3 Brick to a PS4 controller. The EV3 is running [ev3dev](https://www.ev3dev.org/) and running a version of Python called [Pybricks](https://github.com/pybricks/pybricks-micropython). However, the code reacting to the PS4 controller events and the mapping of different buttons should apply to any Python/PS4 project.
5
5
@@ -11,14 +11,14 @@ When the PS4 is paried with the device it creates three event files. These files
11
11
Using a terminal check out the contents of the /dev/input folder before and after you pair the Bluetooth device. You should notice three new event files. On my device these files where:
12
12
13
13
* /dev/input/event2 (touchpad events)
14
-
* /dev/input/event3 (controller movement, like tilting, etc...)
14
+
* /dev/input/event3 (controller movement, like tilting, shaking, etc...)
15
15
* /dev/input/event4 (buttons, sticks, etc...)
16
16
17
-
Each event provides five values, but we only need the event ID, code, and value. Here is a list of all events I could find:
17
+
Each event provides five values, but we only need the event ID, code, and value. Here is a list of all events I could map:
18
18
19
19
## Button and Stick Events
20
20
21
-
For me button and stick events were found in /dev/input/event4. If you're working on a PS4 project, these are probably the events you're looking for.
21
+
With my device, the button and stick events were found in /dev/input/event4. If you're working on a PS4 project, these are probably the events you're looking for.
@@ -49,6 +49,8 @@ Note that the left and right sticks often trigger ongoing events if the controll
49
49
50
50
## Controller Movement
51
51
52
+
Movement events were found in /dev/input/event3.
53
+
52
54
These events are triggered by physically moving or tilting the controller. I'm not as confident with these. I could not tell the difference with codes one and two.
53
55
54
56
<table>
@@ -63,7 +65,9 @@ These events are triggered by physically moving or tilting the controller. I'm n
63
65
64
66
## Touch Pad Events
65
67
66
-
These events are triggered by using or pressing the touchpad on the PS4 controller. I could not figure out the difference between code 252 and 230 or 333 and 47.
68
+
Movement events were found in /dev/input/event2.
69
+
70
+
These events are triggered by using or pressing the touchpad on the PS4 controller. I could not figure out the difference between codes 252 and 230 or 333 and 47.
0 commit comments