internal void RenderControllerMappingButton(MixedRealityControllerMappingProfile controllerMappingProfile) { var controllerType = controllerMappingProfile.ControllerType.Type; var handedness = controllerMappingProfile.Handedness; if (handedness != Handedness.Right) { GUILayout.BeginHorizontal(); } var typeName = controllerType?.Name.ToProperCase(); if (controllerType?.Name == "WindowsMixedRealityMotionController" && controllerMappingProfile.Handedness == Handedness.None) { typeName = "HoloLens 1"; } var buttonContent = new GUIContent($"Edit {typeName} Action Mapping", ControllerMappingLibrary.GetControllerTextureScaled(controllerMappingProfile)); if (GUILayout.Button(buttonContent, ControllerButtonStyle, GUILayout.Height(128f), GUILayout.MinWidth(32f), GUILayout.ExpandWidth(true))) { EditorApplication.delayCall += () => ControllerPopupWindow.Show(controllerMappingProfile, new SerializedObject(controllerMappingProfile).FindProperty("interactionMappingProfiles")); } if (handedness != Handedness.Left) { GUILayout.EndHorizontal(); } }
protected override void OnEnable() { base.OnEnable(); mixedRealityControllerMappings = serializedObject.FindProperty("mixedRealityControllerMappings"); thisProfile = target as MixedRealityControllerMappingProfile; }
private static Texture2D GetControllerTextureInternal(MixedRealityControllerMappingProfile mappingProfile, bool scaled) { Texture2D texture = null; if (mappingProfile != null && mappingProfile.ControllerType.Type != null) { var controllerName = mappingProfile.ControllerType.Type.Name.Replace("OpenVR", string.Empty); controllerName = controllerName.Replace("Simulated", string.Empty); texture = GetControllerTextureInternal($"{RootTexturePath}{controllerName}", mappingProfile.Handedness, scaled); if (texture != null) { return(texture); } texture = GetControllerTextureInternal($"{RootTexturePath}{controllerName}", Handedness.None, scaled); } if (texture == null) { texture = GetControllerTextureInternal($"{RootTexturePath}Generic_controller", mappingProfile.Handedness, scaled); } if (texture == null) { texture = GetControllerTextureInternal($"{RootTexturePath}Generic_controller", Handedness.Right, scaled); } return(texture); }
private static Texture2D GetControllerTextureCached(MixedRealityControllerMappingProfile mappingProfile, bool scaled = false) { var key = new Tuple <Type, Handedness, bool>(mappingProfile.ControllerType.Type, mappingProfile.Handedness, scaled); if (CachedTextures.TryGetValue(key, out var texture)) { return(texture); } texture = GetControllerTextureInternal(mappingProfile, scaled); CachedTextures.Add(key, texture); return(texture); }
protected override void OnEnable() { base.OnEnable(); if (!MixedRealityInspectorUtility.CheckMixedRealityConfigured(false)) { return; } mixedRealityControllerMappingProfiles = serializedObject.FindProperty("mixedRealityControllerMappingProfiles"); if (!MixedRealityToolkit.Instance.ActiveProfile.IsInputSystemEnabled || MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile == null) { return; } thisProfile = target as MixedRealityControllerMappingProfile; defaultLabelWidth = EditorGUIUtility.labelWidth; defaultFieldWidth = EditorGUIUtility.fieldWidth; }
protected override void OnEnable() { base.OnEnable(); controllerType = serializedObject.FindProperty(nameof(controllerType)); handedness = serializedObject.FindProperty(nameof(handedness)); visualizationProfile = serializedObject.FindProperty(nameof(visualizationProfile)); useCustomInteractions = serializedObject.FindProperty(nameof(useCustomInteractions)); interactionMappingProfiles = serializedObject.FindProperty(nameof(interactionMappingProfiles)); controllerMappingProfile = target as MixedRealityControllerMappingProfile; var showButtons = useCustomInteractions.boolValue; interactionsList = new ReorderableList(serializedObject, interactionMappingProfiles, false, false, showButtons, showButtons) { elementHeight = EditorGUIUtility.singleLineHeight * 1.5f }; interactionsList.drawElementCallback += DrawConfigurationOptionElement; interactionsList.onAddCallback += OnConfigurationOptionAdded; interactionsList.onRemoveCallback += OnConfigurationOptionRemoved; }
public void TestNoControllerMappingProfileUpdate() { foreach (string guid in AssetDatabase.FindAssets("t:MixedRealityControllerMappingProfile DefaultMixedRealityControllerMappingProfile")) { MixedRealityControllerMappingProfile asset = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(MixedRealityControllerMappingProfile)) as MixedRealityControllerMappingProfile; bool wereMappingsUpdated = false; foreach (MixedRealityControllerMapping mapping in asset.MixedRealityControllerMappings) { if (mapping.ControllerType.Type == null) { continue; } if (mapping.UpdateInteractionSettingsFromDefault()) { wereMappingsUpdated = true; } } Assert.IsFalse(wereMappingsUpdated, "DefaultMixedRealityControllerMappingProfile needed an update. This should never be checked in needing an update."); } }
private void OnEnable() { if (!CheckMixedRealityManager(false)) { return; } mixedRealityControllerMappingProfiles = serializedObject.FindProperty("mixedRealityControllerMappingProfiles"); if (!MixedRealityManager.Instance.ActiveProfile.IsInputSystemEnabled || MixedRealityManager.Instance.ActiveProfile.InputActionsProfile == null) { return; } renderMotionControllers = serializedObject.FindProperty("renderMotionControllers"); useDefaultModels = serializedObject.FindProperty("useDefaultModels"); globalLeftHandModel = serializedObject.FindProperty("globalLeftHandModel"); globalRightHandModel = serializedObject.FindProperty("globalRightHandModel"); thisProfile = target as MixedRealityControllerMappingProfile; defaultLabelWidth = EditorGUIUtility.labelWidth; defaultFieldWidth = EditorGUIUtility.fieldWidth; }
/// <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) { }
/// <inheritdoc /> public GenericJoystickController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile) : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile) { }
/// <inheritdoc /> public UnityTouchController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile) : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile) { }
/// <summary> /// Shows the controller pop out window using the provided profile and serialized interaction mapping property /// </summary> /// <param name="profile"></param> /// <param name="interactionMappingProfiles"></param> public static void Show(MixedRealityControllerMappingProfile profile, SerializedProperty interactionMappingProfiles) { var handednessTitleText = profile.Handedness != Handedness.None ? $"{profile.Handedness} Hand " : string.Empty; if (window != null) { window.Close(); } if (profile.ControllerType?.Type == null) { Debug.LogError($"No controller type defined for {profile.name}"); return; } window = (ControllerPopupWindow)CreateInstance(typeof(ControllerPopupWindow)); window.currentControllerName = profile.ControllerType?.Type?.Name; window.currentControllerName = profile.ControllerType?.Type?.Name; window.titleContent = new GUIContent($"{window.currentControllerName} {handednessTitleText}Input Action Assignment"); window.controllerDataProviderProfile = profile; window.currentInteractionProfiles = interactionMappingProfiles; window.currentControllerTexture = ControllerMappingLibrary.GetControllerTexture(profile); isMouseInRects = new bool[interactionMappingProfiles.arraySize]; var asset = AssetDatabase.LoadAssetAtPath <TextAsset>(EditorWindowOptionsPath); if (asset.IsNull()) { var empty = new ControllerInputActionOptions { Controllers = new List <ControllerInputActionOption> { new ControllerInputActionOption { Controller = null, Handedness = Handedness.None, InputLabelPositions = new[] { new Vector2(0, 0) }, IsLabelFlipped = new [] { false } } } }; File.WriteAllText(Path.GetFullPath(EditorWindowOptionsPath), JsonUtility.ToJson(empty, true)); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } else { controllerInputActionOptions = JsonUtility.FromJson <ControllerInputActionOptions>(asset.text); // if the controller option doesn't exist, then make a new one. if (!controllerInputActionOptions.Controllers.Any(option => option.Controller == window.currentControllerName && option.Handedness == window.Handedness)) { var newOption = new ControllerInputActionOption { Controller = window.currentControllerName, Handedness = window.Handedness, InputLabelPositions = new Vector2[interactionMappingProfiles.arraySize], IsLabelFlipped = new bool[interactionMappingProfiles.arraySize] }; controllerInputActionOptions.Controllers.Add(newOption); } window.currentControllerOption = controllerInputActionOptions.Controllers.FirstOrDefault(option => option.Controller == window.currentControllerName && option.Handedness == window.Handedness); if (window.currentControllerOption.IsLabelFlipped == null) { window.currentControllerOption.IsLabelFlipped = new bool[interactionMappingProfiles.arraySize]; } if (window.currentControllerOption.InputLabelPositions == null) { window.currentControllerOption.InputLabelPositions = new Vector2[interactionMappingProfiles.arraySize]; } } var windowSize = new Vector2(window.IsCustomController || window.currentControllerTexture == null ? 896f : 768f, 512f); window.ShowUtility(); window.maxSize = windowSize; window.minSize = windowSize; window.CenterOnMainWin(); }
/// <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; }
/// <inheritdoc /> public GenericOpenVRController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile) : base(controllerDataProvider, trackingState, controllerHandedness, controllerMappingProfile) { nodeType = controllerHandedness == Handedness.Left ? XRNode.LeftHand : XRNode.RightHand; }
/// <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; }
/// <summary> /// Gets a texture based on the <see cref="MixedRealityControllerMappingProfile"/>. /// </summary> /// <param name="mappingProfile"></param> /// <returns>The scaled texture for the controller profile, if none found then a generic texture is returned.</returns> /// <remarks> /// The file name should be formatted as:<para/>XRTK/StandardAssets/Textures/{ControllerName}_{handedness}_{theme}_{scaled}.png<para/> /// </remarks> public static Texture2D GetControllerTextureScaled(MixedRealityControllerMappingProfile mappingProfile) { return(GetControllerTextureCached(mappingProfile, true)); }
/// <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) { }