Skip to content

Commit

Permalink
Hjelp
Browse files Browse the repository at this point in the history
  • Loading branch information
SDraw committed Jan 29, 2023
1 parent 783c343 commit d8c79ed
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions ml_lme/LeapInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,39 +127,53 @@ public override void UpdateInput()
if(l_data.m_leftHand.m_present && (!m_inVR || (VRTrackerManager.Instance.leftHand == null) || !VRTrackerManager.Instance.leftHand.active || !Settings.FingersOnly))
{
float l_strength = l_data.m_leftHand.m_grabStrength;
m_inputManager.interactLeftValue = l_strength;
if(m_interactLeft != (l_strength > Settings.HoldThreadhold))
{
m_interactLeft = (l_strength > Settings.HoldThreadhold);
m_inputManager.interactLeftUp |= !m_interactLeft;
m_inputManager.interactLeftDown |= m_interactLeft;
}
m_inputManager.gripLeftValue = 1f - l_strength; // Inversed
if(m_interactLeft)
m_inputManager.interactLeftValue = Mathf.InverseLerp(Settings.HoldThreadhold, 1f, l_strength);
else
m_inputManager.interactLeftValue = Mathf.Max(0f, m_inputManager.interactLeftValue);

if(m_gripLeft != (l_strength < Settings.ReleaseThreadhold))
{
m_gripLeft = (l_strength < Settings.ReleaseThreadhold);
m_inputManager.gripLeftUp |= !m_gripLeft;
m_inputManager.gripLeftDown |= m_gripLeft;
}
if(m_gripLeft)
m_inputManager.gripLeftValue = Mathf.InverseLerp(Settings.ReleaseThreadhold, 0f, l_strength);
else
m_inputManager.gripLeftValue = Mathf.Max(0f, m_inputManager.gripLeftValue);
}

if(l_data.m_rightHand.m_present && (!m_inVR || (VRTrackerManager.Instance.rightHand == null) || !VRTrackerManager.Instance.rightHand.active || !Settings.FingersOnly))
{
float l_strength = l_data.m_rightHand.m_grabStrength;
m_inputManager.interactRightValue = l_strength;
if(m_interactRight != (l_strength > Settings.HoldThreadhold))
{
m_interactRight = (l_strength > Settings.HoldThreadhold);
m_inputManager.interactRightUp |= !m_interactRight;
m_inputManager.interactRightDown |= m_interactRight;
}
m_inputManager.gripRightValue = 1f - l_strength;
if(m_interactRight)
m_inputManager.interactRightValue = Mathf.InverseLerp(Settings.HoldThreadhold, 1f, l_strength);
else
m_inputManager.interactRightValue = Mathf.Max(0f, m_inputManager.interactRightValue);

if(m_gripRight != (l_strength < Settings.HoldThreadhold))
{
m_gripRight = (l_strength < Settings.HoldThreadhold);
m_inputManager.gripRightUp |= !m_gripRight;
m_inputManager.gripRightDown |= m_gripRight;
}
if(m_gripRight)
m_inputManager.gripRightValue = Mathf.InverseLerp(Settings.ReleaseThreadhold, 0f, l_strength);
else
m_inputManager.gripRightValue = Mathf.Max(0f, m_inputManager.gripRightValue);
}
}
}
Expand Down

0 comments on commit d8c79ed

Please sign in to comment.