/// <summary>
        /// Unassign keyboard key or joystick button when double clicked a Datagrid cell.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGrid_MouseButtonDoubleClick(object sender, MouseButtonEventArgs e)
        {
            KeyMappingTimer.Stop();

            KeyAssgn selectedItem = (KeyAssgn)KeyMappingGrid.SelectedItem;

            if (selectedItem == null)
            {
                return;
            }
            if (KeyMappingGrid.CurrentColumn == null)
            {
                return;
            }
            if (selectedItem.GetVisibility() != "White")
            {
                return;
            }
            if (selectedItem.GetCallback() == "SimDoNothing")
            {
                return;
            }

            KeyMappingWindow.ShowKeyMappingWindow(selectedItem, keyFile, deviceControl, sender);
            KeyMappingGrid.Items.Refresh();
            KeyMappingGrid.UnselectAllCells();

            KeyMappingTimer.Start();
        }
Пример #2
0
        private void JoystickButtonMonitor()
        {
            for (int i = 0; i < deviceControl.devList.Count; i++)
            {
                byte[] buttons;
                int[]  povs;

                buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons();
                for (int ii = 0; ii < 32; ii++)
                {
                    if (buttons[ii] == 128 && deviceControl.joyAssign[i].dx[ii].assign[0].GetCallback() == "SimHotasPinkyShift" && pressedByHand == false)
                    {
                        Select_PinkyShift.IsChecked = false;
                    }
                    if (buttons[ii] == 0 && deviceControl.joyAssign[i].dx[ii].assign[0].GetCallback() == "SimHotasPinkyShift" && pressedByHand == false)
                    {
                        Select_PinkyShift.IsChecked = true;
                    }

                    if (buttons[ii] == neutralButtons[i].buttons[ii])
                    {
                        continue;
                    }
                    if (buttons[ii] == 0)
                    {
                        getNeutralPosition();
                        continue;
                    }

                    if (deviceControl.joyAssign[i].dx[ii].assign[0].GetCallback() == "SimHotasPinkyShift" && pressedByHand == false)
                    {
                        continue;
                    }

                    Pinky     pinkyStatus     = Pinky.UnShift;
                    Behaviour behaviourStatus = Behaviour.Press;
                    if (Select_PinkyShift.IsChecked == false)
                    {
                        pinkyStatus = Pinky.Shift;
                    }
                    if (Select_DX_Release.IsChecked == false)
                    {
                        behaviourStatus = Behaviour.Release;
                    }

                    // Construct DX button instance.
                    if (tmpCallback.GetCallback() == "SimHotasPinkyShift")
                    {
                        tmpJoyStick[i].dx[ii].Assign(tmpCallback.GetCallback(), Pinky.UnShift, Behaviour.Press, Invoke.Default, 0);
                        tmpJoyStick[i].dx[ii].Assign(tmpCallback.GetCallback(), Pinky.Shift, Behaviour.Press, Invoke.Default, 0);
                    }
                    else
                    {
                        tmpJoyStick[i].dx[ii].Assign(tmpCallback.GetCallback(), pinkyStatus, behaviourStatus, invokeStatus, 0);
                    }
                    //while (buttons[ii] != neutralButtons[i].buttons[ii])
                    //{
                    //    buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons();
                    //}
                    getNeutralPosition();
                    return;
                }
                povs    = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView();
                buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons();
                for (int ii = 0; ii < 4; ii++)
                {
                    if (povs[ii] == neutralButtons[i].povs[ii])
                    {
                        continue;
                    }
                    if (povs[ii] == -1)
                    {
                        getNeutralPosition();
                        continue;
                    }

                    Pinky pinkyStatus = Pinky.UnShift;
                    if (Select_PinkyShift.IsChecked == false)
                    {
                        pinkyStatus = Pinky.Shift;
                    }

                    // Construct POV button instance.
                    tmpJoyStick[i].pov[ii].Assign(povs[ii], tmpCallback.GetCallback(), pinkyStatus, 0);
                    //while (povs[ii] != neutralButtons[i].povs[ii])
                    //{
                    //    povs = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView();
                    //}
                    getNeutralPosition();
                    return;
                }
            }
        }