PSP joystick & buttons

test output

Following the installation of the toolchain, I decided to make a little program to get some information about the PSP's interface, from the programmers point of view. That is, it would use SDL's joystick functions to find out how many axis and buttons and which codes did they report to the program. Although it might seem useless it is an easy exercise in checking events and it could even be the base for a future game.

I first tested the program on my computer, using a Logitech USB pad that I have for playing emulators. I intended to use it for real games but I still haven't found one which doesn't use the mouse. By the way, the pad works flawlessly in linux, just in case you were looking for a compatible joystick for your linux box.

The pad reported as having six axes, where the axes corresponded to the two analog joysticks and one digital joystick (two axes per joystick: vertical and horizontal), so I was expecting to find a very similar result in the PSP, but with four axes since it only has two joysticks.

Logitech dual action pad

Instead, I got an interesting result: two axes only, and the rest were buttons! PSP is reporting the digital joystick as simply four isolated buttons. This, although being surprising, also makes much easier to program simple stuff where you just need to react when a button has been pressed, instead of having to check the value of the axis which is reporting motions, and deduct the appropriate intended direction from there.

I also noticed that the analog joystick can sometimes have a very erratic behaviour, reporting movements while no one is even touching the console. It might be because it's not a brand new PSP and maybe there's some dirt or something in the controls ... or maybe we were experiencing a earthquake and nobody noticed? :)

For the record, these are the reported SDL button codes, so you can look for an SDL_JOYBUTTONDOWN type of event, and compare event.jbutton.button to the following values to decide what to do:

Left: 7 Right: 9 Up: 8 Down: 6 L: 4 R: 5 Triangle: 0 Square: 3 Circle: 1 Cross: 2 start: 11 select: 10

I didn't manage to read the other buttons, they seem to be out of the reach of SDL. Maybe it's got something to do with kernel/user mode, but it doesn't worry me for the time being.

If you want to try this at home - worry not, it's safe and harmless! Here's the source code. You'll notice I also used the balls and hats functions, but I must confess that while I suspect that balls is referring to trackballs, I have no idea what hats is referring to. If anybody knows, let me know in the comments so that I can stop imagining a little Mexican hat dressing a gamepad :-D

Here's also a possible sample output, using my logitech pad and pressing buttons and moving sticks randomly:


Index: 0
Name: Logitech Logitech Dual Action
Num axes: 6
Num balls: 0
Num hats: 0
Num buttons: 12
// moving the digital stick
Axis motion: j index = 0 axis = 5 value = -32767
Axis motion: j index = 0 axis = 5 value = 0
Axis motion: j index = 0 axis = 5 value = 32767
Axis motion: j index = 0 axis = 5 value = 0
Axis motion: j index = 0 axis = 4 value = -32767
Axis motion: j index = 0 axis = 4 value = 0
Axis motion: j index = 0 axis = 4 value = 32767
Axis motion: j index = 0 axis = 4 value = 0
// moving analog sticks, note the values aren't "all, minus all or nothing" here
// you should get similar values with the psp's analog stick
Axis motion: j index = 0 axis = 0 value = 337
Axis motion: j index = 0 axis = 0 value = 1013
Axis motion: j index = 0 axis = 0 value = 2026
Axis motion: j index = 0 axis = 0 value = 4053
Axis motion: j index = 0 axis = 0 value = 5742
Axis motion: j index = 0 axis = 0 value = 7094
Axis motion: j index = 0 axis = 0 value = 10134
Axis motion: j index = 0 axis = 0 value = 13174
Axis motion: j index = 0 axis = 0 value = 15877
Axis motion: j index = 0 axis = 0 value = 19593
Axis motion: j index = 0 axis = 0 value = 22633
Axis motion: j index = 0 axis = 0 value = 26349
Axis motion: j index = 0 axis = 0 value = 30741
Axis motion: j index = 0 axis = 0 value = 32767
Axis motion: j index = 0 axis = 1 value = -1014
Axis motion: j index = 0 axis = 1 value = -3379
Axis motion: j index = 0 axis = 1 value = -4392
Axis motion: j index = 0 axis = 1 value = -5743
Axis motion: j index = 0 axis = 1 value = -7432
Axis motion: j index = 0 axis = 1 value = -9121
Axis motion: j index = 0 axis = 1 value = -11486
Axis motion: j index = 0 axis = 1 value = -13175
Axis motion: j index = 0 axis = 1 value = -14189
Axis motion: j index = 0 axis = 1 value = -16553
Axis motion: j index = 0 axis = 1 value = -19932
Axis motion: j index = 0 axis = 1 value = -22296
Axis motion: j index = 0 axis = 1 value = -25337
Axis motion: j index = 0 axis = 1 value = -28039
Axis motion: j index = 0 axis = 1 value = -32767
Axis motion: j index = 0 axis = 0 value = 25673
Axis motion: j index = 0 axis = 0 value = 16890
Axis motion: j index = 0 axis = 0 value = 8445
Axis motion: j index = 0 axis = 0 value = 3378
Axis motion: j index = 0 axis = 0 value = 1013
Axis motion: j index = 0 axis = 0 value = 0
Axis motion: j index = 0 axis = 1 value = -31755
Axis motion: j index = 0 axis = 1 value = -27026
Axis motion: j index = 0 axis = 1 value = -22296
Axis motion: j index = 0 axis = 1 value = -13851
Axis motion: j index = 0 axis = 1 value = -3379
Axis motion: j index = 0 axis = 1 value = 0
Axis motion: j index = 0 axis = 2 value = 3040
Axis motion: j index = 0 axis = 2 value = 7769
Axis motion: j index = 0 axis = 2 value = 10472
Axis motion: j index = 0 axis = 3 value = -3041
Axis motion: j index = 0 axis = 2 value = 13512
Axis motion: j index = 0 axis = 3 value = -5068
Axis motion: j index = 0 axis = 2 value = 16215
Axis motion: j index = 0 axis = 3 value = -10473
Axis motion: j index = 0 axis = 2 value = 19593
Axis motion: j index = 0 axis = 3 value = -17229
Axis motion: j index = 0 axis = 2 value = 22971
Axis motion: j index = 0 axis = 3 value = -24661
Axis motion: j index = 0 axis = 2 value = 26011
Axis motion: j index = 0 axis = 3 value = -32767
Axis motion: j index = 0 axis = 2 value = 28038
Axis motion: j index = 0 axis = 2 value = 30741
Axis motion: j index = 0 axis = 2 value = 31078
Axis motion: j index = 0 axis = 2 value = 30065
Axis motion: j index = 0 axis = 2 value = 28038
Axis motion: j index = 0 axis = 2 value = 22295
Axis motion: j index = 0 axis = 2 value = 15539
Axis motion: j index = 0 axis = 2 value = 9458
Axis motion: j index = 0 axis = 2 value = 3040
Axis motion: j index = 0 axis = 2 value = 0
Axis motion: j index = 0 axis = 2 value = -676
Axis motion: j index = 0 axis = 2 value = -2365
Axis motion: j index = 0 axis = 2 value = -3041
Axis motion: j index = 0 axis = 2 value = -3716
Axis motion: j index = 0 axis = 2 value = -4392
Axis motion: j index = 0 axis = 2 value = -5068
Axis motion: j index = 0 axis = 2 value = -7432
Axis motion: j index = 0 axis = 2 value = -11148
Axis motion: j index = 0 axis = 2 value = -13513
Axis motion: j index = 0 axis = 2 value = -16216
Axis motion: j index = 0 axis = 2 value = -18580
Axis motion: j index = 0 axis = 2 value = -19932
Axis motion: j index = 0 axis = 2 value = -21621
Axis motion: j index = 0 axis = 3 value = -31755
Axis motion: j index = 0 axis = 3 value = -27363
Axis motion: j index = 0 axis = 3 value = -22972
Axis motion: j index = 0 axis = 3 value = -19594
Axis motion: j index = 0 axis = 3 value = -16216
Axis motion: j index = 0 axis = 3 value = -15202
Axis motion: j index = 0 axis = 3 value = -11824
Axis motion: j index = 0 axis = 2 value = -19932
Axis motion: j index = 0 axis = 3 value = -10135
Axis motion: j index = 0 axis = 2 value = -18580
Axis motion: j index = 0 axis = 3 value = -8784
Axis motion: j index = 0 axis = 2 value = -14864
Axis motion: j index = 0 axis = 3 value = -6419
Axis motion: j index = 0 axis = 2 value = -8108
Axis motion: j index = 0 axis = 3 value = -3041
Axis motion: j index = 0 axis = 2 value = -676
Axis motion: j index = 0 axis = 3 value = -1014
Axis motion: j index = 0 axis = 2 value = 0
Axis motion: j index = 0 axis = 3 value = 0
// buttons!
Pressed button 0
Pressed button 1
Pressed button 3
Pressed button 2
Pressed button 2
Pressed button 1
Pressed button 7
Pressed button 5
Pressed button 6
Pressed button 4
Pressed button 5
Pressed button 4
Pressed button 6
Pressed button 9
Pressed button 8