Skip to content

Commit 79d6e12

Browse files
EditorHandsInput.cs latest PR comments
1 parent 2221760 commit 79d6e12

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

Assets/HoloToolkit/Input/Scripts/InputSources/EditorHandsInput.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,30 @@ public EditorHandData(uint handId)
5858
/// Delay before a finger pressed is considered.
5959
/// This mitigates fake finger taps that can sometimes be detected while the hand is moving.
6060
/// </summary>
61-
private const float FINGER_PRESS_DELAY = 0.07f;
61+
private const float fingerPressDelay = 0.07f;
6262

6363
/// <summary>
6464
/// The maximum interval between button down and button up that will result in a clicked event.
6565
/// </summary>
66-
private const float MAX_CLICK_DURATION = 0.5f;
66+
private const float maxClickDuration = 0.5f;
6767

6868
/// <summary>
6969
/// Number of fake hands supported in the editor.
7070
/// </summary>
71-
private const int EDITOR_HANDS_COUNT = 2;
71+
private const int editorHandsCount = 2;
7272

7373
/// <summary>
74-
/// Array containing the hands data for the two fake hands
74+
/// Array containing the hands data for the two fake hands.
7575
/// </summary>
76-
private readonly EditorHandData[] editorHandsData = new EditorHandData[EDITOR_HANDS_COUNT];
76+
private readonly EditorHandData[] editorHandsData = new EditorHandData[editorHandsCount];
7777

7878
/// <summary>
7979
/// Dictionary linking each hand ID to its data.
8080
/// </summary>
8181
private readonly Dictionary<uint, EditorHandData> handIdToData = new Dictionary<uint, EditorHandData>(4);
8282
private readonly List<uint> pendingHandIdDeletes = new List<uint>();
8383

84-
// HashSets used to be able to quickly update the hands data when hands become visible / not visible
84+
// HashSets used to be able to quickly update the hands data when hands become visible / not visible.
8585
private readonly HashSet<uint> currentHands = new HashSet<uint>();
8686
private readonly HashSet<uint> newHands = new HashSet<uint>();
8787

@@ -108,7 +108,7 @@ public override bool TryGetPosition(uint sourceId, out Vector3 position)
108108

109109
public override bool TryGetOrientation(uint sourceId, out Quaternion orientation)
110110
{
111-
// Orientation is not supported by hands
111+
// Orientation is not supported by hands.
112112
orientation = Quaternion.identity;
113113
return false;
114114
}
@@ -264,22 +264,22 @@ private EditorHandData GetOrAddHandData(uint sourceId)
264264
/// <param name="time">Unscaled time of last event.</param>
265265
private void UpdateHandState(DebugInteractionSourceState handSource, EditorHandData editorHandData, float deltaTime, float time)
266266
{
267-
// Update hand position
267+
// Update hand position.
268268
Vector3 handPosition;
269269
if (handSource.Properties.Location.TryGetPosition(out handPosition))
270270
{
271271
editorHandData.HandDelta = handPosition - editorHandData.HandPosition;
272272
editorHandData.HandPosition = handPosition;
273273
}
274274

275-
// Check for finger presses
275+
// Check for finger presses.
276276
if (handSource.Pressed != editorHandData.IsFingerDownPending)
277277
{
278278
editorHandData.IsFingerDownPending = handSource.Pressed;
279-
editorHandData.FingerStateUpdateTimer = FINGER_PRESS_DELAY;
279+
editorHandData.FingerStateUpdateTimer = fingerPressDelay;
280280
}
281281

282-
// Finger presses are delayed to mitigate issue with hand position shifting during air tap
282+
// Finger presses are delayed to mitigate issue with hand position shifting during air tap.
283283
editorHandData.FingerStateChanged = false;
284284
if (editorHandData.FingerStateUpdateTimer > 0)
285285
{
@@ -317,7 +317,7 @@ private void SendHandStateEvents(EditorHandData editorHandData, float time)
317317
// New down presses are straightforward - fire input down and be on your way.
318318
if (editorHandData.IsFingerDown)
319319
{
320-
InputManager.Instance.RaiseSourceDown(this, editorHandData.HandId);
320+
inputManager.RaiseSourceDown(this, editorHandData.HandId);
321321
editorHandData.CumulativeDelta = Vector3.zero;
322322
}
323323
// New up presses require sending different events depending on whether it's also a click, hold, or manipulation.
@@ -326,22 +326,22 @@ private void SendHandStateEvents(EditorHandData editorHandData, float time)
326326
// A gesture is always either a click, a hold or a manipulation.
327327
if (editorHandData.ManipulationInProgress)
328328
{
329-
InputManager.Instance.RaiseManipulationCompleted(this, editorHandData.HandId, editorHandData.CumulativeDelta);
329+
inputManager.RaiseManipulationCompleted(this, editorHandData.HandId, editorHandData.CumulativeDelta);
330330
editorHandData.ManipulationInProgress = false;
331331
}
332332
// Clicks and holds are based on time, and both are overruled by manipulations.
333333
else if (editorHandData.HoldInProgress)
334334
{
335-
InputManager.Instance.RaiseHoldCompleted(this, editorHandData.HandId);
335+
inputManager.RaiseHoldCompleted(this, editorHandData.HandId);
336336
editorHandData.HoldInProgress = false;
337337
}
338338
else
339339
{
340340
// We currently only support single taps in editor.
341-
InputManager.Instance.RaiseInputClicked(this, editorHandData.HandId, 1);
341+
inputManager.RaiseInputClicked(this, editorHandData.HandId, 1);
342342
}
343343

344-
InputManager.Instance.RaiseSourceUp(this, editorHandData.HandId);
344+
inputManager.RaiseSourceUp(this, editorHandData.HandId);
345345
}
346346
}
347347
// If the finger state hasn't changed, and the finger is down, that means if calculations need to be done
@@ -358,23 +358,23 @@ private void SendHandStateEvents(EditorHandData editorHandData, float time)
358358
// Starting a manipulation will cancel an existing hold.
359359
if (editorHandData.HoldInProgress)
360360
{
361-
InputManager.Instance.RaiseHoldCanceled(this, editorHandData.HandId);
361+
inputManager.RaiseHoldCanceled(this, editorHandData.HandId);
362362
editorHandData.HoldInProgress = false;
363363
}
364364

365-
InputManager.Instance.RaiseManipulationStarted(this, editorHandData.HandId, editorHandData.CumulativeDelta);
365+
inputManager.RaiseManipulationStarted(this, editorHandData.HandId, editorHandData.CumulativeDelta);
366366
editorHandData.ManipulationInProgress = true;
367367
}
368368
// Holds are triggered by time.
369-
else if (!editorHandData.HoldInProgress && (time - editorHandData.FingerDownStartTime >= MAX_CLICK_DURATION))
369+
else if (!editorHandData.HoldInProgress && (time - editorHandData.FingerDownStartTime >= maxClickDuration))
370370
{
371-
InputManager.Instance.RaiseHoldStarted(this, editorHandData.HandId);
371+
inputManager.RaiseHoldStarted(this, editorHandData.HandId);
372372
editorHandData.HoldInProgress = true;
373373
}
374374
}
375375
else
376376
{
377-
InputManager.Instance.RaiseManipulationUpdated(this, editorHandData.HandId, editorHandData.CumulativeDelta);
377+
inputManager.RaiseManipulationUpdated(this, editorHandData.HandId, editorHandData.CumulativeDelta);
378378
}
379379
}
380380
}
@@ -384,23 +384,23 @@ private void SendHandStateEvents(EditorHandData editorHandData, float time)
384384
/// </summary>
385385
private void SendHandVisibilityEvents()
386386
{
387-
// Send event for new hands that were added
387+
// Send event for new hands that were added.
388388
foreach (uint newHand in newHands)
389389
{
390-
InputManager.Instance.RaiseSourceDetected(this, newHand);
390+
inputManager.RaiseSourceDetected(this, newHand);
391391
}
392392

393-
// Send event for hands that are no longer visible and remove them from our dictionary
393+
// Send event for hands that are no longer visible and remove them from our dictionary.
394394
foreach (uint existingHand in handIdToData.Keys)
395395
{
396396
if (!currentHands.Contains(existingHand))
397397
{
398398
pendingHandIdDeletes.Add(existingHand);
399-
InputManager.Instance.RaiseSourceLost(this, existingHand);
399+
inputManager.RaiseSourceLost(this, existingHand);
400400
}
401401
}
402402

403-
// Remove pending hand IDs
403+
// Remove pending hand IDs.
404404
for (int i = 0; i < pendingHandIdDeletes.Count; ++i)
405405
{
406406
handIdToData.Remove(pendingHandIdDeletes[i]);

0 commit comments

Comments
 (0)