public float GetAxis() { if (type == VirtualInputChannelType.Axis) { if (isAxisToAxisRemapped) { float value = UnInput.GetAxisRaw(name); if (value < 0) { return(-Easing.Ease(axisToAxisRemapType, axisToAxisRemapPhase, -value) * axisToAxisRemapScale); } else { return(Easing.Ease(axisToAxisRemapType, axisToAxisRemapPhase, value) * axisToAxisRemapScale); } } else { return(UnInput.GetAxisRaw(name)); } } else if (type == VirtualInputChannelType.Button) { if (negName != null) { bool pos = UnInput.GetButton(name), neg = UnInput.GetButton(negName); if (pos ^ neg) { return(pos ? buttonToAxisValue : -buttonToAxisValue); } else { return(0); } } else { return(UnInput.GetButton(name) ? buttonToAxisValue : 0); } } else // Key { if (negKey != UnKeyCode.None) { bool pos = UnInput.GetKey(key), neg = UnInput.GetKey(negKey); if (pos ^ neg) { return(pos ? buttonToAxisValue : -buttonToAxisValue); } else { return(0); } } else { return(UnInput.GetKey(key) ? buttonToAxisValue : 0); } } }
public static new bool GetButton(string buttonName) { if (!Enabled) { return(false); } return(UnityInput.GetButton(buttonName)); }
public bool GetButton() { if (type == VirtualInputChannelType.Axis) { return(UnInput.GetAxisRaw(name) > axisToButtonThreshold); } else if (type == VirtualInputChannelType.Button) { return(UnInput.GetButton(name)); } else { return(UnInput.GetKey(key)); } }
/// <summary> /// Ask to update input from Unity's Input /// </summary> public void Parse(int inputState) { if (!isLocalPlayer) { return; } CurrentInput.InputState = inputState; CurrentInput.Left = UnityInput.GetKey(KeyCode.LeftArrow) || UnityInput.GetKey(KeyCode.A); CurrentInput.Right = UnityInput.GetKey(KeyCode.RightArrow) || UnityInput.GetKey(KeyCode.D); CurrentInput.Forward = UnityInput.GetKey(KeyCode.UpArrow) || UnityInput.GetKey(KeyCode.W); CurrentInput.Backward = UnityInput.GetKey(KeyCode.DownArrow) || UnityInput.GetKey(KeyCode.S); CurrentInput.SetPitch(cameraAim.Pitch); CurrentInput.SetYaw(cameraAim.Yaw); CurrentInput.Jump = UnityInput.GetButton("Jump"); CurrentInput.Fire = UnityInput.GetButton("Fire1"); CurrentInput.Aim = UnityInput.GetButton("Fire2"); CurrentInput.Run = UnityInput.GetButton("Run"); }
// does a button with a name of 'name' exist? public static bool IsInputSetup(string name) { if (_inputExistsMap.ContainsKey(name)) { return(_inputExistsMap[name]); } bool exists; // this is a really horrible way to do this since throwing exceptions "for no reason" sucks... try { UnityInput.GetButton(name); exists = true; } catch { exists = false; } _inputExistsMap.Add(name, exists); return(exists); }
private void Update() { m_jump = UnityInput.GetButtonDown("Jump"); m_crouch = UnityInput.GetButton("Crouch"); m_horizontalMove = UnityInput.GetAxis("Horizontal"); }
public static bool IsButtonReleased(string name) { return(!UnityInput.GetButton(name)); }
public static bool IsButtonPressed(string name) { return(UnityInput.GetButton(name)); }
private void UpdateCurrentJumpState() { currentJumpState = UnityInput.GetButton("Jump"); }
static private CoroutineRet _waitInput(axis[] arr, Actions action) { int idx = action.idx(); bool done = false; while (!done) { /* Wait until the end of the next frame */ yield return(null); if (waitCaller.lastKey != KeyCode.None) { arr[idx] = new axis(waitCaller.lastKey); done = true; break; } else { /* Test every option in every gamepad :grimacing: */ for (int gpIdx = 1; !done && gpIdx < gamepadNum; gpIdx++) { for (int gpAxis = 0; gpAxis < gamepadAxisNum; gpAxis++) { string name = $"joystick {gpIdx} axis {gpAxis}"; int i = gpIdx * gamepadAxisNum + gpAxis; float rest = Input.axisRest[i]; float val = DefInput.GetAxisRaw(name); float diff = val - rest; /* Check that the axis is 80% of the way pressed * in the given direction */ if (val > rest && diff > 0.25f && diff / (1.0f - rest) >= 0.8f) { arr[idx] = new axis(name, axisType.positiveAxis, rest); done = true; break; } else if (val < rest && diff < -0.25f && Math.Abs(diff / (1.0f + rest)) >= 0.8f) { arr[idx] = new axis(name, axisType.negativeAxis, rest); done = true; break; } } for (int gpBt = 0; gpBt < gamepadButtonNum; gpBt++) { string name = $"joystick {gpIdx} button {gpBt}"; if (DefInput.GetButton(name)) { arr[idx] = new axis(name, axisType.none); done = true; break; } } } } } waitFunc = null; waitCaller.GetComponentInChildren <KeyLogger>().enabled = false; waitCaller = null; }