Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Question "Device is DISABLED" for mouse every time a game starts?

Discussion in 'Input System' started by msh91, Apr 16, 2021.

  1. msh91

    msh91

    Joined:
    Apr 22, 2017
    Posts:
    37
    I'm using the new input system with Unity 2020.3.3f1 , and the mouse isn't working.
    When looking at the input debugger, then mouse screen, there is a message there:

    "Device is DISABLED. Control value will not receive updates. To force-enable this device, you can right-click it in the input debugger and use 'Enable Device'".

    While the force-enable works, the mouse will be disabled again when I restart the game.
    How do i fix it? why is it even happening?
     
  2. NibbleByte3

    NibbleByte3

    Joined:
    Aug 9, 2017
    Posts:
    81
    I have the same issue. No click action bindings are triggered (want to bind "Back" action on the right mouse click), but the InputSystemUIInputModule seems to work and UI gets clicks. "Enable device" doesn't work for me. Removing the InputSystemUIInputModule didn't help too.

    I'm using Unity 2020.2.7f with Input System package 1.1.0-preview.3.
    I don't use PlayerInput component, I create my own IInputActionCollection instance, generated from the editor.
    I'm sure the action is enabled, as the keyboard and gamepad bindings work fine.

    upload_2021-5-3_17-9-50.png

    Reported this to Unity via the "Report a bug" form.
     
    Last edited: May 3, 2021
    Adamsauce likes this.
  3. NibbleByte3

    NibbleByte3

    Joined:
    Aug 9, 2017
    Posts:
    81
    I've found out why this happens.
    I had "Simulate Touch Input From Mouse or Pen" enabled which suppressed mouse events. Turning it off fixed it for me. Check yours in the "Input Debug" window, "Options" button.
     
    Donn999, kamsin25, mingkimlow and 2 others like this.
  4. BrotherWrong

    BrotherWrong

    Joined:
    Feb 19, 2017
    Posts:
    6
    Didn't help in my case, I'm afraid. Whenever I switch into playmode the mouse gets disabled again. But even when I pause playmode, enable the mouse device and unpause no input is detected or recorded.

    Did anyone ever find a solution for this? Without mouse input, my game is broken. :(
     
  5. NibbleByte3

    NibbleByte3

    Joined:
    Aug 9, 2017
    Posts:
    81
    I see in your other post that you tried a lot of stuff and it didn't work. I guess you'll have to strap on and dive in with the debugger. :D If I were you, I'd put break point on all the places InputDevice.m_DeviceFlags changes. With some patience you should get to the culprit.
     
  6. BrotherWrong

    BrotherWrong

    Joined:
    Feb 19, 2017
    Posts:
    6
    Thanks. Sounds like I borked this up somewhere. Not sure how to debug this with Playmaker though. Wish me luck. :p
     
    NibbleByte3 likes this.
  7. BrotherWrong

    BrotherWrong

    Joined:
    Feb 19, 2017
    Posts:
    6
    How would I do that?
     
  8. NibbleByte3

    NibbleByte3

    Joined:
    Aug 9, 2017
    Posts:
    81
    Uhm... not sure what you're asking and what is your background. So here it goes...

    If you're asking what to look for, it's hard to say:

    Looking at the InputDevice.enabled code it returns false when m_DeviceFlags has flags "DeviceFlags.DisabledInRuntime", "DeviceFlags.DisabledInFrontend", "DeviceFlags.DisabledWhileInBackground", etc...
    Code (CSharp):
    1.  
    2.         public bool enabled
    3.         {
    4.             get
    5.             {
    6.                 #if UNITY_EDITOR
    7.                 if (InputState.currentUpdateType == InputUpdateType.Editor && (m_DeviceFlags & DeviceFlags.DisabledWhileInBackground) != 0)
    8.                     return true;
    9.                 #endif
    10.  
    11.                 if ((m_DeviceFlags & (DeviceFlags.DisabledInFrontend | DeviceFlags.DisabledWhileInBackground)) != 0)
    12.                     return false;
    13.  
    14.                 return QueryEnabledStateFromRuntime();
    15.             }
    16.         }
    So you need to find who is setting those, which indeed can be hard as this code is very deep.


    If you're asking how to do debugging in general:

    How to debug with Visual Studio - https://www.youtube.com/watch?v=d0815qbx3BA (random tutorial on the internet).
    What you need is the "Call Stack" panel at the bottom right.
    So, in VS go to the "PackageCache\com.unity.inputsystem@1.2.0\InputSystem\Devices\InputDevice.cs" file and put a break point (F9) on every line the m_DeviceFlags is set.

    Attach the debugger and run the game and keep resuming till you get who is setting it with disable flags. Check with the call stack to trace back the culprit.

    If your break points don't work and you don't see the Unity.InputSystem project in Visual Studio like so:
    upload_2022-1-9_14-16-16.png

    You need to enable generating of such projects in the preferences. Go to Edit/Preferences/External Tools and enable "Embedded packages", "Local packages", "Registry packages", "Built-in packages" (one of those should be it).
    upload_2022-1-9_14-18-45.png

    Restart Unity, make sure it rebuilds the projects (reimport some .cs file).


    I can't help you much more without actually having the project right in front of me. :(
     
  9. BrotherWrong

    BrotherWrong

    Joined:
    Feb 19, 2017
    Posts:
    6
    Wow, thank you for this very detailed response. I will definitely use that at a later point. I was able to fix the issue by deleting the existing Event System and creating a new Empty GameObject with Input System components, which automatically added a new Event System component. This seems to have fixed the missing mouse input (at least for now).
    Thanks again for your help. It is much appreciated.
     
    NibbleByte3 likes this.
  10. BrotherWrong

    BrotherWrong

    Joined:
    Feb 19, 2017
    Posts:
    6
    btw I resolved the issue by deleting the existing Event System and creating an empty GO and adding an Input System component to that. The Event System component was added automatically to the empty GO and everything was working fine afterwards.
    Now for my new nemesis: Touch controls. :D
     
    NibbleByte3 likes this.
  11. sdb7

    sdb7

    Joined:
    Apr 8, 2013
    Posts:
    23
    if you add simulator tab, the mouse is disabled by default (tested at 2021,2.18f1)..and yeah i dont read change list...its huuuge.
     
  12. Huacanacha

    Huacanacha

    Joined:
    Aug 16, 2013
    Posts:
    60
    You can force Mouse to be enabled (for example while playing in Editor with the Simulator open) as follows:

    if (!Mouse.current.enabled) {
    InputSystem.EnableDevice(Mouse.current);
    }
     
    sergienkomv, nfijala and socialtrens like this.