Exemple #1
0
 private void btn_startwork_Click(object sender, EventArgs e)
 {
     mycontroller = new Classes.XboxController();
     if (mycontroller.IsConnected == true)
     {
         lbl_cntconn.Text = "Controller ist mit dem Computer verbunden und wurde erkannt";
     }
     myConverter = new Classes.ConvertInput();
     clk_updatecontroller.Start();
 }
        public void ConvertAllInput(XboxController controller)
        {
            if (controller.magnitudeLeft != 0)       //linker Stick wird bewegt, beweg mal die Figur mit
            {
                if (controller.normalizedLX >= 0.6 && controller.normalizedLY <= 0.5)
                {
                    sendInputToKeyboard(0);
                }
                else if (controller.normalizedLX <= -0.5 && controller.normalizedLY >= -0.49)
                {
                    sendInputToKeyboard(1);
                }
                else if (controller.normalizedLX >= -0.49 && controller.normalizedLY <= -0.5)
                {
                    sendInputToKeyboard(2);
                }
                else if (controller.normalizedLX <= 0.49 && controller.normalizedLY >= 0.5)
                {
                    sendInputToKeyboard(3);
                }
            }

            if (controller.magnitudeRight != 0)
            {
                MoveCursor(controller.normalizedRX, controller.normalizedRY, controller.normalizedMagnitudeRight);
            }

            if (controller.padButtons == GamepadButtonFlags.LeftShoulder && oldstate != GamepadButtonFlags.LeftShoulder)
            {
                inputsimulate.Mouse.LeftButtonDown();
            }
            else if (oldstate == GamepadButtonFlags.LeftShoulder && controller.padButtons != GamepadButtonFlags.LeftShoulder)
            {
                inputsimulate.Mouse.LeftButtonUp();
            }

            if (controller.padButtons == GamepadButtonFlags.RightShoulder && oldstate != GamepadButtonFlags.RightShoulder)
            {
                inputsimulate.Mouse.RightButtonDown();
            }
            else if (oldstate == GamepadButtonFlags.RightShoulder && controller.padButtons != GamepadButtonFlags.RightShoulder)
            {
                inputsimulate.Mouse.RightButtonUp();
            }

            if (controller.padButtons == GamepadButtonFlags.LeftThumb && oldstate != GamepadButtonFlags.LeftThumb)
            {
                inputsimulate.Keyboard.KeyDown(VirtualKeyCode.LSHIFT);
            }
            else if (oldstate == GamepadButtonFlags.LeftThumb && controller.padButtons != GamepadButtonFlags.LeftThumb)
            {
                inputsimulate.Keyboard.KeyUp(VirtualKeyCode.LSHIFT);
            }

            if (controller.padButtons == GamepadButtonFlags.A && oldstate != GamepadButtonFlags.A)
            {
                inputsimulate.Keyboard.KeyDown(VirtualKeyCode.SPACE);
            }
            else if (oldstate == GamepadButtonFlags.A && controller.padButtons != GamepadButtonFlags.A)
            {
                inputsimulate.Keyboard.KeyUp(VirtualKeyCode.SPACE);
            }

            if (controller.padButtons == GamepadButtonFlags.B && oldstate != GamepadButtonFlags.B)
            {
                inputsimulate.Mouse.LeftButtonDown();
            }
            else if (oldstate == GamepadButtonFlags.B && controller.padButtons != GamepadButtonFlags.B)
            {
                inputsimulate.Mouse.LeftButtonUp();
            }

            oldstate = controller.padButtons;
        }