Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to move mouse cursor with Gamepad stick?

Hi, I've enabled mouse cursor for a sort of menu stage and it moves and is controlled just fine with the mouse input, but how do I move it with the Gampead stick? Is this possible in BP at all?

Product Version: Not Selected
more ▼

asked Sep 01 '14 at 04:35 PM in Blueprint Scripting

avatar image

Albert Espín
987 81 98 361

avatar image Raiden58237 Sep 01 '14 at 10:00 PM

Are you using a Microsoft Wired Xbox 360 Gamepad?

avatar image Albert Espín Sep 02 '14 at 05:53 AM

Yes, I am.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Use Rama's plugin to move mouse cursor in BP https://answers.unrealengine.com/questions/37165/set-mouse-position-via-blueprint.html

All you just need is to set your gamepad stick to control BP function moving mouse cursor.

more ▼

answered Sep 01 '14 at 10:05 PM

avatar image

626 20 23 239

avatar image Albert Espín Sep 02 '14 at 10:35 PM

I'm on 4.2 and can't go to 4.4 in this project (the plugin is in 4.4) or I will get a bunch of errors. I've asked Rama if he could please provide me with a 4.2 older built but haven't got a response yet.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Go into the Project Settings and within the Input, set it up so you can use one of the Analog sticks as well as the mouse cursor. They should be listed as something like gamepad joystick x or something like that. Obviously you will need to setup the axis within blueprint but this would most probs be similar to how the default controls are setup with a character. I would supply a picture but I am not on my own computer at the moment. Let me know how you get on.

more ▼

answered Sep 02 '14 at 02:32 PM

avatar image

97 14 21 27

avatar image Albert Espín Sep 02 '14 at 10:34 PM

Hi, thanks for the suggestion, but as far as I know there you can create Input events with Gamepad Left and Right X and Y axes but there's no configuration there on making the mouse controllable by Gamepad and I haven't found how to manually modify mouse position in BP.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hey Albert, I recently had to do this as well. This isn't perfect but it should get you on the right direction.

I used Rama's code for setting the cursor position in blueprints. (As a disclaimer I don't know C++ so this is sort of hobbled together)

Go to file Add Code to Project. Create a new class from PlayerController and call it NewPlayerController

in the .h file:

 #pragma once
 #include "Kismet/BlueprintFunctionLibrary.h"
 #include "GameFramework/PlayerController.h"
 #include "MyNewPlayerController.generated.h"
 class YOURPROJECT_API AMyNewPlayerController : public APlayerController
     UFUNCTION(BlueprintCallable, Category = "YOURCATEGORY")
     static bool Viewport__SetMousePosition(const APlayerController* ThePC, const float& PosX, const float& PosY);

In the .cpp file:

 #include "YOURPROJECT.h"
 #include "MyNewPlayerController.h"
 AMyNewPlayerController::AMyNewPlayerController(const class FPostConstructInitializeProperties& PCIP)
 : Super(PCIP)
 bool AMyNewPlayerController::Viewport__SetMousePosition(const APlayerController* ThePC, const float& PosX, const float& PosY)
         if (!ThePC) return false;
         //Get Player
         const ULocalPlayer * VictoryPlayer = Cast<ULocalPlayer>(ThePC->Player);
         //PlayerController::Player is UPlayer
         if (!VictoryPlayer) return false;
         //get view port ptr
         const UGameViewportClient * VictoryViewportClient =
             Cast < UGameViewportClient >(VictoryPlayer->ViewportClient);
         if (!VictoryViewportClient) return false;
         FViewport * VictoryViewport = VictoryViewportClient->Viewport;
         if (!VictoryViewport) return false;
         //Set Mouse
         VictoryViewport->SetMouse(int32(PosX), int32(PosY));
         return true;

After rebuilding, open your playercontroller blueprint and reparent it to your new playercontroller. Right click, and enter "Set mouse" and you should see the new node you created, under whatever category you entered in the .h file.

This is my playercontroller, controlling the cursor with the D pad: alt text

more ▼

answered Sep 15 '14 at 09:05 AM

avatar image

1.8k 49 22 67

avatar image abhishek17 Mar 26 '15 at 06:31 PM

Hi. Do you know how to simulate mouse click with gamepad? I basically want to click on a menu button with gamepad. How can I go about it? Any help would be greatly appreciated.

avatar image 7hny Jul 15 '15 at 10:20 AM
 FViewportClient* Client = GEngine->GameViewport->Viewport->GetClient();
  Client->InputKey(GEngine->GameViewport->Viewport, 0, Key, EInputEvent::IE_Pressed);

Then you can just make a Key variable in BP, assign "Mouse Left Click" to default value.

avatar image aerique Sep 10 '15 at 09:49 PM

Awesome, thanks for that example. I've been looking for that!

avatar image Mosel3y Mar 27 '15 at 09:20 AM

I couldn't figure out a way to do that, but if your widget has focus, you can use the left analog stick or D-Pad to select buttons and use the A button on the gamepad to click them. It only works for buttons. That is in 4.6 though. You can also trace to get the widget under the cursor position, I done that with a 3D widget component in 4.6. You wouldn't use the actual cursor, just an icon on screen that represents the cursor.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question