Jump to content

[Unity] InputDevice to get buttons does not work


Fangh

Recommended Posts

Hello.
This piece of code works on Oculus Quest but not on HTC Vive Focus Plus (the debugtext stays empty)

  • Unity 2019.4.29
  • Vive Input Utility 1.13.4
  • Vive Wave XR Plugin 4.1.1-r3.2
  • Vive Wave XR Plugin Essence 4.1.1-r3.2
  • XR Plugin Management 4.1.0

image.thumb.png.2fe3ed9221d5d8796218eefc4e2927fe.png

 

I need a solution to make a way to get the input from Oculus Quest AND HTC Vive Focus Plus.
Thank you

Link to comment
Share on other sites

Hi @Fangh,

It seems you have import VIU 1.13.4.

You can try following methods to see if this resolves your problem.

public ViveRoleProperty role = ViveRoleProperty.New();

if (ViveInput.GetPress(role, ControllerButton.Trigger))
{
    //
}

if (ViveInput.GetPress(role, ControllerButton.Grip))
{
    //
}

if (ViveInput.GetPress(role, ControllerButton.Pad))
{
    //
}

For controller name, you can try below code.
var deviceState = VRModule.GetCurrentDeviceState(role.GetDeviceIndex());
deviceState.modelNumber or deviceState.renderModelName

Let me know if you have further questions.

Link to comment
Share on other sites

Thank you.
It works on the HTC Vive Focus Plus.
But the app crash (and even the play mode) on Oculus Quest.
I have renamed the AndroidManifest.xml to AndroidManifest.htc and putted in the Plugins/HTC Folder so it is not build on the Quest apk

image.thumb.png.69f1190007f924d61cf9f39d5478282f.png

Edited by Fangh
Link to comment
Share on other sites

I don't need the Oculus Integration SDK to make a functionnal build for the Oculus Quest.
The Oculus XR Plugin is sufficient. My build works well in the Oculus Quest if I remove everything about the WaveXR.

image.png.ea57325c996bcfe8711bec257d19b505.png

Link to comment
Share on other sites

It's now working.

(reminder : I don't have the Oculus SDK in my project)


This is what I did :

  1. Remove Vive Wave Essence
  2. Remove Vive Input Utility
  3. Remove Vive Wave Native
  4. Remove Plugins/Android/CustomManifest.xml
  5. Remove Wave/XR/Platform/Android/CustomManifest.xml
  6. Using a XRRig (Device Based)
  7. Kept only Vive Wave XR Plugin 4.1.1-r3.2
  8. Use the codebase found here : https://hub.vive.com/storage/docs/en-us/UnityXR/UnityXRButton.html#unity-input-helper

 

Here is my code which work both on Oculus Quest and HTC Vive Focus Plus :

using UnityEngine;
using UnityEngine.InputSystem.XR;
using UnityEngine.XR;

public class WaveControllerTest : MonoBehaviour
{
    public TextMeshPro debugText;
    public XRNode node;

    // Update is called once per frame
    void Update()
    {

        InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(node), InputHelpers.Button.Trigger, out bool triggerValue, 0.5f);
        if (triggerValue)
        {
            debugText.text = $"{node}-trigger";
        }

        InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(node), InputHelpers.Button.Grip, out bool gripPressed, 0.5f);
        if (gripPressed)
        {
            debugText.text = $"{node}-gripPressed";
        }
        InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(node), InputHelpers.Button.PrimaryAxis2DUp, out bool touchpadValue, 0.5f);
        if (touchpadValue)
        {
            debugText.text = $"{node}-touchpad";
        }

        InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(node), InputHelpers.Button.PrimaryButton, out bool primaryButton, 0.5f);
        if (primaryButton)
        {
            debugText.text = $"{node}-primaryButton";
        }
    }
}

 

Obviously, the primarybutton works only with the Quest but I expected that and that's fine.

Edited by Fangh
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...