/// <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);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ControllableXboxViewItem" /> class.
 /// </summary>
 /// <param name="virtualControllerViewModel">A reference to the virtual controller view model</param>
 /// <param name="xboxViewItem">Xbox to associate with this object</param>
 public ControllableXboxViewItem(VirtualControllerViewModel virtualControllerViewModel, XboxViewItem xboxViewItem)
 {
     this.virtualControllerViewModel = virtualControllerViewModel;
     this.xboxViewItem = xboxViewItem;
 }
        /// <summary>
        /// Handler for mouse down on Up
        /// </summary>
        /// <param name="sender">Originating UI element for this event</param>
        /// <param name="e">mouse button event args</param>
        private void PressUp_MouseDown(object sender, MouseButtonEventArgs e)
        {
            VirtualControllerViewModel viewModel = this.DataContext as VirtualControllerViewModel;

            viewModel.SetControllerButtonDown(XboxAutomationButtonFlags.DPadUp);
        }
        /// <summary>
        /// Handler for key up of any key
        /// </summary>
        /// <param name="sender">Originating UI element for this event</param>
        /// <param name="e">Key event args</param>
        private void AnyButton_KeyUp(object sender, KeyEventArgs e)
        {
            VirtualControllerViewModel viewModel = this.DataContext as VirtualControllerViewModel;

            viewModel.ReleaseControllerButton();
        }
        /// <summary>
        /// Handler for mouse down on Left Trigger
        /// </summary>
        /// <param name="sender">Originating UI element for this event</param>
        /// <param name="e">mouse button event args</param>
        private void PressLeftTrigger_MouseDown(object sender, MouseButtonEventArgs e)
        {
            VirtualControllerViewModel viewModel = this.DataContext as VirtualControllerViewModel;

            viewModel.PressLeftTrigger();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualControllerWindow" /> class.
 /// </summary>
 /// <param name="viewModel">A reference to the virtual controller view model</param>
 public VirtualControllerWindow(VirtualControllerViewModel viewModel)
 {
     this.InitializeComponent();
     this.DataContext = viewModel;
 }