White Shining Rock Logo
White Shining Rock Logo

UI Redo: Part 5 - Controllers

November 17, 2021 | Dukus | 9 Comments

I didn't support a gamepad style controller in Banished. Mostly because by the time I thought it would be useful, there was so much intractable hard to change UI that I didn't want to add another 500K of C++ code and tons of layout data to make the game work.

With a clean slate and new game, the implementation of adding controller support to my engine was actually fairly easy. The low level code to read an xbox controller on PC is really simple, and since my entire input system is setup to handle remapping any input to any button (mouse, keyboard, or controller) it just worked once I could read the controller. (I'll mostly likely be adding support for other controllers later, and the Steam input API.)

I had to add a mode for the game to know what the player was doing with input devices. If you use the keyboard and mouse, it reports one thing, and if you use the controller it reports another. This way during testing I can flip flop from keyboard to controller, and the UI changes behavior and look automatically. And if users happen to want to switch between the couch with Steam Link to desktop computer, it'll just work no matter what input interface you grab.

Then I made a few changes to the user interface internals to make buttons and other elements focusable and navigable, and I was pretty much done.

The tricky places are where the keyboard/mouse and controller modes have differing schemes. Keyboard users will use WASD+mouse for looking and moving around, but when holding a controller it's two thumbsticks. A row of buttons that users will click on with the mouse requires the controller to have focusable buttons that can be navigated with the d-pad. It's two sets of code to maintain, but there aren't that many places that do it, and it's pretty small (so far).

Having this dual controlling scheme has actually been really helpful in designing interfaces. I've been trying to keep it simple and make designs that work for both keyboard play and controller play so that I'm not displaying two different things for different modes. It's a design constraint that has been really helpful. I'll change UI to show different buttons and have diverging layouts where it makes sense, but I'm avoiding it as much as possible.

I had a lot of control schemes already setup that didn't strictly use UI elements (like placing objects, navigating the world, inspecting objects, etc). I did have to go back through and make them workable with a controller, but I'm glad it's done early, before I have a huge amount of user interface in place.

Having done this early on will also make it more possible and easy to ship the game on consoles, but that's far away right now. My focus is to be able to play from the couch, as well as in front of a keyboard.

So that's it for UI changes.

Hopefully these changes I've talked about in the last 5 posts will improve my quality of programming life and allow me to change user interface quickly and without breaking things. The UI will look better, and control better.

I do often question performing a major upgrading an integral system like this - the idea is that it will save me time and effort later, but it takes a bit of time up front, with rework of assets that are already in place. With a currently working system that outwardly has very similar functionality, I wonder if I should just carry on with what I've got and make progress?

But I'm avoiding that technical debt, right?

Onward to other things!

Leave a Reply

9 comments on “UI Redo: Part 5 - Controllers”

  1. That's awesome for controller fans.
    Personally I have ZERO dexterity and fine control required to use a gamepad, esp to play games that require more than 8 points to control.
    (Moving = 4, jump, Sprint, fire, use).

  2. We are always in debt !

    " The only constant in life is death and taxes"
    -Ben Franklin

    Keep up the great work Luke !!

  3. Is it possible to be any more excited for a game release? For me, no!

    I know this might still be unknown Luke, but any even theoretic plan on when you are looking to ship?

  4. Please, ...' just carry on and make progress'...
    A lot of us are hoping for your new game while we are still young enough to play.

  5. I play Banished on my large TV, on my couch, with a keyboard and mouse running my PC.

    i hope to continue to do the same, even if it's on console. weeeee

  6. Hi Luke, that's some cool inputs you're working on! I have a Wooting keyboard which can do both digital input as well as analog input with an xbox interface. I bet that it would work fantastic with how you're adding support for those kind of controllers/inputs!

    Looking forward to all possibilities with these kinds of controllers.

    I case you are interested in what this keyboard is about: https://wooting.io/

More Posts

UI Redo: Part 3

October 25, 2021

UI Redo: Part 2

October 19, 2021
1 2 3 47
Back to devlog
Back to devlog
© Copyright 2021 Shining Rock Software
Website Design & Branding by Carrboro Creative
menu-circlecross-circle linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram