Skip to content

Commit 09cba44

Browse files
Renamed input pressed to float input changed and raise only on changes to inputs.
1 parent 39daa05 commit 09cba44

File tree

6 files changed

+48
-108
lines changed

6 files changed

+48
-108
lines changed

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/WindowsMixedRealityController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ protected void UpdateTriggerData(InteractionSourceState interactionSourceState,
463463
if (interactionMapping.Changed)
464464
{
465465
// Raise input system Event if it enabled
466-
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionSourceState.selectPressedAmount);
466+
MixedRealityToolkit.InputSystem?.RaiseFloatInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionSourceState.selectPressedAmount);
467467
}
468468
break;
469469
}

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Receivers/InteractionReceiver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void IMixedRealityInputHandler<float>.OnInputChanged(InputEventData<float> event
207207
{
208208
if (IsInteractable(eventData.selectedObject))
209209
{
210-
InputPressed(eventData.selectedObject, eventData);
210+
FloatInputChanged(eventData.selectedObject, eventData);
211211
}
212212
}
213213

@@ -381,11 +381,11 @@ protected virtual void InputDown(GameObject targetObject, InputEventData eventDa
381381
protected virtual void InputUp(GameObject targetObject, InputEventData eventData) { }
382382

383383
/// <summary>
384-
/// Raised when the target interactable object receives an input pressed event.
384+
/// Raised when the target interactable object receives a float input changed event.
385385
/// </summary>
386386
/// <param name="targetObject"></param>
387387
/// <param name="eventData"></param>
388-
protected virtual void InputPressed(GameObject targetObject, InputEventData<float> eventData) { }
388+
protected virtual void FloatInputChanged(GameObject targetObject, InputEventData<float> eventData) { }
389389

390390
/// <summary>
391391
/// Raised when the target interactable object receives an input changed event.

Assets/MixedRealityToolkit.Services/InputSystem/MixedRealityInputSystem.cs

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -989,99 +989,75 @@ public void RaiseOnInputDown(IMixedRealityInputSource source, Handedness handedn
989989

990990
#endregion Input Down
991991

992-
#region Input Pressed
992+
#region Input Up
993993

994-
private static readonly ExecuteEvents.EventFunction<IMixedRealityInputHandler<float>> OnInputPressedEventHandler =
995-
delegate (IMixedRealityInputHandler<float> handler, BaseEventData eventData)
994+
private static readonly ExecuteEvents.EventFunction<IMixedRealityInputHandler> OnInputUpEventHandler =
995+
delegate (IMixedRealityInputHandler handler, BaseEventData eventData)
996996
{
997-
var casted = ExecuteEvents.ValidateEventData<InputEventData<float>>(eventData);
998-
handler.OnInputChanged(casted);
997+
var casted = ExecuteEvents.ValidateEventData<InputEventData>(eventData);
998+
handler.OnInputUp(casted);
999999
};
10001000

10011001
/// <inheritdoc />
1002-
public void RaiseOnInputPressed(IMixedRealityInputSource source, MixedRealityInputAction inputAction)
1003-
{
1004-
inputAction = ProcessRules(inputAction, true);
1005-
1006-
// Create input event
1007-
floatInputEventData.Initialize(source, inputAction);
1008-
1009-
// Pass handler through HandleEvent to perform modal/fallback logic
1010-
HandleEvent(floatInputEventData, OnInputPressedEventHandler);
1011-
}
1012-
1013-
/// <inheritdoc />
1014-
public void RaiseOnInputPressed(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction)
1015-
{
1016-
inputAction = ProcessRules(inputAction, true);
1017-
1018-
// Create input event
1019-
floatInputEventData.Initialize(source, handedness, inputAction);
1020-
1021-
// Pass handler through HandleEvent to perform modal/fallback logic
1022-
HandleEvent(floatInputEventData, OnInputPressedEventHandler);
1023-
}
1024-
1025-
/// <inheritdoc />
1026-
public void RaiseOnInputPressed(IMixedRealityInputSource source, MixedRealityInputAction inputAction, float pressAmount)
1002+
public void RaiseOnInputUp(IMixedRealityInputSource source, MixedRealityInputAction inputAction)
10271003
{
1028-
inputAction = ProcessRules(inputAction, pressAmount);
1004+
inputAction = ProcessRules(inputAction, false);
10291005

10301006
// Create input event
1031-
floatInputEventData.Initialize(source, inputAction, pressAmount);
1007+
inputEventData.Initialize(source, inputAction);
10321008

10331009
// Pass handler through HandleEvent to perform modal/fallback logic
1034-
HandleEvent(floatInputEventData, OnInputPressedEventHandler);
1010+
HandleEvent(inputEventData, OnInputUpEventHandler);
10351011
}
10361012

10371013
/// <inheritdoc />
1038-
public void RaiseOnInputPressed(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction, float pressAmount)
1014+
public void RaiseOnInputUp(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction)
10391015
{
1040-
inputAction = ProcessRules(inputAction, pressAmount);
1016+
inputAction = ProcessRules(inputAction, false);
10411017

10421018
// Create input event
1043-
floatInputEventData.Initialize(source, handedness, inputAction, pressAmount);
1019+
inputEventData.Initialize(source, handedness, inputAction);
10441020

10451021
// Pass handler through HandleEvent to perform modal/fallback logic
1046-
HandleEvent(floatInputEventData, OnInputPressedEventHandler);
1022+
HandleEvent(inputEventData, OnInputUpEventHandler);
10471023
}
10481024

1049-
#endregion Input Pressed
1025+
#endregion Input Up
10501026

1051-
#region Input Up
1027+
#region Float Input Changed
10521028

1053-
private static readonly ExecuteEvents.EventFunction<IMixedRealityInputHandler> OnInputUpEventHandler =
1054-
delegate (IMixedRealityInputHandler handler, BaseEventData eventData)
1029+
private static readonly ExecuteEvents.EventFunction<IMixedRealityInputHandler<float>> OnFloatInputChanged =
1030+
delegate (IMixedRealityInputHandler<float> handler, BaseEventData eventData)
10551031
{
1056-
var casted = ExecuteEvents.ValidateEventData<InputEventData>(eventData);
1057-
handler.OnInputUp(casted);
1032+
var casted = ExecuteEvents.ValidateEventData<InputEventData<float>>(eventData);
1033+
handler.OnInputChanged(casted);
10581034
};
10591035

10601036
/// <inheritdoc />
1061-
public void RaiseOnInputUp(IMixedRealityInputSource source, MixedRealityInputAction inputAction)
1037+
void RaiseFloatInputChanged(IMixedRealityInputSource source, MixedRealityInputAction inputAction, float inputValue)
10621038
{
1063-
inputAction = ProcessRules(inputAction, false);
1039+
inputAction = ProcessRules(inputAction, inputValue);
10641040

10651041
// Create input event
1066-
inputEventData.Initialize(source, inputAction);
1042+
floatInputEventData.Initialize(source, inputAction, inputValue);
10671043

10681044
// Pass handler through HandleEvent to perform modal/fallback logic
1069-
HandleEvent(inputEventData, OnInputUpEventHandler);
1045+
HandleEvent(floatInputEventData, OnFloatInputChanged);
10701046
}
10711047

10721048
/// <inheritdoc />
1073-
public void RaiseOnInputUp(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction)
1049+
void RaiseFloatInputChanged(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction, float inputValue)
10741050
{
1075-
inputAction = ProcessRules(inputAction, false);
1051+
inputAction = ProcessRules(inputAction, inputValue);
10761052

10771053
// Create input event
1078-
inputEventData.Initialize(source, handedness, inputAction);
1054+
floatInputEventData.Initialize(source, handedness, inputAction, inputValue);
10791055

10801056
// Pass handler through HandleEvent to perform modal/fallback logic
1081-
HandleEvent(inputEventData, OnInputUpEventHandler);
1057+
HandleEvent(floatInputEventData, OnFloatInputChanged);
10821058
}
10831059

1084-
#endregion Input Up
1060+
#endregion Float Input Changed
10851061

10861062
#region Input Position Changed
10871063

Assets/MixedRealityToolkit/Interfaces/InputSystem/IMixedRealityInputSystem.cs

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -306,60 +306,45 @@ public interface IMixedRealityInputSystem : IMixedRealityEventSystem
306306

307307
#endregion Input Down
308308

309-
#region Input Pressed
310-
311-
/// <summary>
312-
/// Raise Input Pressed.
313-
/// </summary>
314-
/// <param name="source"></param>
315-
/// <param name="inputAction"></param>
316-
void RaiseOnInputPressed(IMixedRealityInputSource source, MixedRealityInputAction inputAction);
317-
318-
/// <summary>
319-
/// Raise Input Pressed.
320-
/// </summary>
321-
/// <param name="source"></param>
322-
/// <param name="handedness"></param>
323-
/// <param name="inputAction"></param>
324-
void RaiseOnInputPressed(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction);
309+
#region Input Up
325310

326311
/// <summary>
327-
/// Raise Input Pressed.
312+
/// Raise the input up event.
328313
/// </summary>
329314
/// <param name="source"></param>
330315
/// <param name="inputAction"></param>
331-
/// <param name="pressAmount"></param>
332-
void RaiseOnInputPressed(IMixedRealityInputSource source, MixedRealityInputAction inputAction, float pressAmount);
316+
void RaiseOnInputUp(IMixedRealityInputSource source, MixedRealityInputAction inputAction);
333317

334318
/// <summary>
335-
/// Raise Input Pressed.
319+
/// Raise the input up event.
336320
/// </summary>
337321
/// <param name="source"></param>
338322
/// <param name="handedness"></param>
339323
/// <param name="inputAction"></param>
340-
/// <param name="pressAmount"></param>
341-
void RaiseOnInputPressed(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction, float pressAmount);
324+
void RaiseOnInputUp(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction);
342325

343-
#endregion Input Pressed
326+
#endregion Input Up
344327

345-
#region Input Up
328+
#region Float Input Changed
346329

347330
/// <summary>
348-
/// Raise the input up event.
331+
/// Raise Float Input Changed.
349332
/// </summary>
350333
/// <param name="source"></param>
351334
/// <param name="inputAction"></param>
352-
void RaiseOnInputUp(IMixedRealityInputSource source, MixedRealityInputAction inputAction);
335+
/// <param name="inputValue"></param>
336+
void RaiseFloatInputChanged(IMixedRealityInputSource source, MixedRealityInputAction inputAction, float inputValue);
353337

354338
/// <summary>
355-
/// Raise the input up event.
339+
/// Raise Float Input Changed.
356340
/// </summary>
357341
/// <param name="source"></param>
358342
/// <param name="handedness"></param>
359343
/// <param name="inputAction"></param>
360-
void RaiseOnInputUp(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction);
344+
/// <param name="inputValue"></param>
345+
void RaiseFloatInputChanged(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction, float inputValue);
361346

362-
#endregion Input Up
347+
#endregion Float Input Changed
363348

364349
#region Input Position Changed
365350

Assets/MixedRealityToolkit/Providers/UnityInput/GenericJoystickController.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,13 @@ protected void UpdateButtonData(MixedRealityInteractionMapping interactionMappin
103103
MixedRealityToolkit.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
104104
}
105105
}
106-
else
107-
{
108-
if (interactionMapping.BoolData)
109-
{
110-
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
111-
}
112-
}
113106
}
114107

115108
/// <summary>
116109
/// Update an Interaction Float data type from a SingleAxis (float) input
117110
/// </summary>
118111
/// <remarks>
119-
/// Raises an Input System "Pressed" event when the float data changes
112+
/// Raises a Float Input Changed event when the float data changes
120113
/// </remarks>
121114
/// <param name="interactionMapping"></param>
122115
protected void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMapping)
@@ -150,7 +143,7 @@ protected void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMa
150143
if (interactionMapping.Changed)
151144
{
152145
// Raise input system Event if it enabled
153-
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.FloatData);
146+
MixedRealityToolkit.InputSystem?.RaiseFloatInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.FloatData);
154147
}
155148
return;
156149
default:
@@ -171,13 +164,6 @@ protected void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMa
171164
MixedRealityToolkit.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction);
172165
}
173166
}
174-
else
175-
{
176-
if (interactionMapping.BoolData)
177-
{
178-
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, singleAxisValue);
179-
}
180-
}
181167
}
182168

183169
/// <summary>

Assets/MixedRealityToolkit/Providers/UnityInput/MouseController.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,6 @@ public void Update()
129129
MixedRealityToolkit.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
130130
}
131131
}
132-
else
133-
{
134-
if (Interactions[i].BoolData)
135-
{
136-
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction);
137-
}
138-
}
139132
}
140133
}
141134
}

0 commit comments

Comments
 (0)