Key Mapper

View java here (https://github.com/jacobjlandry/KeyMapper)

This was a first attempt to re-learn Java, which I haven’t used seriously in many years. It was a blast and I remember why I liked the language to begin with.

What is it?

So I like to play Elite Dangerous. In this game you fly a simulated spaceship around a 1:1 scale of the Milky Way. At first I was just casually playing on mouse/keyboard, but as I really started to enjoy it I started to get more involved. I added a HOTAS (Hands-on-throttle-and-stick) and mounted them to my gaming chair. I also bought some high-quality headphones to truly appreciate the sound quality in the game (which is stellar by the way). Most recently, I purchased a voice pack from Voice Attack so that I can control some aspects of the game with my voice. Unfortunately, voice attack doesn’t work unless there are keyboard commands filled in for every single possible binding in the game. There are over 300 possible bindings to fill in and I had absolutely no interest in doing this manually, and voice attack doesn’t provide any automated way to do this. You can download other people’s configurations but I wanted to make my own, I had already customized my HOTAS controls quite a bit and didn’t want to start over. So I was left with either; don’t use the voice pack, return the voice pack, fill in the bindings.

FILL IN THE BINDINGS

I chose to fill in the bindings but I didn’t want to do it manually. I wrote this java app that will take in the .binds XML file from the game, figure out what keyboard commands are used and unused, then fill in all of the empty primary and secondary bindings with unused command combinations. This takes all of the normal keys that can be used, combines them with possible modifier keys (shift, control, etc.) to create a fully functioning bindings file.

The Process

So this started out a bit rocky. My first thought was “ok, well, it’s XML so lets just read and write XML files.” I thought maybe it would be a good thing to learn how to do since, clearly, games still use them. However, after a while of hacking away at it (and getting pretty far) I decided to take the more obvious, simple approach. Writing the XML manually felt like the right thing to do, and it might have created a stronger system if I wanted to really provide in-depth editor capabilities in the future, but for now I just wanted a working file so I could play my game. So I chose to simply target all of the populated and unpopulated bindings with simple regex commands.

I knew the following to be true:

Empty Binds:

<Primary Device=“” Key=“” />

Filled Binds:

<Primary Device=“Keyboard” Key=“A”/>

Modified Binds:

<Primary Device=“Keyboard” Key=“A”>
	<Modifier Key=“LEFT_SHIFT”>
</Primary>

Using this logic I could easily find all of the Primary and Secondary commands that were populated, subtract those from the available options, then fill in the rest. This happens in basically three simple steps.

  1. Find the bindings
  2. Find the unused bindings
  3. Fill the bindings.

And Done!

Fun

It was a simple app, in the end, and I have some more things I could potentially do with in the future if I decide to. I want to keep pushing my Java skills forward but I’m not sure I’ll do it in this app. Some of these things include adding a UI or a complicated editor, as mentioned above, to really strengthen the abilities of the app. I could also add support for other games, especially those supported by Voice Attack. At any rate, I had a great time making it and I’m happy to be back in the pilot seat and talking to my ship.

Command Recognized: Self Destruct!