Using gamepad for menu navigation?

Hi there,

I am currently at a block I can’t get my head around: How do you set up a menu to be controlled witch a gamepad?

Normally, I would do it by selecting the first button as soon as a player moves the stick and let Unreal’s navigation do the rest, but I can’t find a way to do that. Do I have to write my own buttons for this?

Thanks in advance!

Update: SetKeyboardFocus() on one of the UButtons does the trick when it comes to selection and using the button, but is there a way to make it hovered?

I found something in the Unreal forum. The problem is that they suggest to add something to the engine code in the SWidget.h. This can’t be the only way right?

    /** @return True if this widget hovered */
    virtual bool IsHovered() const
    {
        return bIsHovered || HasKeyboardFocus();
    }

It’s not as straight-forward as using a mouse as you have to handle the menu item states manually - they cannot be handled automatically.

  • First, set up actions for menu up, down etc for your navigation controls, probably keyboard as well as gamepad.

  • Then, you’d need a variable to track which menu item is currently selected, and probably an array of options that can be selected in and which order as in up and down. The item you are tracking could be an index to this array so when 0, you can’t go up, when array length -1, you can’t go down.

  • As you detect action up, you check for 0, and do nothing, otherwise set the state back to normal of the selected item, subtract 1 and set it to hover.

  • As for down, same idea but add 1 and check for length -1.

This assumes of course your menu is a simple up-down menu.

There are a number of guides and samples out there, a lot of which are Blueprint but also a few people asking exactly this and using C++. I hope this helps.

Just as I hoped it would not be. Thanks a bunch, I’ll go on and write my own navigation system then. xD

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.