Example #1
0
		public InputDevice( string name )
		{
			Name = name;
			Meta = "";

			LastChangeTick = 0;

			const int numInputControlTypes = (int) InputControlType.Count + 1;
			Controls = new InputControl[numInputControlTypes];

			LeftStickX = new OneAxisInputControl();
			LeftStickY = new OneAxisInputControl();
			LeftStick = new TwoAxisInputControl();
			LeftStick.LowerDeadZone = 0.2f;

			RightStickX = new OneAxisInputControl();
			RightStickY = new OneAxisInputControl();
			RightStick = new TwoAxisInputControl();
			RightStick.LowerDeadZone = 0.2f;

			DPadX = new OneAxisInputControl();
			DPadY = new OneAxisInputControl();
			DPad = new TwoAxisInputControl();
			DPad.LowerDeadZone = 0.2f;

			Command = AddControl( InputControlType.Command, "Command" );
		}
Example #2
0
        public InputDevice(string name)
        {
            Name = name;
            Meta = "";

            LastChangeTick = 0;

            const int numInputControlTypes = (int)InputControlType.Count + 1;

            Controls = new InputControl[numInputControlTypes];

            LeftStickX = new OneAxisInputControl();
            LeftStickY = new OneAxisInputControl();
            LeftStick  = new TwoAxisInputControl();
            LeftStick.LowerDeadZone = 0.2f;

            RightStickX = new OneAxisInputControl();
            RightStickY = new OneAxisInputControl();
            RightStick  = new TwoAxisInputControl();
            RightStick.LowerDeadZone = 0.2f;

            DPadX = new OneAxisInputControl();
            DPadY = new OneAxisInputControl();
            DPad  = new TwoAxisInputControl();
            DPad.LowerDeadZone = 0.2f;

            Command = AddControl(InputControlType.Command, "Command");
        }
Example #3
0
        void AddAliasControls()
        {
            RemoveAliasControls();

            if (IsKnown)
            {
                LeftStick  = new TwoAxisInputControl();
                RightStick = new TwoAxisInputControl();
                DPad       = new TwoAxisInputControl();

                AddControl(InputControlType.LeftStickX, "Left Stick X");
                AddControl(InputControlType.LeftStickY, "Left Stick Y");
                AddControl(InputControlType.RightStickX, "Right Stick X");
                AddControl(InputControlType.RightStickY, "Right Stick Y");
                AddControl(InputControlType.DPadX, "DPad X");
                AddControl(InputControlType.DPadY, "DPad Y");

#if UNITY_PS4
                AddControl(InputControlType.Command, "OPTIONS button");
#else
                AddControl(InputControlType.Command, "Command");
#endif

                ExpireControlCache();
            }
        }
Example #4
0
        public InputDevice( string name )
        {
            Name = name;
            Meta = "";

            LastChangeTick = 0;

            const int numInputControlTypes = (int) InputControlType.Count + 1;
            Controls = new InputControl[numInputControlTypes];

            LeftStick = new TwoAxisInputControl();
            RightStick = new TwoAxisInputControl();
            DPad = new TwoAxisInputControl();
        }
        public InputDevice(string name)
        {
            Name = name;
            Meta = "";

            LastChangeTick = 0;

            int numInputControlTypes = Enum.GetValues(typeof(InputControlTarget)).Length;
            Controls = new InputControl[numInputControlTypes];

            LeftStick = new TwoAxisInputControl();
            RightStick = new TwoAxisInputControl();
            DPad = new TwoAxisInputControl();
        }
Example #6
0
        public InputDevice(string name)
        {
            Name = name;
            Meta = "";

            LastChangeTick = 0;

            const int numInputControlTypes = (int)InputControlType.Count + 1;

            Controls = new InputControl[numInputControlTypes];

            LeftStick  = new TwoAxisInputControl();
            RightStick = new TwoAxisInputControl();
            DPad       = new TwoAxisInputControl();
        }
Example #7
0
        void RemoveAliasControls()
        {
            LeftStick  = TwoAxisInputControl.Null;
            RightStick = TwoAxisInputControl.Null;
            DPad       = TwoAxisInputControl.Null;

            RemoveControl(InputControlType.LeftStickX);
            RemoveControl(InputControlType.LeftStickY);
            RemoveControl(InputControlType.RightStickX);
            RemoveControl(InputControlType.RightStickY);
            RemoveControl(InputControlType.DPadX);
            RemoveControl(InputControlType.DPadY);
            RemoveControl(InputControlType.Command);

            ExpireControlCache();
        }
        void UpdateInputState()
        {
            lastVectorState = thisVectorState;
            thisVectorState = Vector2.zero;

            TwoAxisInputControl dir = MoveAction ?? direction;

            if (Utility.AbsoluteIsOverThreshold(dir.X, analogMoveThreshold))
            {
                thisVectorState.x = Mathf.Sign(dir.X);
            }

            if (Utility.AbsoluteIsOverThreshold(dir.Y, analogMoveThreshold))
            {
                thisVectorState.y = Mathf.Sign(dir.Y);
            }

            if (VectorIsReleased)
            {
                nextMoveRepeatTime = 0.0f;
            }

            if (VectorIsPressed)
            {
                if (lastVectorState == Vector2.zero)
                {
                    if (Time.realtimeSinceStartup > lastVectorPressedTime + 0.1f)
                    {
                        nextMoveRepeatTime = Time.realtimeSinceStartup + moveRepeatFirstDuration;
                    }
                    else
                    {
                        nextMoveRepeatTime = Time.realtimeSinceStartup + moveRepeatDelayDuration;
                    }
                }

                lastVectorPressedTime = Time.realtimeSinceStartup;
            }

            lastSubmitState = thisSubmitState;
            thisSubmitState = SubmitAction == null ? SubmitButton.IsPressed : SubmitAction.IsPressed;

            lastCancelState = thisCancelState;
            thisCancelState = CancelAction == null ? CancelButton.IsPressed : CancelAction.IsPressed;
        }
Example #9
0
 private void AddAliasControls()
 {
     RemoveAliasControls();
     if (IsKnown)
     {
         LeftStick  = new TwoAxisInputControl();
         RightStick = new TwoAxisInputControl();
         DPad       = new TwoAxisInputControl();
         AddControl(InputControlType.LeftStickX, "Left Stick X");
         AddControl(InputControlType.LeftStickY, "Left Stick Y");
         AddControl(InputControlType.RightStickX, "Right Stick X");
         AddControl(InputControlType.RightStickY, "Right Stick Y");
         AddControl(InputControlType.DPadX, "DPad X");
         AddControl(InputControlType.DPadY, "DPad Y");
         AddControl(InputControlType.Command, "Command");
         ExpireControlCache();
     }
 }
Example #10
0
        void AddAliasControls()
        {
            RemoveAliasControls();

            if (IsKnown)
            {
                LeftStick  = new TwoAxisInputControl();
                RightStick = new TwoAxisInputControl();

                DPad = new TwoAxisInputControl();
                DPad.DeadZoneFunc = DeadZone.Separate;

                AddControl(InputControlType.LeftStickX, "Left Stick X");
                AddControl(InputControlType.LeftStickY, "Left Stick Y");
                AddControl(InputControlType.RightStickX, "Right Stick X");
                AddControl(InputControlType.RightStickY, "Right Stick Y");
                AddControl(InputControlType.DPadX, "DPad X");
                AddControl(InputControlType.DPadY, "DPad Y");

                                #if UNITY_PS4
                AddControl(InputControlType.Command, "OPTIONS button");
                                #else
                AddControl(InputControlType.Command, "Command");
                                #endif

                LeftCommandControl    = DeviceStyle.LeftCommandControl();
                leftCommandSource     = GetControl(LeftCommandControl);
                hasLeftCommandControl = !leftCommandSource.IsNullControl;
                if (hasLeftCommandControl)
                {
                    AddControl(InputControlType.LeftCommand, leftCommandSource.Handle);
                }

                RightCommandControl    = DeviceStyle.RightCommandControl();
                rightCommandSource     = GetControl(RightCommandControl);
                hasRightCommandControl = !rightCommandSource.IsNullControl;
                if (hasRightCommandControl)
                {
                    AddControl(InputControlType.RightCommand, rightCommandSource.Handle);
                }

                ExpireControlCache();
            }
        }
 protected InControlInputModule()
 {
     direction = new TwoAxisInputControl();
     direction.StateThreshold = analogMoveThreshold;
 }
 // TODO: Is there a better way to handle this? Maybe calculate deltaTime internally.
 public void Filter(TwoAxisInputControl twoAxisInputControl, float deltaTime)
 {
     UpdateWithAxes(twoAxisInputControl.X, twoAxisInputControl.Y, InputManager.CurrentTick, deltaTime);
 }
 protected InControlInputModule()
 {
     direction = new TwoAxisInputControl();
     direction.StateThreshold = analogMoveThreshold;
 }
Example #14
0
    private void CheckController(InputControl trigger, InputControl bumper, InputControl stickButton, TwoAxisInputControl stick, int selectedNum, Ray controller)
    {
        if (trigger.IsPressed)
        {
            if (SelectedObject[selectedNum] == null)
            {
                Collider[] hits = Physics.OverlapSphere(controller.origin, 0.1f, 1 << BuiltLayer); ;
                if (hits.Length > 0)
                {
                    Collider closest = hits.OrderBy(hit => Vector3.Distance(hit.transform.position, controller.origin)).First();
                    SelectedObject[selectedNum] = closest.transform;
                }
                else
                {
                    SelectedObject[selectedNum] = GameObject.CreatePrimitive(PrimitiveType.Cube).transform;
                    SelectedObject[selectedNum].GetComponent<Renderer>().material.color = CurrentColors[selectedNum];
                    SelectedObject[selectedNum].gameObject.layer = BuiltLayer;

                    StartCoroutine(PopIn(SelectedObject[selectedNum]));
                }
            }

            SelectedObject[selectedNum].position = controller.origin;
        }
        else
            SelectedObject[selectedNum] = null;

        if (stickButton.IsPressed)
        {
            if (ColorWheels[selectedNum] == null)
            {
                ColorWheels[selectedNum] = GameObject.Instantiate(ColorWheelPrefab).GetComponent<ColorWheel>();
            }

            CurrentColors[selectedNum] = ColorWheels[selectedNum].Select(stick.Vector);

            if (SelectedObject[selectedNum] != null)
                SelectedObject[selectedNum].GetComponent<Renderer>().material.color = CurrentColors[selectedNum];

            ColorWheels[selectedNum].transform.position = controller.origin;
            ColorWheels[selectedNum].transform.LookAt(KinectManager.Instance.CurrentAvatar.Head);
        }
        else
        {
            if (ColorWheels[selectedNum] != null)
                Destroy(ColorWheels[selectedNum].gameObject);
        }

        if (bumper.IsPressed)
        {
            if (GunAim[selectedNum] == null)
            {
                GunAim[selectedNum] = GameObject.Instantiate(AimPrefab).GetComponent<Aim>();
            }

            GunAim[selectedNum].DoUpdate(controller.origin, controller.direction);
        }
        else
        {
            if (GunAim[selectedNum] != null)
            {
                Destroy(GunAim[selectedNum].gameObject);

                GameObject bullet = GameObject.Instantiate<GameObject>(BulletPrefab);
                bullet.GetComponent<Bullet>().Launch(controller);
            }

        }
    }
 void Awake()
 {
     filteredDirection = new TwoAxisInputControl();
     filteredDirection.StateThreshold = 0.5f;
 }
		// TODO: Is there a better way to handle this? Maybe calculate deltaTime internally.
		public void Filter( TwoAxisInputControl twoAxisInputControl, float deltaTime )
		{
			UpdateWithAxes( twoAxisInputControl.X, twoAxisInputControl.Y, InputManager.CurrentTick, deltaTime );
		}