mixedreality/com.microsoft.mixedreality..../Core/EventDatum/Input/BaseInputEventData.cs

52 lines
1.7 KiB
C#

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using UnityEngine.EventSystems;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Base class of all input events.
/// </summary>
public abstract class BaseInputEventData : BaseEventData
{
/// <summary>
/// The UTC time at which the event occurred.
/// </summary>
public DateTime EventTime { get; private set; }
/// <summary>
/// The source the input event originates from.
/// </summary>
public IMixedRealityInputSource InputSource { get; private set; }
/// <summary>
/// The id of the source the event is from, for instance the hand id.
/// </summary>
public uint SourceId => InputSource.SourceId;
/// <summary>
/// The input action for this event.
/// </summary>
public MixedRealityInputAction MixedRealityInputAction { get; private set; }
/// <summary>
/// Constructor.
/// </summary>
/// <param name="eventSystem">Typically will be <see href="https://docs.unity3d.com/ScriptReference/EventSystems.EventSystem-current.html">EventSystems.EventSystem.current</see></param>
protected BaseInputEventData(EventSystem eventSystem) : base(eventSystem) { }
/// <summary>
/// Used to initialize/reset the event and populate the data.
/// </summary>
protected void BaseInitialize(IMixedRealityInputSource inputSource, MixedRealityInputAction inputAction)
{
Reset();
EventTime = DateTime.UtcNow;
InputSource = inputSource;
MixedRealityInputAction = inputAction;
}
}
}