Skip to content

Commit 766245b

Browse files
author
David Kline (ANALOG)
committed
input system now gives instance of itself to gaze provider
1 parent d949e7a commit 766245b

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

Assets/MixedRealityToolkit.Services/InputSystem/FocusProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ public void OnSourceLost(SourceStateEventData eventData)
942942
if (gazeProviderPointingData != null && eventData.InputSource.Pointers[i].PointerId == gazeProviderPointingData.Pointer.PointerId)
943943
{
944944
// If the source lost is the gaze input source, then reset it.
945-
if (eventData.InputSource.SourceId == MixedRealityToolkit.InputSystem.GazeProvider.GazeInputSource.SourceId)
945+
if (eventData.InputSource.SourceId == ((IMixedRealityInputSystem)Service).GazeProvider.GazeInputSource.SourceId)
946946
{
947947
gazeProviderPointingData.ResetFocusedObjects();
948948
gazeProviderPointingData = null;

Assets/MixedRealityToolkit.Services/InputSystem/GazeProvider.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public bool Enabled
8383
set { enabled = value; }
8484
}
8585

86+
/// <inheritdoc />
87+
public IMixedRealityInputSystem InputSystem { private get; set; }
88+
8689
/// <inheritdoc />
8790
public IMixedRealityInputSource GazeInputSource
8891
{
@@ -249,7 +252,7 @@ public override bool TryGetPointerRotation(out Quaternion rotation)
249252
/// <param name="inputSource"></param>
250253
public void RaisePointerDown(MixedRealityInputAction mixedRealityInputAction, Handedness handedness = Handedness.None, IMixedRealityInputSource inputSource = null)
251254
{
252-
MixedRealityToolkit.InputSystem.RaisePointerDown(this, mixedRealityInputAction, handedness, inputSource);
255+
gazeProvider.InputSystem?.RaisePointerDown(this, mixedRealityInputAction, handedness, inputSource);
253256
}
254257

255258
/// <summary>
@@ -260,8 +263,8 @@ public void RaisePointerDown(MixedRealityInputAction mixedRealityInputAction, Ha
260263
/// <param name="inputSource"></param>
261264
public void RaisePointerUp(MixedRealityInputAction mixedRealityInputAction, Handedness handedness = Handedness.None, IMixedRealityInputSource inputSource = null)
262265
{
263-
MixedRealityToolkit.InputSystem.RaisePointerClicked(this, mixedRealityInputAction, 0, handedness, inputSource);
264-
MixedRealityToolkit.InputSystem.RaisePointerUp(this, mixedRealityInputAction, handedness, inputSource);
266+
gazeProvider.InputSystem?.RaisePointerClicked(this, mixedRealityInputAction, 0, handedness, inputSource);
267+
gazeProvider.InputSystem?.RaisePointerUp(this, mixedRealityInputAction, handedness, inputSource);
265268
}
266269
}
267270

@@ -355,7 +358,7 @@ protected override void OnDisable()
355358
{
356359
base.OnDisable();
357360
GazePointer.BaseCursor?.SetVisibility(false);
358-
MixedRealityToolkit.InputSystem?.RaiseSourceLost(GazeInputSource);
361+
InputSystem?.RaiseSourceLost(GazeInputSource);
359362
}
360363

361364
#endregion MonoBehaviour Implementation
@@ -407,12 +410,11 @@ private IMixedRealityPointer InitializeGazePointer()
407410

408411
gazePointer = new InternalGazePointer(this, "Gaze Pointer", null, raycastLayerMasks, maxGazeCollisionDistance, gazeTransform, stabilizer);
409412

410-
if (GazeCursor == null &&
411-
MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile != null &&
412-
MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.PointerProfile != null &&
413-
MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.PointerProfile.GazeCursorPrefab != null)
413+
if ((GazeCursor == null) &&
414+
(GazeCursorPrefab != null))
414415
{
415-
var cursor = Instantiate(GazeCursorPrefab, MixedRealityToolkit.Instance.MixedRealityPlayspace);
416+
// todo: update....
417+
GameObject cursor = Instantiate(GazeCursorPrefab, MixedRealityToolkit.Instance.MixedRealityPlayspace);
416418
SetGazeCursor(cursor);
417419
}
418420

@@ -422,7 +424,7 @@ private IMixedRealityPointer InitializeGazePointer()
422424
private async void RaiseSourceDetected()
423425
{
424426
await WaitUntilInputSystemValid;
425-
MixedRealityToolkit.InputSystem.RaiseSourceDetected(GazeInputSource);
427+
InputSystem?.RaiseSourceDetected(GazeInputSource);
426428
GazePointer.BaseCursor?.SetVisibility(true);
427429
}
428430

Assets/MixedRealityToolkit.Services/InputSystem/MixedRealityInputSystem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public override void Initialize()
154154
if (profile.PointerProfile.GazeProviderType?.Type != null)
155155
{
156156
GazeProvider = CameraCache.Main.gameObject.EnsureComponent(profile.PointerProfile.GazeProviderType.Type) as IMixedRealityGazeProvider;
157+
GazeProvider.InputSystem = this;
157158
GazeProvider.GazeCursorPrefab = profile.PointerProfile.GazeCursorPrefab;
158159
}
159160
else

Assets/MixedRealityToolkit/Interfaces/InputSystem/IMixedRealityGazeProvider.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public interface IMixedRealityGazeProvider
1515
/// </summary>
1616
bool Enabled { get; set; }
1717

18+
/// <summary>
19+
/// The <see cref="IMixedRealtyInputSystem"/> instance for which this object is providing gaze data.
20+
/// </summary>
21+
IMixedRealityInputSystem InputSystem { set; }
22+
1823
/// <summary>
1924
/// The Gaze Input Source for the provider.
2025
/// </summary>
@@ -26,7 +31,7 @@ public interface IMixedRealityGazeProvider
2631
IMixedRealityPointer GazePointer { get; }
2732

2833
/// <summary>
29-
///
34+
/// The prefab to be instantiated as the gaze cursor.
3035
/// </summary>
3136
GameObject GazeCursorPrefab { get; set; }
3237

0 commit comments

Comments
 (0)