Skip to content

Commit

Permalink
Expose pointermediators in focusprovider, make defaultpointermediator…
Browse files Browse the repository at this point in the history
… extensible
  • Loading branch information
julenka committed Jun 3, 2019
1 parent 1d4697d commit c2b6dc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
Expand Up @@ -7,14 +7,14 @@ namespace Microsoft.MixedReality.Toolkit.Input
{
public class DefaultPointerMediator : IMixedRealityPointerMediator
{
private readonly HashSet<IMixedRealityPointer> allPointers = new HashSet<IMixedRealityPointer>();
private readonly HashSet<IMixedRealityPointer> farInteractPointers = new HashSet<IMixedRealityPointer>();
private readonly HashSet<IMixedRealityNearPointer> nearInteractPointers = new HashSet<IMixedRealityNearPointer>();
private readonly HashSet<IMixedRealityTeleportPointer> teleportPointers = new HashSet<IMixedRealityTeleportPointer>();
private readonly HashSet<IMixedRealityPointer> unassignedPointers = new HashSet<IMixedRealityPointer>();
private readonly Dictionary<IMixedRealityInputSource, HashSet<IMixedRealityPointer>> pointerByInputSourceParent = new Dictionary<IMixedRealityInputSource, HashSet<IMixedRealityPointer>>();

public void RegisterPointers(IMixedRealityPointer[] pointers)
protected readonly HashSet<IMixedRealityPointer> allPointers = new HashSet<IMixedRealityPointer>();
protected readonly HashSet<IMixedRealityPointer> farInteractPointers = new HashSet<IMixedRealityPointer>();
protected readonly HashSet<IMixedRealityNearPointer> nearInteractPointers = new HashSet<IMixedRealityNearPointer>();
protected readonly HashSet<IMixedRealityTeleportPointer> teleportPointers = new HashSet<IMixedRealityTeleportPointer>();
protected readonly HashSet<IMixedRealityPointer> unassignedPointers = new HashSet<IMixedRealityPointer>();
protected readonly Dictionary<IMixedRealityInputSource, HashSet<IMixedRealityPointer>> pointerByInputSourceParent = new Dictionary<IMixedRealityInputSource, HashSet<IMixedRealityPointer>>();

public virtual void RegisterPointers(IMixedRealityPointer[] pointers)
{
for (int i = 0; i < pointers.Length; i++)
{
Expand Down Expand Up @@ -50,7 +50,7 @@ public void RegisterPointers(IMixedRealityPointer[] pointers)
}
}

public void UnregisterPointers(IMixedRealityPointer[] pointers)
public virtual void UnregisterPointers(IMixedRealityPointer[] pointers)
{
for (int i = 0; i < pointers.Length; i++)
{
Expand All @@ -68,7 +68,7 @@ public void UnregisterPointers(IMixedRealityPointer[] pointers)
}
}

public void UpdatePointers()
public virtual void UpdatePointers()
{
// If there's any teleportation going on, disable all pointers except the teleporter
foreach (IMixedRealityTeleportPointer pointer in teleportPointers)
Expand Down
12 changes: 10 additions & 2 deletions Assets/MixedRealityToolkit.Services/InputSystem/FocusProvider.cs
Expand Up @@ -32,6 +32,14 @@ public class FocusProvider : BaseDataProvider, IMixedRealityFocusProvider
private PointerHitResult hitResult3d = new PointerHitResult();
private PointerHitResult hitResultUi = new PointerHitResult();

public ref readonly Dictionary<uint, IMixedRealityPointerMediator> PointerMediators
{
get
{
return ref pointerMediators;
}
}

/// <summary>
/// Number of IMixedRealityNearPointers that are active (IsInteractionEnabled == true).
/// </summary>
Expand All @@ -42,7 +50,7 @@ public class FocusProvider : BaseDataProvider, IMixedRealityFocusProvider
/// are active (IsInteractionEnabled == true), excluding the gaze cursor
/// </summary>
public int NumFarPointersActive { get; private set; }

private IMixedRealityInputSystem inputSystem = null;

/// <summary>
Expand Down Expand Up @@ -848,7 +856,7 @@ PointerHitResult GetPrioritizedHitResult(PointerHitResult hit1, PointerHitResult

return (hit1.hitObject != null) ? hit1 : hit2;
}

/// <summary>
/// Disable inactive pointers to unclutter the way for active ones.
/// </summary>
Expand Down

0 comments on commit c2b6dc5

Please sign in to comment.