Search Unity

Tablet as input device.

Discussion in 'Input System' started by topofsteel, Oct 7, 2020.

  1. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    Is it possible to use a tablet as an input device for a standalone build? Possibly with a companion app communication with the main application? Thanks.
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Possible, yes. But ATM it will require some jumping through hoops.

    There's built-in support for connecting one instance of the input system to a remote instance. Means that, for example, you can build a scene with an arrangement of On-Screen Controls and deploy that to the tablet device.

    So, say, in some very simplistic example, you want the tablet to act as a remote control for toggling a light in the player. You can build a device representing that functionality

    Code (CSharp):
    1. InputSystem.RegisterLayout(@"
    2.    {
    3.        ""name"" : ""MyRemoteControl"",
    4.        ""controls"" : [
    5.            { ""name"" : ""toggleLight"", ""layout"" : ""Button"" }
    6.        ]
    7.    }
    8. ");
    and then build a scene using an OnScreenButton that is bound to
    "<MyRemoteControl>/toggleLight"
    .

    Running that scene on the tablet will create a MyRemoteControl devices locally on the tablet and use the on-screen button to control the toggleLight button.

    The remoting part is a little trickier. Mostly because the existing APIs need some massaging to make setting this up easier.

    The built-in remoting support currently is enabled only in the editor and in development players. Also, the only network transport implemented out-of-the-box is through PlayerConnection and thus limited to connecting players to the Unity editor.

    So what it'd need is
    1. Either deployment as development player or embedding the input system package locally in Packages/ and modifying the code in InputSystem.
    2. Provide an implementation of
      IObserver<InputRemoting.Message>
      and plug that into the player's
      InputRemoting
      instance running on the tablet using the
      Subscribe
      method. This implementation will receive binary message blobs that need to be forwarded to your player instance that is to receive the remote control input.
    3. Provide an implementation that receives the messages on the player side receiving the remoted input (feeding
      InputRemoting.Message
      instances to
      InputRemoting
      ).
    With this in place, the MyRemoteControl device would be mirrored from the player on the tablet to the standalone player.

    So yeah, not trivial, but doable :)
     
  3. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    Thank you for the through reply, not trivial at all. It looks like there is support in 2020.1+ for graphic tablets, but I'm wanting to present a shape for the user to trace. Possibly a companion app communicating over the network instead of through the input system. Thanks again.