Configurable Buttons

by Bernhard Klemenjak

Each time I tell someone about an implementation that I’m not 100% sure about, I start with the words “I don’t know if that’s quite so smart”.

So in this case, I start this entry with:
I don’t know if that’s quite so smart. I have spent many many hours with the input configuration in Schein. First, we had a simple image showing the configuration of all gamepad and keyboard buttons that are used. That was good enough in the beginning.

Then, since there are (roughly) ten trillion different gamepad designs and nearly as many different “favourite configurations”, we wanted to allow the user to customize his gamepad buttons. Well, now the gamepad buttons can be customized freely. For the keyboard, static images should suffice; maybe we’ll make them customizable as well someday. And surely that day came.

Button Configuration
I thought “No problem!”, I can surely reuse most of the already existing gamepad configuration. In retrospect, I wearily smile about that. Following, there are some findings:
For the gamepad buttons, I took only text as representation, for example “Left”, “A” or “Button 5”. For the keyboard I thought there would already be a cool “Pressed-key-to-character-function”. But there is none – at least not really. After more brooding and trying I came to the conclusion: 3 different implementations, depending on the type of key.

  1. Keys that transform 1:1 to a single sign/letter
    for example A/S/1/*
  2. Keys to display as a symbol
    for example Return/Shift/Space
  3. Keys that are represented as (partly) language-dependent abbreviations
    for example CTRL/ALT/DEL

Additionally, there are keys that do not transform well to a specific character with DirectInput (at least in my opinion). As for example special characters in non-English languages (Ä/Ö/Ü). So I limited the keys of category 1 to those that are representable with ASCII values between “!” (33) and “~” (126), everything below or above that is ignored. In the end there’ve also been keys that needed to be prohibited explicitly – but I hope nobody will be angry that he cannot assign the windows key.