Skip to content

Commit 16d44e7

Browse files
author
Robert El-Soudani
committed
Add xml comments and IInputSourceInfoProvider
1 parent cd7caf6 commit 16d44e7

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

Assets/HoloToolkit/Input/Scripts/Focus/InputSourcePointer.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,12 @@ public bool OwnsInput(BaseEventData eventData)
6565

6666
public bool InputIsFromSource(BaseEventData eventData)
6767
{
68-
var inputData = (eventData as BaseInputEventData);
68+
var inputData = (eventData as IInputSourceInfoProvider);
6969

70-
if (inputData != null)
71-
{
72-
return (inputData.InputSource == InputSource) && (inputData.SourceId == InputSourceId);
73-
}
74-
75-
var pointerInputEventData = (eventData as PointerInputEventData);
76-
77-
if (pointerInputEventData != null)
78-
{
79-
return (pointerInputEventData.InputSource == InputSource) && (pointerInputEventData.InputSourceId == InputSourceId);
80-
}
81-
82-
return false;
70+
return (inputData != null)
71+
&& (inputData.InputSource == InputSource)
72+
&& (inputData.SourceId == InputSourceId)
73+
;
8374
}
8475
}
8576
}

Assets/HoloToolkit/Input/Scripts/InputEventData/BaseInputEventData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace HoloToolkit.Unity.InputModule
88
/// <summary>
99
/// Base class of all input events.
1010
/// </summary>
11-
public abstract class BaseInputEventData : BaseEventData
11+
public abstract class BaseInputEventData : BaseEventData, IInputSourceInfoProvider
1212
{
1313
/// <summary>
1414
/// The source the input event originates from.

Assets/HoloToolkit/Input/Scripts/InputEventData/PointerInputEventData.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
using HoloToolkit.Unity.InputModule;
54
using UnityEngine.EventSystems;
65

76
namespace HoloToolkit.Unity.InputModule
87
{
9-
public class PointerInputEventData : PointerEventData
8+
/// <summary>
9+
/// Describes a Unity pointer event that was generated by a specific input source and ID.
10+
/// </summary>
11+
public class PointerInputEventData :
12+
PointerEventData,
13+
IInputSourceInfoProvider
1014
{
1115
public IInputSource InputSource { get; set; }
1216

13-
public uint InputSourceId { get; set; }
17+
public uint SourceId { get; set; }
1418

1519
public PointerInputEventData(EventSystem eventSystem) : base(eventSystem)
1620
{

Assets/HoloToolkit/Input/Scripts/Utilities/InputSourceInfo.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using System;
5+
46
namespace HoloToolkit.Unity.InputModule
57
{
68
/// <summary>
79
/// InputSourceInfo gives you the input source like hands or motion controller.
810
/// It will also report the source id for that source.
911
/// </summary>
10-
public struct InputSourceInfo
12+
public struct InputSourceInfo :
13+
IInputSourceInfoProvider
1114
{
1215
public IInputSource InputSource;
1316
public uint SourceId;
@@ -19,9 +22,34 @@ public InputSourceInfo(IInputSource inputSource, uint sourceId) :
1922
SourceId = sourceId;
2023
}
2124

25+
IInputSource IInputSourceInfoProvider.InputSource
26+
{
27+
get { return InputSource; }
28+
}
29+
30+
uint IInputSourceInfoProvider.SourceId
31+
{
32+
get { return SourceId; }
33+
}
34+
35+
public bool Matches(IInputSourceInfoProvider other)
36+
{
37+
return ((other != null) && Matches(other.InputSource, other.SourceId));
38+
}
39+
2240
public bool Matches(IInputSource otherInputSource, uint otherSourceId)
2341
{
2442
return ((InputSource == otherInputSource) && (SourceId == otherSourceId));
2543
}
2644
}
45+
46+
/// <summary>
47+
/// IInputSourceInfoProvider gives you the input source like hands or motion controller.
48+
/// It will also report the source id for that source.
49+
/// </summary>
50+
public interface IInputSourceInfoProvider
51+
{
52+
IInputSource InputSource { get; }
53+
uint SourceId { get; }
54+
}
2755
}

Assets/HoloToolkit/Utilities/Scripts/HashCodes.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
namespace HoloToolkit.Unity
55
{
6+
/// <summary>
7+
/// Provides helper methods for combining hash codes of many properties or objects into an
8+
/// aggregated hash code.
9+
/// </summary>
610
public static class HashCodes
711
{
812
public static int Combine(int first, int second)

0 commit comments

Comments
 (0)