public static float GetAxisValue(GamepadAxis axis) { switch (axis) { case GamepadAxis.DpadX: return Input.GetAxis("DPad_XAxis"); case GamepadAxis.DpadY: return -Input.GetAxis("DPad_YAxis"); case GamepadAxis.LStickX: return Input.GetAxis("L_XAxis"); case GamepadAxis.LStickY: return -Input.GetAxis("L_YAxis"); case GamepadAxis.RStickX: return Input.GetAxis("R_XAxis"); case GamepadAxis.RStickY: return -Input.GetAxis("R_YAxis"); case GamepadAxis.Triggers: //* return Input.GetAxis("Triggers"); /*/ float LTrigger = Input.GetAxis("TriggersL"); float RTrigger = Input.GetAxis("TriggersR"); return RTrigger - LTrigger; //*/ } return 0; }
public string GetAxisName (GamepadAxis axis) { for (int i = 0; i < axisNames.Count; i++) { if (axisNames [i].axis == axis) return axisNames [i].name; } return axis.ToString (); }
public string GetName(GamepadAxis axis) { switch (axis) { case GamepadAxis.LStickX: return "L Stick X"; case GamepadAxis.LStickY: return "L Stick Y"; case GamepadAxis.RStickX: return "R Stick X"; case GamepadAxis.RStickY: return "R Stick Y"; case GamepadAxis.DpadX: return "Dpad X"; case GamepadAxis.DpadY: return "Dpad Y"; case GamepadAxis.Triggers: return "Triggers"; } return "None"; }
public float GetAxis(GamepadAxis axis, GamepadIndex gamepad) { GamepadReading?state = GetCurrentState(gamepad); double value = 0.0; if (state.HasValue) { switch (axis) { case GamepadAxis.LeftThumbstickX: value = state.Value.LeftThumbstickX; break; case GamepadAxis.LeftThumbstickY: value = state.Value.LeftThumbstickY; break; case GamepadAxis.RightThumbstickX: value = state.Value.RightThumbstickX; break; case GamepadAxis.RightThumbstickY: value = state.Value.RightThumbstickY; break; case GamepadAxis.DPadX: value = m_dpadState[(int)gamepad].X; break; case GamepadAxis.DPadY: value = m_dpadState[(int)gamepad].Y; break; case GamepadAxis.LeftTrigger: value = state.Value.LeftTrigger; break; case GamepadAxis.RightTrigger: value = state.Value.RightTrigger; break; } } return((float)value); }
//---------------------------------------------- // interface //---------------------------------------------- //is button fopr this action currently pressed public bool ControlPressed(PlayerControlsGamepad.E_Input inpAction) { if ((int)inpAction >= GetActionCount()) { return(false); } JoyInput btn = m_InputK[(int)inpAction]; if (btn.joyAxis == E_JoystickAxis.NONE) { return(Input.GetKey(btn.key)); } else { return(Input.GetAxis(GamepadAxis.GetAxis(btn.joyAxis)) > 0.95f); } }
public void Copy(InputBinding source) { m_positive = source.m_positive; m_negative = source.m_negative; m_deadZoneType = source.m_deadZoneType; m_deadZone = source.m_deadZone; m_gravity = source.m_gravity; m_sensitivity = source.m_sensitivity; m_scale = source.m_scale; m_snap = source.m_snap; m_invert = source.m_invert; m_type = source.m_type; m_axis = source.m_axis; m_joystick = source.m_joystick; m_gamepadAxis = source.m_gamepadAxis; m_gamepadButton = source.m_gamepadButton; m_gamepadIndex = source.m_gamepadIndex; }
#pragma warning restore 0649 public float GetAxisValue(GamepadAxis axis) { switch ((int)axis) { case 0: return(LeftStickX); case 1: return(LeftStickY); case 2: return(RightStickX); case 3: return(RightStickY); case 4: return(LeftTrigger); case 5: return(RightTrigger); } return(0.0f); }
public string GetAsString(bool usePositive) { switch (m_type) { case InputType.KeyButton: return(m_positive.ToString()); case InputType.MouseAxis: return(mouseAxisNames[mouseAxis]); case InputType.DigitalAxis: return(usePositive ? m_positive.ToString() : m_negative.ToString()); case InputType.GamepadButton: return(m_gamepadButton.ToString()); case InputType.GamepadAnalogButton: return((useNegativeAxisForButton ? "-" : "+") + GamepadAxis.ToString()); case InputType.GamepadAxis: return(GamepadAxis.ToString()); } return("ERROR"); }
public float this[GamepadAxis axis] { get { switch (axis) { case GamepadAxis.LeftTrigger: return MathF.Clamp(this.state.Triggers.Left, 0.0f, 1.0f); case GamepadAxis.LeftThumbstickX: return MathF.Clamp(this.state.ThumbSticks.Left.X, -1.0f, 1.0f); case GamepadAxis.LeftThumbstickY: return MathF.Clamp(this.state.ThumbSticks.Left.Y, -1.0f, 1.0f); case GamepadAxis.RightTrigger: return MathF.Clamp(this.state.Triggers.Right, 0.0f, 1.0f); case GamepadAxis.RightThumbstickX: return MathF.Clamp(this.state.ThumbSticks.Right.X, -1.0f, 1.0f); case GamepadAxis.RightThumbstickY: return MathF.Clamp(this.state.ThumbSticks.Right.Y, -1.0f, 1.0f); default: return 0.0f; } } }
public static float GetAxis(GamepadAxis axis, int gamepad) { GenericGamepadProfile profile; if (!GamepadAvailable(gamepad, out profile)) { return(0.0f); } int axisID = -1; switch (axis) { case GamepadAxis.LeftThumbstickX: axisID = profile.LeftStickXAxis; break; case GamepadAxis.LeftThumbstickY: axisID = profile.LeftStickYAxis; break; case GamepadAxis.RightThumbstickX: axisID = profile.RightStickXAxis; break; case GamepadAxis.RightThumbstickY: axisID = profile.RightStickYAxis; break; case GamepadAxis.DPadX: if (profile.DPadType == GamepadDPadType.Button) { return(m_dpadState[gamepad].axes[0]); } axisID = profile.DPadXAxis; break; case GamepadAxis.DPadY: if (profile.DPadType == GamepadDPadType.Button) { return(m_dpadState[gamepad].axes[1]); } axisID = profile.DPadYAxis; break; case GamepadAxis.LeftTrigger: return(AdjustOSXAxis(Input.GetAxis(m_axisNameLookupTable[gamepad * InputBinding.MAX_JOYSTICK_AXES + profile.LeftTriggerAxis]), gamepad, ref checkedGamepadLTriggersForInitialization)); case GamepadAxis.RightTrigger: return(AdjustOSXAxis(Input.GetAxis(m_axisNameLookupTable[gamepad * InputBinding.MAX_JOYSTICK_AXES + profile.RightTriggerAxis]), gamepad, ref checkedGamepadRTriggersForInitialization)); } return(axisID >= 0 ? Input.GetAxis(m_axisNameLookupTable[gamepad * InputBinding.MAX_JOYSTICK_AXES + axisID]) : 0.0f); }
public int GetAxis(GamepadAxis axis) { switch (axis) { case GamepadAxis.StickLeftX: return _controller.LeftThumbStick.X/256; case GamepadAxis.StickLeftY: return -_controller.LeftThumbStick.Y/256; case GamepadAxis.StickRightX: return _controller.RightThumbStick.X/256; case GamepadAxis.StickRightY: return -_controller.RightThumbStick.Y/256; case GamepadAxis.TriggerLeft: return _controller.LeftTrigger; case GamepadAxis.TriggerRight: return _controller.RightTrigger; } return 0; }
public float GetAxisValue(GamepadAxis axis, int playerNumber) { if (this.PlayerMappings[playerNumber].OverridesAxisReading) { return(this.PlayerMappings[playerNumber].OverrideAxisReading(axis)); } float input = Input.GetAxisRaw(this.PlayerMappings[playerNumber].AxisBindingLookupTable[axis].AxisName); //int multiplier = input > this.PlayerMappings[playerNumber].AxisBindingLookupTable[axis].UnpressedValue ? 1 : -1; //Make sure that we don't get false positives, due to the deadzone there is on buttons //bool valueBiggerThanDeadzone = input > this.PlayerMappings[playerNumber].AxisBindingLookupTable[axis].UnpressedValue + (multiplier * this.PlayerMappings[playerNumber].AxisBindingLookupTable[axis].DeadZoneOffset); if (this.IsValueInDeadzone(input, this.PlayerMappings[playerNumber].AxisBindingLookupTable[axis])) { return(0.0f); } return(input * (this.PlayerMappings[playerNumber].AxisBindingLookupTable[axis].Inverted ? -1 : 1)); }
/// <summary> /// Reads the analog values of the specified axis on a player's gamepad. /// </summary> /// <param name="player">The player to query, starting with 0.</param> /// <param name="axis">The gamepad axis to query.</param> public static Vector2 GetGamepadAxis(int player, GamepadAxis axis) { if (GetGamepadConnected(player)) { switch (axis) { case GamepadAxis.LeftStick: return(GamepadsByPlayer[player].LeftStick); case GamepadAxis.RightStick: return(GamepadsByPlayer[player].RightStick); case GamepadAxis.Triggers: return(GamepadsByPlayer[player].Triggers); default: throw new Exception("Unhandled case."); } } else { return(Vector2.Zero); } }
public static string GetName(GamepadAxis axis) { switch (axis) { case GamepadAxis.LStickX: return("L Stick Horizontal"); case GamepadAxis.LStickY: return("L Stick Vertical"); case GamepadAxis.RStickX: return("R Stick Horizontal"); case GamepadAxis.RStickY: return("R Stick Vertical"); case GamepadAxis.DpadX: return("Dpad Horizontal"); case GamepadAxis.DpadY: return("Dpad Vertical"); case GamepadAxis.Triggers: return("Triggers"); } return(null); }
public EventData(EventType t) { type = t; key = KeyConstant.Unknown; scancode = Scancode.Unknow; joystick = null; direction = JoystickHat.Centered; gamepadButton = GamepadButton.A; gamepadAxis = GamepadAxis.LeftX; text = null; flag = false; fx = 0; fy = 0; fz = 0; fw = 0; fp = 0; idx = 0; idy = 0; lid = 0; }
public bool GetAxisAsButtonUp(GamepadAxis axis, int playerNumber, PositiveNegativeAxis whichDirection) { var mapping = this.AxisToButtonStates.Where(state => state.BelongingMapping == this.PlayerMappings[playerNumber] && state.Axis == axis && state.DoesAxisMatter == whichDirection).ToList(); if (mapping.Count != 0) { return(!mapping[0].PressedInCurrentFrame && mapping[0].PressedLastFrame); } else { //Add to list (Basically "subscribe" to it var newAxisState = new AxisState() { BelongingMapping = this.PlayerMappings[playerNumber], Axis = axis, DoesAxisMatter = whichDirection }; if (this.PlayerMappings[playerNumber].OverridesAxisReading) { float value = this.PlayerMappings[playerNumber].OverrideAxisReading(axis); newAxisState.PressedInCurrentFrame = value != 0; } else { GamepadAxisInfo info = this.PlayerMappings[playerNumber].AxisBindingLookupTable[axis]; float value = Input.GetAxisRaw(info.AxisName); int multiplier = whichDirection == PositiveNegativeAxis.Negative ? -1 : 1; if (multiplier < 0) { newAxisState.PressedInCurrentFrame = value < info.UnpressedValue + (multiplier * info.DeadZoneOffset); } else { newAxisState.PressedInCurrentFrame = value > info.UnpressedValue + (multiplier * info.DeadZoneOffset); } } //newAxisState.PressedInCurrentFrame = value > info.UnpressedValue + (multiplier * info.DeadZoneOffset); this.AxisToButtonStates.Add(newAxisState); return(!newAxisState.PressedInCurrentFrame && newAxisState.PressedLastFrame); } }
public void AddAxis(string a_buttonName, GamepadAxis a_axis, float a_deadzone, bool a_inverted = false) { InputAction action = new InputAction { name = a_buttonName, inputType = InputType.Axis, axisName = a_axis.ToString(), deadzone = a_deadzone, inverted = a_inverted }; var id = GetId(a_buttonName); if (id != -1) { m_inputList[id] = action; } else { m_inputList.Add(action); } }
bool ScanJoystickAxis() { int axes = 8; for (int i = 0; i < axes; i++) { GamepadAxis axis = (GamepadAxis)i; for (int x = 0; x < InputBinding.MAX_JOYSTICKS; x++) { float axisRaw = InputManager.Gamepad.GetAxisRaw(axis, x); if (Mathf.Abs(axisRaw) >= 1.0f) { if (m_scanHandler(ScanResult.GamepadAxisResult(axis, axisRaw))) { return(EndScan()); } } } } return(false); }
public void Copy(InputBinding source) { m_positive = source.m_positive; m_negative = source.m_negative; m_deadZone = source.m_deadZone; m_gravity = source.m_gravity; m_sensitivity = source.m_sensitivity; m_snap = source.m_snap; m_invert = source.m_invert; useNegativeAxisForButton = source.useNegativeAxisForButton; m_type = source.m_type; rebindable = source.rebindable; sensitivityEditable = source.sensitivityEditable; invertEditable = source.invertEditable; mouseAxis = source.mouseAxis; m_gamepadAxis = source.m_gamepadAxis; m_gamepadButton = source.m_gamepadButton; }
static bool ScanJoystickAxis(int numJoysticks) { int axes = 8; for (int i = 0; i < axes; i++) { GamepadAxis axis = (GamepadAxis)i; for (int x = 0; x < numJoysticks; x++) { float axisRaw = GamepadHandler.GetAxisRaw(axis, x, .2f); if (Mathf.Abs(axisRaw) >= 1.0f) { if (scanHandler(ScanResult.GamepadAxisResult(axis, axisRaw))) { return(EndScan()); } } } } return(false); }
public override float GetGamepadAxisRaw(IGamepadController gamepad, GamepadAxis axis) { var axisValue = GetGamepadAxisRaw(gamepad, GetGamepadAxisRawMapping(axis)); #if UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX if (axis == GamepadAxis.D_Pad_Left || axis == GamepadAxis.D_Pad_Top || axis == GamepadAxis.L_Stick_Left || axis == GamepadAxis.L_Stick_Top || axis == GamepadAxis.R_Stick_Left || axis == GamepadAxis.R_Stick_Top) { axisValue *= -1; } #elif UNITY_STANDALONE_WIN if (axis == GamepadAxis.D_Pad_Left || axis == GamepadAxis.L_Stick_Left || axis == GamepadAxis.L_Stick_Top || axis == GamepadAxis.R_Stick_Left || axis == GamepadAxis.R_Stick_Top) { axisValue *= -1; } #endif return(axisValue); }
/// <summary> /// Mimics an axis to act like a button. This is useful for triggers on controllers like PS4 or Xbox, where you want the triggers to be a button, and not an analog value /// </summary> /// <param name="axis"></param> /// <param name="playerNumber"></param> /// <returns></returns> public bool GetAxisAsButtonDown(GamepadAxis axis, int playerNumber) { var mapping = this.AxisToButtonStates.Where(state => state.BelongingMapping == this.PlayerMappings[playerNumber] && state.Axis == axis && state.DoesAxisMatter == PositiveNegativeAxis.Indifferent).ToList(); if (mapping.Count != 0) { return(mapping[0].PressedInCurrentFrame && !mapping[0].PressedLastFrame); } else { //Add to list (Basically "subscribe" to it) var newAxisState = new AxisState() { BelongingMapping = this.PlayerMappings[playerNumber], Axis = axis }; if (this.PlayerMappings[playerNumber].OverridesAxisReading) { float value = this.PlayerMappings[playerNumber].OverrideAxisReading(axis); newAxisState.PressedInCurrentFrame = value != 0; } else { GamepadAxisInfo info = this.PlayerMappings[playerNumber].AxisBindingLookupTable[axis]; float value = this.GetAxisValue(axis, playerNumber); int multiplier = value >= info.UnpressedValue ? 1 : -1; if (multiplier < 0) { newAxisState.PressedInCurrentFrame = value < info.UnpressedValue + (multiplier * info.DeadZoneOffset); } else { newAxisState.PressedInCurrentFrame = value > info.UnpressedValue + (multiplier * info.DeadZoneOffset); } } this.AxisToButtonStates.Add(newAxisState); return(newAxisState.PressedInCurrentFrame); } }
public float this[GamepadAxis axis] { get { switch (axis) { case GamepadAxis.LeftTrigger: return(MathF.Clamp(this.state.Triggers.Left, 0.0f, 1.0f)); case GamepadAxis.LeftThumbstickX: return(MathF.Clamp(this.state.ThumbSticks.Left.X, -1.0f, 1.0f)); case GamepadAxis.LeftThumbstickY: return(MathF.Clamp(this.state.ThumbSticks.Left.Y, -1.0f, 1.0f)); case GamepadAxis.RightTrigger: return(MathF.Clamp(this.state.Triggers.Right, 0.0f, 1.0f)); case GamepadAxis.RightThumbstickX: return(MathF.Clamp(this.state.ThumbSticks.Right.X, -1.0f, 1.0f)); case GamepadAxis.RightThumbstickY: return(MathF.Clamp(this.state.ThumbSticks.Right.Y, -1.0f, 1.0f)); default: return(0.0f); } } }
public static bool IsGamepadAxisChange(this Joystick joy, GamepadAxis axis) { if (currentAxisMemory.TryGetValue(joy, out var currValue) && lastAxisMemory.TryGetValue(joy, out var lastValue)) { switch (axis) { case GamepadAxis.LeftX: return(currValue.LeftX != lastValue.LeftX); case GamepadAxis.LeftY: return(currValue.LeftY != lastValue.LeftY); case GamepadAxis.RightX: return(currValue.RightX != lastValue.RightX); case GamepadAxis.RightY: return(currValue.RightY != lastValue.RightY); case GamepadAxis.TriggerLeft: return(currValue.TriggerLeft != lastValue.TriggerLeft); case GamepadAxis.TriggerRight: return(currValue.TriggerRight != lastValue.TriggerRight); } } return(false); }
float GetGpadAxis(E_Input inp) { JoyInput inpButton = GamepadInputManager.Instance.GetActionButton(inp); string axisName = GamepadAxis.GetAxis(inpButton.joyAxis); if (axisName != "") { //invert up axis for looking if (inp == E_Input.Axis_ViewUp) { return(-Input.GetAxis(axisName)); } else { return(Input.GetAxis(axisName)); } } else { if (inp == E_Input.Axis_MoveRight) { return(Input.GetAxis("HorizontalMove")); } else if (inp == E_Input.Axis_MoveUp) { return(Input.GetAxis("VerticalMove")); } else if (inp == E_Input.Axis_ViewRight) { return(Input.GetAxis("HorizontalView")); } else if (inp == E_Input.Axis_ViewUp) { return(Input.GetAxis("VerticalView")); } } return(0); }
public static string GetButtonLabel(JoyInput command) { if (command.joyAxis != E_JoystickAxis.NONE) { return(GamepadAxis.GetAxisLabel(command.joyAxis)); } else { #if MADFINGER_KEYBOARD_MOUSE switch (command.key) { case KeyCode.Mouse0: return("Mouse Left"); case KeyCode.Mouse1: return("Mouse Right"); case KeyCode.Mouse5: return("Mouse Wheel Down"); case KeyCode.Mouse6: return("Mouse Wheel Up"); } #endif string keyName = command.key.ToString(); if (keyName.StartsWith("Joystick0") || keyName.StartsWith("Joystick1") || keyName.StartsWith("Joystick2") || keyName.StartsWith("Joystick3") || keyName.StartsWith("Joystick4")) { keyName = keyName.Substring(9); } else if (keyName.StartsWith("Joystick")) { keyName = keyName.Substring(8); } return(keyName); } }
public override float OverrideAxisReading(GamepadAxis axis) { if (axis == GamepadAxis.RightHorizontal) { RaycastHit mouseHit; RaycastHit centerHit; Ray rayMouse = Camera.main.ScreenPointToRay(Input.mousePosition); Ray rayCenter = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2)); if (Physics.Raycast(rayMouse, out mouseHit, Mathf.Infinity, 1 << 8) && Physics.Raycast(rayCenter, out centerHit, Mathf.Infinity, 1 << 8)) { return(mouseHit.point.x - centerHit.point.x); } return(0.0f); } else if (axis == GamepadAxis.RightVertical) { RaycastHit mouseHit; RaycastHit centerHit; Ray rayMouse = Camera.main.ScreenPointToRay(Input.mousePosition); Ray rayCenter = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2)); if (Physics.Raycast(rayMouse, out mouseHit, Mathf.Infinity, 1 << 8) && Physics.Raycast(rayCenter, out centerHit, Mathf.Infinity, 1 << 8)) { return(mouseHit.point.z - centerHit.point.z); } return(0.0f); } else { float floatToReturn = 0.0f; foreach (var key in this.axisOverrides[axis]) { floatToReturn += Input.GetKey(key.VirtualButton) ? 1.0f * key.NegativePositiveMultiplier : 0.0f; } return(floatToReturn); } }
private static string GetPromptImagePath(this GamepadAxis axis, GamepadType type) { if (type == GamepadType.Unknown) { type = GamepadType.Xbox360; } string buttonName; switch (axis) { case GamepadAxis.LeftStickX: case GamepadAxis.LeftStickY: { buttonName = "left_stick"; break; } case GamepadAxis.RightStickX: case GamepadAxis.RightStickY: { buttonName = "right_stick"; break; } default: { buttonName = axis.ToString().ToLowerUnderscored(); break; } } return(AssetPath.Combine( "gui/prompts/" + type.ToString().ToLowerUnderscored(), buttonName + ".png" )); }
public int GetAxis(GamepadAxis axis) { switch (axis) { case GamepadAxis.StickLeftX: return(_controller.LeftThumbStick.X / 256); case GamepadAxis.StickLeftY: return(-_controller.LeftThumbStick.Y / 256); case GamepadAxis.StickRightX: return(_controller.RightThumbStick.X / 256); case GamepadAxis.StickRightY: return(-_controller.RightThumbStick.Y / 256); case GamepadAxis.TriggerLeft: return(_controller.LeftTrigger); case GamepadAxis.TriggerRight: return(_controller.RightTrigger); } return(0); }
public override float GetAxis(GamepadAxis axis) { switch (axis) { case GamepadAxis.LeftStickX: return(state.ThumbSticks.Left.X); case GamepadAxis.LeftStickY: return(state.ThumbSticks.Left.Y); case GamepadAxis.RightStickX: return(state.ThumbSticks.Right.X); case GamepadAxis.RightStickY: return(state.ThumbSticks.Right.Y); case GamepadAxis.LeftTrigger: return(GetTrigger(GamepadTrigger.Left)); case GamepadAxis.RightTrigger: return(GetTrigger(GamepadTrigger.Right)); } return(0); }
public int GetAxis(GamepadAxis axis) { if (Ds4 == null || !IsAlive()) return 0; var cState = Ds4.getCurrentState(); switch (axis) { case GamepadAxis.StickLeftX: return cState.LX - 127; case GamepadAxis.StickLeftY: return cState.LY - 127; case GamepadAxis.StickRightX: return cState.RX - 127; case GamepadAxis.StickRightY: return cState.RY - 127; case GamepadAxis.TriggerLeft: return cState.L2; case GamepadAxis.TriggerRight: return cState.R2; default: return 0; } }
//must be called every frame void OnUpdate() { int numAxis = (int)E_JoystickAxis.COUNT; for (int i = 0; i < numAxis; i++) { float axisVal = Input.GetAxis(GamepadAxis.GetAxis((E_JoystickAxis)i)); if (m_WasAxisPressed[i] == false && axisVal > 0.65f) { m_WasAxisPressed[i] = true; m_AxisDown[i] = true; } else if (m_WasAxisPressed[i] == true && axisVal < 0.25f) { m_WasAxisPressed[i] = false; m_AxisUp[i] = true; } else { m_AxisDown[i] = false; m_AxisUp[i] = false; } } }
public JoystickAxis(GamepadAxis axis, float exponent, float multiplier) { m_axis = axis; m_exponent = exponent; m_multiplier = multiplier; }
/// <summary> /// Called when a Joystick's virtual gamepad axis is moved. /// </summary> /// <param name="joystick">The joystick object.</param> /// <param name="axis">The virtual gamepad axis.</param> /// <param name="value">The new axis value.</param> public virtual void JoystickGamepadAxis(Joystick joystick, GamepadAxis axis, float value) { }
public override float GetAxis (GamepadAxis axis) { switch(axis) { case GamepadAxis.LeftStickX: return state.ThumbSticks.Left.X; case GamepadAxis.LeftStickY: return state.ThumbSticks.Left.Y; case GamepadAxis.RightStickX: return state.ThumbSticks.Right.X; case GamepadAxis.RightStickY: return state.ThumbSticks.Right.Y; case GamepadAxis.LeftTrigger: return GetTrigger(GamepadTrigger.Left); case GamepadAxis.RightTrigger: return GetTrigger(GamepadTrigger.Right); } return 0; }
public GamepadAxisEventArgs(GamepadInput inputChannel, GamepadAxis axis, float axisValue, float axisDelta) : base(inputChannel) { this.axis = axis; this.axisValue = axisValue; this.axisDelta = axisDelta; }
/// <summary> /// Returns the specified axis value change since last frame. /// </summary> /// <param name="axis"></param> /// <returns></returns> public float AxisSpeed(GamepadAxis axis) { return(this.currentState.AxisValue[(int)axis] - this.lastState.AxisValue[(int)axis]); }
public GamepadAxisEventArgs(GamepadAxis axis, float axisValue, float axisDelta) { this.axis = axis; this.axisValue = axisValue; this.axisDelta = axisDelta; }
public float GetAxisRaw(GamepadAxis axis, GamepadIndex gamepad) { float value = GetAxis(axis, gamepad); return(Mathf.Approximately(value, 0) ? 0.0f : Mathf.Sign(value)); }
/// <summary> /// [GET] Returns the specified gamepad axis current value. /// </summary> /// <param name="axis"></param> /// <returns></returns> public float this[GamepadAxis axis] { get { return this.currentState.AxisValue[(int)axis]; } }
public override float GetAxis (GamepadAxis axis) { float value = currentState.GetAxis (axis); return Mathf.InverseLerp (config.deadZone, 1, Mathf.Abs (value)) * Mathf.Sign (value); }
/// <summary> /// Returns the specified axis value change since last frame. /// </summary> /// <param name="axis"></param> /// <returns></returns> public float AxisSpeed(GamepadAxis axis) { return this.currentState.AxisValue[(int)axis] - this.lastState.AxisValue[(int)axis]; }
public float GetAxisRaw(GamepadAxis axis, int gamepad) { float value = GetAxis(axis, gamepad); return(Mathf.RoundToInt(value));// Mathf.Approximately(value, 0) ? 0.0f : Mathf.Sign(value); }
public abstract float GetAxis (GamepadAxis axis);
private static bool OverThreshold(GamepadAxis axis, float threshold) { return JoystickAxis.GetAxisValue(axis) / threshold > 1; }
public float GetAxis (GamepadAxis axisType) { switch (axisType) { case GamepadAxis.LeftStickX: return GetInputValue (UnGamepadConfig.InputTarget.LeftStickX); case GamepadAxis.LeftStickY: return GetInputValue (UnGamepadConfig.InputTarget.LeftStickY); case GamepadAxis.RightStickX: return GetInputValue (UnGamepadConfig.InputTarget.RightStickX); case GamepadAxis.RightStickY: return GetInputValue (UnGamepadConfig.InputTarget.RightStickY); case GamepadAxis.LeftTrigger: return GetTrigger(GamepadTrigger.Left); case GamepadAxis.RightTrigger: return GetTrigger(GamepadTrigger.Right); } throw new UnityException (); }
/// <summary> /// Called when gamepad axis is moved. /// </summary> /// <param name="axis">The gamepad axis.</param> public virtual void OnGamepadAxis(GamepadAxis axis) { }