Revision: 01.01.2014
Revision: 30.12.2013
Drafted: 23.12.2013

Game Controlls and the Web

Part 1: How come?

Since a few weeks I'm playing with a new project, a little Simulator for classic like CPU systems, written in JavaScript. As with most fun projects, it generates almost a new idea every other source line. Beside Canvas or Web Audio (Positional Audio for 8 Bit CPUs - wie cool ist das denn :) and others, the discovery of the Gamepad API (right in time for Christmas) has been the latest diversion. What a nifty idea. So I went ahead tried to get some information. Not easy, since there are quite some different implementation non concluding standard papers or look alikes and lots of outdated pages and code about. After a daylong search I learned that Firefox 24 already includes a complete implementation. Cool. If just the Mozilla documentation would already reflect this. This is basicly the the only 'official' info, and a bit outdated (I did try to make it more current, but my knowledge here is limited. Ted Mielczarek (one of the draft devs) offered additional insight in a recent Article on hacks.mozilla.org. There's also a Chrome implementation, but unlike Mozillas simple configuration switch you have to getsome kind of nightly builds, whatsoever. I'm not going down that road. So all Kudos to FF here (On the other hand, during this project I learned to like Chromes debugging and rather smooth handling - then again, both are more than just a little weired when it comes to timestamps (Fate.now/performance.now) and requestAnimationFrame implementation - I never thought I'd say this, but IE does a better job here).

Anyway, long story short, I did a little Implementation. I'm not realy satisfied with how the Interface has been designed, but thats a story for a different rant - beside that, a more important question sufaced: How to test? So I had to get me some gamepads. The developers offered a list of compatible devices like:

All rather high priced (Euro 50+) brands. Not exactly what I intended to spend. So I got me two (edit 3 by now) 9.99 thingies at various stores. Rather generic devices - one even included force feedback ... at 9.99 :))

Disclaimer

I'm a dinosaur when it comes to game controls. I grew up on coin ops, the first joystick I had was something weired (from todays point of view) where one had to _hold_ a stick in one hand and turn a *knob* with the other. After that joysticks had either digital buttons and where sold with 2600 systems or combined paddles, plugged into a DIP16 socket (*G*). Quickshot was already a next gerneration device, and Gamepads are something I first encontered at the Sega Megadrive of my younger daughter. Not my way. So some of my impressions may look weired to younger readers. Same goes for some definitions I made up to describe my findings. Also, all my discoveries are made using Windows 7. I do unse Linux, but for Development and more important testing I prefer to use what 70+ per cent of all users out there employ. I whish more developers of cross platform programs would also think more about their user base - we might have less weired behaviour (of recent features) in FF or Chrome. Then again ... I'm just a dinosaur. As support for this claim I might add, that my prefered development language is Assembler in any variation for any CPU :)

As longer as I dig into here, as more it seams like a darwineske field trip discovering evolution. I literaly collect and catalouge specimen in hope to find some hints about a hidden structure.

The Pads

About Variations

My intention is to learn what devices are out there and gather data to compare it's behaviour. Unlike joysticks, gamepads have quite some variations. As of not there are at least 3 basic gamepad styles and a bunch of variations. Most prevalent are two styles:

PlayStation(PS)-Style
Two little joysticks in the lower row, 4 buttons on the right upper side and a 4 direction switch on the upper left
xBox-Style
Like before, but the left joystick switched position with the directional switch.
The default mapping used in the W3C Draft is much like the PS-Style type. The newest Draft (31.12.) added a plus a 13th button in the middle. I couldn't realy find any controller like that. Either it's supposed to reflect the xBox-Style Guide button or maybe the new PS4 touchpad - which again seams odd. While the 'old' Wii feaures GameCube/PlayStation style controllers, a new design has been introduced with the Wii-U. Either as part of the tablet, or as the Wii-U Pro Controller.
Wii-U-Style
Two little joysticks in the upper row, 4 buttons on the lower right side, a 4 direction rocker on the lower left and 3 buttons in the middle
There are already adaptors available to connect Wii-U-Pro Controllers to PCs. Searching Chineese manufacturers/sellers sites bring up some new PC/USB Controllers in Wii-U style, so we can expect so see more of them. Tink geek offers a nice SNES styled Wii-U Controller. Which brings us to ...

A group of gamepads are based on the classic Nintendo

SNES-Style
with a 4 way rocker on the left, 2 buttons in the middle, 4 diamond placed buttons on the right, and two 'fire' buttons atop.
They are available as rather close clones or pseudo-cool retro designs or even tiny foldable pads like the Buffalo Mini USB Pad. Ofc, the NES variation with (only) two right buttons is also available. More variations include modern designs like the Logitech Precision (with 4 fire buttons on top). These Controllers are often named as n-Button-Controllers and available in lots of combinations and up to 14 additional buttons (I wouldn't be surprised to find even more :) placed around the SNES basic elements.

This Guy has a nice overview how buttons may be assigned from different devices. An interesting development seams to be the way rocker switches are offered. The classic variation is 8 way, like the old 2600. Newer Pads (most notably the latest xBox contoller) limit this to 4 way again.

Whats Missing: Joysticks (for now) and Wheels and more unusual controlls. Most of the later apear as Keyboard anyway - which brings up again one real issue I would love to see in the Gamepad API: Unified handling of Gamepads, Sticks, Presenters and Keyboard(alikes). Sigh. It's not cool to do all of this reassignment during runtime in JavaScript.

Well, curiosity killed the cat - or in this case my purse - I got me 3 more controllers - a (simple) digital gamepad, a PS3 Dance Map, and the eventually most featured contoller availabe, the Simraceway SRW-S1 Steering Wheel (1 axis, 2 sliders, one rocker and 17 Buttons) - 29,99 - resistance was futile :). Controller Madness.

Data Collection

Tools

To collect Data and behaviour, various ways are used:

  1. Device Information from USB Device Tree Viewer
  2. Device Information from Windows7 control Panel > Devices and Printers > Generic USB Joystick > Properties Dialogue
  3. Device Interpretation from Windows7 control Panel > Devices and Printers > Generic USB Joystick > Game Controller Setings > Test Dialogue
  4. Behaviour from Windows7 control Panel > Devices and Printers > Generic USB Joystick > Game Controller Setings > Test screen
  5. Behaviour from Firefox using Ted Mielczares Gamepad API Test

Button Numbering

All button numbers try to follow whats written/engraved on the controller itself. Numbering usually starts with 1. In case of inconsistent numbering (like using the same numbere again) a logical sequenced number (read what the USB Report returns) is used.

Control Elements

Further several types of input controls are used:

Button
General button reporting on/off. Offering a binary Value (0/1)
Axis
An analogue (well, digital sampled). Offering a signed Number, usually handled as a -1..0..+1 value
Rocker/Hat
A digital (button) based 2600 joystick like device. Represented as seperate entity of 4 switches, offering a series of 4 binary values (0/1). The switches are handled via a single hat pice, thus mechanical connected
Trigger/Slider
An analogue 'button', a slider. Offering a unsigned Number, usually handled as a 0..+1 value.
In technical Terms there is no difference between axis and sliders. Axis _schould_ be signed, sliders positive values, but thats not always true. More USB protocoll snpooping is needed here. Buttons and rockers are also based on the same priciple (on/off switches). Still, on API side they are not to be mixed. Same goes for buttons and triggers. While they may seam as exchangable due similar placements (on newer xBox style controllers triggers replaced Button 7/8), they are NO when looking at the API. When viewing triggers as buttons, a emulation may take plac.

Big Ben USB Controller

My first buy was a no name controller at Game Stop at Euro 9.99. It's a PS-Style variatoon and includes even a force feedback (dual motor rumble).

Rather average Controller. I couldn't find a way to make the rumble work.

Basic Data

Brandnamebigben play
ProductnamePCPADVIBASS
Product-IDBB5007Slv(Slv = Silver)
USB Product String"Generic USB Joystick "
USB-VID1345Sino Lite Technology Corp.
USB-PID1000
USB-REV0100
USB-Class(es)03/00/00
USB-Device (Windows)USBPDO-12
gamepad.id (Firefox)"1345-1000-Generic USB Joystick"
Style (Layout)PS
SwitchableYes: Default digital, switchable to Analogue

Detailed Information

See GP1-page.

Speedlink Thunderstrike

Next one is a no name bought at Conrad (again Euro 9.99). It's a PS-Style variation, but this time silent.

Packaging

Speedlink Thunderstrike package picture 1Speedlink Thunderstrike package picture 2

Basic Data

BrandnameSpeedlink
ProductnameThunderstrike
Product-IDSL-6515-BK(BK = Black)
USB Product String"Generic USB Joystick "
USB-VID0079DragonRise Inc.
USB-PID0006Generic USB Joystick (!)
USB-REV0107
USB-Class(es)03/00/00
USB-Device (Windows)USBPDO-12
gamepad.id (Firefox)"79-6-Generic USB Joystick"
Style (Layout)PS
SwitchableYes: Default digital, switchable to Analogue

Guessing from a quick search, this controller (either just the chip or the whole device) is also sold as "SpeedLink Strike"

Except for a different asignment of the 4 top right buttons (diamond) it's virtually equal to the bigben gamepad. See there for comments regarding handling and FF-'features'.

Detailed Information

See GP2-page.

Thrustmaster Dual Analog 4

This time a well known classic brand, Thrustmaster ... well, since been bought by french Guillemo, more like a hazbeen. It's a xBox-Style variation, bought at 14.99, again at Game Stop. I realy try hard to buy local, but somehow more and more shops drop game products, or PC products at all. Even Game Stop doesn't carry any (real) Joysticks (nowadays called Flightsticks) anymore :(

Basic Data

BrandnameThrustmaster
ProductnameDual Analog 4
Product-ID2960737
USB Product String"Thrustmaster dual analog 3.2"
USB Manufacturer String"Mega World"
USB-VID044FThrustMaster, Inc.
USB-PIDB315According to Linux USB-ID List: Firestorm Dual Analog 3
USB-REV0101
USB-Class(es)03/00/00
USB-Device (Windows)USBPDO-12
gamepad.id (Firefox)(not recognized)
Layout StylexBox
SwitchableNo (always analogue)

Detailed Information

See GP3-page.

Conclusions

These are not the Contollers you look for

Or, regarding FireFox, at least not the gamepad API I would like to see. It's way too much tied to a certain type of controller. This might result in sever harm - read less than intended usage. With a multi polar ... err ... heterogenus gamepad world out there, only two strategies are usefull: Either just present the very basic switches and sliders, or offer as much structure as possible to be derivated from the HID descriptors. The third way, make everything look like PSx will result in another proof of the 2nd Hammer Theorem: If you treat all your tools like a hammer, expect them to break early and often.

Lessons learned

What I called 'Styles' should rather be named 'Layouts'. Also there is realy a basic difference of Analogue and Digital sticks. partly rooted in history, but also in function. Like said before, it gets more and more like a field study in Entomology. The part about Styles may need rewriting.

Further research

It might be a good idea to see what kind of reports are _realy_ sent

Bugs: