Browsers have become extremely powerful and capable enough to handle complex graphics computations, especially for playing video games. From 2D site scrollers, retro emulation, to even high end 3D games. It's possible to play almost any type of game on the web today.
And for a majority of these games that we see and play on the web, the primary form of input has always been keyboard or mouse based. And for touch screen devices, you've seen on screen control layouts like these, which at times can hinder the game experience. And using these types of controls can turn out to be quite a daunting task for gamers who prefer more natural controls, you know, like a directional pad or a joystick for character movements.
Now, desktop games provide this flexibility of using external devices like game pads and joysticks, maybe because they have native support for this built right in. But when it comes to the web, for a long time, there has been no native support for this at all. Developers had to design these complex mouse or keyboard based interfaces for game controls that can be quite tricky to operate.
So, a few years back, the W3C introduced the GamePaths specification, which defines a low level interface to represent gaming devices. Which means using this API, developers will be able to connect GamePaths and similar devices to the browser and then be able to use them in their gaming applications. Which means you'll be able to use devices such as the DualShock, Joy-Con and even next gen devices like the DualSense and Xbox Series X controllers.
Now, as of today, the GamePaths specification is still a work in progress. It's published as a working draft. The specification is intended to become a W3C recommendation. For now we can see that the API itself is supported by all modern browsers, which is definitely a good sign. So let's take a look at the details of the API itself. So the API exposes a method on the Navigator interface which returns a list of GamePad objects and each GamePad object represents a GamePad that is connected to the browser. Now this GamePad interface returns useful information about the connected GamePad. Information related to the buttons, the axis, which are the joysticks basically. The current states and other information like the device ID, status, et cetera. If we look closely at the GamePad buttons, we see that every button is an instance of the GamePad button interface. This represents an individual button on the GamePad and allows access to the current state of button. Using this, we can determine whether the button was pressed or not and carry out the appropriate action in the game. Now, every GamePad manufacturer creates many different kinds of products and each might have a unique style or a layout of buttons and axis. But it's the job of the user agent, of course, to support as many of these as possible, which is why the GamePad API recommends a de facto standard layout, which is called a Standard GamePad Layout. And this layout has been made popular by many gaming consoles. And in this layout, buttons and axis are laid out in a particular order that we'll see. So this is how the Standard GamePad Layout looks. And in this layout, button locations are placed out in a left cluster of four buttons, a right cluster of four buttons, a center cluster of three buttons.
Comments