0 votes
by (170 points)
edited by

There are three buttons on the right side of the Pico G2 headwear. I want the user to interact with the object in VR by pressing some of these buttons, similar to pressing a key on a keyboard. The KeyCode.JoystickButton0 seems not working.

It would be helpful if you could direct me to any tutorials or resources. thanks.

1 Answer

0 votes
by (44.8k points)

What is your system version and SDK version? About the KeyCode.JoystickButton0 not working, have you checked "both"?
enter image description here

by (170 points)

Unity 2020 with PICO XR plugin is what I'm using. The Android SDK is version 30. The KeyCode.Escape work fine. The Default Active Input Handling was set to Old by default in Player Settings, and it was not working. I switched to Both and it still didn't work.

by (170 points)

I also came across this thread and he could not find the way to fix it. He said it gets the key event in the JNI level, but it doesn't pass it to Unity.

https://github.com/ViveSoftware/ViveInputUtility-Unity/issues/165

by (170 points)

I used the following code to capture what key was pressed.

    foreach (KeyCode vKey in System.Enum.GetValues(typeof(KeyCode)))
    {
        if (Input.GetKey(vKey))
        {
            myText.text = vKey.ToString();
        }
    }

I found that Escape and Home button can be detected but not JoystickButton0. I think it is impossible to use JoystickButton0 in Unity.

When I press the Home button, however, the app closes and I am returned to the main screen. Is there a way to prevent it?

by (44.8k points)

Regarding the issue of JoystickButton0, has the PXRManager script been added to the XRRig in your project? If it has been added and still has no effect, we can check it for you, would you mind sending your project to our email (pico_devsupport@bytedance.com)?

About the home button, you can refer to
https://sdk.picovr.com/docs/XRPlatformSDK/Unity/cn/chapter_seven.html#unity

by (170 points)

Thank you for your reply. An email with a project file on Google Drive has been sent to you.

by (44.8k points)

What is the PUI version of your device? we have tested your project, the Joystick1Button0 can be shown. Can you tell me more details about the issue? For example, Joystick1Button0 can be showed but JoystickButton0 can not? Or neither is shown? enter image description here

by (170 points)

On the right side of the headset, there are three buttons. The Escape key works perfectly. When a user presses this button, I could use it to trigger an event. The Home button is also functional, but it will close the VR and return you to the main menu. I'd be grateful if you could provide some sample code on how to avoid this.

The issue is that the middle button of the headset, the Confirm button or JoystickButton0. It does not respond at all. I need a user to press this key to do something.

By the way, I tested a few buttons on the remote control and they all work properly. However, for my project, I will only use the headset's button.

by (44.8k points)

Hello, What is your PUI version and the Unity XR Platform SDK version? The SDK version You can get by the following way:
enter image description here

For the confrrm button, you can try the following way to use it:

        if (Input.GetKeyDown(KeyCode.JoystickButton0))
        {
            Debug.Log("JoystickButton0+" + KeyCode.JoystickButton0);
        }

For the home button: You can modify the home button in the following way:

https://sdk.picovr.com/docs/XRPlatformSDK/Unity/en/chapter_seven.html#propertysethomekey
note: Set Home key. It will redefine Home key and affect the function of Home key defined by the system. Please use this function with discretion.
And please initialize System Service before using the interfaces.
For initializing System Service, you can refer to the following link:
https://sdk.picovr.com/docs/XRPlatformSDK/Unity/en/chapter_seven.html#system-related

by (170 points)

PICO G2 - PUI is 3.6.0
SDK is 1.2.4

By the way, I just got a chance to look at the log file, and this error keeps reappearing. I'm not sure whether it has anything to do with the button.

2021-09-27 10:02:51.097 4935-4983/? E/Unity: OPENGL NATIVE PLUG-IN ERROR: GLINVALIDENUM: enum argument out of range
2021-09-27 10:02:51.099 4935-4983/? I/GsMacro: EEEE glError (GLINVALIDENUM) D:/scmbuild/unitysdk/PicoXRPlatformUnitySDK/PicoSDKMobile_CoreLib/CoreLib/src/main/jni/UnityPlugin.cpp:1629

enter image description here

by (44.8k points)

Hello,
G2 is no longer supported.
And the error you mentioned is a known issue and a bug of Unity engine, which is not affected and can be ignored.

...