Esempio n. 1
0
        protected override float ImpGetAxis(AxisCode axis)
        {
            InputControl tmp    = GetInputControlAxis(_inputDevice, axis);
            float        aValue = 0;
            float        dZone  = 0;

            if (tmp != null)
            {
                AxisControl aControl = null;

                if (axis == AxisCode.LeftStick_Horizontal || axis == AxisCode.RightStick_Horizontal)
                {
                    aControl = ((Vector2Control)tmp).x;
                    dZone    = _deadZoneThumbStick;
                }
                else if (axis == AxisCode.LeftStick_Vertical || axis == AxisCode.RightStick_Vertical)
                {
                    aControl = ((Vector2Control)tmp).y;
                    dZone    = _deadZoneThumbStick;
                }
                else
                {
                    aControl = (AxisControl)tmp;
                    dZone    = _deadZoneIndexTrigger;
                }

                aValue = aControl.ReadValue();
            }

            return(Mathf.Abs(aValue) > dZone ? aValue : 0);
        }
Esempio n. 2
0
 /// <summary>
 /// Class is used as help for <code>PlayerInput</code> class to better organisation with passing<br>
 /// arguments to user by AxisCodeerface methods such as <code>TriggerInput</code>.
 /// Use it only, if you know what it should do.</br>
 /// </summary>
 /// <param name="unityInputX">Name of input project settings, make sure that string exists</param>
 /// <param name="code">code of axis, for single axis codes it can be only: LEFT_TRIGGER and RIGHT_TRIGGER that this class contains, so pass them to avoid exception</param>
 /// <param name="deadZoneX">Deadzone of X axis</param>
 public JoystickAxis(PInput input, string unityInputX, AxisCode code, float deadZoneX)
 {
     this.input = input;
     SetCode(code);
     this.unityInputX = unityInputX;
     this.deadZoneX   = deadZoneX;
 }
Esempio n. 3
0
        public static float GetAxis(AxisCode axis)
        {
            XRController controller = GetXRController(axis);

            if (controller != null)
            {
                InputControl tmp      = GetInputControlAxis(controller, axis);
                AxisControl  aControl = null;

                if (axis == AxisCode.LeftStick_Horizontal || axis == AxisCode.RightStick_Horizontal)
                {
                    aControl = ((Vector2Control)tmp).x;
                }
                else if (axis == AxisCode.LeftStick_Vertical || axis == AxisCode.RightStick_Vertical)
                {
                    aControl = ((Vector2Control)tmp).y;
                }
                else
                {
                    aControl = (AxisControl)tmp;
                }

                return(aControl.ReadValue());
            }

            return(0);
        }
Esempio n. 4
0
        public float GetAxis(AxisCode axis)
        {
            if ((int)axis < 450)
            {
                //TODO: Feels bad man
                return(GetButton((ActionKeyCode)((int)axis)) ? 1 : 0);
            }
            switch (axis)
            {
            case AxisCode.GamepadAxisRightX:
                return(CurrentState.ThumbSticks.Right.X);

            case AxisCode.GamepadAxisRightY:
                return(CurrentState.ThumbSticks.Right.Y);

            case AxisCode.GamepadAxisLeftX:
                return(CurrentState.ThumbSticks.Left.X);

            case AxisCode.GamepadAxisLeftY:
                return(CurrentState.ThumbSticks.Left.Y);

            case AxisCode.GamepadAxisRightTrigger:
                return(CurrentState.Triggers.Right);

            case AxisCode.GamepadAxisLeftTrigger:
                return(CurrentState.Triggers.Left);

            default:
                Debug.LogError("Not a Gamepad Axis");
                break;
            }
            return(0.0f);
        }
Esempio n. 5
0
        public float GetKeyY(AxisCode code)
        {
            // In each case, we checks if button on up or down is pressed, if user holds
            // two buttons in the same time, it results zero
            float result = 0;

            switch (code)
            {
            case AxisCode.LeftStick:
                result += (Input.GetKey(LeftStick_DY) ? -1 : 0) + (Input.GetKey(LeftStick_UY) ? 1 : 0);
                break;

            case AxisCode.RightStick:
                result += (Input.GetKey(RightStick_DY) ? -1 : 0) + (Input.GetKey(RightStick_UY) ? 1 : 0);
                break;

            case AxisCode.Arrows:
                result += (Input.GetKey(Arrows_DY) ? -1 : 0) + (Input.GetKey(Arrows_UY) ? 1 : 0);
                break;

            default:
                throw new System.Exception("Wrong AxisCode - KeyboardSettings::GetKeyY");
            }
            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// Constructs a new <see cref="ControllerAxis"/> using the given code.
        /// </summary>
        /// <param name="controller">The controller's device ID.</param>
        /// <param name="code">The code for the axis represented by this <see cref="ControllerAxis"/>.</param>
        public ControllerAxis(int controller, AxisCode code)
        {
            Assert.Index(controller, Core.Input.ControllersMax);

            this.controller = controller;
            this.code       = code;
        }
Esempio n. 7
0
    public static bool Up(AxisCode input, bool firstFixedOnly = true)
    {
        if (checkInput || !firstFixedOnly)
        {
            return((axisStates[(int)input - firstAxisCodeValue] & AxisState.Up) == AxisState.Up);
        }

        return(false);
    }
Esempio n. 8
0
        public override float GetAxis(AxisCode ac)
        {
            if (!_axisMapping.ContainsKey(ac))
            {
                return(0.0f);
            }

            return(Input.GetAxis(_axisMapping[ac]));
        }
Esempio n. 9
0
        public void SetKey(string uniqueKeyName, AxisCode joystickAxis, TargetController targetController = TargetController.All)
        {
            int i = GetUniqueIndex(uniqueKeyName);

            inputs[i].Type             = KeyType.ControllerAxis;
            inputs[i].Axis             = joystickAxis;
            inputs[i].targetController = targetController;

            hUtility.SaveBinings(inputs);
        }
    void AddAxisInAxisInput(TCT_AxisInput _action, AxisCode _key)
    {
        if (_action.AllAxisCode.Any(n => n == AxisCode.None))
        {
            Debug.LogWarning("A axis is not assign. Please assign it to get an other key");
            return;
        }

        _action.AddKey(_key);
    }
Esempio n. 11
0
        private static InputControl GetInputControlAxis(XRController controller, AxisCode axis)
        {
            InputControl result = null;

            string[] values = _toAxisControl[axis];
            for (int i = 0; result == null && i < values.Length; i++)
            {
                result = controller.TryGetChildControl(values[i]);
            }

            return(result);
        }
 float GetRawAxis(AxisCode axis)
 {
     if ((int)axis < 400)
     {
         return(Input.GetKeyUp((KeyCode)((int)axis)) ? 1f : 0f);
     }
     else if ((int)axis > 500)
     {
         Input.GetAxisRaw(AxisLookup(axis));
     }
     return(0f);
 }
Esempio n. 13
0
        public override float GetAxis(AxisCode ac)
        {
            if(!_axisMapping.ContainsKey(ac))
                return 0.0f;
            if(trackedObj.index == SteamVR_TrackedObject.EIndex.None)
                return 0.0f;

            var device = SteamVR_Controller.Input((int)trackedObj.index);

            // todo:    use a struct for us to define if we want to map x or y from the device.GetAxis method
            return device.GetAxis(_axisMapping[ac]).x;
        }
Esempio n. 14
0
        public KeyCode GetKey(AxisCode code)
        {
            switch (code)
            {
            case AxisCode.LeftTrigger:
                return(LeftTrigger);

            case AxisCode.RightTrigger:
                return(RightTrigger);

            default:
                throw new System.Exception("Wrong AxisCode - KeyboardSettings::GetKey");
            }
        }
Esempio n. 15
0
        protected override void SetCode(AxisCode code)
        {
            this.code = code;
            switch (code)
            {
            case AxisCode.LeftStick:
            case AxisCode.RightStick:
            case AxisCode.Arrows:
                break;

            default:
                throw new System.Exception("JoystickDoubleAxis::SetCode::(Wrong type parameter, you should use " +
                                           "LeftStick, RightStick or Arrows to initialize double axis)");
            }
        }
        private string AxisLookup(AxisCode axis)
        {
            switch (axis)
            {
            case AxisCode.MouseX:
                return("Mouse X");

            case AxisCode.MouseY:
                return("Mouse y");

            default:
                Debug.LogError("Not a mouse axis");
                return("");
            }
        }
Esempio n. 17
0
        protected override float ImpGetAxis(AxisCode axis)
        {
            float result = 0;

            if (axis == AxisCode.HorizontalDelta)
            {
                result = _inputDevice.delta.x.ReadValue() * _mouseSensitivity;
            }
            else if (axis == AxisCode.VerticalDelta)
            {
                result = _inputDevice.delta.y.ReadValue() * _mouseSensitivity;
            }

            return(result);
        }
Esempio n. 18
0
        protected virtual void SetCode(AxisCode code)
        {
            // When user pass wrong argument then it throws excpetion
            this.code = code;
            switch (code)
            {
            case AxisCode.LeftTrigger:
            case AxisCode.RightTrigger:
                break;

            default:
                throw new System.Exception("JoystickAxis::SetCode::(Wrong code parameter, you should use " +
                                           "LeftTrigger or RightTrigger to initialize single axis)");
            }
        }
Esempio n. 19
0
    public static float Axis(AxisCode input, bool firstFixedOnly = false)
    {
        if (!firstFixedOnly || checkInput)
        {
            if (settings.trackAxisStates)
            {
                return(axisValues[(int)input - firstAxisCodeValue]);
            }
            else
            {
                return(Input.GetAxis(((AxisCode)input).ToString()));
            }
        }

        return(0);
    }
Esempio n. 20
0
    public static bool Pressed(AxisCode input, bool firstFixedOnly = false)
    {
        if (!firstFixedOnly || checkInput)
        {
            if (settings.trackAxisStates)
            {
                return((axisStates[(int)input - firstAxisCodeValue] & AxisState.Pressed) == AxisState.Pressed);
            }
            else
            {
                return(Input.GetAxisRaw(((AxisCode)input).ToString()) != 0);
            }
        }

        return(false);
    }
    public static float GetAxis(AxisCode _axisCode, float _sensibility = 1, float _deadZone = 0)
    {
        switch (_axisCode)
        {
        case AxisCode.MouseX:
            return(MouseX(_sensibility, _deadZone));

        case AxisCode.MouseY:
            return(MouseY(_sensibility, _deadZone));

        default:
            break;
        }

        return(0);
    }
Esempio n. 22
0
        public override float GetAxis(AxisCode ac)
        {
            if (!_axisMapping.ContainsKey(ac))
            {
                return(0.0f);
            }
            if (trackedObj.index == SteamVR_TrackedObject.EIndex.None)
            {
                return(0.0f);
            }

            var device = SteamVR_Controller.Input((int)trackedObj.index);


            // todo:    use a struct for us to define if we want to map x or y from the device.GetAxis method
            return(device.GetAxis(_axisMapping[ac]).x);
        }
 float GetSmoothedAxis(AxisCode axis)
 {
     if ((int)axis < 400)
     {
         return(Input.GetKeyUp((KeyCode)((int)axis)) ? 1f : 0f);
     }
     else if ((int)axis > 500)
     {
         if (!LockCursor)
         {
             return(Input.GetAxisRaw(AxisLookup(axis)));
         }
         else
         {
         }
     }
     return(0f);
 }
Esempio n. 24
0
        protected override float ImpGetAxis(AxisCode axis)
        {
            float result = 0;

            //Left Stick
            if (axis == AxisCode.LeftStick_Horizontal)
            {
                float f = _inputDevice.leftStick.right.ReadValue();
                result = f > 0 ? f : -1 * _inputDevice.leftStick.left.ReadValue();
            }
            else if (axis == AxisCode.LeftStick_Vertical)
            {
                float f = _inputDevice.leftStick.up.ReadValue();
                result = f > 0 ? f : -1 * _inputDevice.leftStick.down.ReadValue();
            }

            //Right Stick
            else if (axis == AxisCode.RightStick_Horizontal)
            {
                float f = _inputDevice.rightStick.right.ReadValue();
                result = f > 0 ? f : -1 * _inputDevice.rightStick.left.ReadValue();
            }
            else if (axis == AxisCode.RightStick_Vertical)
            {
                float f = _inputDevice.rightStick.up.ReadValue();
                result = f > 0 ? f : -1 * _inputDevice.rightStick.down.ReadValue();
            }

            //Left Trigger
            else if (axis == AxisCode.LeftTrigger)
            {
                result = _inputDevice.leftTrigger.ReadValue();
            }

            //Right Trigger
            else if (axis == AxisCode.RightTrigger)
            {
                result = _inputDevice.rightTrigger.ReadValue();
            }

            return(Mathf.Abs(result) > _deadZone ? result : 0);
        }
Esempio n. 25
0
        /// <summary>
        /// Checks if axis is in dead zone
        /// </summary>
        /// <param name="code">Code of axis</param>
        /// <returns>TRUE if is in dead zone, otherwise returns FALSE</returns>
        public bool IsInDeadZone(AxisCode code)
        {
            switch (code)
            {
            case AxisCode.LeftStick:
                return(IsInDead(leftStick.X, leftStick.DeadZoneX) && IsInDead(leftStick.Y, leftStick.DeadZoneY));

            case AxisCode.RightStick:
                return(IsInDead(rightStick.X, rightStick.DeadZoneX) && IsInDead(rightStick.Y, rightStick.DeadZoneY));

            case AxisCode.Arrows:
                return(IsInDead(arrows.X, arrows.DeadZoneX) && IsInDead(arrows.Y, arrows.DeadZoneY));

            case AxisCode.LeftTrigger:
                return(IsBelowDead(leftTrigger.X, leftTrigger.DeadZoneX));

            case AxisCode.RightTrigger:
                return(IsBelowDead(rightTrigger.X, rightTrigger.DeadZoneX));
            }
            return(false);
        }
Esempio n. 26
0
 public override float GetAxis(AxisCode ac)
 {
     throw new NotImplementedException();
 }
Esempio n. 27
0
 private static XRController GetXRController(AxisCode axis)
 {
     return(axis <= AxisCode.LeftGrip ? XRController.leftHand : XRController.rightHand);
 }
Esempio n. 28
0
 public static void SetKey(string uniqueKeyName, AxisCode joystickAxis, TargetController targetController = TargetController.All)
 {
     hManager.Active().SetKey(uniqueKeyName, joystickAxis, targetController);
 }
Esempio n. 29
0
        /// <summary>
        /// Reads the current value of a controller axis.
        /// </summary>
        /// <param name="id">The device ID of the controller to read.</param>
        /// <param name="axis">The <see cref="AxisCode"/> representing the axis to read.</param>
        /// <returns>The current position value of the axis.</returns>
        public short GetAxisValue(int id, AxisCode axis)
        {
            Assert.Index(id, Core.Input.ControllersMax);

            return(coreState.Controllers[id].Axes[(int)(axis)]);
        }
 void RemoveAxisCode(TCT_AxisInput _axis, AxisCode _code)
 {
     _axis.RemoveKey(_code);
 }
Esempio n. 31
0
 public JoystickDoubleAxis(PInput input, string unityInputX, string unityInputY, AxisCode code, float deadZoneX, float deadZoneY) : base(input, unityInputX, code, deadZoneX)
 {
     this.unityInputY = unityInputY;
     this.deadZoneY   = deadZoneY;
 }
Esempio n. 32
0
 // get value of this axis
 public abstract float GetAxis(AxisCode ac);
Esempio n. 33
0
 // get value of this axis
 public abstract float GetAxis(AxisCode ac);