Gamepad Menu Navigation Issues
I am trying to include full gamepad (XBox one controller) support. I would like to have a cursor controlled by the left thumbstick and the "a" button (gamepad face bottom) to select (generate a click). Very similar to Destiny's menu system if you are familiar with the game. I have just set my controls in blueprint to control the mouse cursor with the thumbstick relatively easily. I thought that would be the hard part but apparently generating a click is the real issue.
This is a very similar issue: https://answers.unrealengine.com/questions/206312/simulate-left-click-with-abutton-of-gamepad.html
In the potential solution above, the line trace will not fire the on pressed event of the button. Even if the line trace correctly finds the button, how do I go about "pressing" it with a reference to the object?
Here are some other potential solutions I would like to pass by the unreal experts here:
The biggest issue here is that I can't manually fire off the onpressed event in any way other than an actual click or touch to my knowledge.
Another issue: Mouse controls will be killed if/when this game is exported to Xbox, correct? Xbox does not have mouse support? I can absolutely emulate a "virtual" mouse with some interface work but this is something I would like to consider when picking a solution.
Please help me out!!! This is hurting my brain and I will liberally be handing out +1s to anyone can offer constructive ideas or solutions.
Thank you so much in advance!
I found a solution for the left click event that triggers UI 'on clicked' events. I've looked into this because I want a handtracker to move the mouse and also click things. You'll have to go into c++ to make it work, but its not too complicated and if you struggle with it, let me know. So add a new c++ class which inherits from player controller (this is nog mandatory but its nice to have it in a player controller) Then in your .h file add 2 functions like so:
The blueprint callable makes it so that you can trigger the function from blueprints. The first function simulates the click down and the second function the release. You need both.
Then in the .cpp file add the code below. The first part triggers any LMB click events and the part below that handles the UI clicks.
For my hand tracking solution in the blueprint I trigger the mouse click down on a hand pinch. Don't forget to also trigger the mouse click up events with a small delay or on a button release. In your instance you can detect a specific button press and then trigger the mouse click down function and trigger the mouse click up on button release.
answered Apr 02 '19 at 07:54 AM
You... kinda can, but it's a little wonky. Here's what I did:
I ran into this issue and came up with a way to do it, but honestly, it's probably just one of those things that isn't grammatically incorrect, but that you should probably just try to avoid doing things that way? (My use is on a menu for a game that will use mouse and keyboard, as well as controller. I used Rama's plugin to move the cursor, but couldn't click, (I will explain how I now click) but even after being able to click, it isn't better than just having an array of buttons, and swapping focus between them with D-Pad or something, and having A activate the highlighted button?
The workaround I came up with (Hopefully images are simple enough to get into this, I've never really posted on these forums much/at all before.) involves grabbing button input on the player pawn, which sets a bool. (This could probably be done on a player controller, or any blueprint accepting input if it's single-player. I have it on the player pawn because I'm using an in-level menu, and am now thinking about moving it to the controller in case of other pawns.
So the pressed output of the input button event for Gamepad Face Button Bottom (A on Xbox, X on PS) sets the variable "IsPressingA" on the player to true. Releasing that button then sets the variable to false.
Then, in the widget blueprint, have an event tick that feeds into a cast to the player (I cast to the owner of the widget, which I assume is probably what you want depending on your use) you want input from (Who has the "IsPressingA" bool on them.) If the cast is works, have it feed into a Branch, which is directed by getting the IsPressingA bool. (Which you can rename obviously.) If true, then you can run that into a sequence with one output for each of your buttons. These outputs then feed into more branches, which will check if each button is currently hovered. (Unless they're overlapping, this should only ever be true of one of them.) Now, you can feed that "True" branch into the code you have tied to that button, be it a widget swap, or a level change, or exiting the game, or whatever.
Now.... you kind of have a way to spoof input. Yay.
Hopefully this is kinda what you were looking for?
Follow this question
Once you sign in you will be able to subscribe for any updates here