How can I disable input from mouse entirely?

I basically want to disable the mouse when a gamepad is connected.

I don’t want to lock or hide the cursor. I want there to be ZERO input from the mouse. If the cursor is locked it will interfere with the gamepad’s input setup.

Am I able to disable the mouse through script? Perhaps re-enable it later?

Create a bool to hold if the gamepad is connected, and if it is, don’t read from mouse, read from gamepad.
Or if you want it from InputActions asset, just create a Mouse ActionMap, ad then Enable to Disable according to your needs.

You could just do

InputSystem.DisableDevice(Mouse.current);
InputSystem.EnableDevice(Mouse.current);

depending on how the rest of your code works.

2 Likes

And what if I’m not using the new input manager? I’m using old fashioned, and I don’t believe the namespace InputSystem works with old input manager.

Action map is only for new input manager yes? I can’t seem to get the InputSystem namespace to register.

Just came back to say I found it more valuable to detect whether the controller is active. If so, I don’t check mouse controls. Fairly simple, but because I’m using Rewired I still needed to learn some more about the namespace.for Rewired. Have it working fine.

Reference:
https://guavaman.com/projects/rewired/docs/HowTos.html

If you use rewired and you want to completely disable mouse input. Don’t forget to uncheck “Allow Mouse Input” in the Rewired Standalone Input Module. Else the mouse clickes are still registered by the Input module and will for example reset the current selection in the Event System.