Search Unity

Question Oculus Quest 2 Keyboard with XR RIg

Discussion in 'XR Interaction Toolkit and Input' started by Fred-Koa, Oct 14, 2021.

  1. Fred-Koa

    Fred-Koa

    Joined:
    Feb 5, 2019
    Posts:
    20
    My project is using an XR Rig and I want to use the Oculus Quest system keyboard. After a whole day of research I am able to display it in build (but not in the editor...). But when it appears the default oculus hands appear and my hand models are not tracked anymore... And when I close the keyboard a simple press on the Oculus button exits the application (without opening the "quit" menu). Is there a way to fix all these problems ?
     
  2. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Using XRI toolkit, TextMeshPro Input field and an AndroidManifest.xml containing
    <uses-feature android:name="oculus.software.overlay_keyboard" android:required="false"/>

    should be all you require. And yeah this does not work in the editor ofcourse. Because it is a system keyboard of Oculus. Oculus Link is a streaming simulation. So the system keyboard is not available there.

    Yeah, system keyboard and thus system input tracking. The Unity application goes in a paused state. I think you can use OnApplicationFocus, but I'm not sure. Haven't tested it yet, but I am about to today since I'm busy with this as well.

    The oculus button has always been for this, an exit app button. That is a system button. When you're done typing on the keyboard you're supposed to hit the blue enter button.

    It's the system keyboard. It can't be customized.

    The only real problem I am facing with the system keyboard is that when you dismiss it using its cancel button (keyboard with arrow down icon) or clicking outside the keyboard. Unity regains focus but the XR controllers aren't tracking anymore until the app loses focus and regains focus again. Which means it isn't properly resuming.
     
    gotiobg and jlhardyphd like this.
  3. Fred-Koa

    Fred-Koa

    Joined:
    Feb 5, 2019
    Posts:
    20
    Yes I modified the manifest. And I call TouchScreenKeyboard.Open to display the keyboard. I know that when you play the game in the editor the headset is not seen as a Quest but as a rift. But when you read the Oculus docs they say that you should use a virtual keyboard instead of a physical one to prevent the player from having to remove his headset. If it applies to the Quest it should apply to the Rift too.
    Anyways it's not a big problem for me as I can use a home made keyboard in this case.

    Yes, I know that the Oculus button is used to quit the app. But it should not quit immediately. it should display a message box asking the user if he really want to quit the app before.
    And what bothers me is that this behavior happens after I closed the keyboard...

    That's another problem in my eyes. We should be able to choose if the type of keyboard (textual, numeric, email, URL...).
    Or at least choose the position where it appears as it is a 3D object. But I can live with these limitations until Unity decide to improve that.
     
  4. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    I use Unity 2021.1.24 and I don't even need to call TouchScreenKeyboard. Just having a TextMeshPro Input Field is enough. The regular Unity Input Field does not work though.

    The docs say many things. but yeah a virtual keyboard is fine. Either System Keyboard or a self made in-game keyboard suffices. If you want to support a hardware keyboard, that is up to you.


    It only seems to happen when you close the keyboard using its own dismiss button or clicking outside of it. Unity does not get full focus back. XR Controllers are not moving anymore. If you then press the oculus button then yes, it will indeed close the app.
    If you click on the blue checkmark button, Unity will resume normally and it will work as you expect it to. But that is definitely part of a bug.

    If you need a customized keyboard, go with an in-game one and don't rely on the system keyboard. That way you're in full control over the keyboard.

    Oculus controls the system keyboard, if anything they should open it up more and make it more accessible / customizable. Oculus should do a lot more with their XR plugin in my opinion. But they rather seem to stick with their Oculus Integration package which is bloated.

    [off-topic rant]
    There are many other things that I've already suggested on Unity's roadmap platform, in their XRI github issues or even here on the forums. I also have countless of bug reports. All of it takes them really long to implement or fix. Which is very frustrating when you're in a rapid development environment yourself. But all we can do is send bug reports, do forum posts and suggestions on the roadmap.
     
    Last edited: Oct 15, 2021
  5. Fred-Koa

    Fred-Koa

    Joined:
    Feb 5, 2019
    Posts:
    20
    Well infortunately our game should work with any language. That's the main reason why I want to use the system keyboard because I don't want to spend several month coding a keyboard for each language. Including asian ones which need multi-key characters and an auto-correct like system to choose the right character.

    I hoped Unity had already a multi-language keyboard but their mobile keyboard is only an american qwerty one...
     
  6. Fred-Koa

    Fred-Koa

    Joined:
    Feb 5, 2019
    Posts:
    20
    I asked Oculus in one of their forums and got this answer:

     
    Last edited: Oct 22, 2021
    MaskedMouse likes this.
  7. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Could you provide a link to this forum thread?
     
  8. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Last edited: Oct 22, 2021
  9. Fred-Koa

    Fred-Koa

    Joined:
    Feb 5, 2019
    Posts:
    20
    Sorry I just realized it's not a public forum. That's probably because we had access to prototype devices at one point.
     
  10. Fred-Koa

    Fred-Koa

    Joined:
    Feb 5, 2019
    Posts:
    20
    According to this forum rules I should not share its content publicly but I guess it's not a confidential information.
     
  11. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Alright well, if they're working on it then it'll be fixed eventually I guess.
    Let's hope it doesn't take them several months...
     
  12. Riiich

    Riiich

    Joined:
    Sep 30, 2014
    Posts:
    19
    So I still have an issue. Everything seems to be working for the most part using either the "focus on an InputField" or "TouchScreenKeyboard.Open()" methods.

    Though one thing that's for some reason not working is that if you click the blue "done" button, the keyboard closes but "OVRManager.InputFocusAquired" is never fired, unless I manually go out of the app and back in.
     
  13. Fred-Koa

    Fred-Koa

    Joined:
    Feb 5, 2019
    Posts:
    20
    It seems to be fixed now. At least with Unity 2021.3.1f1 and the latest Oculus Integration asset.
     
  14. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Yeah if you're using TMPro Input Field the only thing you need to do is add the
    <uses-feature android:name="oculus.software.overlay_keyboard" android:required="false"/>
    to the manifest.
    You wouldn't even need the Oculus Integration asset for that either. Personally I avoid using that package when possible because of all the Oculus specific references. It makes it more difficult to support other VR headsets.
    So I just use the XR management and XR interaction package which can be configured to work with any VR headset.

    The only issue left that I noticed was that the input field itself didn't receive a call to deactivate upon dismissing the system keyboard. So when the application regains focus using
    OnApplicationFocus
    , I call
    EventSystem.SetSelectedGameObject(null);
    . If I don't, I couldn't select the input field again.
     
  15. andersoncc

    andersoncc

    Unity Technologies

    Joined:
    Apr 9, 2021
    Posts:
    14
    Hi, the issue related to the ugui
    InputField
    not showing up the system keyboard on a Quest build is fixed.

    The fix is in the following Unity versions (or above): 2019.4, 2020.3, 2021.3 and 2022.1
     
  16. NicolasSouza-NIckSDev

    NicolasSouza-NIckSDev

    Joined:
    Jun 9, 2017
    Posts:
    7
    No, it´s not!
    i´m on 2020.3 using XRRig and just XrToolkit and it´s not showing keyboar... anoying
     
    geoinnovacion likes this.
  17. Grimmjow_Jaegerjackquez

    Grimmjow_Jaegerjackquez

    Joined:
    Dec 14, 2021
    Posts:
    16
    And Bump, it is still not fixed. Nice!!!
     
  18. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    I didn’t have any issues anymore using the latest 2022.2 and OculusXR.
     
  19. Grimmjow_Jaegerjackquez

    Grimmjow_Jaegerjackquez

    Joined:
    Dec 14, 2021
    Posts:
    16
    Well yeah , I am not using OculusXR but the XR kit , the problem seems to be there.
     
  20. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
  21. dukvah

    dukvah

    Joined:
    Mar 10, 2022
    Posts:
    3
    I am using version "2021.3.5f1". When I click on the input field, the keyboard does not open.
     
  22. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Update to the latest 2021.3 LTS and try again.

    Also make sure the
    <uses-feature android:name="oculus.software.overlay_keyboard" android:required="false"/>
    is in the manifest xml.
     
    VRDave_Unity likes this.
  23. dukvah

    dukvah

    Joined:
    Mar 10, 2022
    Posts:
    3

    When I add this code, the system keyboard opens, but because Unity is removing my application from OnFocus, the application freezes and becomes ugly. Is there any way to prevent this? (I turned off the joysticks using OnApplicationFocus but it still freezes very annoyingly.)
     
  24. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    The System Keyboard is a layer running outside of the Unity application. Hence you're losing application focus.
    This way you can enable / disable certain behaviours or UI.

    To keep the app running in the background you have to make sure that "Run in background" is enabled.
    Go to the player settings, select standalone from the tabs and expand Resolution and presentation.
    There you will find the
    Run in background*
    toggle.
    This will affect the Android build to keep on running the app whilst it is in the background.

    Note: there was a bug somewhere last year where if you switched back and forth between the Standalone and Android tabs in the player settings it would disable Run in background.
    I reported that bug and it got fixed, but I can't remember which versions were affected.
    If you make sure you're running the latest LTS or Tech Stream, it should already be fixed.
     
    dukvah likes this.
  25. VRDave_Unity

    VRDave_Unity

    Unity Technologies

    Joined:
    Nov 19, 2021
    Posts:
    275
    As @MaskedMouse stated, this Run in Background behavior was partially fixed last December and should have been back-ported to older editor releases. A more comprehensive solution is currently in development and should be available in an upcoming release.

    The other option for maintaining focus is if you use the Input System package (and related Tracked Pose Driver), you can Create a Settings Asset in the project settings for the Input System Package. Once you have created the asset you can set the Background Behavior to Ignore Focus. This will also solve the focus issue, regardless of the Run in Background flag.
    upload_2023-4-4_9-26-44.png
     
    dukvah likes this.
  26. dukvah

    dukvah

    Joined:
    Mar 10, 2022
    Posts:
    3
    Thank you, that worked. I couldn't find the "Run in background" part. I think it's still buggy in my version. But when I followed the steps that @VRDave_Unity said, there was no problem.
     
  27. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
  28. garyAtBioDigital

    garyAtBioDigital

    Joined:
    Feb 15, 2023
    Posts:
    1
    I'm not seeing the Background Behavior option in Input System Package settings, using Editor 2020.3.34
     
  29. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Using TMP inputfield + android permissions = keyboard appears.

    Although there is still weird behaviour as mentioned.. double screens, Oculus has an overlay ontop of Unity, so you now have 4 hands, and sometimes cancelling or closing keyboard stops input next time, but then works if you click it again.
    Also my keyboard rapidly closes and opens a bunch of times when clicking, most likely because of the triggers "button down state" being called multiple times over frames, rather than a one time button trigger.
    Anyway thanks everyone that posted, hopefully we continue to get more improvements as time goes on!
     
  30. Riiich

    Riiich

    Joined:
    Sep 30, 2014
    Posts:
    19
  31. Riiich

    Riiich

    Joined:
    Sep 30, 2014
    Posts:
    19
    With the new system on https://developer.oculus.com/documentation/unity/VK-unity-custom-integrations/

    Using the new actions:

    Code (CSharp):
    1. class OVRVirtualKeyboard : Monobehaviour {
    2.     Action<string> CommitText;
    3.     Action Backspace;
    4.     Action Enter;
    5.     Action KeyboardShown;
    6.     Action KeyboardHidden;
    7. }
    You could use KeyboardShown and KeyboardHidden to hide your hands / 3D models for example
     
  32. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    The problem with that is it comes with the integration SDK. It's Oculus only.
    It is great when you're working with Oculus only. But if you're developing for multiple VR platforms this will be the first thing to get thrown out of the window.
    Even if you're developing for Oculus only at first. Whenever you do expand to other headsets it's quite a pain to get all Oculus specific things out.
    This is why XR Interaction Toolkit exists to not be bound to some headset specific SDK.
    The system keyboard works without the Oculus integration SDK.
    It would be nice to see a virtual keyboard implementation from the XR Interaction toolkit. Something that works for any headset.
     
    jesusluvsyooh likes this.
  33. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Yeah what MaskedMouse said ^
    But i still appreciate the reply Riiich
     
    Riiich likes this.
  34. LuigiNicastroCapco

    LuigiNicastroCapco

    Joined:
    Jun 1, 2022
    Posts:
    1
    When I use the interaction toolkit and the TMP Input Field, it works properly in the editor but testing on a Quest headset I can never see the caret or select where to put text
     
  35. FlavoX

    FlavoX

    Joined:
    Jun 17, 2018
    Posts:
    4
    I'm posting here because this is the only thread on the web that appears to talk about the issue.

    I have two issues, that appear to happen "randomly" (build only):

    1) I click on the TMPro Input Field, the application loses focus. Default Quest 2 controllers show up, but the keyboard does not. Pressing the Oculus button does nothing. The app does not seem to freeze, but I can't return to it. Can't close it either. Only thing I can do is restart the device.

    2) I click on the TMPro Input Field, the keyboard shows up. I type and then press the Enter/Confirm button on the keyboard. The keyboard goes away, but the focus does not return to the application. Same thing, I can only restart the device.

    I tried the other suggestions on this thread, but nothing seems to fix it.
     
  36. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Do make sure that you're using the latest Unity 2022.3, TMPro, XR Interaction Toolkit, Oculus XR with the manifest defining you want to use the system keyboard.
    As well as updating your Quest to the latest version

    It should work just fine as I've tested it like a week ago.
    I had the issue where the keyboard popped up again after filling it and ending it. I had to update XR Interaction Toolkit for it to work normally again.
     
  37. FlavoX

    FlavoX

    Joined:
    Jun 17, 2018
    Posts:
    4
    I was using Unity 2021.3.12f1. So tried updating it, but the issue remains. All packages seem to be in their latest stable version:

    Unity 2022.3.15f1
    XR Interaction Toolkit 2.5.2
    Oculus XR Plugin 4.1.2
    TextMeshPro 3.0.6 (I tried the latest pre-release 4.0.0, but it messed up all objects that used it)
    My Quest 2 is also fully updated

    Anyway, thank you for your reply.
     
  38. FlavoX

    FlavoX

    Joined:
    Jun 17, 2018
    Posts:
    4
    So, just a small update that hopefully will help someone.

    I created a new clean scene with nothing more than the XR Rig, a Canvas and a TMPro Input Field with the default settings. And it worked. Then I compared the clean input field with the other one that had the issue, and apparentely the problem is related to the Line Type setting.

    I've tested all three options (Single Line, Multiline Submit and Multiline Newline) and the only one that seems to not reproduce the issue is the Single Line. So, Multiline doesn't work.

    Not sure if this is expected or maybe a bug, but for now I'll stick with the Single Line option.
     
  39. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Likely a bug then. You could submit a bug report in a new project with minimal setup.