Saturday, February 16, 2008

Controls, McSchmols

The best way to play a side-scrolling platform game is with a gamepad. Although the side scrolling game will have to support a keyboard, it is in the (unnamed) game's best interest if we get good peripheral support from the beginning. So, I went about looking for some documentation on getting the Playstation 3 SixAxis controller working in Linux.

It turns out there is a website with a couple of interesting videos using the bluetooth capabilities at http://www.pabr.org/sixlinux/sixlinux.en.html. Only by connecting the Sixaxis through bluetooth will the motion sensing capabilities of the gamepad be detected.

I don't really care too much about the bluetooth stuff or motion sensing for the game at the moment, though, even if it is fairly slick. I just want a nice standard gamepad to test the game out with, and is not too hard for the user to get working. For Linux at least, as long as the user is using 2.6.21 or higher (which includes Ubuntu Gutsy Gibbon 7.10), it is really simple:

  1. Plug in the Sixaxis to the computer via USB.

  2. Wait for the LEDs to start blinking. Hit the PS button to "wake up" the controller.

  3. Start using it with various games.

  4. (optional) install the joystick package and run jstest to see the raw data coming out of the controller. In Ubuntu 7.10, all I had to do was:

    sudo apt-get install joystick

    And then run jstest with the Sixaxis as so (with no other controllers connected):
    jstest --normal /dev/input/js0


Seriously, it is that simple. DON'T forget step 2. If you don't hit the PS button, the gamepad will not register anything, and you will spend at least an hour looking through forums just to discover you needed to hit a button like a chump like I did.

And there you have it. One controller, ready for use in Linux, good for the high-quality platformer we're sure to put out sometime within a decade I should hope.


But what about the Windows folks? It took a little research, but I finally found the drivers that actually work for my Windows XP system when connected via USB.
  1. Download sixaxisdriver.exe. You might need to search around to find it, but I was able to download mine here. Install it.
  2. Connect the Sixaxis to the PC via USB.
  3. Launch DriverLoader.exe and load driver.
  4. (optional) You should have a working ps3 gamepad in Windows now. Go to http://onakasuita.org/ps3/ and download the PS3 testing. It doesn't do anything other than show the raw data coming out of the controller, including the motion axes! I must say it was more fun to play around with that than I would have originally thought. It is really sensitive too.
A screen shot of the fun:
You can see clearly where I was shaking the remote like a madman and where I had set it down.

Setting up the gamepad was more of a hassle in Windows, so it might not be the "official" input device on that platform for the game. But still, the PS3 gamepad is one of the best around, so if the user had the option, I would tell them to go for it.

2 comments:

paul said...

That is cool. Now if someone would get me a ps3 controller. Have you tried anything with the wiimot thing?

Redsaz said...

Not quite yet, but I wouldn't mind trying that out sometime as well.