Sunday, 7 May 2017

Menus with Controller Support

One of my goals with this project was to create menus with controller support.

I thought this would be a simple affair, but it seems it's a bit more difficult than simply having the controller focus a widget.

The expectation was that setting the button style for mouse hover would also work for having the button focused with the controller, but this is not the case.

There is a 'quirk', though it is intended functionality, with UE4's menus in that mouse hover and controller button focus are treated as different things, which is probably useful in some circumstances, but makes controllers interacting with simple list menus more complex than they need to be.

To get this to work as one would expect, you need to capture which menu item is being focused by the controller and set the button style accordingly.

This is achieved by first adding all of the buttons in the menu to an array when the menu is created in memory.



This array is then used by a loop function checking the focus status of each button in turn, constantly updating which one is focused or not. This makes is less efficient than it would be if focus was treated as hover.



While this method works for the controller, it also breaks the standard hover functionality of the mouse, so we need to capture the hover status of the buttons and convert that hover into a focus state so it can be processed correctly by our function.



I feel it is an oversight on Epic's part to not at least allow a option in the widget setting that lets focus be treated as, or at least handled in the same way as, a mouse hover event. Another way this could be solved is have a focus style setting in the list along with hover. Games are being forced to be less efficient if they are required to use this method to control menus in a way the player would expect, plus it takes a much longer time for the developer to set each menu up.

Just look at all the extra code and looping required just to add this controller functionality to a menu.

No comments:

Post a Comment