Exemplo n.º 1
0
 /// <summary>
 /// Sets a controller button as down (only 1 button can be down at a time using the virtual controller)
 /// </summary>
 /// <param name="buttons">Button(s) to press</param>
 public void SetControllerButtonDown(XboxAutomationButtonFlags buttons)
 {
     lock (this)
     {
         this.handlingVirtualPress = true;
         XBOX_AUTOMATION_GAMEPAD pad = new XBOX_AUTOMATION_GAMEPAD();
         pad.Buttons = buttons;
         this.SetGamepadStates(pad);
     }
 }
        /// <summary>
        /// Handler for key down of any key
        /// </summary>
        /// <param name="sender">Originating UI element for this event</param>
        /// <param name="e">Key event args</param>
        private void AnyButton_KeyDown(object sender, KeyEventArgs e)
        {
            VirtualControllerViewModel viewModel = this.DataContext as VirtualControllerViewModel;
            XboxAutomationButtonFlags  buttons   = new XboxAutomationButtonFlags();

            switch (e.Key)
            {
            case Key.A:
                buttons = XboxAutomationButtonFlags.DPadLeft;
                break;

            case Key.S:
                buttons = XboxAutomationButtonFlags.DPadDown;
                break;

            case Key.W:
                buttons = XboxAutomationButtonFlags.DPadUp;
                break;

            case Key.D:
                buttons = XboxAutomationButtonFlags.DPadRight;
                break;

            case Key.D8:
            case Key.NumPad8:
                buttons = XboxAutomationButtonFlags.Y_Button;
                break;

            case Key.D6:
            case Key.NumPad6:
                buttons = XboxAutomationButtonFlags.B_Button;
                break;

            case Key.D4:
            case Key.NumPad4:
                buttons = XboxAutomationButtonFlags.X_Button;
                break;

            case Key.D2:
            case Key.NumPad2:
                buttons = XboxAutomationButtonFlags.A_Button;
                break;
            }

            viewModel.SetControllerButtonDown(buttons);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Send the desired controller signal to every console
        /// </summary>
        /// <param name="buttons">Button pressed</param>
        public void SendControllerButton(XboxAutomationButtonFlags buttons)
        {
            // check if we have a quadrant already set up. quadrant will be 1, 2, 3 or 4
            if (this.controlledQuadrant != 0)
            {
                this.gamepad.LeftThumbX   = 0;
                this.gamepad.LeftThumbY   = 0;
                this.gamepad.LeftTrigger  = 0;
                this.gamepad.RightThumbX  = 0;
                this.gamepad.RightThumbY  = 0;
                this.gamepad.RightTrigger = 0;
                this.gamepad.Buttons      = buttons;

                try
                {
                    this.xboxDevice.XboxConsole.XboxAutomation.QueueGamepadState(this.controlledQuadrant - 1, this.gamepad, 200, 0);
                    this.gamepad.Buttons = new XboxAutomationButtonFlags();
                    this.xboxDevice.XboxConsole.XboxAutomation.QueueGamepadState(this.controlledQuadrant - 1, this.gamepad, 100, 0);
                }
                catch
                {
                }
            }
        }