From b4ca6c52558d5c9dc4d3ce110affd0ee42dcc75f Mon Sep 17 00:00:00 2001
From: Robert Long <robert@robertlong.me>
Date: Thu, 3 May 2018 17:42:26 -0700
Subject: [PATCH] Oculus Go Support

---
 src/assets/stylesheets/hub.scss  |  2 +-
 src/components/hand-controls2.js |  2 ++
 src/hub.html                     |  3 ++-
 src/input-mappings.js            | 17 +++++++++++++++++
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/assets/stylesheets/hub.scss b/src/assets/stylesheets/hub.scss
index dd69bc88a..d9519c92f 100644
--- a/src/assets/stylesheets/hub.scss
+++ b/src/assets/stylesheets/hub.scss
@@ -8,7 +8,7 @@
 @import 'audio';
 @import 'info-dialog';
 
-.a-enter-vr {
+.a-enter-vr, .a-orientation-modal {
   display: none;
 }
 
diff --git a/src/components/hand-controls2.js b/src/components/hand-controls2.js
index e8aca3e7c..ca01817e0 100644
--- a/src/components/hand-controls2.js
+++ b/src/components/hand-controls2.js
@@ -13,6 +13,7 @@ const POSES = {
 export const CONTROLLER_OFFSETS = {
   default: new THREE.Matrix4(),
   "oculus-touch-controls": new THREE.Matrix4().makeTranslation(0, -0.015, 0.04),
+  "oculus-go-controls": new THREE.Matrix4(),
   "vive-controls": new THREE.Matrix4().compose(
     new THREE.Vector3(0, -0.017, 0.13),
     new THREE.Quaternion().setFromEuler(new THREE.Euler(-40 * THREE.Math.DEG2RAD, 0, 0)),
@@ -115,6 +116,7 @@ AFRAME.registerComponent("hand-controls2", {
     if (hand !== prevData) {
       el.setAttribute("vive-controls", controlConfiguration);
       el.setAttribute("oculus-touch-controls", controlConfiguration);
+      el.setAttribute("oculus-go-controls", controlConfiguration);
       el.setAttribute("windows-motion-controls", controlConfiguration);
       el.setAttribute("daydream-controls", controlConfiguration);
       el.setAttribute("gearvr-controls", controlConfiguration);
diff --git a/src/hub.html b/src/hub.html
index 76fb7230c..ea2cff76b 100644
--- a/src/hub.html
+++ b/src/hub.html
@@ -33,7 +33,8 @@
         mute-mic="eventSrc: a-scene; toggleEvents: action_mute"
         freeze-controller="toggleEvent: action_freeze"
         personal-space-bubble="debug: false;"
-        >
+        vr-mode-ui="enabled: false"
+    >
 
         <a-assets>
             <img id="tooltip"  src="./assets/hud/tooltip.9.png" >
diff --git a/src/input-mappings.js b/src/input-mappings.js
index f99854981..14636bd85 100644
--- a/src/input-mappings.js
+++ b/src/input-mappings.js
@@ -34,6 +34,9 @@ const config = {
       },
       "gearvr-controls": {
         trackpad: "trackpad_dpad4"
+      },
+      "oculus-go-controls": {
+        trackpad: "trackpad_dpad4"
       }
     }
   },
@@ -123,6 +126,16 @@ const config = {
         triggerdown: ["action_primary_down"],
         triggerup: ["action_primary_up"]
       },
+      "oculus-go-controls": {
+        trackpad_dpad4_pressed_west_down: "snap_rotate_left",
+        trackpad_dpad4_pressed_east_down: "snap_rotate_right",
+        trackpad_dpad4_pressed_center_down: ["action_primary_down"],
+        trackpad_dpad4_pressed_north_down: ["action_primary_down"],
+        trackpad_dpad4_pressed_south_down: ["action_primary_down"],
+        trackpadup: ["action_primary_up"],
+        triggerdown: ["action_primary_down"],
+        triggerup: ["action_primary_up"]
+      },
       keyboard: {
         m_press: "action_mute",
         q_press: "snap_rotate_left",
@@ -182,6 +195,10 @@ const config = {
       "gearvr-controls": {
         trackpaddown: { right: "action_ui_select_down" },
         trackpadup: { right: "action_ui_select_up" }
+      },
+      "oculus-go-controls": {
+        trackpaddown: { right: "action_ui_select_down" },
+        trackpadup: { right: "action_ui_select_up" }
       }
     }
   }
-- 
GitLab