Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fix PicoVR 6dof hand detection #2751

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/src/picovr/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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