/** * Get a keyboard keybinding for a button */ public ControlButtonBinding.KeyBinding?GetKeyboardKeybinding(EDControlButton button) { if (buttonBindings.ContainsKey(button)) { var buttonBinding = buttonBindings[button]; return(buttonBinding.KeyboardKeybinding); } return(null); }
/** * Check to see if a button has a keyboard keybinding we can act on */ public bool HasKeyboardKeybinding(EDControlButton button) { if (!buttonBindings.ContainsKey(button)) { return(false); } var buttonBinding = buttonBindings[button]; return(buttonBinding.HasKeyboardKeybinding); }
public static IKeyPress GetControlButton(EDControlButton control, KeyboardInterface.KeyCombo?defaultKeycombo = null) { var bindings = EDStateManager.instance.controlBindings; if (bindings == null) { Debug.LogWarning("Control bindings not loaded"); return(null); } else { var keyBinding = bindings.GetKeyboardKeybinding(control); string key = ""; string[] modifiers = null; if (keyBinding == null) { if (defaultKeycombo == null) { // XXX: Make this an error and add a warning that emits even when there is a default keycombo Debug.LogWarningFormat("The \"{0}\" Elite Dangerous control has no keyboard binding and there is no default keycombo to fallback to", Enum.GetName(typeof(EDControlButton), control)); return(null); } } else { key = keyBinding.Value.Key; modifiers = keyBinding.Value.Modifiers.Select(mod => mod.Key).ToArray(); } // @todo Implement this as a press and release var keyPress = KeyboardInterface.Key(key, modifiers); if (keyPress == null) { Debug.LogWarningFormat( "Could not send keypress {0}, did not understand one or more of the keys", KeyboardInterface.KeyComboDebugString(key, modifiers)); } return(keyPress); } }
public static IKeyPress GetControlButton(EDControlButton control, KeyboardInterface.KeyCombo?defaultKeycombo = null) { var bindings = EDStateManager.instance.controlBindings; if (bindings == null) { Debug.LogWarning("Control bindings not loaded"); return(null); } else { var keyBinding = bindings.GetKeyboardKeybinding(control); string key = ""; string[] modifiers = null; if (keyBinding == null) { if (defaultKeycombo == null) { Debug.LogWarningFormat("Control was not bound and there is no default keycombo to fallback to"); return(null); } } else { key = keyBinding.Value.Key; modifiers = keyBinding.Value.Modifiers.Select(mod => mod.Key).ToArray(); } // @todo Implement this as a press and release var keyPress = KeyboardInterface.Key(key, modifiers); if (keyPress == null) { Debug.LogWarningFormat( "Could not send keypress {0}, did not understand one or more of the keys", KeyboardInterface.KeyComboDebugString(key, modifiers)); } return(keyPress); } }