ViveSoftware / ViveInputUtility-Unity

A toolkit that helps developing/prototyping VR apps.
http://u3d.as/uF7
Other
357 stars 82 forks source link

WaveSDK+Pico VR : Can't Detect KeyCode.JoystickButton0 #165

Open wojiuxuihuan opened 4 years ago

wojiuxuihuan commented 4 years ago

Hi, When I build to Android Platform, it can't detect Input such as "Input.GetKey(KeyCode.JoystickButton0)", will ViveInput.cs provide such method? Thanks!

By the way, After checking the Logcat, I can see that it will recognise the key, I just don't know how to get them through Script. here's the log info:

2019-09-12 15:05:24.418 868-903/? D/2DToVR: VRScene::onKeyPressed: 4, 0, 1. 2019-09-12 15:05:24.597 868-2025/? D/2DToVR: VRScene::onKeyPressed: 4, 0, 0. 2019-09-12 15:05:25.028 868-904/? D/2DToVR: VRScene::onKeyPressed: 1001, 0, 1. 2019-09-12 15:05:25.197 868-903/? D/2DToVR: VRScene::onKeyPressed: 1001, 0, 0.

chengnay commented 4 years ago

@wojiuxuihuan ViveInput.cs does provide following APIs, ViveInput.GetPress ViveInput.GetPressDown ViveInput.GetPressUp

For example, ViveInput.GetPress(role, ControllerButton.Trigger);

wojiuxuihuan commented 4 years ago

@wojiuxuihuan ViveInput.cs does provide following APIs, ViveInput.GetPress ViveInput.GetPressDown ViveInput.GetPressUp

For example, ViveInput.GetPress(role, ControllerButton.Trigger);

Thanks, But I am look for a way to detect Android Key Event, which is included in KeyCode such as KeyCode.Escape or KeyCode.JoystickButton0m, will those method works too?

chengnay commented 4 years ago

Just curious, how you can fire KeyCode such as KeyCode.Escape or KeyCode.JoystickButton0 in Android?

wojiuxuihuan commented 4 years ago

Just curious, how you can fire KeyCode such as KeyCode.Escape or KeyCode.JoystickButton0 in Android?

Because I use Pico Device, which has three buttons(Menu、Return、Apply) in HMD.

chengnay commented 4 years ago

@wojiuxuihuan But your title says WaveSDK+Vive Focus? Will the application run on Pico device?

chengnay commented 4 years ago

@wojiuxuihuan But your title says WaveSDK+Vive Focus? Will the application run on Pico device?

Yes, here the device picture: image

Yup, I saw this picture too, but I mean if without modify anything, your application built from WaveSDK can run?

Taking WaveSDK as an example, there will be a input id enum in wvr.cs, this should provide all the keys for developer. I am not sure whether Pico device does provide such SDK for developer or not.

wojiuxuihuan commented 4 years ago

@wojiuxuihuan But your title says WaveSDK+Vive Focus? Will the application run on Pico device?

Yes, here the device picture: image

Yup, I saw this picture too, but I mean if without modify anything, your application built from WaveSDK can run?

Taking WaveSDK as an example, there will be a input id enum in wvr.cs, this should provide all the keys for developer. I am not sure whether Pico device does provide such SDK for developer or not.

1.Pico Device support WaveSDK,so it works fine. 2.Pico provide SDK too, but it doesn't works well with WaveSDK, and useless, so I thorw it away,

chengnay commented 4 years ago

@wojiuxuihuan I look through the PVR SDK, it has its own KeyCode mapping. public enum Pvr_KeyCode { APP = 1, TOUCHPAD = 2, HOME = 3, VOLUMEUP = 4, VOLUMEDOWN = 5, TRIGGER = 6, A = 7, B = 8, X = 9, Y = 10, Left =11, Right = 12, }

If it works with WaveSDK, then you might need to tweak the WaveVRModule.cs by your own to get the right key for Pico device.

In Assets\HTC.UnityPlugin\VRModule\Modules\WaveVRModule.cs, UpdateDeviceInput function and print some logs and find out what you will get.

wojiuxuihuan commented 4 years ago

WaveVRModule

Thanks for your help!

chengnay commented 4 years ago

@wojiuxuihuan I don't have device to help you out, but feel free to ask question.

EDIT: I just got the device, I might try it out too :)

wojiuxuihuan commented 4 years ago

@wojiuxuihuan I don't have device to help you out, but feel free to ask question.

EDIT: I just got the device, I might try it out too :)

Here’s the keymap: //Input.GetKeyDown(KeyCode.Escape)--HMD Return //Input.GetKeyDown(KeyCode.Menu)--HMD Menu //KeyCode.JoystickButton0 --HMD Enter

It seems that it can recongnise Escape and Menu, but JoystickButton0 just don't work...

I also try to add to following text into AndroidManifest.xml as someone told me, but it fails too: (meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true")

chengnay commented 4 years ago

I will take a look at it when I get another device, previous device is not able to debug because the battery is completely dead.

What will happen when you press HMD Enter? Not sure is it because the system gets the button event before releasing to application.

wojiuxuihuan commented 4 years ago

I will take a look at it when I get another device, previous device is not able to debug because the battery is completely dead.

What will happen when you press HMD Enter? Not sure is it because the system gets the button event before releasing to application.

I think that it gets the key event in the JNI level, but it doesn't pass it to Unity. Here's the Log: 2019-09-11 15:07:05.017 972-1541/? I/WindowManager: sendDatatoSurfaceFligner transactId: 2001 mode : 0 2019-09-11 15:07:05.017 868-903/? E/SurfaceFlinger: Get Key code:1001 2019-09-11 15:07:05.017 868-903/? D/2DToVR: VRScene::onKeyPressed: 1001, 0, 1. 2019-09-11 15:07:05.019 8636-8636/? D/Svr_VRPlatform: dispatchKeyEvent 2019-09-11 15:07:05.019 8636-8636/? D/VRAudioManager: dispatchKeyEvent 2019-09-11 15:07:05.019 8636-8636/? D/Svr_VRPlatform: Get KeyEvent 2019-09-11 15:07:05.019 8636-8636/? D/VRCORE_VRActivity: onKeyDown: Key Event handled by default handler

chengnay commented 4 years ago

@wojiuxuihuan It looks like that key event does not pass to Unity. I loop through all KeyCode or even try Input.anyKeyDown and no goal.

wojiuxuihuan commented 4 years ago

@wojiuxuihuan It looks like that key event does not pass to Unity. I loop through all KeyCode or even try Input.anyKeyDown and no goal.

Exactly, I try it the same way before. Is there anyway that I can get nofity whenever JNI get the button event?

chengnay commented 4 years ago

Have you ever tried using PVR SDK and build apk to try it out? Or does PVR SDK have customer support?

I am really confused by the KeyCode printed in log which is totally different from the one we see in Unity. KeyCode 4 for Return => KeyCode.Escape(27) KeyCode 3 for Menu => KeyCode.Menu(319) KeyCode 1001 for Enter => KeyCode.JoystickButton0(330)

The actual KeyCode values do not match.

wojiuxuihuan commented 4 years ago

Have you ever tried using PVR SDK and build apk to try it out? Or does PVR SDK have customer support?

I am really confused by the KeyCode printed in log which is totally different from the one we see in Unity. KeyCode 4 for Return => KeyCode.Escape(27) KeyCode 3 for Menu => KeyCode.Menu(319) KeyCode 1001 for Enter => KeyCode.JoystickButton0(330)

The actual KeyCode values do not match.

PVR SDK has some issue with ViveInputUtility, so we have to exclude it, and the PVR customer support told me about the Key Binding, and I try it with PVR SDK only, which works fine. So I wonder, will VIU change the key binding? or will Android did the dirty work? Anyway, thanks for your time:)

chengnay commented 4 years ago

@wojiuxuihuan I just discuss internally with SW PM, he would like to know what is your purpose of getting that Enter key? As not all AIO devices support Enter key, if it is really important for your application and development, we will evaluate and probably support in the future.

wojiuxuihuan commented 4 years ago

@wojiuxuihuan I just discuss internally with SW PM, he would like to know what is your purpose of getting that Enter key? As not all AIO devices support Enter key, if it is really important for your application and development, we will evaluate and probably support in the future.

Thanks!Our Customer request that the VR Device should run without the controller, because they have dozens of Pico devices running at the same time, and they might mess up the HeadSet-Controller Connection. So we have to use the HMD button instead.

chengnay commented 4 years ago

@wojiuxuihuan WaveSDK will not support additional key binding which does not existed in Focus HMD. Currently, VIU has no plan to support PVR SDK in current roadmap.

To my understanding, it shouldn't mess up the HeadSet-Controller connection, every headset should stay connected to only that particular controller unless user makes a new connection to a new headset. Could you double check with your customer?

wojiuxuihuan commented 4 years ago

@wojiuxuihuan WaveSDK will not support additional key binding which does not existed in Focus HMD. Currently, VIU has no plan to support PVR SDK in current roadmap.

To my understanding, it shouldn't mess up the HeadSet-Controller connection, every headset should stay connected to only that particular controller unless user makes a new connection to a new headset. Could you double check with your customer?

I see, guess I have no choice but use return button instead…

There's a strange setting about Pico HeadSet, it doesn't stay connect to the controller which paired before, once HeadSet-Controller connection is lost, the HeadSet will connect the first controller which is active(long press the menu button on controller), so if you have two or more Devices, they may mess up.

chengnay commented 4 years ago

@wojiuxuihuan Is the above symptom occur in your custom application? or even in HOME? Is it 100% fail rate if there are two or more devices?

sidhants commented 4 years ago

@wojiuxuihuan Have you successfully used Wave SDK (Vive Focus/Plus) and PicoVR SDK in the same project with VIU? I am evaluating if they are feasible in my project?

@chengnay Any thoughts please?

wojiuxuihuan commented 4 years ago

@wojiuxuihuan Is the above symptom occur in your custom application? or even in HOME? Is it 100% fail rate if there are two or more devices?

Those are Pico System's default setting, but we found another way to get it down, which is we use the "Return" button to repalce the "Enter" button, a bit rule but effective _

wojiuxuihuan commented 4 years ago

@wojiuxuihuan Have you successfully used Wave SDK (Vive Focus/Plus) and PicoVR SDK in the same project with VIU? I am evaluating if they are feasible in my project?

@chengnay Any thoughts please?

I don't use PicoVR SDK at all, FYI

sidhants commented 4 years ago

@wojiuxuihuan Have you successfully used Wave SDK (Vive Focus/Plus) and PicoVR SDK in the same project with VIU? I am evaluating if they are feasible in my project? @chengnay Any thoughts please?

I don't use PicoVR SDK at all, FYI

I guess you are using Pico G2. I have a Neo 2 which is not Wave supported yet.

wojiuxuihuan commented 4 years ago

@wojiuxuihuan Have you successfully used Wave SDK (Vive Focus/Plus) and PicoVR SDK in the same project with VIU? I am evaluating if they are feasible in my project? @chengnay Any thoughts please?

I don't use PicoVR SDK at all, FYI

I guess you are using Pico G2. I have a Neo 2 which is not Wave supported yet.

Yes, sorry to hear that.