Skip to main content
Participant
September 29, 2022

Oculus Interaction SDK scrolling with thumbstick

Hey currently with the interaction sdk I am able to scroll with a click and drag with the primary button. I have not been able to find a way to just scroll with the joystick. Has anyone been able to fix this/find this?

This topic has been closed for replies.

5 replies

New Participant
September 30, 2022

Interaction SDK is broken with most of UI elements. InputFields are not working at all since v41

Participant
October 3, 2022

how are you or others getting around this? 

RedShed
Participant
April 5, 2024

I was actually quite close to implementing a feature for scrolling via thumbstick, but ultimately decided against it, since it doesn't really fit into my app.
But in a nutshell, that's how I would do it (in pseudocode):
1. Create a script and attach it to a scrolview.
2. OnPointerEnter -> triggerStays = true;
3. OnPointerExit -> triggerStays = false;

(For detecting whether you are currently pointing at the viewport)

4. Void update() -> if triggerStays = true execute following code:
var thumbstickposition = OVRInput.getThumbstickposition;
scrollRect.verticalNormalizedPosition = scrollRect.verticalNormalizedPosition  + ( (- sthumbstickPosition) * scrollingSpeed);

A short explenation: the scrollrect can be manually moved via scrollRect.verticalNormalizedPosition = xyz.
When the thumbstick is up, it will return the value of 1. if it's down, it will return the value of -1. That means, if the thumbstick is down, you'll be subtracting a number from the verticalNormalizedPosition each frame, moving the scrollview up. And the opposite for the other direction. Cool part is, that youll be able to scroll faster the farther you go from the thumbstick center.

Fell free to ask me for a code implementation

Anton111111
Inspiring
April 8, 2024

My solution:

    private bool _hovered = false;
    private bool _scrolling = false;
  
private void Update()
    {
        if (_hovered || _scrolling)
        {
            var primary = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
            var secondary = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
            var range =
                (secondary.y != 0)
                    ? secondary.y
                    : (primary.y != 0)
                        ? primary.y
                        : 0;

            if (range != 0)
            {
                _scrolling = true;
                _recyclableScrollRect.verticalNormalizedPosition += range * 0.03f;
            }
            else
            {
                _scrolling = false;
            }
        }
    }
RedShed
Participant
April 11, 2024

Anton111111 wrote:

My solution:

 

 

    private bool _hovered = false;
    private bool _scrolling = false;
  
private void Update()
    {
        if (_hovered || _scrolling)
        {
            var primary = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
            var secondary = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
            var range =
                (secondary.y != 0)
                    ? secondary.y
                    : (primary.y != 0)
                        ? primary.y
                        : 0;

            if (range != 0)
            {
                _scrolling = true;
                _recyclableScrollRect.verticalNormalizedPosition += range * 0.03f;
            }
            else
            {
                _scrolling = false;
            }
        }
    }

 

 

 

I think you could even add a * Time.deltaTime to the code to make the scrolling speed frame rate independent.
Something like this:

_recyclableScrollRect.verticalNormalizedPosition += range * 0.03f * Time.deltaTime;