public void Update(float deltaTime) { if (m_type == InputType.GamepadAnalogButton) { for (int i = 0; i < maxJoysticks; i++) { if (GamepadHandler.GamepadAvailable(i, out _)) { UpdateAxisAsButtons(i, GamepadHandler.GetAxis(m_gamepadAxis, i)); } } } else if (m_type == InputType.GamepadAxis) { if (updateAsButton) { for (int i = 0; i < maxJoysticks; i++) { if (GamepadHandler.GamepadAvailable(i, out _)) { UpdateAxisAsButtons(i, GetAxis(i)); } } } } else if (m_type == InputType.MouseAxis) { if (updateAsButton) { UpdateAxisAsButtons(0, GetAxis(0)); } } if (m_type == InputType.DigitalAxis) { UpdateDigitalAxisValue(deltaTime); } else if (m_type == InputType.KeyButton) { if (updateAsAxis) { UpdateButtonAsAxisValue(deltaTime, 0); } } else if (m_type == InputType.GamepadButton) { if (updateAsAxis) { for (int i = 0; i < maxJoysticks; i++) { if (GamepadHandler.GamepadAvailable(i, out _)) { UpdateButtonAsAxisValue(deltaTime, i); } } } } }
public float GetAxis(int playerID) { float axis = 0; if (m_type == InputType.DigitalAxis) { axis = m_invert ? -digitalAxisValue : digitalAxisValue; } else if (m_type == InputType.MouseAxis) { axis = Input.GetAxis(rawMouseAxisName) * m_sensitivity; axis = m_invert ? -axis : axis; } else if (m_type == InputType.GamepadAxis) { axis = GamepadHandler.GetAxis(m_gamepadAxis, playerID); if ((axis < 0 && axis > -m_deadZone) || (axis > 0 && axis < m_deadZone)) { axis = AXIS_NEUTRAL; } axis = Mathf.Clamp(axis * m_sensitivity, -1, 1); axis = m_invert ? -axis : axis; } else if (m_type == InputType.GamepadAnalogButton) { axis = GamepadHandler.GetAxis(m_gamepadAxis, playerID); if ((axis < 0 && axis > -m_deadZone) || (axis > 0 && axis < m_deadZone)) { axis = AXIS_NEUTRAL; } axis = Mathf.Clamp(axis * m_sensitivity, -1, 1); axis = m_invert ? -axis : axis; } else if (m_type == InputType.KeyButton) { axis = buttonsAsAxisValue[0]; axis = m_invert ? -axis : axis; } else if (m_type == InputType.GamepadButton) { axis = buttonsAsAxisValue[playerID]; axis = m_invert ? -axis : axis; } return(axis); }