michael orlitzky

SDL key codes for the XO gamepad

Or, how to play Gameboy ROMs on the OLPC using Visual Boy Advance. Visual Boy Advance uses SDL for whatever it does under GNU/Linux, and thus uses the SDL key codes to map the keys that are pressed to inputs.

These key codes are defined in a header file, SDL_keysym.h, using the names of keys with which you are probably familiar. On the XO, however, many of the keys have been relabeled, including the ones used for the gamepad and buttons.

Here are key codes for the gamepad:

DirectionKey Code
Up0108
Right0106
Down0102
Left0104

...and the buttons...

ButtonKey Code
X0103
Square0107
Circle0109
Check0101

And finally, the little button that flips the screen between portrait and landscape display. This is really the only hard one to figure out.

ButtonKey Code
Switch Orientation0000

If you're using these for Visual Boy Advance, you can, of course, bind them however you want. The relevant section from my config is below; I've used the display rotation button for my Start.

If you're wondering, there is no key code for the power button. I'm using the enter key for Select.

Joy0_Left=0104
Joy0_Right=0106
Joy0_Up=0108
Joy0_Down=0102
Joy0_A=0103
Joy0_B=0101
Joy0_L=0107
Joy0_R=0109
Joy0_Start=0000

If anyone figures out how to get GBA games running with the XO's limited resources, hit me up. I've only been able to manage Gameboy and Gameboy Color games so far.