/ Forums
New To The Forum? Click Here To Read The How To Guide. -- Developers Click Here.

[SOLVED] Click events fired twice on Gear VR

tomazvovktomazvovk Posts: 59
Hiro Protagonist
edited March 13 in Unity
Hello, I am having a strange problem since the latest Oculus/GearVR update (not sure which one it was :blush: ). When I click on a button in Editor it works as expected, same when running the app in dev mode on the phone. But when I put the phone into Gear VR, clicks/taps are executed twice. I tried debugging via Wi-Fi and adb printed debug text from the same function twice (looks like in different frames though). I am using OVRCameraRig, GazePointerRing (from sample framework) and OVRInputModule. Buttons are standard ones from Unity's UI.

I have two apps with this problem. One is made in Unity 5.4.2f2 (Oculus Utilities v1.9.0, OVRPlugin v1.8.0) and another in Unity 5.5.0f3 (Oculus Utilities v1.10.0, OVRPlugin v1.10.0).

I tried to run older version of the app made in Unity 5.4.2f2 and it has the same porblem. I know that it worked before.

Here is additional information on GearVR/Oculus software installed on the phone:

Samsung Galaxy S6, Android 6.0.1

Gear VR Service 2.6.41
Gear VR SetupWizard 2.3.20
Gear VR Shell 2.3.02
Gear VR System 1.1.05

Oculus 2.26.7
Oculus System Activities 1.11.0-45918658
Oculus System Driver 1.0.4.2-45411680

You can see the OVRInputModule settings in the image below. "Invert Swipe Y Axis" setting was added by me but it doesn't affect clicks. Any help appreciated!


Comments

  • imperativityimperativity Posts: 976 Oculus Staff
    Hi,

    I'm looking into this issue and will have some guidance for you in the new year.

    Thanks for your patience.
  • tomazvovktomazvovk Posts: 59
    Hiro Protagonist
    edited December 2016
    I just wanted to add, that I created a new empty project in Unity 5.5.0f3 (Oculus Utilities v1.10.0, OVRPlugin v1.10.0). Same problem.

    When I take the phone from Gear VR I can see a notification about disconnected mouse. Is this normal?

    @imperativity
    Thanks, I'll be patient :)
  • vrdavebvrdaveb Posts: 1,555 Oculus Staff
    > when I put the phone into Gear VR, clicks/taps are executed twice.

    Are you using OVRInput in addition to OVRInputModule? If so, you may want to skip your OVRInput-based code when the active controller is the touchpad:

    if (OVRInput.GetActiveController() != OVRInput.Controller.Touchpad) { /* do input handling */ }
    We recently added touchpad support to OVRInput and without the above check, you may get your gamepad button handling logic firing at unexpected times in addition to the usual touchpad handling code.

    If you are really getting duplicate touchpad input, make sure you don't have two copies of components like OVRTouchpad or OVRInputModule in your scene.
  • tomazvovktomazvovk Posts: 59
    Hiro Protagonist
    edited January 3
    @vrdaveb ;
    I'm using OVRInputModule only. I added the following code to print active device to the console:
    Debug.Log(OVRInput.GetActiveController().ToString());
    First click prints None and immedeatelly after it prints Touchpad. Every click after that prints Touchpad twice. Checking if there are multiple copies of components mentioned above was the first thing I did.

    I made another empty project (Unity 5.5.0f3), imported Utilities 1.10 package and copied OVRHarness, OVRInspector and Parse folders from Oculus Sample Framework (1.5.1). I made an empty scene with OVRCameraRig, GazePointerRing and world space Canvas (with Graphic Raycaster disabled and OVRRaycaster enabled). EventSystem's standalone input module is disabled and OVRInputModule is enabled).

    I set up player settings for VR and clicks worked as they should. I noticed that I forgot to set Android API level (it was set to 9 - Android 2.3.1). As soon as I changed API level, clicks started to get called twice. I tried to change API back to 9 and it didn't work anymore. Then I cleared data and cache on the phone and installed the app again. Clicks started to work again. But I can't replicate this again. It worked only once, no matter how many times I change API or delete data/cache. Uninstalling and reinstalling also doesn't help.

    I updated Android SDK's, tools, platform tools, etc... It didn't help.
  • imperativityimperativity Posts: 976 Oculus Staff
    Hi Tomazvovk,

    Are you still experiencing this issue at this time? Were you able to replicate it again?

    Let me know.
  • tomazvovktomazvovk Posts: 59
    Hiro Protagonist
    Hello, sorry for late reply. Yes, I still have this problem.
  • imperativityimperativity Posts: 976 Oculus Staff
    Ok. We will have a fix addressing this issue in Oculus Utilities 1.12 by the end of February. Stay tuned.
  • tomazvovktomazvovk Posts: 59
    Hiro Protagonist
    @imperativity
    Okay, good to know.Thank you again for helping out!
  • tomazvovktomazvovk Posts: 59
    Hiro Protagonist
    Confirming that the issue has been resolved using the latest Oculus Utilities (1.12).
  • imperativityimperativity Posts: 976 Oculus Staff
    Excellent. Thanks for the follow up!
  • teliportmeteliportme Posts: 1
    Virtual Boy (or Girl)
    I'm Having the same issue now after upgrading to 5.6.0f3 with both Oculus Utilities 1.12 and 1,13. 
  • imperativityimperativity Posts: 976 Oculus Staff
    @teliportme

    Welcome to the Oculus Forums.

    Can you describe in detail the setup of your project and any or all similarities with the original developer's problem above? These issues should not be present anymore in the latest utilities releases, so the more information you can provide the better.
  • Rogar303Rogar303 Posts: 5
    Virtual Boy (or Girl)
    I am having this issue as well in Unity 5.6.0f3, and Oculus Utilities 1.14. Regular UI Buttons are being clicked twice. All I have in my scene is the EventSystem with the OVRInputModule, a Canvas with the OVRRaycaster, and a Button in the canvas, and I can see that the button click is most often than not triggered twice. Might be worth noting that every time I swipe, instead of click in center of the Touchpad, the button click is triggered once. With that said, though, I don't expect a click when swiping so this is another issue I am having.
  • SerFreemanSerFreeman Posts: 2
    Virtual Boy (or Girl)
    I had the same problem. I don't know what is official solution but you can try mine which works in my case.
    Go to OVRInputModule.cs script and change this method.
    virtual protected PointerEventData.FramePressState GetGazeButtonState()
            {
                //var pressed = Input.GetKeyDown(gazeClickKey) || OVRInput.GetDown(joyPadClickButton);
                //var released = Input.GetKeyUp(gazeClickKey) || OVRInput.GetUp(joyPadClickButton);
    
    //#if UNITY_ANDROID && !UNITY_EDITOR
    //            // On Gear VR the mouse button events correspond to touch pad events. We only use these as gaze pointer clicks 
    //            // on Gear VR because on PC the mouse clicks are used for actual mouse pointer interactions.
    //            pressed |= Input.GetMouseButtonDown(0);
    //            released |= Input.GetMouseButtonUp(0);
    //#endif
                var pressed = Input.GetMouseButtonDown(0);
                var released = Input.GetMouseButtonUp(0);
    
                if (pressed && released)
                    return PointerEventData.FramePressState.PressedAndReleased;
                if (pressed)
                    return PointerEventData.FramePressState.Pressed;
                if (released)
                    return PointerEventData.FramePressState.Released;
                return PointerEventData.FramePressState.NotChanged;
            }

  • Rogar303Rogar303 Posts: 5
    Virtual Boy (or Girl)
    Hey SerFreeman, your solution works! Thank you very much!!! 

    I'm still having the issue where a swipe is registered as a click as well, but that issue I can work around on. 
  • summitgamessummitgames Posts: 1
    Virtual Boy (or Girl)
    I have developing this for almost one and a half year.. they update new things and bring more problems that worked perfectly fine.. Its the same problem i am facing gets clicked twice on gear vr and swipe gets registers as click.
  • Rogar303Rogar303 Posts: 5
    Virtual Boy (or Girl)
    This alternative solution allowed clicks and swipes to be independent, but with it OnDown and OnUp no longer worked: 
    var pressed = Input.GetKeyDown(gazeClickKey) || OVRInput.GetDown(joyPadClickButton);
    var released = Input.GetKeyUp(gazeClickKey) || OVRInput.GetUp(joyPadClickButton);
    
    if (pressed && released)
        return PointerEventData.FramePressState.PressedAndReleased;
    if (pressed)
        return PointerEventData.FramePressState.Pressed;
    if (released)
        return PointerEventData.FramePressState.Released;
    return PointerEventData.FramePressState.NotChanged;
    Just set the gazeClickKey to Keycode.Space.
  • imperativityimperativity Posts: 976 Oculus Staff
    For anyone else that stumbles across this thread. Please consider the following with regards to this issue:

    You may be using both Input and OVRInput.  Try to stick with just OVRInput on Gear VR and maybe go back to Input for non-VR builds.
Sign In or Register to comment.