Exemplo n.º 1
0
 static void GetXYFromDirection(DirectionKey dkey, out byte x, out byte y)
 {
     if (dkey.HasFlag(DirectionKey.Left) && !dkey.HasFlag(DirectionKey.Right))
     {
         x = STICK_MIN;
     }
     else if (!dkey.HasFlag(DirectionKey.Left) && dkey.HasFlag(DirectionKey.Right))
     {
         x = STICK_MAX;
     }
     else
     {
         x = STICK_CENTER;
     }
     if (dkey.HasFlag(DirectionKey.Up) && !dkey.HasFlag(DirectionKey.Down))
     {
         y = STICK_MIN;
     }
     else if (!dkey.HasFlag(DirectionKey.Up) && dkey.HasFlag(DirectionKey.Down))
     {
         y = STICK_MAX;
     }
     else
     {
         y = STICK_CENTER;
     }
 }
Exemplo n.º 2
0
 static HAT GetHATFromDirection(DirectionKey dkey)
 {
     if (dkey.HasFlag(DirectionKey.Up) && dkey.HasFlag(DirectionKey.Down))
     {
         dkey &= ~DirectionKey.Up & ~DirectionKey.Down;
     }
     if (dkey.HasFlag(DirectionKey.Left) && dkey.HasFlag(DirectionKey.Right))
     {
         dkey &= ~DirectionKey.Left & ~DirectionKey.Right;
     }
     if (dkey == DirectionKey.Up)
     {
         return(HAT.TOP);
     }
     if (dkey == DirectionKey.Down)
     {
         return(HAT.BOTTOM);
     }
     if (dkey == DirectionKey.Left)
     {
         return(HAT.LEFT);
     }
     if (dkey == DirectionKey.Right)
     {
         return(HAT.RIGHT);
     }
     if (dkey.HasFlag(DirectionKey.Up) && dkey.HasFlag(DirectionKey.Left))
     {
         return(HAT.TOP_LEFT);
     }
     if (dkey.HasFlag(DirectionKey.Up) && dkey.HasFlag(DirectionKey.Right))
     {
         return(HAT.TOP_RIGHT);
     }
     if (dkey.HasFlag(DirectionKey.Down) && dkey.HasFlag(DirectionKey.Left))
     {
         return(HAT.BOTTOM_LEFT);
     }
     if (dkey.HasFlag(DirectionKey.Down) && dkey.HasFlag(DirectionKey.Right))
     {
         return(HAT.BOTTOM_RIGHT);
     }
     return(HAT.CENTER);
 }