make the "A" button on my controller to left click in game for main menu

make the “A” button on my controller to left click in game for main menu

Hey @Willyboy0509! Welcome to the forums!

Can you provide a little more context to what you are currently having difficulty with, as it’s hard to understand the question being asked? Are you simply trying to set up making your “A” button to have the same function as left mouse click? If so, what engine version are you using? The answer will change depending on if you are using 4.X or 5.0+.

Any additional specifics you provide may go a long way in solving your problem!

I’m simply trying to set up making my “A” button to have the same function as left mouse click. im using unreal 5.3

I also got my right stick on my gamepad to move the mouse, im just trying to make the “A” button to act as left click for it work in the main menu

Hey @Willyboy0509,

Is there a reason you are having the gamepad move the mouse instead of just having a gamepad compatible main menu like in the following non-Epic affiliated tutorial video?

Add a Widget Interaction Component to the blueprint where you handle input; this will allow any device to pretend its input is the LMB:

The widget must be visible and be in focus for the above to work.

1 Like

it kinda worked, i can press ‘A’ on my gamepad but it does not interact with the widget, also i have a sound that plays when i click a button and it spams that when a hover with gamepad

my main menu is 3d so using it like a normal flat menu would not work

Anything more specific?

i have a sound that plays when i click a button and it spams that when a hover with gamepad

So it is interacting then, no? Or?


Any chance you could elaborate a bit?

I went back to the 2d main menu and im still using the "move the mouse with the gamepad right stick, i did your thing with the make the “A” button act like left click and i added a print string to show that it works and it does, but it does not press the buttons in the main menu.

I wish this solution works but is not working for me.
I have this button…place the mouse over the button and press the key to emulate the mouse click and in the click I print hello.

It prints when pressing the actual mouse left button but is not working when I press “I”

image

also on hover I force button focus to be sure:

image

Are we talking about a Widget Component? If so, this will only trigger onReleased by default. You’d need to change the way native buttons handle mouse down:

image

Setting focus manually should not be necessary, not with native buttons hungrily consuming it anyway.

not working :frowning:

using the widget debugger it seems that pressing my test key ‘I’ it actually triggers LMB but the click is not executed in the button.

Note: I want to interact with a widget in the viewport and not a 3d widget component in the 3d world.

The current workaround I implemented for my case is set a bool for hover in/out (true/false) and then create an event for each ‘click’ event in parallel that triggers the button event like this:

onButtonHover → bHover = true
onButtonUnhover → bHover = false
onButtonClick → doSomething
onGamepadButtonPressed → is bHover true? → doSomething

I have A LOT of buttons in my UI and this implementation is per button and painful.

ummmm…it turns out that if the button is FOCUSED then A gamepad button acts as a click press by default BUT when hovering a button it is not focused so if I force focus on hover then it works perfect and is the final solution. No need widget interaction component (actually works for 3d widget components only)

2 Likes

another problem I was having is turning the system cursor OFF and keep it off. Also force first focus to make it dissappear at the beginning.

Even setting show mouse cursor to invisible from player controller, it will be visible until first click.
My solution was create an ‘invisible’ widget in the background (a full screen image with opacity 0 but visible) and set focus on it.

Then everytime I focus something then the pointer appears again so I set cursor to NONE to every widget in the game like this:

(nada is the invisible widget for first click)

it actually works…but…is it the right way?

1 Like

Tested it (just in case) and it works fine. That’s UE 5.4.2.

As a Blueprint project user,

Man I’m frustrated, I’ve had enough of searching, maybe I’ll just go with Eldany’s hack. It’s simply insane how complicated it is to have a gamepad button click traditional UMG buttons in a context where the Gamepad also controls the mouse cursor, many Triple A titles are doing this BTW (Destiny, Marvel Rivals, ETC). 3D space is a breeze, you can make whatever system you want without the WidgetInteraction Component Everynone mentioned. 2D UMG is near impossible unless you make your own CPP code.

I’ve been using UE since 4.14 ish and this is the biggest headache I’ve had to deal with by far. 70 something threads, no real blueprint solutions, just hacks like the focus mentioned above (good find BTW, but ■■■■ (really? This forum censors “d 4 m n”?, you think your clients are children or something?)).

RAMA had a plugin in 2016 ish and it no longer works.

The other solutions I keep seeing are how CommonUI have AnalogMouse for the gamepad “click” behaviour instead of this focus-only BS approach for gamepads forced with the traditional UMG buttons. Porting over to CommonUI is a big no on year-long projects.

1 Like

There is a plugin on the marketplace that does the same thing as rama and it’s cheap
“Gamepad virtual Cursor”

For a small indie develop it is an option because it saves work, but seeing it in triple A games means that the developers are lazy because it is not the best way to move through menus with a controller.

It only moves the mouse cursor, as described, so that is wrong I’m afraid. It does not work the same as RAMA’s plugin which had the ability to trigger OnPressed / OnClick events of UMG Buttons using gamepad, without the need to be focused on buttons.

Note: The plugin is only responsible for moving the cursor using the selected controller stick. It lacks Common UI support, as well as reassigning keys on the controller that are responsible for left and right mouse clicks and drag n drop events.

If sound is spamming, a do once node is usually your friend.