Skip to content

Commit

Permalink
More refactoring of Input Events (#2112)
Browse files Browse the repository at this point in the history
* some cleanup

* review changes

* Fixed editor/runtime logic

* Tested and updated for 2018.1.0f1 against IL2CPP
Resolved build errors and warnings

* Removed #IF UNITY_EDITOR for now.  Will need reviewing for build later.

* Fixed Building against editor asmdef.
Cleaned up build warnings in Controller Pointer Options

* Cleaned up MixedRealityManager a bit more

* Fixed Standalone Compilation.
Added EnforceEditorSettings script and custom assembly definition.

* Removed duplicate assembly definition for Input System Editor

* Reverted some project settings

* Changed assembly namespaces

* Some finishing touches on the Settings Enforcer

* updated inspector custom assembly namespace

* for real this time

* Let's just change all the namespaces!

* renamed a file

* Broke the circular references to the Input System in Core.

* Fixed custom assembly references.
Reverted tests changes.

* Profile instantiation of managers. (#11)

* testing out instantiation

* refactoring

* More work on some stuff

* reverted some changes

* CR edits

* more cleanup.
Added fingers and thumb to input types

* More input system cleanup.
Removed Tags.
Added clearer useage of 2DoF, 3DoF, and 6DoF input events.
More documentation.

* Cleaned up some stuff from merge

* removed another straggler

* reverted file

* Review pass comments
  • Loading branch information
StephenHodgson authored May 17, 2018
1 parent 822d72d commit 7c8b445
Show file tree
Hide file tree
Showing 35 changed files with 1,060 additions and 630 deletions.
10 changes: 3 additions & 7 deletions Assets/MixedRealityToolkit/InputSystem/Cursors/BaseCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ public virtual void OnSourceLost(SourceStateEventData eventData)
}
}

public virtual void OnSourcePositionChanged(SourcePositionEventData eventData) { }

public virtual void OnSourceRotationChanged(SourceRotationEventData eventData) { }

#endregion IMixedRealitySourceStateHandler Implementation

#region IMixedRealityFocusChangedHandler Implementation
Expand All @@ -200,7 +196,7 @@ public virtual void OnFocusChanged(FocusEventData eventData) { }
/// Function for receiving OnPointerDown events from InputManager
/// </summary>
/// <param name="eventData"></param>
public virtual void OnPointerDown(ClickEventData eventData)
public virtual void OnPointerDown(InputClickEventData eventData)
{
foreach (var sourcePointer in eventData.InputSource.Pointers)
{
Expand All @@ -215,13 +211,13 @@ public virtual void OnPointerDown(ClickEventData eventData)
/// Function for receiving OnPointerClicked events from InputManager
/// </summary>
/// <param name="eventData"></param>
public virtual void OnPointerClicked(ClickEventData eventData) { }
public virtual void OnPointerClicked(InputClickEventData eventData) { }

/// <summary>
/// Function for receiving OnPointerUp events from InputManager
/// </summary>
/// <param name="eventData"></param>
public virtual void OnPointerUp(ClickEventData eventData)
public virtual void OnPointerUp(InputClickEventData eventData)
{
foreach (var sourcePointer in eventData.InputSource.Pointers)
{
Expand Down
4 changes: 0 additions & 4 deletions Assets/MixedRealityToolkit/InputSystem/Focus/FocusProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,6 @@ public void OnSourceLost(SourceStateEventData eventData)
}
}

public void OnSourcePositionChanged(SourcePositionEventData eventData) { }

public void OnSourceRotationChanged(SourceRotationEventData eventData) { }

#endregion ISourceState Implementation
}
}
506 changes: 287 additions & 219 deletions Assets/MixedRealityToolkit/InputSystem/MixedRealityInputManager.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public virtual void OnInputPressed(InputPressedEventData eventData) { }
/// <summary>
/// Updates target point orientation via thumbstick
/// </summary>
public virtual void OnDualAxisInputChanged(DualAxisInputEventData eventData) { }
public virtual void On2DoFInputChanged(TwoDoFInputEventData eventData) { }

#endregion IMixedRealityInputHandler Implementation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ public void Reset()
ThumbstickPositionUpdated = false;
TouchpadPositionUpdated = false;
TouchpadTouchedUpdated = false;
PositionUpdated = false;
RotationUpdated = false;
PointerPositionUpdated = false;
PointerRotationUpdated = false;
GripPositionUpdated = false;
GripRotationUpdated = false;
SelectPressedAmountUpdated = false;
}

Expand All @@ -125,8 +127,10 @@ public void Reset()
public bool ThumbstickPositionUpdated;
public bool TouchpadPositionUpdated;
public bool TouchpadTouchedUpdated;
public bool PositionUpdated;
public bool RotationUpdated;
public bool PointerPositionUpdated;
public bool PointerRotationUpdated;
public bool GripPositionUpdated;
public bool GripRotationUpdated;
public bool SelectPressedAmountUpdated;

public override bool TryGetPointerPosition(IMixedRealityPointer pointer, out Vector3 position)
Expand Down Expand Up @@ -815,9 +819,14 @@ private static void UpdateInteractionSource(InteractionSourceState interactionSo
newGripPosition = CameraCache.Main.transform.parent.TransformPoint(newGripPosition);
}

if (sourceData.PointerPosition.IsAvailable || sourceData.GripPosition.IsAvailable)
if (sourceData.PointerPosition.IsAvailable)
{
sourceData.PositionUpdated = sourceData.PointerPosition.CurrentReading != newPointerPosition || sourceData.GripPosition.CurrentReading != newGripPosition;
sourceData.PointerPositionUpdated = sourceData.PointerPosition.CurrentReading != newPointerPosition;
}

if (sourceData.GripPosition.IsAvailable)
{
sourceData.GripPositionUpdated = sourceData.GripPosition.CurrentReading != newGripPosition;
}

sourceData.PointerPosition.CurrentReading = newPointerPosition;
Expand All @@ -839,9 +848,14 @@ private static void UpdateInteractionSource(InteractionSourceState interactionSo
newGripRotation.eulerAngles = CameraCache.Main.transform.parent.TransformDirection(newGripRotation.eulerAngles);
}

if (sourceData.PointerRotation.IsAvailable || sourceData.GripRotation.IsAvailable)
if (sourceData.PointerRotation.IsAvailable)
{
sourceData.PointerRotationUpdated = sourceData.PointerRotation.CurrentReading != newPointerRotation;
}

else if (sourceData.GripRotation.IsAvailable)
{
sourceData.RotationUpdated = sourceData.PointerRotation.CurrentReading != newPointerRotation || sourceData.GripRotation.CurrentReading != newGripRotation;
sourceData.GripRotationUpdated = sourceData.GripRotation.CurrentReading != newGripRotation;
}

sourceData.PointerRotation.CurrentReading = newPointerRotation;
Expand Down Expand Up @@ -955,24 +969,34 @@ private void InteractionManager_InteractionSourceUpdated(InteractionSourceUpdate

UpdateInteractionSource(args.state, inputSource);

if (inputSource.PositionUpdated)
if (inputSource.PointerPositionUpdated)
{
inputSystem.Raise3DoFInputChanged(inputSource, (Handedness)args.state.source.handedness, InputType.PointerPosition, inputSource.PointerPosition.CurrentReading);
}

if (inputSource.GripPositionUpdated)
{
inputSystem.Raise3DoFInputChanged(inputSource, (Handedness)args.state.source.handedness, InputType.GripPosition, inputSource.GripPosition.CurrentReading);
}

if (inputSource.PointerRotationUpdated)
{
inputSystem.RaiseSourcePositionChanged(inputSource, (Handedness)args.state.source.handedness, inputSource.PointerPosition.CurrentReading, inputSource.GripPosition.CurrentReading);
inputSystem.Raise3DoFInputChanged(inputSource, (Handedness)args.state.source.handedness, InputType.PointerRotation, inputSource.PointerRotation.CurrentReading);
}

if (inputSource.RotationUpdated)
if (inputSource.GripRotationUpdated)
{
inputSystem.RaiseSourceRotationChanged(inputSource, (Handedness)args.state.source.handedness, inputSource.PointerRotation.CurrentReading, inputSource.GripRotation.CurrentReading);
inputSystem.Raise3DoFInputChanged(inputSource, (Handedness)args.state.source.handedness, InputType.GripRotation, inputSource.GripRotation.CurrentReading);
}

if (inputSource.ThumbstickPositionUpdated)
{
inputSystem.RaiseDualAxisInputChanged(inputSource, (Handedness)args.state.source.handedness, InputType.ThumbStick, inputSource.Thumbstick.CurrentReading.Position);
inputSystem.Raise2DoFInputChanged(inputSource, (Handedness)args.state.source.handedness, InputType.ThumbStick, inputSource.Thumbstick.CurrentReading.Position);
}

if (inputSource.TouchpadPositionUpdated)
{
inputSystem.RaiseDualAxisInputChanged(inputSource, (Handedness)args.state.source.handedness, InputType.Touchpad, inputSource.Touchpad.CurrentReading.AxisButton.Position);
inputSystem.Raise2DoFInputChanged(inputSource, (Handedness)args.state.source.handedness, InputType.Touchpad, inputSource.Touchpad.CurrentReading.AxisButton.Position);
}

if (inputSource.TouchpadTouchedUpdated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void IMixedRealityInputHandler.OnInputDown(InputEventData eventData)

void IMixedRealityInputHandler.OnInputPressed(InputPressedEventData eventData) { }

void IMixedRealityInputHandler.OnDualAxisInputChanged(DualAxisInputEventData eventData) { }
void IMixedRealityInputHandler.On2DoFInputChanged(TwoDoFInputEventData eventData) { }

void IMixedRealitySourceStateHandler.OnSourceDetected(SourceStateEventData eventData) { }

Expand All @@ -399,9 +399,5 @@ void IMixedRealitySourceStateHandler.OnSourceLost(SourceStateEventData eventData
StopDragging();
}
}

void IMixedRealitySourceStateHandler.OnSourcePositionChanged(SourcePositionEventData eventData) { }

void IMixedRealitySourceStateHandler.OnSourceRotationChanged(SourceRotationEventData eventData) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#if !UNITY_EDITOR
using Windows.Foundation;
using Windows.Storage.Streams;

using Microsoft.MixedReality.Toolkit.Internal.Extensions;
#endif
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ public abstract class BaseInputEventData : BaseEventData
/// </summary>
public uint SourceId { get; private set; }

/// <summary>
/// An optional, input-source-dependent object to be associated with this event.
/// </summary>
public object[] Tags { get; private set; }

/// <summary>
/// Constructor.
/// </summary>
Expand All @@ -36,13 +31,11 @@ public BaseInputEventData(EventSystem eventSystem) : base(eventSystem) { }
/// Used to initialize/reset the event and populate the data.
/// </summary>
/// <param name="inputSource"></param>
/// <param name="tags"></param>
protected void BaseInitialize(IMixedRealityInputSource inputSource, object[] tags)
protected void BaseInitialize(IMixedRealityInputSource inputSource)
{
Reset();
InputSource = inputSource;
SourceId = InputSource.SourceId;
Tags = tags;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ public DictationEventData(UnityEngine.EventSystems.EventSystem eventSystem) : ba
/// <param name="inputSource"></param>
/// <param name="dictationResult"></param>
/// <param name="dictationAudioClip"></param>
/// <param name="tags"></param>
public void Initialize(IMixedRealityInputSource inputSource, string dictationResult, AudioClip dictationAudioClip = null, object[] tags = null)
public void Initialize(IMixedRealityInputSource inputSource, string dictationResult, AudioClip dictationAudioClip = null)
{
BaseInitialize(inputSource, tags);
BaseInitialize(inputSource);
DictationResult = dictationResult;
DictationAudioClip = dictationAudioClip;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@ namespace Microsoft.MixedReality.Toolkit.Internal.EventDatum.Input
/// <summary>
/// Describes an Input Event that involves a tap, click, or touch.
/// </summary>
public class ClickEventData : InputEventData
public class InputClickEventData : InputEventData
{
/// <summary>
/// Number of Clicks, Taps, or Presses that triggered the event.
/// </summary>
public int Count { get; private set; }

/// <inheritdoc />
public ClickEventData(EventSystem eventSystem) : base(eventSystem) { }
public InputClickEventData(EventSystem eventSystem) : base(eventSystem) { }

/// <summary>
/// Used to initialize/reset the event and populate the data.
/// </summary>
/// <param name="inputSource"></param>
/// <param name="count"></param>
/// <param name="tags"></param>
public void Initialize(IMixedRealityInputSource inputSource, int count, object[] tags = null)
public void Initialize(IMixedRealityInputSource inputSource, int count)
{
BaseInitialize(inputSource, tags);
BaseInitialize(inputSource);
Count = count;
}

Expand All @@ -38,10 +37,9 @@ public void Initialize(IMixedRealityInputSource inputSource, int count, object[]
/// <param name="inputSource"></param>
/// <param name="count"></param>
/// <param name="handedness"></param>
/// <param name="tags"></param>
public void Initialize(IMixedRealityInputSource inputSource, int count, Handedness handedness, object[] tags = null)
public void Initialize(IMixedRealityInputSource inputSource, int count, Handedness handedness)
{
Initialize(inputSource, handedness, tags);
Initialize(inputSource, handedness);
Count = count;
}

Expand All @@ -52,10 +50,9 @@ public void Initialize(IMixedRealityInputSource inputSource, int count, Handedne
/// <param name="count"></param>
/// <param name="inputType"></param>
/// <param name="handedness"></param>
/// <param name="tags"></param>
public void Initialize(IMixedRealityInputSource inputSource, int count, InputType inputType, Handedness handedness, object[] tags = null)
public void Initialize(IMixedRealityInputSource inputSource, int count, InputType inputType, Handedness handedness)
{
Initialize(inputSource, handedness, inputType, tags);
Initialize(inputSource, handedness, inputType);
Count = count;
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7c8b445

Please sign in to comment.