Example #1
0
 /// <summary>
 /// Sets the pointer behavior for pointer of type T, for all input types.
 /// </summary>
 /// <typeparam name="T">All pointer types that equal or derive from this type will be set.</typeparam>
 /// <param name="pointerBehavior">Desired <seealso cref="Microsoft.MixedReality.Toolkit.Input.PointerBehavior"/>.</param>
 /// <param name="handedness">Specify handedness to restrict to only right, left.</param>
 public static void SetPointerBehavior <T>(PointerBehavior pointerBehavior, Handedness handedness = Handedness.Any) where T : class, IMixedRealityPointer
 {
     foreach (InputSourceType type in Enum.GetValues(typeof(InputSourceType)))
     {
         SetPointerBehavior <T>(pointerBehavior, type, handedness);
     }
 }
Example #2
0
 /// <summary>
 /// Sets the behavior for the given pointer type and input type.
 /// </summary>
 /// <typeparam name="T">All pointer types that equal or derive from this type will be set.</typeparam>
 /// <param name="pointerBehavior">Desired <seealso cref="Microsoft.MixedReality.Toolkit.Input.PointerBehavior"/>.</param>
 /// <param name="sourceType">Allows setting different behaviors for different input types (hands, controllers, etc.)</param>
 /// <param name="handedness">Specify handedness to restrict to only right, left.</param>
 public static void SetPointerBehavior <T>(PointerBehavior pointerBehavior, InputSourceType sourceType, Handedness handedness = Handedness.Any) where T : class, IMixedRealityPointer
 {
     if (CoreServices.InputSystem.FocusProvider is IPointerPreferences preferences)
     {
         preferences.SetPointerBehavior <T>(handedness, sourceType, pointerBehavior);
     }
     else
     {
         WarnAboutSettingCustomPointerBehaviors();
     }
 }
Example #3
0
 /// <summary>
 /// Sets the behavior for the gaze pointer.
 /// </summary>
 /// <param name="pointerBehavior">Desired <seealso cref="Microsoft.MixedReality.Toolkit.Input.PointerBehavior"/>.</param>
 public static void SetGazePointerBehavior(PointerBehavior pointerBehavior)
 {
     if (CoreServices.InputSystem.FocusProvider is IPointerPreferences pointerPreferences)
     {
         pointerPreferences.GazePointerBehavior = pointerBehavior;
         foreach (InputSourceType sourceType in Enum.GetValues(typeof(InputSourceType)))
         {
             pointerPreferences.SetPointerBehavior <GGVPointer>(Handedness.Any, sourceType, pointerBehavior);
         }
     }
     else
     {
         WarnAboutSettingCustomPointerBehaviors();
     }
 }
Example #4
0
        /// <summary>
        /// Toggles a pointer's "enabled" behavior. If a pointer's <see cref="Microsoft.MixedReality.Toolkit.Input.PointerBehavior"/> is Default or AlwaysOn,
        /// set it to AlwaysOff. Otherwise, set the pointer's behavior to Default.
        /// Will set this state for all matching pointers.
        /// </summary>
        /// <typeparam name="T">Type of pointer to set</typeparam>
        /// <param name="inputType">Input type of pointer to set</param>
        public void TogglePointerEnabled <T>(InputSourceType inputType) where T : class, IMixedRealityPointer
        {
            PointerBehavior oldBehavior = PointerUtils.GetPointerBehavior <T>(Handedness.Any, inputType);
            PointerBehavior newBehavior;

            if (oldBehavior == PointerBehavior.AlwaysOff)
            {
                newBehavior = PointerBehavior.Default;
            }
            else
            {
                newBehavior = PointerBehavior.AlwaysOff;
            }
            PointerUtils.SetPointerBehavior <T>(newBehavior, inputType);
        }
        private void ApplyPointerBehavior(IMixedRealityPointer pointer, PointerBehavior behavior)
        {
            if (behavior == PointerBehavior.Default)
            {
                return;
            }

            bool isPointerOn = behavior == PointerBehavior.AlwaysOn;

            pointer.IsActive = isPointerOn;
            if (pointer is GenericPointer genericPtr)
            {
                genericPtr.IsInteractionEnabled = isPointerOn;
            }

            unassignedPointers.Remove(pointer);
        }
Example #6
0
 /// <summary>
 /// Sets the behavior for the poke pointer with given handedness.
 /// </summary>
 /// <param name="pointerBehavior">Desired <seealso cref="Microsoft.MixedReality.Toolkit.Input.PointerBehavior"/>.</param>
 /// <param name="handedness">Specify handedness to restrict to only right, left.</param>
 public static void SetHandPokePointerBehavior(PointerBehavior pointerBehavior, Handedness handedness = Handedness.Any)
 {
     SetPointerBehavior <PokePointer>(pointerBehavior, InputSourceType.Hand, handedness);
 }
Example #7
0
 /// <summary>
 /// Sets the behavior for the motion controller ray with given handedness
 /// </summary>
 /// <param name="pointerBehavior">Desired <seealso cref="Microsoft.MixedReality.Toolkit.Input.PointerBehavior"/>.</param>
 /// <param name="handedness">Specify handedness to restrict to only right, left.</param>
 public static void SetMotionControllerRayPointerBehavior(PointerBehavior pointerBehavior, Handedness handedness = Handedness.Any)
 {
     SetPointerBehavior <ShellHandRayPointer>(pointerBehavior, InputSourceType.Controller, handedness);
 }