Beispiel #1
0
        private void KeyMappingGrid_KeyDown()
        {
            bool Shift           = false;
            bool Ctrl            = false;
            bool Alt             = false;
            int  catchedScanCode = 0;

            directInputDevice.GetCurrentKeyboardState();
            for (int i = 1; i < 238; i++)
            {
                if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i])
                {
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftShift |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightShift)
                    {
                        Shift = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftControl |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightControl)
                    {
                        Ctrl = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftAlt |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightAlt)
                    {
                        Alt = true;
                        continue;
                    }
                    catchedScanCode = i;
                }
            }
            if (catchedScanCode == 0)
            {
                return;
            }

            Pinky pinkyStatus = Pinky.UnShift;

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

            if (pinkyStatus == Pinky.UnShift)
            {
                tmpCallback.SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
            }
            if (pinkyStatus == Pinky.Shift)
            {
                tmpCallback.Setkeycombo(catchedScanCode, Shift, Ctrl, Alt);
            }
        }
Beispiel #2
0
        /// <summary>
        /// You pressed keyboard keys? I will check which key was pressed with Shift/Ctrl/Alt.
        /// </summary>
        private void KeyMappingGrid_KeyDown()
        {
            if (SearchBox.IsSelectionActive == true)
            {
                return;
            }
            if (SearchBox.IsFocused == true)
            {
                return;
            }
            if (SearchBox.IsKeyboardFocused == true)
            {
                return;
            }

            bool Shift = false;
            bool Ctrl  = false;
            bool Alt   = false;

            int catchedScanCode = 0;

            directInputDevice.GetCurrentKeyboardState();

            for (int i = 1; i < 238; i++)
            {
                if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i])
                {
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftShift |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightShift)
                    {
                        Shift = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftControl |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightControl)
                    {
                        Ctrl = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftAlt |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightAlt)
                    {
                        Alt = true;
                        continue;
                    }
                    catchedScanCode = i;
                }
            }
            if (catchedScanCode == 0)
            {
                return;
            }
            if (Select_PinkyShift.IsChecked == false)
            {
                return;
            }

            KeyAssgn keytmp = new KeyAssgn("SimDoNothing - 1 0 0XFFFFFFFF 0 0 0 - 1 \"nothing\"");

            keytmp.SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
            Label_AssgnStatus.Content = "INPUT " + keytmp.GetKeyAssignmentStatus();

            // If the key assignment was found, jump to the mapping for it and highlight it.
            var key = keyFile.keyAssign.FirstOrDefault(x => x.GetKeyAssignmentStatus() == keytmp.GetKeyAssignmentStatus());

            if (key != null)
            {
                Label_AssgnStatus.Content += "\t/" + key.Mapping;

                KeyMappingGrid.UpdateLayout();
                KeyMappingGrid.ScrollIntoView(key);
                KeyMappingGrid.SelectedIndex = KeyMappingGrid.Items.IndexOf(key);
            }
        }
Beispiel #3
0
        /// <summary>
        /// You pressed keyboard keys? I will check which key was pressed with Shift/Ctrl/Alt.
        /// </summary>
        private void KeyMappingGrid_KeyDown()
        {
            if (currentIndex < 0)
            {
                currentIndex = 1;
                statusSearch = Search.Search;
                return;
            }
            if (SearchBox.IsSelectionActive == true)
            {
                return;
            }
            if (SearchBox.IsFocused == true)
            {
                return;
            }
            if (SearchBox.IsKeyboardFocused == true)
            {
                return;
            }

            bool Shift = false;
            bool Ctrl  = false;
            bool Alt   = false;

            int catchedScanCode = 0;

            directInputDevice.GetCurrentKeyboardState();

            for (int i = 1; i < 238; i++)
            {
                if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i])
                {
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftShift |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightShift)
                    {
                        Shift = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftControl |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightControl)
                    {
                        Ctrl = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftAlt |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightAlt)
                    {
                        Alt = true;
                        continue;
                    }
                    catchedScanCode = i;
                }
            }
            if (catchedScanCode == 0)
            {
                return;
            }
            if (statusSearch == Search.Search)
            {
                if (Select_PinkyShift.IsChecked == false)
                {
                    return;
                }

                KeyAssgn keytmp = new KeyAssgn("SimDoNothing - 1 0 0XFFFFFFFF 0 0 0 - 1 \"nothing\"");
                keytmp.SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
                Label_AssgnStatus.Content = "INPUT " + keytmp.GetKeyAssignmentStatus();

                // If the key assignment was found, jump to the mapping for it and highlight it.
                var key = keyFile.keyAssign.FirstOrDefault(x => x.GetKeyAssignmentStatus() == keytmp.GetKeyAssignmentStatus());
                if (key != null)
                {
                    Label_AssgnStatus.Content += "\t/" + key.Mapping;

                    KeyMappingGrid.UpdateLayout();
                    KeyMappingGrid.ScrollIntoView(key);
                    KeyMappingGrid.SelectedIndex = KeyMappingGrid.Items.IndexOf(key);
                }

                return;
            }
            if (KeyMappingGrid.SelectedIndex == -1)
            {
                return;
            }

            var selectedItem = (KeyAssgn)KeyMappingGrid.SelectedItem;

            if (selectedItem.Visibility != "White")
            {
                return;
            }

            Pinky pinkyStatus = Pinky.UnShift;

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

            KeyMappingGrid.ScrollIntoView(selectedItem);
            KeyMappingGrid.SelectedIndex = currentIndex;

            if (pinkyStatus == Pinky.UnShift)
            {
                selectedItem.SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
            }
            if (pinkyStatus == Pinky.Shift)
            {
                selectedItem.Setkeycombo(catchedScanCode, Shift, Ctrl, Alt);
            }

            // Unassign the previous mapping that was assigned to this key/key combo.
            var oldKey = keyFile.keyAssign.FirstOrDefault(x => (x != selectedItem) && x.GetKeyAssignmentStatus() == selectedItem.GetKeyAssignmentStatus());

            if (oldKey != null)
            {
                oldKey.UnassignKeyboard();
            }

            KeyMappingGrid.Items.Refresh();
            KeyMappingGrid.UnselectAllCells();
            statusSearch = Search.Search;
        }
        /// <summary>
        /// You pressed keyboard keys? I will check which key was pressed with Shift/Ctrl/Alt.
        /// </summary>
        private void KeyMappingGrid_KeyDown()
        {
            if (currentIndex < 0)
            {
                currentIndex = 1;
                statusSearch = Search.Search;
                return;
            }
            if (SearchBox.IsSelectionActive == true)
            {
                return;
            }
            if (SearchBox.IsFocused == true)
            {
                return;
            }
            if (SearchBox.IsKeyboardFocused == true)
            {
                return;
            }

            bool Shift = false;
            bool Ctrl  = false;
            bool Alt   = false;

            int catchedScanCode = 0;

            directInputDevice.GetCurrentKeyboardState();

            for (int i = 1; i < 238; i++)
            {
                if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i])
                {
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftShift |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightShift)
                    {
                        Shift = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftControl |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightControl)
                    {
                        Ctrl = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftAlt |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightAlt)
                    {
                        Alt = true;
                        continue;
                    }
                    catchedScanCode = i;
                }
            }
            if (catchedScanCode == 0)
            {
                return;
            }
            if (statusSearch == Search.Search)
            {
                KeyAssgn keytmp = new KeyAssgn("SimDoNothing - 1 0 0XFFFFFFFF 0 0 0 - 1 \"nothing\"");
                keytmp.SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
                Label_AssgnStatus.Content = "INPUT " + keytmp.GetKeyAssignmentStatus();
                for (int i = 0; i < keyFile.keyAssign.Length; i++)
                {
                    if (keytmp.GetKeyAssignmentStatus() != keyFile.keyAssign[i].GetKeyAssignmentStatus())
                    {
                        continue;
                    }

                    Label_AssgnStatus.Content += "\t/" + keyFile.keyAssign[i].Mapping;

                    KeyMappingGrid.UpdateLayout();
                    KeyMappingGrid.ScrollIntoView(KeyMappingGrid.Items[i]);
                    KeyMappingGrid.SelectedIndex = i;
                }
                return;
            }
            if (KeyMappingGrid.SelectedIndex == -1)
            {
                return;
            }
            if (keyFile.keyAssign[currentIndex].GetVisibility() != "White")
            {
                return;
            }

            Pinky pinkyStatus = Pinky.UnShift;

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

            KeyMappingGrid.ScrollIntoView(KeyMappingGrid.Items[currentIndex]);
            KeyMappingGrid.SelectedIndex = currentIndex;
            if (pinkyStatus == Pinky.UnShift)
            {
                keyFile.keyAssign[currentIndex].SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
            }
            if (pinkyStatus == Pinky.Shift)
            {
                keyFile.keyAssign[currentIndex].Setkeycombo(catchedScanCode, Shift, Ctrl, Alt);
            }

            for (int i = 0; i < keyFile.keyAssign.Length; i++)
            {
                if (keyFile.keyAssign[i].GetKeyAssignmentStatus() != keyFile.keyAssign[currentIndex].GetKeyAssignmentStatus())
                {
                    continue;
                }
                if (i == currentIndex)
                {
                    continue;
                }
                if (keyFile.keyAssign[i].GetVisibility() != "White")
                {
                    continue;
                }
                keyFile.keyAssign[i].UnassignKeyboard();
            }

            KeyMappingGrid.Items.Refresh();
            KeyMappingGrid.UnselectAllCells();
            statusSearch = Search.Search;
        }