How can I control cursor with joystick

Hello people,
I am doing a custom cursor that needs to be controlled by the joystick. To control the cursor with the mouse is quite easy, but I am trying to figure the equivalent but with the joystick axis input.
To move cursor with mouse is done like this:

function OnGUI ()
    GUI.DrawTexture( Rect(Input.mousePosition.x-cursorSizeX/2, (Screen.height-Input.mou.y)-cursorSizeY/2, cursorSizeX, cursorSizeY), myCursor );

How can I do it with Joystick?

Inside of the Input-Manager, you can set the joystick axis to the mouseX and mouseY. That way, you should be able to control the cursor using Input.GetAxis(Mouse X) and Input.GetAxis(Mouse Y).

Input Manager is located under: EditProject SettingsInput

and here is a mapping guide for controllers:
Joystick/Controller - Unity3D (

Already figured it out:

x = Input.GetAxis("Horizontal") * speed * Time.deltaTime; 
y = Input.GetAxis("Vertical") * speed * Time.deltaTime;

Hi there ! :slight_smile:

I resurrect this subject after a few years because I have trouble controlling the Unity Cursor with the Xbox controller left joystick. The context in game is this one :

  • Oculus Player with movements controlled by left Xbox joystick
  • Pressing B Button, a Pause Menu is displaying (simple canva Camera Space)
  • Unity Cursor appear and shall “OnClick” buttons (among them : resume)

Of course, my question is about the third step of this process as I fail to recover joystick movement while canceling the one of the first step’s setup. The cursor in pause menu shall be controlled by left joystick.

I’m pretty new to c sharp and i’m confused between both coding and unity’s drag & droping logic on this specific task.

I will surely appreciate any help from you ! :heart:


Now struggling on how to constraint GUI Cursor position at screen limits and how to make the GUI cursor act like a mouse, regarding “OnClick” behavior.

using System.Collections.Generic;
using UnityEngine;

public class XboxCursor : MonoBehaviour
    public Vector3 originalPosition; //Original Position stored for "Start at Center position" Cursor behavior
    private Vector3 startPos;
    private Transform thisTransform;
    public float sensitivity = 0.2f;
    void Start()
        thisTransform = transform;
        this.transform.position = originalPosition; //Wrong method for reset to center position...
    void Update()
        // Joystick Axis Acting
        Vector3 inputDirection = * sensitivity;
        inputDirection.x = Input.GetAxisRaw("Horizontal") * 0.1f;
        inputDirection.y = Input.GetAxisRaw("Vertical") * 0.1f;
        thisTransform.position = startPos + inputDirection * sensitivity;
        startPos = thisTransform.position;
        //Screen Constraint  -- Not Working at all for some reason
        this.transform.position = new Vector3(Mathf.Clamp(transform.position.x, -1f, 1f),
                        Mathf.Clamp(transform.position.y, -2f, 2f), transform.position.z);
        // Mouse OnClick Mimetism
        if (Input.GetButtonDown("Button A"))
            Debug.Log("Mouse Click !"); //But still at real mouse position ! xP
           //TP Mouse (Bad Opt)
           //Raycast GUI (Good Opt... Searching Doc...)

EDIT : Leaving this here, but subject abandoned after new UX project approach.

I want to know about this… how to make virtual mouse cursor for control via Nintendo Switch pro controller connected to PC.

There is also a paid solution in the unity asset store that does this for Windows: