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

Commit 7195a5c

Browse files
authored
Fix PicoVR 6dof hand detection (#2751)
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.
1 parent 78f5696 commit 7195a5c

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

app/src/picovr/cpp/native-lib.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ JNI_METHOD(void, nativeEndFrame)
109109
BrowserWorld::Instance().EndFrame();
110110
}
111111

112+
JNI_METHOD(void, nativeSetFocusedController)
113+
(JNIEnv*, jobject, jint index) {
114+
if (gDestroyed) {
115+
return;
116+
}
117+
sDevice->SetFocused(index);
118+
}
119+
112120
JNI_METHOD(void, nativeUpdateControllerPose)
113121
(JNIEnv*, jobject, jint index, jboolean dof6, jfloat px, jfloat py, jfloat pz, jfloat qx, jfloat qy, jfloat qz, jfloat qw) {
114122
if (gDestroyed) {

app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,18 @@ private void updateControllers() {
113113
}
114114

115115
if (mControllerManager != null) {
116+
int hand = VrActivity.getPvrHandness(this);
117+
if (hand != mHand) {
118+
nativeSetFocusedController(hand);
119+
mHand = hand;
120+
}
116121
CVController main = mControllerManager.getMainController();
117122
if (main != null) {
118-
updateController(0, main);
123+
updateController(hand, main);
119124
}
120125
CVController sub = mControllerManager.getSubController();
121126
if (sub != null) {
122-
updateController(1, sub);
127+
updateController(1 - hand, sub);
123128
}
124129
} else if (mHbManager != null) {
125130
update3DofController();
@@ -243,7 +248,8 @@ public void onRendererShutdown() {
243248

244249
@Override
245250
public void initGL(int width, int height) {
246-
nativeInitialize(width, height, getAssets(), mType, VrActivity.getPvrHandness(this));
251+
mHand = VrActivity.getPvrHandness(this);
252+
nativeInitialize(width, height, getAssets(), mType, mHand);
247253
}
248254

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

0 commit comments

Comments
 (0)