Skip to content

Commit

Permalink
Fix PicoVR 6dof hand detection (#2751)
Browse files Browse the repository at this point in the history
For PicoVR 6dof controllers, the primary controller is the one with focus when the application
is launched. The is an additional call that determines which hand the primary controller is in.
  • Loading branch information
bluemarvin committed Feb 6, 2020
1 parent 78f5696 commit 7195a5c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions app/src/picovr/cpp/native-lib.cpp
Expand Up @@ -109,6 +109,14 @@ JNI_METHOD(void, nativeEndFrame)
BrowserWorld::Instance().EndFrame();
}

JNI_METHOD(void, nativeSetFocusedController)
(JNIEnv*, jobject, jint index) {
if (gDestroyed) {
return;
}
sDevice->SetFocused(index);
}

JNI_METHOD(void, nativeUpdateControllerPose)
(JNIEnv*, jobject, jint index, jboolean dof6, jfloat px, jfloat py, jfloat pz, jfloat qx, jfloat qy, jfloat qz, jfloat qw) {
if (gDestroyed) {
Expand Down
13 changes: 10 additions & 3 deletions app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java
Expand Up @@ -113,13 +113,18 @@ private void updateControllers() {
}

if (mControllerManager != null) {
int hand = VrActivity.getPvrHandness(this);
if (hand != mHand) {
nativeSetFocusedController(hand);
mHand = hand;
}
CVController main = mControllerManager.getMainController();
if (main != null) {
updateController(0, main);
updateController(hand, main);
}
CVController sub = mControllerManager.getSubController();
if (sub != null) {
updateController(1, sub);
updateController(1 - hand, sub);
}
} else if (mHbManager != null) {
update3DofController();
Expand Down Expand Up @@ -243,7 +248,8 @@ public void onRendererShutdown() {

@Override
public void initGL(int width, int height) {
nativeInitialize(width, height, getAssets(), mType, VrActivity.getPvrHandness(this));
mHand = VrActivity.getPvrHandness(this);
nativeInitialize(width, height, getAssets(), mType, mHand);
}

@Override
Expand Down Expand Up @@ -293,6 +299,7 @@ public void onChannelChanged(int var1, int var2) {
protected native void nativeEndFrame();
protected native void nativePause();
protected native void nativeResume();
protected native void nativeSetFocusedController(int index);
protected native void nativeUpdateControllerState(int index, boolean connected, int buttons, float grip, float axisX, float axisY, boolean touched);
protected native void nativeUpdateControllerPose(int index, boolean dof6, float px, float py, float pz, float qx, float qy, float qz, float qw);
protected native void queueRunnable(Runnable aRunnable);
Expand Down

0 comments on commit 7195a5c

Please sign in to comment.