-
Notifications
You must be signed in to change notification settings - Fork 6
Controllers for the PlayStation 2
The PlayStation 2 Linux kernel has a gamepad.ko
device driver for DualShock 2 controllers. Latency, the time between a controller action and the reaction of the system, is designed to be very low, with a 5 ms (200 Hz) rather than an otherwise typical 20 ms (50 Hz) reaction time. In addition, the input/output processor (IOP) detects state changes to avoid needless main processor interrupts, which improves system performance.
The evtest tool in Linux can test controller input events, as applications would observe them. As an example, after the keyboard devices (not shown here), two gamepad ports are listed:
/dev/input/event3: PlayStation 2 gamepad 1
/dev/input/event4: PlayStation 2 gamepad 2
Select the device event number [0-4]:
A list of the possible key code events can be given, where BTN_SOUTH
corresponds cross, BTN_EAST
to circle, and so on:
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 304 (BTN_SOUTH)
Event code 305 (BTN_EAST)
Event code 307 (BTN_NORTH)
Event code 308 (BTN_WEST)
Event code 310 (BTN_TL)
Event code 311 (BTN_TR)
Event code 312 (BTN_TL2)
Event code 313 (BTN_TR2)
Event code 314 (BTN_SELECT)
Event code 315 (BTN_START)
Event code 544 (BTN_DPAD_UP)
Event code 545 (BTN_DPAD_DOWN)
Event code 546 (BTN_DPAD_LEFT)
Event code 547 (BTN_DPAD_RIGHT)
Properties:
evtest
can wait for input, and pressing and releasing for example the cross, circle and START buttons prints the following:
Testing ... (interrupt to exit)
Event: time 1608053409.675738, type 1 (EV_KEY), code 304 (BTN_SOUTH), value 1
Event: time 1608053409.675738, -------------- SYN_REPORT ------------
Event: time 1608053409.899124, type 1 (EV_KEY), code 304 (BTN_SOUTH), value 0
Event: time 1608053409.899124, -------------- SYN_REPORT ------------
Event: time 1608053412.613564, type 1 (EV_KEY), code 305 (BTN_EAST), value 1
Event: time 1608053412.613564, -------------- SYN_REPORT ------------
Event: time 1608053412.738838, type 1 (EV_KEY), code 305 (BTN_EAST), value 0
Event: time 1608053412.738838, -------------- SYN_REPORT ------------
Event: time 1608053427.549995, type 1 (EV_KEY), code 315 (BTN_START), value 1
Event: time 1608053427.549995, -------------- SYN_REPORT ------------
Event: time 1608053427.735774, type 1 (EV_KEY), code 315 (BTN_START), value 0
Event: time 1608053427.735774, -------------- SYN_REPORT ------------
See #22.