예제 #1
0
        private static void P2Thrusted(object sender, GestureEventArgs e)
        {
            double dist = ((ThrustGestureEventArgs)e).DistanceToShoulder;

            //Console.Write(dist + " ");
            if (dist > 0.50)
            {
                Console.Write("P2 Forward ");
                if (sdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_S);
                    sdown = false;
                }
                if (!wdown)
                {
                    DirectInput.KeyDown(DirectInput.VK_W);
                    wdown = true;
                }
            }
            else if (dist > 0.35)
            {
                Console.Write("P2 Neutral ");
                if (sdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_S);
                    sdown = false;
                }
                if (wdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_W);
                    wdown = false;
                }
            }
            else
            {
                Console.Write("P2 Reverse ");
                if (wdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_W);
                    wdown = false;
                }
                if (!sdown)
                {
                    DirectInput.KeyDown(DirectInput.VK_S);
                    sdown = true;
                }
            }
        }
예제 #2
0
        private static void P1Thrusted(object sender, GestureEventArgs e)
        {
            double dist = ((ThrustGestureEventArgs)e).DistanceToShoulder;

            //Console.Write(dist + " ");
            if (dist > 0.50)
            {
                Console.Write("P1 Forward ");
                if (downdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_DOWN);
                    downdown = false;
                }
                if (!updown)
                {
                    DirectInput.KeyDown(DirectInput.VK_UP);
                    updown = true;
                }
            }
            else if (dist > 0.35)
            {
                Console.Write("P1 Neutral ");
                if (downdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_DOWN);
                    downdown = false;
                }
                if (updown)
                {
                    DirectInput.KeyUp(DirectInput.VK_UP);
                    updown = false;
                }
            }
            else
            {
                Console.Write("P1 Reverse ");
                if (updown)
                {
                    DirectInput.KeyUp(DirectInput.VK_UP);
                    updown = false;
                }
                if (!downdown)
                {
                    DirectInput.KeyDown(DirectInput.VK_DOWN);
                    downdown = true;
                }
            }
        }
예제 #3
0
        private static void P1PowerUp(object sender, GestureEventArgs e)
        {
            Direction direction = ((FootEventArgs)e).Foot;

            if (direction == Direction.Left)
            {
                Console.Write("P1 Powerup ");
                if (!enterdown)
                {
                    DirectInput.KeyDown(DirectInput.VK_ENTER);
                    enterdown = true;
                }
            }
            else if (direction == Direction.Right)
            {
                Console.Write("P1 talking ");
                if (!threedown)
                {
                    DirectInput.KeyDown(DirectInput.VK_3);
                    threedown = true;
                }
            }
            else
            {
                if (enterdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_1);
                    enterdown = false;
                }
                if (threedown)
                {
                    DirectInput.KeyUp(DirectInput.VK_3);
                    threedown = false;
                }
            }
        }
예제 #4
0
        private static void P2PowerUp(object sender, GestureEventArgs e)
        {
            Direction direction = ((FootEventArgs)e).Foot;

            if (direction == Direction.Left)
            {
                Console.Write("P2 Powerup ");
                if (!qdown)
                {
                    DirectInput.KeyDown(DirectInput.VK_Q);
                    qdown = true;
                }
            }
            else if (direction == Direction.Right)
            {
                Console.Write("P2 talking ");
                if (!edown)
                {
                    DirectInput.KeyDown(DirectInput.VK_E);
                    edown = true;
                }
            }
            else
            {
                if (qdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_Q);
                    qdown = false;
                }
                if (edown)
                {
                    DirectInput.KeyUp(DirectInput.VK_E);
                    edown = false;
                }
            }
        }
예제 #5
0
        private static void P2Steered(object sender, GestureEventArgs e)
        {
            var direction = ((SteeringGestureEventArgs)e).Direction;

            Console.WriteLine("P2 steering " + direction + " ");
            if (direction < 0)
            {
                if (ddown)
                {
                    DirectInput.KeyUp(DirectInput.VK_D);
                    ddown = false;
                }
                if (direction == -2)
                {
                    if (!xdown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_X);
                        xdown = true;
                    }
                }
                else
                {
                    if (!adown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_A);
                        adown = true;
                    }
                    if (xdown)
                    {
                        DirectInput.KeyUp(DirectInput.VK_X);
                        xdown = false;
                    }
                }
            }
            else if (direction > 0)
            {
                if (adown)
                {
                    DirectInput.KeyUp(DirectInput.VK_A);
                    adown = false;
                }
                if (direction == 2)
                {
                    if (!xdown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_X);
                        xdown = true;
                    }
                }
                else
                {
                    if (!ddown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_D);
                        ddown = true;
                    }
                    if (xdown)
                    {
                        DirectInput.KeyUp(DirectInput.VK_X);
                        xdown = false;
                    }
                }
                //Keyboard.SendKeyAsInput(Keys.Right);
            }
            else
            {
                if (adown)
                {
                    DirectInput.KeyUp(DirectInput.VK_A);
                    adown = false;
                }
                if (ddown)
                {
                    DirectInput.KeyUp(DirectInput.VK_D);
                    ddown = false;
                }
                if (xdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_X);
                    xdown = false;
                }
            }
        }
예제 #6
0
        private static void P1Steered(object sender, GestureEventArgs e)
        {
            var direction = ((SteeringGestureEventArgs)e).Direction;

            Console.Write("P1 steering " + direction + " ");
            if (direction < 0)
            {
                if (rightdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_RIGHT);
                    rightdown = false;
                }
                if (direction == -2)
                {
                    if (!spacedown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_SPACE);
                        spacedown = true;
                    }
                }
                else
                {
                    if (!leftdown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_LEFT);
                        leftdown = true;
                    }
                    if (spacedown)
                    {
                        DirectInput.KeyUp(DirectInput.VK_SPACE);
                        spacedown = false;
                    }
                }
            }
            else if (direction > 0)
            {
                if (leftdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_LEFT);
                    leftdown = false;
                }
                if (direction == 2)
                {
                    if (!spacedown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_SPACE);
                        spacedown = true;
                    }
                }
                else
                {
                    if (!rightdown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_RIGHT);
                        rightdown = true;
                    }
                    if (spacedown)
                    {
                        DirectInput.KeyUp(DirectInput.VK_SPACE);
                        spacedown = false;
                    }
                }
                //Keyboard.SendKeyAsInput(Keys.Right);
            }
            else
            {
                if (leftdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_LEFT);
                    leftdown = false;
                }
                if (rightdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_RIGHT);
                    rightdown = false;
                }
                if (spacedown)
                {
                    DirectInput.KeyUp(DirectInput.VK_SPACE);
                    spacedown = false;
                }
            }
        }
예제 #7
0
        private static void Thrusted(object sender, GestureEventArgs e)
        {
            double dist = ((ThrustGestureEventArgs)e).DistanceToShoulder;

            //Console.Write(dist + " ");
            if (dist > 0.45)
            {
                Console.Write("Forward");
                if (downdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_DOWN);
                    downdown = false;
                }
                if (!updown)
                {
                    DirectInput.KeyDown(DirectInput.VK_UP);
                    updown = true;
                }
                //VirtualKeys.SendKeyAsInput(Keys.Up,30);
                if (dist > 0.6)
                {
                    //VirtualKeys.SendKeyAsInput(Keys.Alt,30);
                    if (!altdown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_LALT);
                        altdown = true;
                    }
                    Console.Write(" with nitro! ");
                }
                else
                {
                    if (altdown)
                    {
                        DirectInput.KeyUp(DirectInput.VK_LALT);
                        altdown = false;
                    }
                }
            }
            else if (dist > 0.3)
            {
                Console.Write("Neutral ");
                if (downdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_DOWN);
                    downdown = false;
                }
                if (updown)
                {
                    DirectInput.KeyUp(DirectInput.VK_UP);
                    updown = false;
                }
            }
            else
            {
                Console.Write("Break ");
                if (updown)
                {
                    DirectInput.KeyUp(DirectInput.VK_UP);
                    updown = false;
                }
                if (!downdown)
                {
                    DirectInput.KeyDown(DirectInput.VK_DOWN);
                    downdown = true;
                }
                //VirtualKeys.SendKeyAsInput(Keys.Down, 30);
            }
        }
예제 #8
0
        private static void Steered(object sender, GestureEventArgs e)
        {
            var direction = ((SteeringGestureEventArgs)e).Direction;

            Console.WriteLine(" steering " + direction);
            if (direction < 0)
            {
                if (rightdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_RIGHT);
                    rightdown = false;
                }
                if (direction == -2)
                {
                    if (!leftdown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_LEFT);
                        leftdown = true;
                    }
                }
                else
                {
                    if (!leftdown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_LEFT);
                        leftdown = true;
                    }
                    else
                    {
                        DirectInput.KeyUp(DirectInput.VK_LEFT);
                        leftdown = false;
                    }
                }
                //VirtualKeys.SendKeyAsInput(Keys.Left,30);
            }
            else if (direction > 0)
            {
                if (leftdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_LEFT);
                    leftdown = false;
                }
                if (direction == 2)
                {
                    if (!rightdown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_RIGHT);
                        rightdown = true;
                    }
                }
                else
                {
                    if (!rightdown)
                    {
                        DirectInput.KeyDown(DirectInput.VK_RIGHT);
                        rightdown = true;
                    }
                    else
                    {
                        DirectInput.KeyUp(DirectInput.VK_RIGHT);
                        rightdown = false;
                    }
                }
                //VirtualKeys.SendKeyAsInput(Keys.Right);
            }
            else
            {
                if (leftdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_LEFT);
                    leftdown = false;
                }
                if (rightdown)
                {
                    DirectInput.KeyUp(DirectInput.VK_RIGHT);
                    rightdown = false;
                }
            }
        }