Skip to content

Commit

Permalink
Add Vive Focus WebXR Interstitial (#3361)
Browse files Browse the repository at this point in the history
  • Loading branch information
daoshengmu authored and bluemarvin committed May 13, 2020
1 parent 0cd26a2 commit aa6e0a0
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 11 deletions.
Expand Up @@ -1162,7 +1162,7 @@ public int getPointerColor() {
@Keep
@SuppressWarnings("unused")
private void setDeviceType(int aType) {
if (DeviceType.isOculusBuild()) {
if (DeviceType.isOculusBuild() || DeviceType.isWaveBuild()) {
runOnUiThread(() -> DeviceType.setType(aType));
}
}
Expand Down
Expand Up @@ -93,6 +93,8 @@ private void initializeControllers() {
addController(DeviceType.PicoNeo2, WebXRInterstitialController.HAND_RIGHT);
} else if (deviceType == DeviceType.PicoG2) {
addController(DeviceType.PicoG2, WebXRInterstitialController.HAND_NONE);
} else if (deviceType == DeviceType.ViveFocus) {
addController(DeviceType.ViveFocus, WebXRInterstitialController.HAND_NONE);
} else if (deviceType == DeviceType.ViveFocusPlus) {
addController(DeviceType.ViveFocusPlus, WebXRInterstitialController.HAND_LEFT);
addController(DeviceType.ViveFocusPlus, WebXRInterstitialController.HAND_RIGHT);
Expand Down
Expand Up @@ -8,14 +8,15 @@

public class DeviceType {
// These values need to match those in Device.h
@IntDef(value = { Unknown, OculusGo, OculusQuest, ViveFocusPlus, PicoNeo2, PicoG2 })
@IntDef(value = { Unknown, OculusGo, OculusQuest, ViveFocus, ViveFocusPlus, PicoNeo2, PicoG2 })
public @interface Type {}
public static final int Unknown = 0;
public static final int OculusGo = 1;
public static final int OculusQuest = 2;
public static final int ViveFocusPlus = 3;
public static final int PicoNeo2 = 4;
public static final int PicoG2 = 5;
public static final int ViveFocus = 3;
public static final int ViveFocusPlus = 4;
public static final int PicoNeo2 = 6;
public static final int PicoG2 = 7;

private static @Type int mType = Unknown;

Expand All @@ -28,6 +29,9 @@ public static void setType(@Type int aType) {
case OculusQuest:
name = "Oculus Quest";
break;
case ViveFocus:
name = "Vive Focus";
break;
case ViveFocusPlus:
name = "Vive Focus Plus";
break;
Expand Down
12 changes: 12 additions & 0 deletions app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp
Expand Up @@ -90,6 +90,7 @@ struct DeviceDelegateWaveVR::State {
GestureDelegatePtr gestures;
std::array<Controller, kMaxControllerCount> controllers;
ImmersiveDisplayPtr immersiveDisplay;
device::DeviceType deviceType;
bool lastSubmitDiscarded;
bool recentered;
vrb::Matrix reorientMatrix;
Expand All @@ -110,6 +111,7 @@ struct DeviceDelegateWaveVR::State {
, renderHeight(0)
, devicePairs {}
, controllers {}
, deviceType(device::UnknownType)
, lastSubmitDiscarded(false)
, recentered(false)
, ignoreNextRecenter(false)
Expand All @@ -132,6 +134,11 @@ struct DeviceDelegateWaveVR::State {
sixDoFControllerCount++;
}
}
if (sixDoFControllerCount) {
deviceType = device::ViveFocusPlus;
} else {
deviceType = device::ViveFocus;
}
reorientMatrix = vrb::Matrix::Identity();
}

Expand Down Expand Up @@ -454,6 +461,11 @@ DeviceDelegateWaveVR::Create(vrb::RenderContextPtr& aContext) {
return result;
}

device::DeviceType
DeviceDelegateWaveVR::GetDeviceType() {
return m.deviceType;
}

void
DeviceDelegateWaveVR::SetRenderMode(const device::RenderMode aMode) {
if (aMode == m.renderMode) {
Expand Down
1 change: 1 addition & 0 deletions app/src/wavevr/cpp/DeviceDelegateWaveVR.h
Expand Up @@ -15,6 +15,7 @@ class DeviceDelegateWaveVR : public DeviceDelegate {
public:
static DeviceDelegateWaveVRPtr Create(vrb::RenderContextPtr& aContext);
// DeviceDelegate interface
device::DeviceType GetDeviceType() override;
void SetRenderMode(const device::RenderMode aMode) override;
device::RenderMode GetRenderMode() override;
void RegisterImmersiveDisplay(ImmersiveDisplayPtr aDisplay) override;
Expand Down
Expand Up @@ -36,7 +36,6 @@ public PlatformActivity() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DeviceType.setType(DeviceType.ViveFocusPlus);

queueRunnable(new Runnable() {
@Override
Expand Down
Binary file added app/src/wavevr/res/drawable/controller_focus.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 41 additions & 5 deletions app/src/wavevr/res/layout/webxr_interstitial_controller.xml
Expand Up @@ -20,8 +20,8 @@
android:background="#00000000"
android:padding="5dp">

<!-- Vive Left Controller -->
<!-- vive Right Controller -->
<!-- Vive Focus Plus Left Controller -->
<!-- vive Focus Plus Right Controller -->
<RelativeLayout
app:visibleGone="@{model == DeviceType.ViveFocusPlus &amp;&amp; hand == WebXRInterstitialController.HAND_LEFT}"
tools:visibility="gone"
Expand All @@ -34,7 +34,7 @@
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:scaleType="fitCenter"
android:src="@drawable/controller_focus_left"
android:src="@drawable/controller_focus_plus_left"
tools:ignore="RtlHardcoded" />
<ImageView
android:layout_width="wrap_content"
Expand Down Expand Up @@ -62,7 +62,7 @@
android:text="@string/webxr_interstitial_exit_webxr"/>
</RelativeLayout>

<!-- Vive Right Controller -->
<!-- Vive Focus Plus Right Controller -->
<RelativeLayout
app:visibleGone="@{model == DeviceType.ViveFocusPlus &amp;&amp; hand == WebXRInterstitialController.HAND_RIGHT}"
tools:visibility="visible"
Expand All @@ -74,7 +74,7 @@
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:scaleType="fitCenter"
android:src="@drawable/controller_focus_right"
android:src="@drawable/controller_focus_plus_right"
tools:ignore="RtlHardcoded" />
<ImageView
android:layout_width="wrap_content"
Expand All @@ -100,6 +100,42 @@
tools:ignore="RtlHardcoded,RtlSymmetry"
android:text="@string/webxr_interstitial_exit_webxr"/>
</RelativeLayout>
<!-- Vive Focus Controller -->
<RelativeLayout
app:visibleGone="@{model == DeviceType.ViveFocus }"
tools:visibility="gone"
android:layout_width="250dp"
android:layout_height="120dp"
>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:scaleType="fitCenter"
android:src="@drawable/controller_focus"
tools:ignore="RtlHardcoded" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingRight="70dp"
android:layout_marginBottom="60dp"
android:layout_centerHorizontal="true"
android:scaleType="fitCenter"
android:src="@drawable/ic_webxr_controller_arrow"
tools:ignore="RtlHardcoded,RtlSymmetry"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="textEnd"
android:layout_alignParentTop="true"
android:paddingRight="140dp"
android:layout_centerHorizontal="true"
android:textSize="18sp"
tools:ignore="RtlHardcoded,RtlSymmetry"
android:text="@string/webxr_interstitial_exit_webxr"/>
</RelativeLayout>
</FrameLayout>

</layout>

0 comments on commit aa6e0a0

Please sign in to comment.