private void ShowAssignedStatus() { string str = ""; str += tmpCallback.GetKeyAssignmentStatus() + "; "; if (str == "; ") { str = ""; } for (int i = 0; i < deviceControl.devList.Count; i++) { str += tmpCallback.ReadJoyAssignment(i, tmpJoyStick); } MappedButton.Content = str; if (str != "") { AwaitingInputs.Content = ""; return; } if (sw.ElapsedMilliseconds > 1000) { AwaitingInputs.Content = ""; } if (sw.ElapsedMilliseconds > 1666) { AwaitingInputs.Content = " AWAITING INPUTS"; sw.Reset(); sw.Start(); } }
private void Save_Click(object sender, RoutedEventArgs e) { deviceControl.joyAssign = tmpJoyStick; SelectedCallback.getOtherKeyInstance(tmpCallback); // Unassign the previous mapping that was assigned to this key/key combo. KeyAssgn oldKey = keyFile.keyAssign.FirstOrDefault(x => x != SelectedCallback && x.GetKeyAssignmentStatus() == SelectedCallback.GetKeyAssignmentStatus()); if (oldKey != null) { oldKey.UnassignKeyboard(); } Close(); }
/// <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); } }