# How to move mouse cursor with Gamepad stick?

**URL:** <https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 1, 2014, 4:35pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609 "2014-09-01T16:35:58Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Albert\_Espin\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Albert\_Espin\_1](https://forums.unrealengine.com/u/Albert_Espin_1)\
**Post date:** [September 1, 2014, 4:35pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/1 "2014-09-01T16:35:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Raiden58237](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Raiden58237](https://forums.unrealengine.com/u/Raiden58237)\
**Post date:** [September 1, 2014, 10:00pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/2 "2014-09-01T22:00:28Z")

</div>

Are you using a Microsoft Wired Xbox 360 Gamepad?

---

<div class="post-metadata">

**Author:** ![TimGS](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TimGS](https://forums.unrealengine.com/u/TimGS)\
**Post date:** [September 1, 2014, 10:05pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/3 "2014-09-01T22:05:48Z")

</div>

Use Rama’s plugin to move mouse cursor in BP [How could I Set mouse position via Blueprint? - Programming & Scripting - Unreal Engine Forums](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.

---

<div class="post-metadata">

**Author:** ![Albert\_Espin\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Albert\_Espin\_1](https://forums.unrealengine.com/u/Albert_Espin_1)\
**Post date:** [September 2, 2014, 5:53am UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/4 "2014-09-02T05:53:58Z")

</div>

Yes, I am.

---

<div class="post-metadata">

**Author:** ![Raiden58237](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Raiden58237](https://forums.unrealengine.com/u/Raiden58237)\
**Post date:** [September 2, 2014, 2:32pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/5 "2014-09-02T14:32:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Albert\_Espin\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Albert\_Espin\_1](https://forums.unrealengine.com/u/Albert_Espin_1)\
**Post date:** [September 2, 2014, 10:34pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/6 "2014-09-02T22:34:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Albert\_Espin\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Albert\_Espin\_1](https://forums.unrealengine.com/u/Albert_Espin_1)\
**Post date:** [September 2, 2014, 10:35pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/7 "2014-09-02T22:35:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [September 15, 2014, 9:05am UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/8 "2014-09-15T09:05:24Z")

</div>

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"

/**
 * 
 */
UCLASS()
class YOURPROJECT_API AMyNewPlayerController : public APlayerController
{

	GENERATED_UCLASS_BODY()

public:
	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:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/3X/a/d/adfb191acd0970a6d44eb2b029f3c4fb8fee19a7.png) ](https://i.imgur.com/QggohRU.png)

---

<div class="post-metadata">

**Author:** ![abhishek17](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@abhishek17](https://forums.unrealengine.com/u/abhishek17)\
**Post date:** [March 26, 2015, 6:31pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/9 "2015-03-26T18:31:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 27, 2015, 9:20am UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/10 "2015-03-27T09:20:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8b31b095](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8b31b095](https://forums.unrealengine.com/u/anonymous_user_8b31b095)\
**Post date:** [July 15, 2015, 10:20am UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/11 "2015-07-15T10:20:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aerique](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aerique](https://forums.unrealengine.com/u/aerique)\
**Post date:** [September 10, 2015, 9:49pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/12 "2015-09-10T21:49:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![VinnyBlood](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VinnyBlood](https://forums.unrealengine.com/u/VinnyBlood)\
**Post date:** [February 20, 2023, 5:48pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/13 "2023-02-20T17:48:48Z")

</div>

Using timeline for incrementing variable’s vaue is the most deeply disturbing thing I saw in years.

---

<div class="post-metadata">

**Author:** ![ArkCreator](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arkcreator/32/1148494_2.png) [@ArkCreator](https://forums.unrealengine.com/u/ArkCreator)\
**Post date:** [December 18, 2023, 2:10am UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/14 "2023-12-18T02:10:53Z")

</div>

Here You GO! [Move Mouse Cursor With Game Pad posted by Shuan | blueprintUE | PasteBin For Unreal Engine](https://blueprintue.com/blueprint/nrn9vpao/)  
Input axis Moue 2D inputs are:  
“Mouse X axis” value: 1  
“Mouse Y axis” value: -1

---

<div class="post-metadata">

**Author:** ![ftshrk-peter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ftshrk-peter](https://forums.unrealengine.com/u/ftshrk-peter)\
**Post date:** [May 27, 2024, 3:03pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/15 "2024-05-27T15:03:21Z")

</div>

Where should this code go?

---

<div class="post-metadata">

**Author:** ![ArkCreator](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arkcreator/32/1148494_2.png) [@ArkCreator](https://forums.unrealengine.com/u/ArkCreator)\
**Post date:** [May 30, 2024, 10:46pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/16 "2024-05-30T22:46:55Z")

</div>

In the player controller

---

<div class="post-metadata">

**Author:** ![ArkCreator](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arkcreator/32/1148494_2.png) [@ArkCreator](https://forums.unrealengine.com/u/ArkCreator)\
**Post date:** [May 30, 2024, 11:13pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/17 "2024-05-30T23:13:01Z")

</div>

Also If you have questions and can’t find the answer on here you could join my Patreon for access to my discord community. I can help you one on one! [Patreon Link](https://patreon.com/ArkCreator?utm_medium=unknown&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink)

---

<div class="post-metadata">

**Author:** ![ArkCreator](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arkcreator/32/1148494_2.png) [@ArkCreator](https://forums.unrealengine.com/u/ArkCreator)\
**Post date:** [May 30, 2024, 11:16pm UTC](https://forums.unrealengine.com/t/how-to-move-mouse-cursor-with-gamepad-stick/292609/18 "2024-05-30T23:16:00Z")

</div>

Let me know if you still need this!
