public float GetAxis(GamepadAxisRaw axis) { if (!Enabled) { return(0f); } return(input.GetGamepadAxisRaw(this, axis)); }
public override float GetGamepadAxisRaw(IGamepadController gamepad, GamepadAxisRaw axis) { var result = 0f; var gamepadRaw = GetGamepad(gamepad); if (gamepadRaw != null) { switch (axis) { case GamepadAxisRaw.AxisX: result = gamepadRaw.leftStick.x.ReadUnprocessedValue(); break; case GamepadAxisRaw.AxisY: result = gamepadRaw.leftStick.y.ReadUnprocessedValue(); break; case GamepadAxisRaw.Axis4: result = gamepadRaw.rightStick.x.ReadUnprocessedValue(); break; case GamepadAxisRaw.Axis5: result = gamepadRaw.rightStick.y.ReadUnprocessedValue(); break; case GamepadAxisRaw.Axis3: result = gamepadRaw.leftTrigger.ReadUnprocessedValue(); break; case GamepadAxisRaw.Axis6: result = gamepadRaw.rightTrigger.ReadUnprocessedValue(); break; case GamepadAxisRaw.Axis7: result = gamepadRaw.dpad.x.ReadUnprocessedValue(); break; case GamepadAxisRaw.Axis8: result = gamepadRaw.dpad.y.ReadUnprocessedValue(); break; } } return(result); }
public override float GetGamepadAxisRaw(IGamepadController gamepad, GamepadAxisRaw axis) { var axisValue = 0f; if (axis == GamepadAxisRaw.None) { return(axisValue); } var gamepadIndex = GetGamepadIndex(gamepad); var axisIndex = (int)axis; if (axisIndex > 0 && gamepadIndex > 0) { // Input Axis Names (Project Settings -> Input Manager) // // Axis{#1}_{#2} // Number {#1} should be 1~10 (Axis index) // Number {#2} can be 1~16 (Gamepad index) // // Important: Set sensibility to 1 and gravity to 0 var axisName = $"Axis{axisIndex}_{gamepadIndex}"; try { axisValue = UnityEngine.Input.GetAxisRaw(axisName); } catch (System.Exception e) { Log.Exception(null, e); } } return(axisValue); }
public abstract float GetGamepadAxisRaw(IGamepadController gamepad, GamepadAxisRaw axis);