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); } }
/// <summary> /// You pressed keyboard keys? I will check which key was pressed with Shift/Ctrl/Alt. /// </summary> private void KeyMappingGrid_KeyDown() { if (SearchBox.IsSelectionActive) { return; } if (SearchBox.IsFocused) { return; } if (SearchBox.IsKeyboardFocused) { 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. KeyAssgn 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); } }