Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Changing the default Virtual Mouse inputs

Discussion in 'Input System' started by Tempus_G, Mar 23, 2022.

  1. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    I have a problem that I am not finding enough information on. Basically my Virtual Mouse which I have created using THIS tutorial, has default buttons. The South button on the gamepad is set as the "Virtual Mouse Left Click" and I am not able to find how to change it. I set up an Action to use the right shoulder as my mouse button, but the south button still sends action calls. How can I change the default Virtual Mouse button mapping in code? Really there should be a way to set what buttons are used to drive the virtual mouse buttons.
     
  2. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    OK. I feel like I have egg on my face for not seeing this before. :oops:
    Basically there was some script that checked for a button in the tutorial. o_O
    Code (CSharp):
    1.         bool aButtonIsPressed = Gamepad.current.aButton.IsPressed();
    2.         if (previousMouseState != aButtonIsPressed)
    3.         {
    4.             virtualMouse.CopyState<MouseState>(out var mouseState);
    5.             mouseState.WithButton(MouseButton.Left, aButtonIsPressed);
    6.             InputState.Change(virtualMouse, mouseState);
    7.             previousMouseState = aButtonIsPressed;
    8.         }
    Commented it out and now no input from the south button that was not asked for.:)