Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move input subsystem implementations to the input package. #11641

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"source": "local",
"dependencies": {
"com.microsoft.mrtk.core": "3.0.0",
"com.microsoft.mrtk.input": "3.0.0",
"com.microsoft.mrtk.tts.windows": "1.0.1"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;

namespace Microsoft.MixedReality.Toolkit.Subsystems
Expand All @@ -20,7 +21,7 @@ namespace Microsoft.MixedReality.Toolkit.Subsystems
/// See <see cref="MRTKHandsAggregatorSubsystem"> for the MRTK implementation.
/// </remarks>
/// </summary>
public interface IHandsAggregatorSubsystem
public interface IHandsAggregatorSubsystem : ISubsystem
{
/// <summary>
/// The playspace-local pose of the near interaction point.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using UnityEngine;

namespace Microsoft.MixedReality.Toolkit.Subsystems
{
Expand All @@ -11,7 +12,7 @@ namespace Microsoft.MixedReality.Toolkit.Subsystems
/// MUST implement this interface, preferably with a direct 1:1 mapping
/// between the provider surface and the subsystem surface.
/// </summary>
public interface IDictationSubsystem
public interface IDictationSubsystem : ISubsystem
{
/// <summary>
/// Start dictation with default configurations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

namespace Microsoft.MixedReality.Toolkit.Subsystems
Expand All @@ -12,7 +13,7 @@ namespace Microsoft.MixedReality.Toolkit.Subsystems
/// MUST implement this interface, preferably with a direct 1:1 mapping
/// between the provider surface and the subsystem surface.
/// </summary>
public interface IKeywordRecognitionSubsystem
public interface IKeywordRecognitionSubsystem : ISubsystem
{
/// <summary>
/// Add or update a keyword to recognize.
Expand Down
2 changes: 1 addition & 1 deletion com.microsoft.mrtk.core/Utilities/HandsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class HandsUtils
/// The first running <see cref="HandsAggregatorSubsystem"/> instance, or null.
/// </returns>
[Obsolete("Deprecated, please use XRSubsystemHelpers.HandsAggregator")]
public static HandsAggregatorSubsystem GetSubsystem() => XRSubsystemHelpers.HandsAggregator;
public static IHandsAggregatorSubsystem GetSubsystem() => XRSubsystemHelpers.HandsAggregator;

internal static readonly HandFinger[] HandFingers = Enum.GetValues(typeof(HandFinger)) as HandFinger[];

Expand Down
18 changes: 9 additions & 9 deletions com.microsoft.mrtk.core/Utilities/XRSubsystemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,52 +152,52 @@ public static XRDisplaySubsystem DisplaySubsystem
}
}

private static HandsAggregatorSubsystem handsAggregator = null;
private static IHandsAggregatorSubsystem handsAggregator = null;

/// <summary>
/// The currently loaded and running hands aggregator, if any.
/// </summary>
public static HandsAggregatorSubsystem HandsAggregator
public static IHandsAggregatorSubsystem HandsAggregator
{
get
{
if (handsAggregator == null || !handsAggregator.running)
{
handsAggregator = GetFirstRunningSubsystem<HandsAggregatorSubsystem>();
handsAggregator = GetFirstRunningSubsystem<IHandsAggregatorSubsystem>();
}
return handsAggregator;
}
}

private static DictationSubsystem dictationSubsystem = null;
private static IDictationSubsystem dictationSubsystem = null;

/// <summary>
/// The currently loaded and running dictation subsystem, if any.
/// </summary>
public static DictationSubsystem DictationSubsystem
public static IDictationSubsystem DictationSubsystem
{
get
{
if (dictationSubsystem == null || !dictationSubsystem.running)
{
dictationSubsystem = GetFirstRunningSubsystem<DictationSubsystem>();
dictationSubsystem = GetFirstRunningSubsystem<IDictationSubsystem>();
}
return dictationSubsystem;
}
}

private static KeywordRecognitionSubsystem keywordRecognitionSubsystem = null;
private static IKeywordRecognitionSubsystem keywordRecognitionSubsystem = null;

/// <summary>
/// The currently loaded and running keyword recognition subsystem, if any.
/// </summary>
public static KeywordRecognitionSubsystem KeywordRecognitionSubsystem
public static IKeywordRecognitionSubsystem KeywordRecognitionSubsystem
{
get
{
if (keywordRecognitionSubsystem == null || !keywordRecognitionSubsystem.running)
{
keywordRecognitionSubsystem = GetFirstRunningSubsystem<KeywordRecognitionSubsystem>();
keywordRecognitionSubsystem = GetFirstRunningSubsystem<IKeywordRecognitionSubsystem>();
}
return keywordRecognitionSubsystem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ArticulatedHandController : ActionBasedController
#region Properties

[Obsolete("Deprecated, please use XRSubsystemHelpers.HandsAggregator instead.")]
protected HandsAggregatorSubsystem HandsAggregator => XRSubsystemHelpers.HandsAggregator;
protected HandsAggregatorSubsystem HandsAggregator => XRSubsystemHelpers.HandsAggregator as HandsAggregatorSubsystem;

#endregion Properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class MRTKRayInteractor :
/// Cached reference to hands aggregator for efficient per-frame use.
/// </summary>
[Obsolete("Deprecated, please use XRSubsystemHelpers.HandsAggregator instead.")]
protected HandsAggregatorSubsystem HandsAggregator => XRSubsystemHelpers.HandsAggregator;
protected HandsAggregatorSubsystem HandsAggregator => XRSubsystemHelpers.HandsAggregator as HandsAggregatorSubsystem;

/// <summary>
/// How unselected the interactor must be to initiate a new hover or selection on a new target.
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these classes make sense to move (apologies for being less certain before: I though you were referring to layer 3 but were actually referring to layer 2, below).

There are three defined parts to an MRTK subsystem:

  1. The interface, largely used to keep the API surface of the subsystems and providers consistent
    1. Lives in Core
  2. The base class, largely scaffolding code linking the subsystem to an abstract provider, following Unity's established patterns
    1. Previously lived in Core, moving to Input in this PR
  3. The actual implementation, largely implementing the abstract provider from 2
    1. Lives in the corresponding packages, like Input or Speech.Windows

1 and 2 should live in the Core, imo, because devs shouldn't need to write the scaffolding themselves or have to import the Input package just to get access to the scaffolding. There's almost no variation in this level, and any needed variation could/should live in the concrete implementation.

3 is where the actual interesting differences lie, and the only level devs should need to write themselves (if they don't want to use MRTK's impl).

The existence of the interface is slightly misleading. I don't believe Unity's pattern for subsystems typically defines explicit interface types, but we used it just to maintain an API consistency across subsystems and their providers.

File renamed without changes.
8 changes: 8 additions & 0 deletions com.microsoft.mrtk.input/Subsystems/Speech.meta

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 @@ -16,7 +16,7 @@ public abstract class HandBasedPoseSource : IPoseSource
/// Cached reference to hands aggregator for efficient per-frame use.
/// </summary>
[Obsolete("Deprecated, please use XRSubsystemHelpers.HandsAggregator instead.")]
protected HandsAggregatorSubsystem HandsAggregator => XRSubsystemHelpers.HandsAggregator;
protected HandsAggregatorSubsystem HandsAggregator => XRSubsystemHelpers.HandsAggregator as HandsAggregatorSubsystem;

[SerializeField]
[Tooltip("The hand on which to track the joint.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ControllerVisualizer : MonoBehaviour
/// Cached reference to hands aggregator for efficient per-frame use.
/// </summary>
[Obsolete("Deprecated, please use XRSubsystemHelpers.HandsAggregator instead.")]
protected HandsAggregatorSubsystem HandsAggregator => XRSubsystemHelpers.HandsAggregator;
protected HandsAggregatorSubsystem HandsAggregator => XRSubsystemHelpers.HandsAggregator as HandsAggregatorSubsystem;

[SerializeField]
[Tooltip("The input action we key into to determine whether this controller is tracked or not")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private set
/// <summary>
/// The keyword recognition subsystem that was stopped by this component.
/// </summary>
private KeywordRecognitionSubsystem keywordRecognitionSubsystem = null;
private IKeywordRecognitionSubsystem keywordRecognitionSubsystem = null;

/// <summary>
/// The inner text value set via the `Text` property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rootNamespace": "Microsoft.MixedReality.Toolkit.Speech.Windows",
"references": [
"Microsoft.MixedReality.Toolkit.Core",
"Microsoft.MixedReality.Toolkit.Input",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems weird. (I don't think we should move these base classes, but if they need to be moved) I'm not sure why the speech classes weren't moved into the speech package. That's where the concrete implementations already live.

"Microsoft.MixedReality.OpenXR",
"Microsoft.MixedReality.Toolkit.TextToSpeech.Windows"
],
Expand Down
1 change: 1 addition & 0 deletions com.microsoft.mrtk.windowsspeech/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"unity": "2021.3",
"dependencies": {
"com.microsoft.mrtk.core": "3.0.0",
"com.microsoft.mrtk.input": "3.0.0",
"com.microsoft.mrtk.tts.windows": "1.0.1"
}
}