Example #1
0
 public bool IsDown(PadKey key)
 {
     if (isDown.Count > 0)
     {
         return(isDown[key]);
     }
     return(false);
 }
Example #2
0
        bool CheckIsDown(PadKey key)
        {
            const double stickThreshold        = 0.2;
            const double stickReverseThreshold = 1 - stickThreshold;

            switch (key)
            {
            case PadKey.None:
                return(false);

            case PadKey.StickUp:
                return(this.Y0 < stickThreshold);

            case PadKey.StickDown:
                return(this.Y0 > stickReverseThreshold);

            case PadKey.StickLeft:
                return(this.X0 < stickThreshold);

            case PadKey.StickRight:
                return(this.X0 > stickReverseThreshold);

            case PadKey.POVUp:
                return(info.dwPOV == POV.Up ||
                       info.dwPOV == POV.UpLeft ||
                       info.dwPOV == POV.UpRight);

            case PadKey.POVDown:
                return(info.dwPOV == POV.Down ||
                       info.dwPOV == POV.DownLeft ||
                       info.dwPOV == POV.DownRight);

            case PadKey.POVLeft:
                return(info.dwPOV == POV.Left ||
                       info.dwPOV == POV.UpLeft ||
                       info.dwPOV == POV.DownLeft);

            case PadKey.POVRight:
                return(info.dwPOV == POV.Right ||
                       info.dwPOV == POV.UpRight ||
                       info.dwPOV == POV.DownRight);

            //case PadKey.SpinUp:
            //    return this.SpinY < stickThreshold;
            //case PadKey.SpinDown:
            //    return this.SpinY > stickReverseThreshold;
            //case PadKey.SpinLeft:
            //    return this.SpinX < stickThreshold;
            //case PadKey.SpinRight:
            //    return this.SpinX > stickReverseThreshold;
            default:
                return((info.dwButtons & (uint)Math.Pow(2, (int)key - 1)) != 0);
            }
        }
Example #3
0
 public static IReadOnlyCollection<PadKey> ToButtons(this string[] config)
 {
     Guard.ForInValidButtonConfig(config);
     var zero = new PadKey(0);
     zero.AddSlot(Letter.Whitespace());
     var buttons = new List<PadKey> { zero };
     for (short i = 0; i < 9; i++)
     {
         var button = new PadKey(i+1);
         if (!String.IsNullOrWhiteSpace(config[i]))
         {
             foreach (var letter in config[i])
             {
                 if (!string.IsNullOrWhiteSpace(letter.ToString()))
                 {
                     button.AddSlot(new Letter(letter));
                 }
             }
         }
         buttons.Add(button);
     }
     return new ReadOnlyCollection<PadKey>(buttons);
 }
Example #4
0
 public bool IsUp(PadKey key)
 {
     return(!isDown[key]);
 }