Repository navigation
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 port 1 DualShock 2
/dev/input/event4: PlayStation 2 gamepad port 2 DualShock 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:
# evtest /dev/input/event3
Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "PlayStation 2 gamepad port 1 DualShock 2"
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 317 (BTN_THUMBL)
Event code 318 (BTN_THUMBR)
Event code 544 (BTN_DPAD_UP)
Event code 545 (BTN_DPAD_DOWN)
Event code 546 (BTN_DPAD_LEFT)
Event code 547 (BTN_DPAD_RIGHT)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 22
Min -128
Max 127
Event code 1 (ABS_Y)
Value 3
Min -128
Max 127
Event code 3 (ABS_RX)
Value -24
Min -128
Max 127
Event code 4 (ABS_RY)
Value 0
Min -128
Max 127
Event type 21 (EV_FF)
Event code 80 (FF_RUMBLE)
Event code 81 (FF_PERIODIC)
Event code 88 (FF_SQUARE)
Event code 89 (FF_TRIANGLE)
Event code 90 (FF_SINE)
Event code 96 (FF_GAIN)
Properties:
Testing ... (interrupt to exit)
evtest waits for controller 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 ------------
The fftest tool in Linux can test controller force-feedback (rumble).
Tip
If you’ve installed an R5900 cross-compiler with Gentoo it’s easy to cross-compile tools to test gamepads for the PlayStation 2. For example, cross-compile evtest with
# LDFLAGS="-static" emerge-mipsr5900el-unknown-linux-musl -v app-misc/evtest
and fftest with
# ACCEPT_KEYWORDS='**' LDFLAGS="-static" emerge-mipsr5900el-unknown-linux-musl -v games-util/joystick
These two MIPS program files can then be copied to the INITRAMFS (or some other usable place) for testing on PlayStation 2 hardware:
$ file /usr/mipsr5900el-unknown-linux-musl/usr/bin/evtest
evtest: ELF 32-bit LSB executable, MIPS, MIPS-III version 1 (SYSV), statically linked, stripped
$ file /usr/mipsr5900el-unknown-linux-musl/usr/bin/fftest
fftest: ELF 32-bit LSB executable, MIPS, MIPS-III version 1 (SYSV), statically linked, stripped
See #22.