The evolution of controller simulation

28 03 2015

When you start writing a gaming framework that should be controlled by a Joystick, you will end up defining callback functions for the controller functions.

To simulate a controller you will also implement callback functions for keyboard clicks and map these keyboard callbacks to controller callback functions.
You start with writing 5 callback functions:

  • cursor up
  • cursor down
  • cursor left
  • cursor right
  • fire

This is a good start and works well. It’s like 1979 you could say. We use a Atari CX40 (I hate it, because I’m left hander) and we could map our 5 callback functions to the CX40 functionality:
The 4 direction callback functions could be simulated on the keyboard by cursor up,down,left,right. The fire button could be emulated by space:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • fire = space

We could already warp to 1983. We now use a competition pro joystick and all buttons sendings their “power on” signal on one wire. Nothing has to change in our framework.

Next we warp to 1984. The Atari 7800 has a joystick, the Atari CX24, that has to 2 different buttons connected to independent wires.
In your framework code our simulation of the fire button with the space key will not work anymore. A good way to handle this evolution will be to use the y key to simulate button a and the x key to simulate button b. The new mapping now looks like this:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • button a = y
  • button b = x

At the same time the joypads emerge into gamerworld thanks to the Nintendo Entertainment Systems.
To cover the start and select button we have to extend our set of callback functions to simulate them as well. The two windows key on the keyboard are good candidates for this task.
My thinkpad has the page up and page down key next to the cursor up key, they would fit perfect, but the majority of keyboards have a different design, so we implement the windows keys.

That result in the following mapping:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • button a = y
  • button b = x
  • start = windows left
  • select = windows right

It’s warptime again and we land in 1990. Our Super Nintendo have 4 buttons and 2 shoulder buttons beside the standard direction pad. Our x,y key approach does not fit anymore.
For me to use 4 keys, its more intuitive to go to the middle row on the keyboard instead of extend the use of the bottom row on the keyboard (c,v key), so the 4 buttons are a,s,d,f

Update 2: It was to early when I wrote it. If cause it hast to be w,a,s,d.

Update 3: First tests shows, that now that the x and y keys are free again, the start and select callbacks could be mapped to these keys 

The shoulder buttons will be strg left and strg right. The mapping now looks like this:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • button up = w
  • button right = d
  • button down = s
  • button left = a
  • start = x
  • select = y
  • shoulder left = strg left
  • shoulder right = strg right

Last warp so far goes to 1994. We all have a playstation and use the psx pad. It adds 2 more shoulder buttons and rearange the should buttons to L1,L2,R1,R2. it also adds 2 analog sticks LS and RS. You could also press this sticks (L3,R3)
The new shoulder buttons (L2,R2) will be simulated by “alt left” and “alt right”.
The sticks are a challenge. My first idea is to simulate them with the number keys. 1-5 for the left stick and 6-0 for the right stick.

Update 1: Thanks to EarX / Linout we must warp to 2006 cause the L3 and R3 Button was not present on the PS2 but on the PS3. 

That a huge change to our framework and ends up in these mapping:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • button up = w
  • button right = d
  • button down = s
  • button left = a
  • start = x
  • select = y
  • L1 = strg left
  • L2 = alt left
  • R1 = strg right
  • R2 = alt right
  • LS up = 1
  • LS down = 2
  • LS left = 3
  • LS right = 4
  • LB = 5
  • RS up = 6
  • RS down = 7
  • RS left = 8
  • RS right = 9
  • RB = 0
Advertisements