Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

WebGL captureAllKeyboardInput bug?

Discussion in 'Input System' started by ErrorX, Oct 28, 2019.

  1. ErrorX

    ErrorX

    Joined:
    May 21, 2014
    Posts:
    22
    Code (CSharp):
    1.     MyInput myInput;
    2.  
    3.     protected void Awake()
    4.     {
    5.         myInput = new MyInput();
    6.         myInput.Enter.Enter.started += (a) =>
    7.         {
    8.            Debug.Log("Hello in webgl");
    9.             WebGLInput.captureAllKeyboardInput = false; //When this is set on false and I release the button. Unity still thinks this button is pressed in a WebGL Build
    10.         };
    11.  
    12.         myInput.Enter.Enable();
    13.     }

    When I disable captureAllKeyboardInput on a started event and I release the button, the input system still thinks the button is pressed.

    So when I enable the captureAllKeyboardInput on a later point in the code. I have to press this button multiple times to get a started event.

    Code (CSharp):
    1.     void EnableKeyboardInput()
    2.     {
    3.         WebGLInput.captureAllKeyboardInput = true;
    4.    
    5.         //Try to reset the input system
    6.         foreach (var item in InputSystem.devices)
    7.         {
    8.             InputSystem.TryResetDevice(item);
    9.             InputSystem.TrySyncDevice(item);
    10.             InputSystem.DisableDevice(item);
    11.             InputSystem.EnableDevice(item);
    12.             InputSystem.Update();
    13.         }
    14.     }
    I tried to reset the input system by calling these functions when I eneble the captureAllKeyboardInput,
    But this does not seem to work.
     
    Last edited: Oct 29, 2019
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    From the looks of it, would say this is coming down to a piece we're missing in the WebGL backend. Could you file a ticket with the Unity bug reporter?

    All these calls rely on the backend handling the device to implement the respective device commands. ATM the WebGL backend implements none of them.

    For DisableDevice() I'm wondering whether there should at least be the option to force resetting the device to its default state regardless of whether the backend responds or not.

    ATM such a forced reset can be achieved manually by sending a state event containing only default state. For the keyboard, it's as simple as

    Code (CSharp):
    1. // Reset keyboard to default state.
    2. InputSystem.QueueStateEvent(Keyboard.current, default(KeyboardState));
     
    Last edited: Oct 30, 2019
  3. ErrorX

    ErrorX

    Joined:
    May 21, 2014
    Posts:
    22
    Last edited: Oct 30, 2019