Skip to content

Commit 2631b94

Browse files
author
David Kline
authored
Merge pull request #2687 from StephenHodgson/vNEXT-TouchScreenInputSourceUpdate
Refactored Touch Screen Input Source to Device Manager
2 parents 3d22587 + 4a83f37 commit 2631b94

35 files changed

+1095
-463
lines changed

Assets/MixedRealityToolkit-SDK/Features/Input/MixedRealityInputManager.cs

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ public class MixedRealityInputManager : MixedRealityEventManager, IMixedRealityI
7070
private SpeechEventData speechEventData;
7171
private DictationEventData dictationEventData;
7272

73-
/// <summary>
74-
/// Current Touch Screen Input Source.
75-
/// </summary>
76-
public TouchscreenInputSource TouchscreenInputSource { get; private set; }
77-
7873
#region IMixedRealityManager Implementation
7974

8075
/// <summary>
@@ -194,11 +189,6 @@ private void InitializeInternal()
194189

195190
speechEventData = new SpeechEventData(EventSystem.current);
196191
dictationEventData = new DictationEventData(EventSystem.current);
197-
198-
if (MixedRealityManager.Instance.ActiveProfile.InputSystemProfile.IsTouchScreenInputEnabled)
199-
{
200-
TouchscreenInputSource = new TouchscreenInputSource();
201-
}
202192
}
203193

204194
/// <inheritdoc />
@@ -257,7 +247,6 @@ public override void Destroy()
257247
UnityEngine.Object.Destroy(gazeProvider);
258248
}
259249

260-
TouchscreenInputSource?.Dispose();
261250
base.Destroy();
262251
}
263252

@@ -1168,6 +1157,20 @@ public void RaiseGestureUpdated(IMixedRealityController controller, MixedReality
11681157
HandleEvent(inputEventData, OnGestureUpdated);
11691158
}
11701159

1160+
private static readonly ExecuteEvents.EventFunction<IMixedRealityGestureHandler<Vector2>> OnGestureVector2PositionUpdated =
1161+
delegate (IMixedRealityGestureHandler<Vector2> handler, BaseEventData eventData)
1162+
{
1163+
var casted = ExecuteEvents.ValidateEventData<InputEventData<Vector2>>(eventData);
1164+
handler.OnGestureUpdated(casted);
1165+
};
1166+
1167+
/// <inheritdoc />
1168+
public void RaiseGestureUpdated(IMixedRealityController controller, MixedRealityInputAction action, Vector2 inputData)
1169+
{
1170+
vector2InputEventData.Initialize(controller.InputSource, controller.ControllerHandedness, action, inputData);
1171+
HandleEvent(vector2InputEventData, OnGestureVector2PositionUpdated);
1172+
}
1173+
11711174
private static readonly ExecuteEvents.EventFunction<IMixedRealityGestureHandler<Vector3>> OnGesturePositionUpdated =
11721175
delegate (IMixedRealityGestureHandler<Vector3> handler, BaseEventData eventData)
11731176
{
@@ -1224,6 +1227,20 @@ public void RaiseGestureCompleted(IMixedRealityController controller, MixedReali
12241227
HandleEvent(inputEventData, OnGestureCompleted);
12251228
}
12261229

1230+
private static readonly ExecuteEvents.EventFunction<IMixedRealityGestureHandler<Vector2>> OnGestureVector2PositionCompleted =
1231+
delegate (IMixedRealityGestureHandler<Vector2> handler, BaseEventData eventData)
1232+
{
1233+
var casted = ExecuteEvents.ValidateEventData<InputEventData<Vector2>>(eventData);
1234+
handler.OnGestureCompleted(casted);
1235+
};
1236+
1237+
/// <inheritdoc />
1238+
public void RaiseGestureCompleted(IMixedRealityController controller, MixedRealityInputAction action, Vector2 inputData)
1239+
{
1240+
vector2InputEventData.Initialize(controller.InputSource, controller.ControllerHandedness, action, inputData);
1241+
HandleEvent(vector2InputEventData, OnGestureVector2PositionCompleted);
1242+
}
1243+
12271244
private static readonly ExecuteEvents.EventFunction<IMixedRealityGestureHandler<Vector3>> OnGesturePositionCompleted =
12281245
delegate (IMixedRealityGestureHandler<Vector3> handler, BaseEventData eventData)
12291246
{
@@ -1266,11 +1283,18 @@ public void RaiseGestureCompleted(IMixedRealityController controller, MixedReali
12661283
HandleEvent(inputEventData, OnGesturePoseCompleted);
12671284
}
12681285

1286+
private static readonly ExecuteEvents.EventFunction<IMixedRealityGestureHandler> OnGestureCanceled =
1287+
delegate (IMixedRealityGestureHandler handler, BaseEventData eventData)
1288+
{
1289+
var casted = ExecuteEvents.ValidateEventData<InputEventData>(eventData);
1290+
handler.OnGestureCanceled(casted);
1291+
};
1292+
12691293
/// <inheritdoc />
12701294
public void RaiseGestureCanceled(IMixedRealityController controller, MixedRealityInputAction action)
12711295
{
12721296
inputEventData.Initialize(controller.InputSource, controller.ControllerHandedness, action);
1273-
HandleEvent(inputEventData, OnGesturePositionUpdated);
1297+
HandleEvent(inputEventData, OnGestureCanceled);
12741298
}
12751299

12761300
#endregion Gesture Events

0 commit comments

Comments
 (0)