internal bool GetInputUp(IDevice device) { if (_actionsList.Count > 1 || __currentInputAction.type != InputActionType.SINGLE) { /*Debug.LogWarning("You found need of GetInputUp with combos. Fork code on github");*/ return(false); } else { return(InputEx.GetInputUp(__currentInputAction, device)); } }
/// <summary> /// Gets the interpolated analog value. /// </summary> /// <returns>The interpolated analog value.</returns> /// <param name="sensitivity">Sensitivity.</param> /// <param name="dreadzone">Dreadzone.</param> /// <param name="gravity">Gravity.</param> internal float GetGenericAnalogValue(IDevice device, float sensitivity, float dreadzone, float gravity) { if (InputEx.GetInputHold(__currentInputAction, device)) { _isActive = true; _timeDelta += Time.deltaTime * sensitivity; //timeDelta need to go from 0 to 1 (which mean from 0 to 100% of range difference) _analogValue = Mathf.Lerp(0, 1, Mathf.Clamp01(_timeDelta)); //Debug.Log("hold"+_analogValue); } else //on KeyUp reset _timeDelta { if (InputEx.GetInputUp(__currentInputAction, device)) { _isActive = false; _timeDelta = 0f; //reset // Debug.Log("UP g="+gravity); //if gravity is not set => drop _analogValue to 0 immidiately if (!(gravity > 0)) { _analogValue = 0; } return(_analogValue); } //effect of gravity if (_analogValue != 0) { _timeDelta += Time.deltaTime * gravity; _analogValue = Mathf.Lerp(_analogValue, 0, Mathf.Clamp01(_timeDelta)); // Debug.Log("gravity"); } } if (_analogValue < dreadzone) { _analogValue = 0f; } return(_analogValue); }