Search Unity

Device Portal - Virtual Input to trigger Hololens

Discussion in 'VR' started by aex_, Feb 26, 2018.

  1. aex_

    aex_

    Joined:
    Feb 26, 2018
    Posts:
    8
    Hello,

    I'd like to use a laptop's keyboard to trigger some behaviors on Hololens using Device Portal / Virtual Input.

    I tried using this kind of code in Unity:

    Code (CSharp):
    1. if (Input.GetKeyDown("f"))
    2. {
    3. // DoSomething()
    4. }
    It works fine when I debug the project using Holographic Remoting inside Unity: I just press F, and something happens.

    But when I deploy the app on the Hololens, and send the keystroke using Device Portal / Virtual Input, the app doesn't recognize the keystroke: nothing happens.

    Am I missing something in Unity?
    Maybe I have to activate something in the app capabilities? (Edit/Player/Publishing)

    Thanks
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    I believe you need to enable the internet server and connection in the publishing settings
     
    tenconmar likes this.
  3. aex_

    aex_

    Joined:
    Feb 26, 2018
    Posts:
    8
    Thank you,

    I tried to enable all the checkboxes in Player/Publishing Settings/Capabilities without success.

    Any other clue?

    When I use the virtual input in other Hololens apps (like Microsoft Edge), the app receives the keystrokes, so it's clearly something missing in my app and not in the Device Portal or the Wifi connection...
     
  4. aex_

    aex_

    Joined:
    Feb 26, 2018
    Posts:
    8
    Maybe it's something in Hololens/Settings/Privacy? (Where we can allow apps to access things).

    For each different capability (Microphone, Camera, Messaging...), there is a menu on the Hololens , where you can choose the prefered behavior ("Let apps control Microphone", and "Choose apps that can control Microphone").


    The weird thing is, when I'm on the Microphone menu, I can choose to Enable or Disable the microphone for my app and all the installed apps that want to access the microphone.
    Perfect.

    But when I'm on the "Radios" menu, which is the menu I need ("Some apps use radios -like WiFi and Bluetooth- in your device to send and receive data."), I can't choose the behavior for my app (the app-list is empty, as if the capability had not been activated...)




    Here are the Capabilities, as exported by Unity in Package.appxmanifest, when I check every checkbox in Player/Publishing Settings/Capabilities:


    Code (CSharp):
    1. <Capabilities>
    2.     <uap:Capability Name="enterpriseAuthentication" />
    3.     <Capability Name="internetClient" />
    4.     <Capability Name="internetClientServer" />
    5.     <uap:Capability Name="musicLibrary" />
    6.     <uap:Capability Name="picturesLibrary" />
    7.     <Capability Name="privateNetworkClientServer" />
    8.     <uap:Capability Name="removableStorage" />
    9.     <uap:Capability Name="sharedUserCertificates" />
    10.     <uap:Capability Name="videosLibrary" />
    11.     <Capability Name="allJoyn" />
    12.     <uap:Capability Name="blockedChatMessages" />
    13.     <uap:Capability Name="chat" />
    14.     <Capability Name="codeGeneration" />
    15.     <uap:Capability Name="objects3D" />
    16.     <uap:Capability Name="phoneCall" />
    17.     <uap:Capability Name="userAccountInformation" />
    18.     <uap:Capability Name="voipCall" />
    19.     <uap2:Capability Name="spatialPerception" />
    20.     <rescap:Capability Name="inputInjectionBrokered" />
    21.     <DeviceCapability Name="webcam" />
    22.     <DeviceCapability Name="proximity" />
    23.     <DeviceCapability Name="microphone" />
    24.     <DeviceCapability Name="location" />
    25.     <DeviceCapability Name="humaninterfacedevice">
    26.       <Device Id="any">
    27.         <Function Type="usage:0001 0004" />
    28.       </Device>
    29.       <Device Id="any">
    30.         <Function Type="usage:0001 0005" />
    31.       </Device>
    32.     </DeviceCapability>
    33.     <DeviceCapability Name="bluetooth" />
    34.   </Capabilities>
     
  5. aex_

    aex_

    Joined:
    Feb 26, 2018
    Posts:
    8
    I just tried to add that line manually in Package.appmanifest:
    Code (CSharp):
    1. <DeviceCapability Name="radios" />
    And now I can see my app in Hololens/Settings/Privacy/Radios

    And it works! (I'm receiving keystrokes from Device Portal now).
    (not totally sure it's the main reason, because I tried a lot of different things...)


     
  6. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Could you please tell what other different things (steps) did you try?
    I am implementing the same.
    Thank you.
     
  7. aex_

    aex_

    Joined:
    Feb 26, 2018
    Posts:
    8
    Hi,

    After deploying my app on the Hololens, I always have to open Microsoft Edge, testing the keyboard with Device Portal.
    It works all the time, so I close Edge, and I open my app, and now it works, I receive keystrokes from Device Portal...
    If I don't test it with Edge, I receive nothing in my app...

    Not really logical, so please tell me if it's working for you, and if you find more logical solutions...
     
  8. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Yes, I followed the same thing like you described. I can give inputs on my Holo Lens's Microsoft Edge. However, in my app it does not recognize. I am giving something like
    Code (CSharp):
    1.  if (Input.GetKeyDown("s"))
    2. {
    3. }
    are you following the same as above or giving different type of input?

    Thank you.
     
  9. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Ah Never mind I got it working. Ticked everything under Player/Publishing Settings/Capabilities.

    Man Build and then Deploy takes forever to Holo Lens. I lose interest in the middle.
     
  10. aex_

    aex_

    Joined:
    Feb 26, 2018
    Posts:
    8
    Yes, good point ("Ticked everything under Player/Publishing Settings/Capabilities")
     
  11. unity_8R3gaxreN6dMTA

    unity_8R3gaxreN6dMTA

    Joined:
    Apr 9, 2018
    Posts:
    9
    Input.GetKeyDown() is throwing an exception with MRTK 2.5.4. What other settings to I need to set in MRTK to allow for Input.GetKeyDown()
     
  12. keveleigh

    keveleigh

    Official Microsoft Employee

    Joined:
    Jun 19, 2015
    Posts:
    35
    What's the exception you're seeing? And which Unity version are you using? There shouldn't be anything more to do in MRTK to enable this, but I'd like to understand your setup more.
     
  13. unity_8R3gaxreN6dMTA

    unity_8R3gaxreN6dMTA

    Joined:
    Apr 9, 2018
    Posts:
    9
    Is there a way to use portal virtual input while the HL2 is in kiosk mode? or are they incompatible?
     
  14. Ilyes_EB

    Ilyes_EB

    Joined:
    Jul 10, 2022
    Posts:
    1
    I followed all the steps you described but it still doesn't take into account when I press a key on my keyboard in the app.