White Shining Rock Logo
White Shining Rock Logo

UI Redo: Part 5 - Controllers

November 17, 2021 | Dukus | 15 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

Your email address will not be published.

15 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/

  7. I’m on the need this to work on iPads and android, as a hit and run vitamin it would be wonderful to play again the games I miss like yours. Truly please bring it, if not for me the for many in the kids hospitals the get iPads only, and some pls doesn’t help. So you can see I’m asking from a good place and if this happens it does if not well I tried.

  8. Just here to say I religiously read your devlog although I understand zero of it because I'm so excited about a new game 😀

  9. Hi, i hope your new game becomes a legend as Banished is, i wanted to just make a quick note about the game, maybe its just a tweak in the settings, but the calculation and of time to space is too strict in my opinion, when you are expanding a city or settlement i would have liked to make more "empty" spaces for parks for example or even 3tiles wide roads between homes but in anther hand its make is so much difficult to make a productive city like that which means less food and production overall which is crucial to sustaining the city. i think the game overall is brilliant and i hope the new one would be the same.

  10. I am really glad that you are still programming and working on a new game. Banished was such a wonderful experience so I am always looking forward with what you'll do next! I dont really know programming, but I want to let you know that I am really interested in your progress.

  11. I am a PC guy, but being able to play banished on xbox would be ideal. I want to play your games on TV easily.

  12. Does this mean that your new game has the potential to be released on (handheld) consoles as well? I know of entire groups of people (including those that have no other means of playing games but by controllers such as people with certain physical disabilities) that would LOVE to be able to play your new game using a controller.

    I might not want to play anything other than racing games, platformers or fighting games with a controller, but that doesn't mean I can't imagine others liking it.

    Be sure to do it right to avoid that pesky technical debt 🙂

More Posts

Code Rot

April 17, 2022

UI Redo: Part 3

October 25, 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