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

Commit

Permalink
Android oculus support (#202)
Browse files Browse the repository at this point in the history
* Initial Commit of Oculus Go OpenVR support on Android

* Controller visualization now working, updated handedness to support "Any" in configuration.
Pointers are not yet however.

* Updated comments and improved the Oculus go inspector

* CHanged using Any to Both hands. Meaning a controller could be in either hand

* Updated missing ref from Any to Both

* Finalised testing / configuration for oculus Go OPENVR support

* If only for the but..
  • Loading branch information
SimonDarksideJ authored Jun 5, 2019
1 parent 9c02702 commit 05970dc
Show file tree
Hide file tree
Showing 20 changed files with 571 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEngine;
using XRTK.Definitions.Devices;
using XRTK.Definitions.Utilities;

namespace XRTK.Providers.Controllers.OpenVR
{
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Input System/Controller Mappings/Oculus Go Controller Mapping Profile", fileName = "OculusGoControllerMappingProfile")]
public class OculusGoControllerMappingProfile : BaseMixedRealityControllerMappingProfile
{
/// <inheritdoc />
public override SupportedControllerType ControllerType => SupportedControllerType.OculusGo;

/// <inheritdoc />
public override string TexturePath => $"{base.TexturePath}OculusGoController";

protected override void Awake()
{
if (!HasSetupDefaults)
{
ControllerMappings = new[]
{
new MixedRealityControllerMapping("Oculus Go Controller", typeof(OculusGoController), Handedness.Both),
};
}

base.Awake();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public enum SupportedControllerType
Xbox,
TouchScreen,
Mouse,
Lumin
Lumin,
OculusGo,
OculusQuest
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,54 @@
false,
false
]
},
{
"Controller": 12,
"Handedness": 3,
"InputLabelPositions": [
{
"x": -101.0,
"y": 306.0
},
{
"x": 329.0,
"y": 439.0
},
{
"x": 328.0,
"y": 415.0
},
{
"x": 329.0,
"y": 463.0
},
{
"x": -16.0,
"y": 117.0
},
{
"x": -90.0,
"y": 175.0
},
{
"x": -90.0,
"y": 220.0
},
{
"x": -90.0,
"y": 198.0
}
],
"IsLabelFlipped": [
true,
false,
false,
false,
true,
true,
true,
true
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEditor;
using XRTK.Inspectors.Profiles;

namespace XRTK.Providers.Controllers.OpenVR.Inspectors.Profiles
{
[CustomEditor(typeof(OculusGoControllerMappingProfile))]
public class OculusGoControllerMappingProfileInspector : BaseMixedRealityControllerMappingProfileInspector { }
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class MixedRealityControllerVisualizationProfileInspector : BaseMixedReal
{
new GUIContent("Left Hand"),
new GUIContent("Right Hand"),
new GUIContent("Either Hand (Both)"),
};

private SerializedProperty renderMotionControllers;
Expand Down Expand Up @@ -182,17 +183,37 @@ private void RenderControllerList(SerializedProperty controllerList)
EditorGUILayout.HelpBox("A controller type must be defined!", MessageType.Error);
}

var handednessValue = mixedRealityControllerHandedness.intValue - 1;

// Reset in case it was set to something other than left or right.
if (handednessValue < 0 || handednessValue > 1) { handednessValue = 0; }
var handednessValue = 0;
switch (mixedRealityControllerHandedness.intValue)
{
case 1:
handednessValue = 0;
break;
case 2:
handednessValue = 1;
break;
default:
handednessValue = 2;
break;
}

EditorGUI.BeginChangeCheck();
handednessValue = EditorGUILayout.IntPopup(new GUIContent(mixedRealityControllerHandedness.displayName, mixedRealityControllerHandedness.tooltip), handednessValue, HandednessSelections, null);

if (EditorGUI.EndChangeCheck())
{
mixedRealityControllerHandedness.intValue = handednessValue + 1;
switch (handednessValue)
{
case 0:
mixedRealityControllerHandedness.intValue = (int)Handedness.Left;
break;
case 1:
mixedRealityControllerHandedness.intValue = (int)Handedness.Right;
break;
default:
mixedRealityControllerHandedness.intValue = (int)Handedness.Both;
break;
}
}

EditorGUILayout.PropertyField(controllerSetting.FindPropertyRelative("poseAction"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public bool SetupConfiguration(Type controllerType)
{
// Assign any known interaction mappings.
if (controllerMappings[i].ControllerType?.Type == controllerType &&
controllerMappings[i].Handedness == ControllerHandedness &&
(controllerMappings[i].Handedness == ControllerHandedness || controllerMappings[i].Handedness == Handedness.Both) &&
controllerMappings[i].Interactions.Length > 0)
{
var profileInteractions = controllerMappings[i].Interactions;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEngine;
using XRTK.Definitions.Devices;
using XRTK.Definitions.InputSystem;
using XRTK.Definitions.Utilities;
using XRTK.Interfaces.InputSystem;

namespace XRTK.Providers.Controllers.OpenVR
{
public class OculusGoController : GenericOpenVRController
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="trackingState"></param>
/// <param name="controllerHandedness"></param>
/// <param name="inputSource"></param>
/// <param name="interactions"></param>
public OculusGoController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
: base(trackingState, controllerHandedness, inputSource, interactions)
{
}

/// <inheritdoc />
public override MixedRealityInteractionMapping[] DefaultInteractions => new[]
{
new MixedRealityInteractionMapping(0, "Spatial Pointer", AxisType.SixDof, DeviceInputType.SpatialPointer, MixedRealityInputAction.None),
new MixedRealityInteractionMapping(1, "Trigger Position", AxisType.SingleAxis, DeviceInputType.Trigger, ControllerMappingLibrary.AXIS_10),
new MixedRealityInteractionMapping(2, "Trigger Press", AxisType.Digital, DeviceInputType.TriggerPress, KeyCode.JoystickButton15),
new MixedRealityInteractionMapping(3, "Trigger Touch", AxisType.Digital, DeviceInputType.TriggerTouch, ControllerMappingLibrary.AXIS_10),
new MixedRealityInteractionMapping(4, "Back", AxisType.Digital, DeviceInputType.ButtonPress, KeyCode.JoystickButton7),
new MixedRealityInteractionMapping(5, "PrimaryTouchpad Touch", AxisType.Digital, DeviceInputType.TouchpadTouch, KeyCode.JoystickButton17),
new MixedRealityInteractionMapping(6, "PrimaryTouchpad Click", AxisType.Digital, DeviceInputType.TouchpadPress, KeyCode.JoystickButton9),
new MixedRealityInteractionMapping(7, "PrimaryTouchpad Axis", AxisType.DualAxis, DeviceInputType.DirectionalPad, ControllerMappingLibrary.AXIS_4, ControllerMappingLibrary.AXIS_5)
};

/// <inheritdoc />
public override void SetupDefaultInteractions(Handedness controllerHandedness)
{
AssignControllerMappings(DefaultInteractions);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ protected override GenericJoystickController GetOrAddController(string joystickN
case SupportedControllerType.OculusRemote:
controllerType = typeof(OculusRemoteController);
break;
case SupportedControllerType.OculusGo:
controllerType = typeof(OculusGoController);
break;
case SupportedControllerType.WindowsMixedReality:
controllerType = typeof(WindowsMixedRealityOpenVRMotionController);
break;
Expand Down Expand Up @@ -113,7 +116,7 @@ protected override GenericJoystickController GetOrAddController(string joystickN
/// <inheritdoc />
protected override SupportedControllerType GetCurrentControllerType(string joystickName)
{
if (string.IsNullOrEmpty(joystickName) || !joystickName.Contains("OpenVR"))
if (string.IsNullOrEmpty(joystickName) || joystickName.Contains("<0"))
{
return SupportedControllerType.None;
}
Expand All @@ -123,6 +126,11 @@ protected override SupportedControllerType GetCurrentControllerType(string joyst
return SupportedControllerType.OculusTouch;
}

if (joystickName.Contains("Oculus Tracked Remote"))
{
return SupportedControllerType.OculusGo;
}

if (joystickName.Contains("Oculus remote"))
{
return SupportedControllerType.OculusRemote;
Expand All @@ -143,7 +151,7 @@ protected override SupportedControllerType GetCurrentControllerType(string joyst
return SupportedControllerType.WindowsMixedReality;
}

Debug.Log($"{joystickName} does not have a defined controller type, falling back to generic controller type");
Debug.LogWarning($"{joystickName} does not have a defined controller type, falling back to generic controller type");

return SupportedControllerType.GenericOpenVR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public virtual void UpdateController()
case AxisType.DualAxis:
UpdateDualAxisData(Interactions[i]);
break;
case AxisType.ThreeDofRotation:
case AxisType.ThreeDofPosition:
case AxisType.SixDof:
UpdatePoseData(Interactions[i]);
break;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 05970dc

Please sign in to comment.