Search Unity

Change Control Scheme on Mouse Move?

Discussion in 'Input System' started by CptOblivion, Aug 8, 2019.

  1. CptOblivion

    CptOblivion

    Joined:
    Mar 8, 2015
    Posts:
    9
    I have separate control schemes for mouse and keyboard (and also separate ones for several different types of controller, and touch, and joysticks- pretty rad how straightforward it is to manage so many types of devices!). This works well, except that moving the mouse doesn't cause the control scheme to switch to mouse. I have to click somewhere on the screen to start using the mouse- in menus this is awkward, since you don't get button highlights until you click somewhere, in gameplay it's slightly less awkward but still feels unresponsive when moving the mouse doesn't cause a response.

    Is there a setting somewhere to allow mouse movement to trigger control scheme switch? Alternately if it's possible to manually set the control scheme in code, I can just put the mouse in every control scheme and have delta mouse trigger a function with that command in it, but I was unable to find such a command.

    Thanks in advance for any help!
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    That sounds buggy. Could you file a ticket on GitHub? Ideally with your .inputactions file or a repro project attached.

    The only controls that should *not* result in a control scheme switch are noisy ones (InputControl.noisy=true) and synthetic ones (InputControl.synthetic=true). Mouse.delta should have neither of those properties.

    So my guess is that there's some bug here that incidentally causes the delta to not result in a change whereas the button does.

    Overall, the PlayerInput API still needs some refinement. One thing you can do, though, is just grab the InputUser from a PlayerInput and force a control scheme switch on it.

    Code (CSharp):
    1. var user = playerInput.user;
    2. user.ActivateControlScheme("Mouse&Keyboard");
     
  3. CptOblivion

    CptOblivion

    Joined:
    Mar 8, 2015
    Posts:
    9
    I'll file the bug, though foolishly before filing the bug I updated to 0.9.1 and the whole system broke. Is there a way to roll back to 0.9.0? I'm getting a NullReferenceException any time I interact with the interface, every other time I try to open the inputactions file it pulls up the windows "what program do you want to use to open this dialog" (every other other time it opens in the editor as expected). In the input mapping interface the properties pane doesn't populate with options if an action is selected (the pane looks right if I select a binding though)- I don't mind remaking the input map but if opening the inputactions file with a broken install hecked up the file (I had autosave on) it might not be as useful for the bug report.

    [edit] found the previous versions in the package manager, back to 0.9.0 and it's stable again. Looks like it was just interface stuff, the file seems fine.
     
    Last edited: Aug 9, 2019
  4. JamhammerRob

    JamhammerRob

    Joined:
    Jan 15, 2016
    Posts:
    13
  5. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
  6. JamhammerRob

    JamhammerRob

    Joined:
    Jan 15, 2016
    Posts:
    13
    Thanks!