How can game developers support analog keyboards?

Considering that analog keyboards are a brand-new product category in today’s gaming peripheral market, it’s no wonder games sometimes lack the proper support for them. From flashing UI elements to completely unexpected behaviour (looking at you, GTA V!), game support can sometimes be… interesting, to say the least.

In this article, I will explore why analog keyboards can be problematic in a game, what causes these problems and what they look like and how developers can solve those issues.

How does an analog keyboard work?

We’ve written two articles pertaining to this topic already, available here and here. In short, analog keyboards work by allowing the keyboard’s output be translated with Windows’ keyboard and mouse APIs or through the controller API of choice, either DirectInput or Xinput. Effectively, this means that the computer sees it as a game controller, a keyboard or both at the same time. I’ll explain why this is important in a bit.

Input handling

Input handling is the term given to how a game receives, interprets, and ultimately delivers an action upon keypress. This is a very crucial layer to get right in terms of properly supporting analog keyboards. The input handling should be built in consideration for dynamic situations – to expect the unexpected. This is to say that the game should expect inputs from different devices simultaneously, to allow for more options. This layer is usually the culprit for the incompatibilities you might see while using an analog keyboard, as the game has a hard time understanding both the keyboard and the game controller aspect of it at the same time.

Let’s delve deeper into the different input methods and APIs available for use when designing a game.

Keyboard and mouse input (KBM, KB/M, KB&M)

Ah, the old classic. Shouldn’t come as a surprise that most games for the PC support this control scheme out of the box. Mouse moves the camera, pressing a key moves your character in one direction, or performs an action. Pretty simple.

Analog controllers

In this modern day and age, the API of choice to handle analog input is most often Xinput. Xinput is originally the API that allowed applications to receive input from the Xbox 360 Controller for Windows. Nowadays though, it has more or less become the industry standard as the API that governs controller input. Xinput replaced the older DirectInput API sometime when the Xbox 360 came out, streamlining the input handling for controllers once and for all. Luckily, this translates to most games supporting Xinput out of the box. Very little configuration is usually required (or even allowed at all!).

What about mixed input?

This is where the problems start. As the analog input handler of choice (let’s say, Xinput) reports actions to the game, the game assumes that the player must be using a game controller. Sometimes, this leads to the game becoming unresponsive towards KB&M input. Sometimes, it’s more minor, such as wrong UI elements being displayed.

The issues arise because the input handling in most games is resigned to accomplish two tasks: either accept and translate input from keyboard and mouse, or accept and translate input from a Xinput-controller. All should be fine and dandy, right? Not quite. In the case of analog keyboards, we need the game to accept input from KB&M as well as the game controller simultaneously. Even moving your mouse can make the game not accept the game controller, or the other way around.

This is why the input handling should optimally designed to expect input from any supported device simultaneously, allowing many, many control configurations to offer more options.

The current model of standard input handling is restrictive and prevents non-standard control schemes or devices from working properly in games that do this.

Visual elements

Let’s say a game does support multiple input devices at the same time. Even then there are still things that can go wrong. The next sore point for games are the visual elements. I’m of course talking about these things:

Overwatch’s command prompts. Q for ultimate, Left Shift and F for normal abilities

Again, the run-of-the-mill input handling system assumes inputs to only come from one source. This leaves us with either:

Fortunately, this is an easy fix. Give us a toggle to force a specific UI. The folks over at Blizzard got this right, as Overwatch features a Force keyboard UI option, found in the advanced game settings.

The gift of god in action. Forcing the keyboard UI in Overwatch prevents the UI from flashing even if the game receives input from Xinput

Flexible mapping

With a flexible input handling system, having proper keymapping and customization options should be a thing. Luckily, this has improved over time, with many games already supporting 3 mappings for the same action. But alas, too many games still fall for the old trap, of letting you only customize the keyboard controls, but locking you into a custom-built controller control scheme, should you choose to use a controller. Give us more options! If I want to shoot with the left trigger and aim with the right, I should be able to do that. This issue is compounded with non-standard devices like analog keyboards or other controllers, whereby you have to resort to remapping the controller itself.

Again, Overwatch gets most of this right. 3 bindings for one action, although slot 3 is specifically resigned for a controller

Recap

So to recap, the best way to make sure your game supports analog keyboards (and any other non-standard controller!) is to abide by these tenets:

Develop a flexible input handling system

Allow for options to force different control scheme UI elements

Make keymapping options as versatile as possible

I would love to see more games embrace the changing nature of control schemes, as we move towards the future. Of course, developing with more customizability won’t come without additional developing costs. Alternative controllers, such as analog keyboards, are only in their adolescence, but if more developers start to pay attention to them from the get-go, the issues should slip into the history books in no time.

Comment

If you happen to have any more questions or would like to comment on the article, you can do so in the following ways:

One Comment

For gaming, a keyboard plays the vital role while playing computer gaming because a player needs to control and give instruction with the help of keyboard. The given information on analog-keyboards is really very nicely explained in this blog which is very essential for the gamers.