Exemple #1
0
        private DualShock4DPadDirection MapDPadDirection(DpadDirection dPad)
        {
            switch (dPad)
            {
            case DpadDirection.None: return(DualShock4DPadDirection.None);

            case DpadDirection.North: return(DualShock4DPadDirection.North);

            case DpadDirection.Northeast: return(DualShock4DPadDirection.Northeast);

            case DpadDirection.East: return(DualShock4DPadDirection.East);

            case DpadDirection.Southeast: return(DualShock4DPadDirection.Southeast);

            case DpadDirection.South: return(DualShock4DPadDirection.South);

            case DpadDirection.Southwest: return(DualShock4DPadDirection.Southwest);

            case DpadDirection.West: return(DualShock4DPadDirection.West);

            case DpadDirection.Northwest: return(DualShock4DPadDirection.Northwest);

            default: throw new NotImplementedException();
            }
        }
        public override void Update(GameTime gameTime)
        {
            _touchLocation = TouchPanel.GetState().FirstOrDefault<TouchLocation>();

             	            if (_touchLocation.State == TouchLocationState.Pressed)
             	            {
             	                _intersectRect.X = (int)_touchLocation.Position.X;
             	                _intersectRect.Y = (int)_touchLocation.Position.Y;
             	                _intersectRect.Width = 1;
             	                _intersectRect.Height = 1;

             	                if (_intersectRect.Intersects(_rightRect))
             	                    PressedDirection = DpadDirection.dRIGTH;
             	                else if (_intersectRect.Intersects(_leftRect))
             	                    PressedDirection = DpadDirection.dLEFT;
             	                else if (_intersectRect.Intersects(_upRect))
             	                    PressedDirection = DpadDirection.dUP;
             	                else if (_intersectRect.Intersects(_downRect))
             	                    PressedDirection = DpadDirection.dDOWN;
             	                else
             	                    PressedDirection = DpadDirection.dNONE;

             	            }
             	            else if ((_touchLocation.State == TouchLocationState.Invalid) || (_touchLocation.State == TouchLocationState.Released))
             	                PressedDirection = DpadDirection.dNONE;

                base.Update(gameTime);
        }
Exemple #3
0
        /// <summary>
        /// needed for "Equals"
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            int hash = 13;

            hash = (hash * 7) + X.GetHashCode();
            hash = (hash * 7) + Y.GetHashCode();
            hash = (hash * 7) + Z.GetHashCode();
            hash = (hash * 7) + XR.GetHashCode();
            hash = (hash * 7) + YR.GetHashCode();
            hash = (hash * 7) + LT.GetHashCode();
            hash = (hash * 7) + RT.GetHashCode();
            hash = (hash * 7) + DpadDirection.GetHashCode();
            hash = (hash * 7) + buttons.GetHashCode();
            return(hash);
        }