public GenericJoystickController( TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSourceDefinition definition, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null) : base(trackingState, controllerHandedness, inputSource, interactions, definition) { // Update the spatial pointer rotation with the preconfigured offset angle if (PointerOffsetAngle != 0f && Interactions != null) { MixedRealityInteractionMapping pointerMapping = null; for (int i = 0; i < Interactions.Length; i++) { MixedRealityInteractionMapping mapping = Interactions[i]; if (mapping.InputType == DeviceInputType.SpatialPointer) { pointerMapping = mapping; break; } } if (pointerMapping == null) { Debug.LogWarning($"A pointer offset is defined for {GetType()}, but no spatial pointer mapping could be found."); return; } MixedRealityPose startingRotation = MixedRealityPose.ZeroIdentity; startingRotation.Rotation *= Quaternion.AngleAxis(PointerOffsetAngle, Vector3.left); pointerMapping.PoseData = startingRotation; } }
public WindowsMixedRealityController( TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSourceDefinition definition, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null) : base(trackingState, controllerHandedness, inputSource, interactions, definition) { }
/// <summary> /// Constructor. /// </summary> protected BaseWindowsMixedRealityXRSDKSource( TrackingState trackingState, Handedness sourceHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null, IMixedRealityInputSourceDefinition definition = null) : base(trackingState, sourceHandedness, inputSource, interactions, definition) { }
/// <summary> /// Constructor. /// </summary> protected SimulatedHand( TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null, IMixedRealityInputSourceDefinition definition = null) : base(trackingState, controllerHandedness, inputSource, interactions, definition) { }
public GenericOpenVRController( TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSourceDefinition definition, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null) : base(trackingState, controllerHandedness, definition, inputSource, interactions) { nodeType = controllerHandedness == Handedness.Left ? XRNode.LeftHand : XRNode.RightHand; }
/// <summary> /// Constructor. /// </summary> protected BaseController( TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null, IMixedRealityInputSourceDefinition definition = null) { TrackingState = trackingState; ControllerHandedness = controllerHandedness; InputSource = inputSource; Interactions = interactions; Definition = definition; IsPositionAvailable = false; IsPositionApproximate = false; IsRotationAvailable = false; Type controllerType = GetType(); if (IsControllerMappingEnabled() && Interactions == null) { // We can only enable controller profiles if mappings exist. MixedRealityControllerMapping[] controllerMappings = GetControllerMappings(); // Have to test that a controller type has been registered in the profiles, // else its Unity input manager mappings will not have been set up by the inspector. bool profileFound = false; if (controllerMappings != null) { for (int i = 0; i < controllerMappings.Length; i++) { if (controllerMappings[i].ControllerType.Type == controllerType) { profileFound = true; // If it is an exact match, assign interaction mappings. if (controllerMappings[i].Handedness == ControllerHandedness && controllerMappings[i].Interactions.Length > 0) { MixedRealityInteractionMapping[] profileInteractions = controllerMappings[i].Interactions; MixedRealityInteractionMapping[] newInteractions = new MixedRealityInteractionMapping[profileInteractions.Length]; for (int j = 0; j < profileInteractions.Length; j++) { newInteractions[j] = new MixedRealityInteractionMapping(profileInteractions[j]); } AssignControllerMappings(newInteractions); break; } } } } // If no controller mappings found, try to use default interactions. if (Interactions == null || Interactions.Length < 1) { SetupDefaultInteractions(); // We still don't have controller mappings, so this may be a custom controller. if (Interactions == null || Interactions.Length < 1) { Debug.LogWarning($"No controller interaction mappings found for {controllerType}."); return; } } // If no profile was found, warn the user. Does not stop the project from running. if (!profileFound) { Debug.LogWarning($"No controller profile found for type {controllerType}; please ensure all controllers are defined in the configured MixedRealityControllerConfigurationProfile."); } } if (GetControllerVisualizationProfile() != null && GetControllerVisualizationProfile().RenderMotionControllers&& InputSource != null) { TryRenderControllerModel(controllerType, InputSource.SourceType); } Enabled = true; }