Skip to content

Commit

Permalink
Merge pull request #841 from StephenHodgson/HTK-Refactor
Browse files Browse the repository at this point in the history
fixed cross platform support from last refactor PR
  • Loading branch information
StephenHodgson authored Aug 12, 2017
2 parents 92f5429 + e5a9862 commit e58ff6b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Assets/HoloToolkit/Input/Scripts/HandGuidance.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEngine;

#if UNITY_WSA
using UnityEngine;
using UnityEngine.VR.WSA.Input;
#endif

Expand All @@ -14,6 +14,7 @@ namespace HoloToolkit.Unity.InputModule
/// </summary>
public class HandGuidance : Singleton<HandGuidance>
{
#if UNITY_WSA
[Tooltip("The Cursor object the HandGuidanceIndicator will be positioned around.")]
public GameObject Cursor;

Expand All @@ -31,7 +32,6 @@ public class HandGuidance : Singleton<HandGuidance>

private uint? currentlyTrackedHand = null;

#if UNITY_WSA
protected override void Awake()
{
base.Awake();
Expand Down
5 changes: 5 additions & 0 deletions Assets/HoloToolkit/Input/Scripts/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ public class InputManager : Singleton<InputManager>
private ManipulationEventData manipulationEventData;
private HoldEventData holdEventData;
private NavigationEventData navigationEventData;

#if UNITY_WSA || UNITY_STANDALONE_WIN
private SpeechKeywordRecognizedEventData speechKeywordRecognizedEventData;
private DictationEventData dictationEventData;
#endif

/// <summary>
/// Indicates if input is currently enabled or not.
Expand Down Expand Up @@ -184,8 +187,10 @@ private void InitializeEventDatas()
manipulationEventData = new ManipulationEventData(EventSystem.current);
navigationEventData = new NavigationEventData(EventSystem.current);
holdEventData = new HoldEventData(EventSystem.current);
#if UNITY_WSA || UNITY_STANDALONE_WIN
speechKeywordRecognizedEventData = new SpeechKeywordRecognizedEventData(EventSystem.current);
dictationEventData = new DictationEventData(EventSystem.current);
#endif
}

#region Unity Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Collections;
using System.Text;
using UnityEngine;

#if UNITY_WSA || UNITY_STANDALONE_WIN
using System.Text;
using UnityEngine.Windows.Speech;
#endif

Expand All @@ -17,6 +17,7 @@ namespace HoloToolkit.Unity.InputModule
/// </summary>
public class DictationInputManager : Singleton<DictationInputManager>, IInputSource
{
#if UNITY_WSA || UNITY_STANDALONE_WIN
/// <summary>
/// Caches the text currently being displayed in dictation display text.
/// </summary>
Expand Down Expand Up @@ -47,12 +48,12 @@ public class DictationInputManager : Singleton<DictationInputManager>, IInputSou
/// Audio clip of the last dictation session.
/// </summary>
private static AudioClip dictationAudioClip;
#if UNITY_WSA || UNITY_STANDALONE_WIN

private static DictationRecognizer dictationRecognizer;
#endif
private static bool isTransitioning;

private static bool hasFailed;
#endif

#region Unity Methods

Expand Down Expand Up @@ -187,6 +188,7 @@ public static IEnumerator StopRecording()
}

#region Dictation Recognizer Callbacks
#if UNITY_WSA || UNITY_STANDALONE_WIN

/// <summary>
/// This event is fired while the user is talking. As the recognizer listens, it provides text of what it's heard so far.
Expand All @@ -200,7 +202,6 @@ private static void DictationRecognizer_DictationHypothesis(string text)
InputManager.Instance.RaiseDictationHypothesis(Instance, 0, dictationResult);
}

#if UNITY_WSA || UNITY_STANDALONE_WIN
/// <summary>
/// This event is fired after the user pauses, typically at the end of a sentence. The full recognized string is returned here.
/// </summary>
Expand Down Expand Up @@ -234,7 +235,6 @@ private static void DictationRecognizer_DictationComplete(DictationCompletionCau
textSoFar = null;
dictationResult = string.Empty;
}
#endif

/// <summary>
/// This event is fired when an error occurs.
Expand All @@ -249,7 +249,7 @@ private static void DictationRecognizer_DictationError(string error, int hresult
textSoFar = null;
dictationResult = string.Empty;
}

#endif
#endregion // Dictation Recognizer Callbacks

#region IInputSource Implementation
Expand Down
2 changes: 1 addition & 1 deletion Assets/HoloToolkit/Input/Scripts/Voice/KeywordManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public enum RecognizerStartBehavior { AutoStart, ManualStart };
[Tooltip("An array of string keywords and UnityEvents, to be set in the Inspector.")]
public KeywordAndResponse[] KeywordsAndResponses;

private readonly Dictionary<string, UnityEvent> responses = new Dictionary<string, UnityEvent>();
#if UNITY_WSA || UNITY_STANDALONE_WIN
private readonly Dictionary<string, UnityEvent> responses = new Dictionary<string, UnityEvent>();
private KeywordRecognizer keywordRecognizer;

void Start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ public partial class RemoteMappingManager : Singleton<RemoteMappingManager>
/// Used for voice commands.
/// </summary>
private KeywordRecognizer keywordRecognizer;
#endif

/// <summary>
/// Collection of supported keywords and their associated actions.
/// </summary>
private Dictionary<string, System.Action> keywordCollection;
#endif

// Use this for initialization.
private void Start()
{
#if UNITY_WSA || UNITY_STANDALONE_WIN
// Create our keyword collection.
keywordCollection = new Dictionary<string, System.Action> { { SendMeshesKeyword, SendMeshes } };

#if UNITY_WSA || UNITY_STANDALONE_WIN
// Tell the KeywordRecognizer about our keywords.
keywordRecognizer = new KeywordRecognizer(keywordCollection.Keys.ToArray());
// Register a callback for the KeywordRecognizer and start recognizing.
Expand Down

0 comments on commit e58ff6b

Please sign in to comment.