Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Does OVRInputModule implement IScrollHandler events for Gear VR / Oculus Go?

binary_natebinary_nate Posts: 9
Greetings everyone. I'm currently porting an app to Gear VR / Oculus Go and am trying to get scrolling working so that when the user points the controller at a 3D GameObject, they can scroll on the touchpad and IScrollHandler events will be sent to the script on that object that implements IScrollHandler.

When I first found that this wasn't working, I assumed that I had misconfigured something, because I could see that there was code in OVRInputModule that executed IScrollHandler events, and there are public options on that script related to scrolling. Digging in deeper, however, I have come to the conclusion that scrolling is not supported for Gear VR / Oculus Go, and that IScrollHandler events are only implemented for an actual mouse and for a gamepad controller. Can anyone please confirm that this conclusion is correct? Here's what I found in OVRInputModule that led me to that conclusion:

- IScrollHandler events are only executed when leftButtonData.buttonData.scrollDelta.sqrMagnitude is non-zero
- There are two places where scrollDelta is set:
        - In GetGazePointerData(), it's set to GetExtraScrollDelta(), which is determined by the gamepad
        - In GetCanvasPointerData(), it's set to Input.mouseScrollDelta
                - I observed that Input.mouseScrollDelta is always (0, 0), even while I'm scrolling on the touchpad
                - I suspected that there would be code in the Oculus Unity Utilities package to map the controller touchpad's scroll to mouseScrollData, but I didn't find anything that appeared to do that
                - If I replace the call to `leftData.scrollDelta = Input.mouseScrollDelta;` in OVRInputModule with a fixed value like `leftData.scrollDelta = new Vector2(1, 1);`, the scroll events are sent to my GameObject like I expect and trigger scrolling. So it's not an issue with how my script is listening for scroll events.

So, can anyone please confirm that scrolling isn't supported out-of-the-box for Gear VR / Oculus? My current plan is to roll my own scrolling or port the GvrPointerScrollInput script from the GoogleVR SDK to work with the Oculus mobile controller, but since those options will take me some time, I thought I'd ask here before diving in.

Best Answer

  • binary_natebinary_nate Posts: 9
    Accepted Answer
    Update: modifying and using GvrPointerScrollInput from the GoogleVR SDK was easier than I thought and gave me the scrolling functionality I wanted. Here's the URL for the original source:


    The changes I made:
    - Updated the signature of HandleScroll to pass in my own pointer interface (that implements TouchDown, IsTouching, TouchUp, and TouchPos using method calls like `OVRInput.GetDown(OVRInput.Touch.PrimaryTouchpad)`) instead of a GvrBasePointer instance.
    - I also removed the IGvrEventExecutor parameter and updated places that used that parameter to instead use ExecuteEvents directly
    - Updated OVRInputModule.ProcessMouseEvent to call `_scrollInput.HandleScroll(leftButtonData.buttonData.pointerCurrentRaycast.gameObject, leftButtonData.buttonData, _controller);`, where _scrollInput is an instance of the modified GvrPointerScrollInput class and _controller is my custom pointer implementation that implements the methods HandleScroll needs (
Sign In or Register to comment.