Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of a controller.
        /// </summary>
        /// <param name="controllerDataProvider">The <see cref="IMixedRealityControllerDataProvider"/> this controller belongs to.</param>
        /// <param name="trackingState">The initial tracking state of this controller.</param>
        /// <param name="controllerHandedness">The controller's handedness.</param>
        /// <param name="controllerMappingProfile"></param>
        protected BaseController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile)
        {
            ControllerDataProvider = controllerDataProvider;
            TrackingState          = trackingState;
            ControllerHandedness   = controllerHandedness;

            var handednessPrefix = string.Empty;

            if (controllerHandedness == Handedness.Left ||
                controllerHandedness == Handedness.Right)
            {
                handednessPrefix = $"{controllerHandedness} ";
            }

            Name = $"{handednessPrefix}{GetType().Name}";

            if (controllerMappingProfile.IsNull())
            {
                throw new Exception($"{nameof(controllerMappingProfile)} cannot be null for {Name}");
            }

            visualizationProfile = controllerMappingProfile.VisualizationProfile;
            var pointers = AssignControllerMappings(controllerMappingProfile.InteractionMappingProfiles);

            // If no controller mappings found, warn the user.  Does not stop the project from running.
            if (Interactions == null || Interactions.Length < 1)
            {
                throw new Exception($"No Controller interaction mappings found for {controllerMappingProfile.name}!");
            }

            InputSource = MixedRealityToolkit.InputSystem?.RequestNewGenericInputSource(Name, pointers);

            for (int i = 0; i < InputSource?.Pointers?.Length; i++)
            {
                InputSource.Pointers[i].Controller = this;
            }

            IsPositionAvailable   = false;
            IsPositionApproximate = false;
            IsRotationAvailable   = false;

            Enabled = true;
        }
 /// <inheritdoc />
 public OculusRemoteOpenVRController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile)
     : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile)
 {
 }
Exemplo n.º 3
0
 /// <inheritdoc />
 public UnityTouchController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile)
     : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile)
 {
 }
 /// <inheritdoc />
 public WindowsMixedRealityHololensOneController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile)
     : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile)
 {
 }
 /// <inheritdoc />
 public WindowsMixedRealityOpenVRMotionController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile)
     : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile)
 {
     PointerOffsetAngle = -30f;
 }
Exemplo n.º 6
0
 /// <inheritdoc />
 public OculusTouchController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile, OculusApi.Controller controllerType = OculusApi.Controller.None, OculusApi.Node nodeType = OculusApi.Node.None)
     : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile, controllerType, nodeType)
 {
 }
Exemplo n.º 7
0
 /// <inheritdoc />
 protected BaseOculusController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile, OculusApi.Controller controllerType = OculusApi.Controller.None, OculusApi.Node nodeType = OculusApi.Node.None)
     : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile)
 {
     ControllerType = controllerType;
     NodeType       = nodeType;
 }
 /// <inheritdoc />
 public GenericJoystickController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile)
     : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile)
 {
 }
Exemplo n.º 9
0
 /// <inheritdoc />
 public GenericOpenVRController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile)
     : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile)
 {
     nodeType = controllerHandedness == Handedness.Left ? XRNode.LeftHand : XRNode.RightHand;
 }