From b12d97845128e1592e0c8efe0e15ef85f6d63b39 Mon Sep 17 00:00:00 2001
From: Greg Fodor <gfodor@gmail.com>
Date: Fri, 9 Nov 2018 20:37:16 +0000
Subject: [PATCH] Fix up oculus bindings

---
 src/hub.html                                  | 10 +--
 src/hub.js                                    |  1 -
 .../userinput/bindings/keyboard-mouse-user.js |  8 ++
 .../userinput/bindings/oculus-touch-user.js   | 82 ++-----------------
 src/systems/userinput/resolve-action-sets.js  | 15 ++--
 5 files changed, 27 insertions(+), 89 deletions(-)

diff --git a/src/hub.html b/src/hub.html
index 9344cbe2c..b935796c0 100644
--- a/src/hub.html
+++ b/src/hub.html
@@ -154,7 +154,7 @@
                     set-yxz-order
                     pinnable
                 >
-                    <a-entity class="interactable-ui" stop-event-propagation__grab-start="event: grab-start" stop-event-propagation__grab-end="event: grab-end">
+                    <a-entity class="ui interactable-ui" stop-event-propagation__grab-start="event: grab-start" stop-event-propagation__grab-end="event: grab-end">
                         <a-entity class="freeze-menu" visible-while-frozen="withinDistance: 3;">
                             <a-entity mixin="rounded-text-action-button" pin-networked-object-button="labelSelector:.pin-button-label; hideWhenPinnedSelector:.hide-when-pinned; uiSelector:.interactable-ui" position="0 0.125 0.01"> </a-entity>
                             <a-entity class="pin-button-label" text=" value:pin; width:1.75; align:center;" text-raycast-hack position="0 0.125 0.02"></a-entity>
@@ -171,7 +171,7 @@
                     super-networked-interactable="counter: #pen-counter;"
                     body="type: dynamic; shape: none; mass: 1;"
                     grabbable="maxGrabbers: 1"
-                    sticky-object="autoLockOnRelease: true; autoLockOnLoad: true; autoLockSpeedLimit: 0;"
+                    sticky-object="autoLockOnRelease: true; autoLockOnLoad: true;"
                     hoverable
                     scale="0.5 0.5 0.5"
                 >
@@ -185,7 +185,7 @@
                         segments-width="16"
                         segments-height="12"
                     ></a-sphere>
-                    <a-entity class="delete-button" visible-while-frozen="withinDistance: 3;">
+                    <a-entity class="ui delete-button" visible-while-frozen="withinDistance: 3;">
                         <a-entity mixin="rounded-text-button" remove-networked-object-button position="0 0 0"> </a-entity>
                         <a-entity text=" value:remove; width:2.5; align:center;" text-raycast-hack position="0 0 0.01"></a-entity>
                     </a-entity>
@@ -207,7 +207,7 @@
                     set-yxz-order
                     auto-scale-cannon-physics-body
                 >
-                    <a-entity class="delete-button" visible-while-frozen="withinDistance: 3;">
+                    <a-entity class="ui delete-button" visible-while-frozen="withinDistance: 3;">
                         <a-entity mixin="rounded-text-button" remove-networked-object-button position="0 0 0"> </a-entity>
                         <a-entity text=" value:remove; width:2.5; align:center;" text-raycast-hack position="0 0 0.01"></a-entity>
                     </a-entity>
@@ -221,7 +221,7 @@
             </template>
 
             <template id="paging-toolbar">
-                <a-entity class="paging-toolbar" visible-to-owner>
+                <a-entity class="ui paging-toolbar" visible-to-owner>
                     <a-entity class="prev-button" position="-0.3 0 0">
                         <a-entity mixin="rounded-text-button" slice9="width: 0.2"> </a-entity>
                         <a-entity text=" value:<; width:2; align:center;" text-raycast-hack position="0 0 0.01"></a-entity>
diff --git a/src/hub.js b/src/hub.js
index bffa1d586..3bf72d895 100644
--- a/src/hub.js
+++ b/src/hub.js
@@ -114,7 +114,6 @@ import "./components/cardboard-controls";
 import "./components/cursor-controller";
 
 import "./components/nav-mesh-helper";
-import "./systems/tunnel-effect";
 
 import "./components/tools/pen";
 import "./components/tools/networked-drawing";
diff --git a/src/systems/userinput/bindings/keyboard-mouse-user.js b/src/systems/userinput/bindings/keyboard-mouse-user.js
index 46e5edaf7..30c347217 100644
--- a/src/systems/userinput/bindings/keyboard-mouse-user.js
+++ b/src/systems/userinput/bindings/keyboard-mouse-user.js
@@ -328,5 +328,13 @@ export const keyboardMouseUserBindings = {
       dest: { value: paths.actions.cursor.grab },
       xform: xforms.rising
     }
+  ],
+
+  [sets.cursorHoveringOnUI]: [
+    {
+      src: { value: paths.device.mouse.buttonLeft },
+      dest: { value: paths.actions.cursor.grab },
+      xform: xforms.rising
+    }
   ]
 };
diff --git a/src/systems/userinput/bindings/oculus-touch-user.js b/src/systems/userinput/bindings/oculus-touch-user.js
index ecdff2202..6bb793a29 100644
--- a/src/systems/userinput/bindings/oculus-touch-user.js
+++ b/src/systems/userinput/bindings/oculus-touch-user.js
@@ -15,16 +15,8 @@ const scaledLeftJoyX = `${name}left/scaledJoyX`;
 const scaledLeftJoyY = `${name}left/scaledJoyY`;
 const rightGripFalling = "${name}right/GripFalling";
 const rightTriggerFalling = `${name}right/TriggerFalling`;
-const cursorDrop2 = `${name}right/cursorDrop2`;
-const cursorDrop1 = `${name}right/cursorDrop1`;
-const rightHandDrop2 = `${name}right/rightHandDrop2`;
-const rightHandDrop1 = `${name}right/rightHandDrop1`;
 const rightGripRising = `${name}right/GripRising`;
 const rightTriggerRising = `${name}right/TriggerRising`;
-const rightGripRisingGrab = `${name}right/grip/RisingGrab`;
-const rightTriggerRisingGrab = `${name}right/trigger/RisingGrab`;
-const leftGripRisingGrab = `${name}left/grip/RisingGrab`;
-const leftTriggerRisingGrab = `${name}left/trigger/RisingGrab`;
 const leftGripFalling = `${name}left/GripFalling`;
 const leftGripRising = `${name}left/GripRising`;
 const leftTriggerRising = `${name}left/TriggerRising`;
@@ -425,22 +417,10 @@ export const oculusTouchUserBindings = {
   [sets.leftHandHoveringOnInteractable]: [
     {
       src: { value: leftButton("grip").pressed },
-      dest: { value: leftGripRisingGrab },
+      dest: { value: paths.actions.leftHand.grab },
       xform: xforms.rising,
       root: leftGripRising,
       priority: 200
-    },
-    {
-      src: { value: leftButton("trigger").pressed },
-      dest: { value: leftTriggerRisingGrab },
-      xform: xforms.rising,
-      root: leftTriggerRising,
-      priority: 200
-    },
-    {
-      src: [leftGripRisingGrab, leftTriggerRisingGrab],
-      dest: { value: paths.actions.leftHand.grab },
-      xform: xforms.any
     }
   ],
 
@@ -523,22 +503,10 @@ export const oculusTouchUserBindings = {
   [sets.cursorHoveringOnInteractable]: [
     {
       src: { value: rightButton("grip").pressed },
-      dest: { value: rightGripRisingGrab },
+      dest: { value: paths.actions.cursor.grab },
       xform: xforms.rising,
       root: rightGripRising,
       priority: 200
-    },
-    {
-      src: { value: rightButton("trigger").pressed },
-      dest: { value: rightTriggerRisingGrab },
-      xform: xforms.rising,
-      root: rightTriggerRising,
-      priority: 200
-    },
-    {
-      src: [rightGripRisingGrab, rightTriggerRisingGrab],
-      dest: { value: paths.actions.cursor.grab },
-      xform: xforms.any
     }
   ],
 
@@ -550,25 +518,11 @@ export const oculusTouchUserBindings = {
     },
     {
       src: { value: rightButton("grip").pressed },
-      dest: { value: cursorDrop1 },
+      dest: { value: paths.actions.cursor.drop },
       xform: xforms.falling,
       root: rightGripFalling,
       priority: 200
     },
-    {
-      src: { value: rightButton("trigger").pressed },
-      dest: {
-        value: cursorDrop2
-      },
-      xform: xforms.falling,
-      root: rightTriggerFalling,
-      priority: 200
-    },
-    {
-      src: [cursorDrop1, cursorDrop2],
-      dest: { value: paths.actions.cursor.drop },
-      xform: xforms.any
-    },
     {
       src: null,
       dest: { value: ensureFrozenViaButtons },
@@ -598,47 +552,21 @@ export const oculusTouchUserBindings = {
   [sets.rightHandHoveringOnInteractable]: [
     {
       src: { value: rightButton("grip").pressed },
-      dest: { value: rightGripRisingGrab },
+      dest: { value: paths.actions.rightHand.grab },
       xform: xforms.rising,
       root: rightGripRising,
       priority: 200
-    },
-    {
-      src: { value: rightButton("trigger").pressed },
-      dest: { value: rightTriggerRisingGrab },
-      xform: xforms.rising,
-      root: rightTriggerRising,
-      priority: 200
-    },
-    {
-      src: [rightGripRisingGrab, rightTriggerRisingGrab],
-      dest: { value: paths.actions.rightHand.grab },
-      xform: xforms.any
     }
   ],
 
   [sets.rightHandHoldingInteractable]: [
     {
       src: { value: rightButton("grip").pressed },
-      dest: { value: rightHandDrop1 },
+      dest: { value: paths.actions.rightHand.drop },
       xform: xforms.falling,
       root: rightGripFalling,
       priority: 200
     },
-    {
-      src: { value: rightButton("trigger").pressed },
-      dest: {
-        value: rightHandDrop2
-      },
-      xform: xforms.falling,
-      root: rightTriggerFalling,
-      priority: 200
-    },
-    {
-      src: [rightHandDrop1, rightHandDrop2],
-      dest: { value: paths.actions.rightHand.drop },
-      xform: xforms.any
-    },
     {
       src: null,
       dest: { value: ensureFrozenViaButtons },
diff --git a/src/systems/userinput/resolve-action-sets.js b/src/systems/userinput/resolve-action-sets.js
index 4341064a1..b0187fa92 100644
--- a/src/systems/userinput/resolve-action-sets.js
+++ b/src/systems/userinput/resolve-action-sets.js
@@ -83,11 +83,18 @@ export function updateActionSetsBasedOnSuperhands() {
   // Cursor
   cursorController.enabled = !(rightHandTeleporting || rightHandHovering || rightHandGrabbing);
 
+  const cursorHoveringOnUI =
+    cursorController.enabled &&
+    !rightHandTeleporting &&
+    !rightHandHovering &&
+    !rightHandGrabbing &&
+    (cursorHand.has("hover-start") && cursorHand.get("hover-start").matches(".ui, .ui *"));
   const cursorHoveringOnInteractable =
     cursorController.enabled &&
     !rightHandTeleporting &&
     !rightHandHovering &&
     !rightHandGrabbing &&
+    !cursorHoveringOnUI &&
     cursorHand.has("hover-start") &&
     cursorHand.get("hover-start").matches(".interactable, .interactable *");
   const cursorHoveringOnCamera =
@@ -95,18 +102,14 @@ export function updateActionSetsBasedOnSuperhands() {
     !rightTeleporter.active &&
     !rightHandHovering &&
     !rightHandGrabbing &&
+    !cursorHoveringOnUI &&
     (cursorHand.has("hover-start") && cursorHand.get("hover-start").matches(".icamera, .icamera *"));
-  const cursorHoveringOnUI =
-    cursorController.enabled &&
-    !rightHandTeleporting &&
-    !rightHandHovering &&
-    !rightHandGrabbing &&
-    (cursorHand.has("hover-start") && cursorHand.get("hover-start").matches(".ui, .ui *"));
   const cursorHoveringOnPen =
     cursorController.enabled &&
     !rightHandTeleporting &&
     !rightHandHovering &&
     !rightHandGrabbing &&
+    !cursorHoveringOnUI &&
     cursorHand.has("hover-start") &&
     cursorHand.get("hover-start").matches(".pen, .pen *");
   const cursorHoldingInteractable =
-- 
GitLab