Introduction

Gamepad Widget is a widget class that allows you to easily create controller compatible widgets for your game. It automatically changes the focused button's style to "Normal", "Hovered" or "Pressed" like it would using a mouse.

Link

Button/Controller interaction

This feature is what made me turn this into a plugin. It allows "focused" buttons to be properly displayed as "Hovered" or "Pressed". Focus navigation with a controller is already supported by Unreal Engine. It however doesn't allow for button styles to be applied straight out of the box.

This plugin manages it automatically for the user.

Widget Input Events

Although bad practice, being able to quickly hook up input events from a widget can save you a lot of time. There are two events available:

OnGamepadButtonDown
OnMouseKeyboardButtonDown

 

Having gamepad events separate from mouse and keyboard ones also allows you to implement device specific behaviours.

Documentation

 

Step 1: Widget creation

   First of all, for your widget to inherit the plugin's features you have to make it a child class of the GamepadWidget class. This is done by creating a new blueprint class and looking for the "GamepadWidget" class (see screenshot). If your widget already exists, you can also reparent it by going to its Class Settings and changing its parent class from UserWidget to GamepadWidget.

Step 2: Widget set up

In your newly created widget, look for the EnableGamepadSupport function. You need to input an array of all the button you wish the gamepad to have access to, and the button that should be selected when the menu is spawned. This all the coding that is required for the plugin to work. 

Buttons will now automatically change style when a gamepad is used and the widget will automatically detect which input device is being used (gamepad or mouse).

Extras

Several functions are available if you want to interact with buttons via blueprints. These require the gamepad support to be enabled (see Step 2) and should work with no issue alongside the plugin's functionalities. 

If you want to further customise the way the plugin works feel free to open up the GamepadWidget widget class and modify from there! Everything is commented so you should be able to understand what's happening under the hood!

Last updated: March 2020
  • GitHub
  • Sketchfab
  • LinkedIn
  • Twitter