Fixing my Input System for Ludum Dare Day 4

Today I've managed to finally finish the Input System :). Of course nothing's perfect and I will have to add and rewrite a lot of things after the jam, but for now it's good enough to make a game with.

XInput

As I said before, I was using Unity's legacy Input Manager (UIM) for handling gamepad input. If you don't know: UIM sucks, especially if you're working with gamepads. So I've decided to ditch it and instead use xinput.

IMGem20220929/em223231123.jpg

Turns out: xinput is kinda cool. It's fairly simple and easy to use. It may not have the best support for non xbox controllers out of the box, but for making simple game's it's more than plenty. ~~besides, steam input handles everything these days anyways.~~

Referencing input

If you want to get the state of an input, you can call it out by its name via the Input Manager. However, this isn't the best, as you have to know how something is called. That's where input references come in: they are just a fancy string that stores a reference to an item and allows you to select it in a window.

Screenshot 2022-09-29 223430.png

In the old version, they used to store the group name and item name, which worked, but could easily break when renaming items. And since this new version uses guids, the references store those instead.

Togglers

Another great feature of qASIC (a collection of tools which this input system is a part of) are the togglers: they are just these really simple scripts that toggle objects when you press a button. They are great for pause menus, hiding UI and even toggling things such as a cheat console. Because they are so simple, they required me to literally modify a single line of code to get them working again.

Screenshot 2022-09-29 223442.png

Remapping

This was another interesting one. I don't want people to remap gamepad keys in the keyboard menu, so I had to think. In Cablebox keys are stored as paths (e.g. key_keyboard/W, key_gamepad/RightStickUp). This makes my job fairly simple as I just need to check the root path to identify the controller type.

Screenshot 2022-09-29 223539.png

Also, the keyboard device was listening to my mouse. You can imagine how fun it was to click and automatically assign my mouse on every binding. So I had to implement a small keycode exclude list and there we go.

Finished?

At this point I've compleated every required feature for Cablebox to function. Now I'm gonna do other pre-jam activities and get ready for this thing. It's been fun, but everything has to come to an end at some point.

Also no, I won't release this thing, it's probably unstable and I will probably have to crack it open during the jam anyways. For now there's the old version that doesn't have gamepad support, but it's really bad compared to the development version.