Gamepad-Friendly UMG ~ Control Cursor with Gamepad Analog Stick! Easily Click Buttons!

For those looking at how to change which analogue stick the input is taken from, in GameAnalogCursor.cpp line 136…


//grab the cursor acceleration
const FVector2D AccelFromAnalogStick = GetAnalogCursorAccelerationValue(GetAnalogValues(), DPIScale);

GetAnalogValues() is the function which gets the stick input, and it can take an argument which is the stick to read, EAnalogStick. It defaults to EAnalogStick::Left, and I’m guessing because its such a common use case this code doesn’t worry about the possibility of changing that. I needed to, and I see a few of you do too, so if you add an argument in here you can change the line to use a different stick…


//grab the cursor acceleration
const FVector2D AccelFromAnalogStick = GetAnalogCursorAccelerationValue(GetAnalogValues(**EAnalogStick::Right**), DPIScale);

You can expose this as a new setting to the editor, but it requires a bit of workaround. This is because EAnalogStick is not a UENUM, which means it can’t be used on a UPROPERTY. However, I worked around this by creating a new UENUM in GamepadCursorSettings.h (I called mine EGamepadAnalogStick), which has the same members “Left”, “Right”, “Max”. You can then make a UPROPERTY based on EGamepadAnalogStick (or whatever you call yours), which allows that value to be changed in the editor along with the others. Now you can create a new inline function to return EAnalogStick, and have that function work out which of the EAnalogStick values is the same as your EGamepadAnalogStick values. Finally, call that function as the argument for GetAnalogValues and you’ve got yourself a new editor setting for the stick! :slight_smile: