public void CompareTo1() { var i1 = new KeyInput('c', KeyModifiers.None); Assert.IsTrue(i1.CompareTo(new KeyInput('z', KeyModifiers.None)) < 0); Assert.IsTrue(i1.CompareTo(new KeyInput('c', KeyModifiers.None)) == 0); Assert.IsTrue(i1.CompareTo(new KeyInput('a', KeyModifiers.None)) > 0); }
public void FindConflictingCommands5() { var commands = Create("::a","::z, h"); var inputs = new KeyInput[] { new KeyInput('z') }; var list = KeyBindingService.FindConflictingCommands(commands, new HashSet<KeyInput>(inputs)); Assert.AreEqual(1, list.Count); }
internal bool TryConvert(Guid commandGroup, uint commandId, IntPtr pvaIn, out KeyInput kiOutput) { kiOutput = null; // Don't ever process a command when we are in an automation function. Doing so will cause VsVim to // intercept items like running Macros and certain wizard functionality if (VsShellUtilities.IsInAutomationFunction(_serviceProvider)) { return false; } EditCommand command; if (!OleCommandUtil.TryConvert(commandGroup, commandId, pvaIn, out command)) { return false; } // If the current state of the buffer cannot process the command then do not convert it if (!_buffer.CanProcess(command.KeyInput)) { return false; } kiOutput = command.KeyInput; return true; }
/// <summary> /// Try and get the KeyInput which corresponds to the given Key and modifiers /// TODO: really think about this method /// </summary> internal bool TryGetKeyInput(Key key, ModifierKeys modifierKeys, out KeyInput keyInput) { // First just check and see if there is a direct mapping var keyType = new KeyType(key, modifierKeys); if (_cache.TryGetValue(keyType, out keyInput)) { return true; } // Next consider only the shift key part of the requested modifier. We can // re-apply the original modifiers later keyType = new KeyType(key, modifierKeys & ModifierKeys.Shift); if (_cache.TryGetValue(keyType, out keyInput)) { // Reapply the modifiers keyInput = KeyInputUtil.ChangeKeyModifiers(keyInput, ConvertToKeyModifiers(modifierKeys)); return true; } // Last consider it without any modifiers and reapply keyType = new KeyType(key, ModifierKeys.None); if (_cache.TryGetValue(keyType, out keyInput)) { // Reapply the modifiers keyInput = KeyInputUtil.ChangeKeyModifiers(keyInput, ConvertToKeyModifiers(modifierKeys)); return true; } return false; }
public void FindConflictingCommands7() { var util = Create("balgh::a", "aoeu::z"); var inputs = new KeyInput[] { KeyInputUtil.CharToKeyInput('z'), KeyInputUtil.CharToKeyInput('a') }; var list = util.FindConflictingCommandKeyBindings(new HashSet<KeyInput>(inputs)); Assert.AreEqual(0, list.Count); }
internal static bool TryConvert(Guid commandGroup, uint commandId, IntPtr variantIn, out KeyInput keyInput, out EditCommandKind kind, out bool isRawText) { if (VSConstants.GUID_VSStandardCommandSet97 == commandGroup) { return TryConvert((VSConstants.VSStd97CmdID)commandId, variantIn, out keyInput, out kind, out isRawText); } if (VSConstants.VSStd2K == commandGroup) { return TryConvert((VSConstants.VSStd2KCmdID)commandId, variantIn, out keyInput, out kind, out isRawText); } if (commandGroup == HiddenCommand.Group && commandId == HiddenCommand.Id) { keyInput = KeyInputUtil.CharWithControlToKeyInput(';'); kind = EditCommandKind.UserInput; isRawText = true; return true; } keyInput = null; kind = EditCommandKind.UserInput; isRawText = false; return false; }
/// <summary> /// Try and map a KeyInput to a single KeyInput value. This will only succeed for KeyInput /// values which have no mapping or map to a single KeyInput value /// </summary> private bool TryGetSingleMapping(KeyInput original, out KeyInput mapped) { var result = _vimBuffer.GetKeyInputMapping(original); if (result.IsNeedsMoreInput || result.IsRecursive || result.IsPartiallyMapped) { // No single mapping mapped = null; return false; } if (result.IsMapped) { var set = ((KeyMappingResult.Mapped)result).Item; if (!set.IsOneKeyInput) { mapped = null; return false; } mapped = set.FirstKeyInput.Value; return true; } // Shouldn't get here because all cases of KeyMappingResult should be // handled above Contract.Assert(false); mapped = null; return false; }
public void FindConflictingCommands3() { var util = Create("::ctrl+z, h"); var inputs = new KeyInput[] { InputUtil.CharAndModifiersToKeyInput('z', KeyModifiers.Control) }; var list = util.FindConflictingCommandKeyBindings(new HashSet<KeyInput>(inputs)); Assert.AreEqual(1, list.Count); }
private void VerifyConvert(VSConstants.VSStd2KCmdID cmd, VimKeyModifiers modifiers, KeyInput ki, EditCommandKind kind) { EditCommand command; Assert.True(OleCommandUtil.TryConvert(VSConstants.VSStd2K, (uint)cmd, IntPtr.Zero, modifiers, out command)); Assert.Equal(ki, command.KeyInput); Assert.Equal(kind, command.EditCommandKind); }
internal VimKeyData(KeyInput keyInput, string text) { Contract.Assert(keyInput != null); KeyInputOptional = keyInput; TextOptional = text; IsDeadKey = false; }
public override bool HandleKeyPress(KeyInput e) { if (e.Event == KeyInputEvent.Down) { var hk = Hotkey.FromKeyInput(e); if (hk == Game.Settings.Keys.DevReloadChromeKey) { ChromeProvider.Initialize(Game.ModData.Manifest.Chrome); return true; } if (hk == Game.Settings.Keys.HideUserInterfaceKey) { foreach (var child in this.Children) child.Visible ^= true; return true; } if (hk == Game.Settings.Keys.TakeScreenshotKey) { if (e.Event == KeyInputEvent.Down) Game.TakeScreenshot = true; return true; } } return base.HandleKeyPress(e); }
public void FindConflictingCommands5() { var util = Create("::a", "::ctrl+z, h"); var inputs = new KeyInput[] { KeyInputUtil.CharWithControlToKeyInput('z') }; var list = util.FindConflictingCommandKeyBindings(new HashSet<KeyInput>(inputs)); Assert.AreEqual(1, list.Count); }
private void VerifyConvert(VSConstants.VSStd97CmdID cmd, KeyInput ki, EditCommandKind kind) { EditCommand command; Assert.True(OleCommandUtil.TryConvert(VSConstants.GUID_VSStandardCommandSet97, (uint)cmd, IntPtr.Zero, VimKeyModifiers.None, out command)); Assert.Equal(ki, command.KeyInput); Assert.Equal(kind, command.EditCommandKind); }
public override bool HandleKeyPress(KeyInput e) { if (world == null) return false; return ProcessInput(e); }
public IEnumerable<ProviderAndCommand> GetOneKeyShortcuts(KeyInput keyInput) { var keyShortcut = new KeyShortcut(keyInput, KeyInput.Default); List<ProviderAndCommand> list; if (dict.TryGetValue(keyShortcut, out list)) return list; return Array.Empty<ProviderAndCommand>(); }
public void FindConflictingCommands4() { var util = Create("::h, z"); var inputs = new KeyInput[] { new KeyInput('z') }; var list = util.FindConflictingCommandKeyBindings(new HashSet<KeyInput>(inputs)); Assert.AreEqual(0, list.Count); }
/// <summary> /// Is this KeyInput intended to be processed by the active display window /// </summary> private bool IsDisplayWindowKey(KeyInput keyInput) { // Consider normal completion if (_broker.IsCompletionActive) { return keyInput.IsArrowKey || keyInput == KeyInputUtil.EnterKey || keyInput == KeyInputUtil.TabKey || keyInput.Key == VimKey.Back; } if (_broker.IsSmartTagSessionActive) { return keyInput.IsArrowKey || keyInput == KeyInputUtil.EnterKey; } if (_broker.IsSignatureHelpActive) { return keyInput.IsArrowKey; } return false; }
public void FindConflictingCommands1() { Create("::ctrl+h"); var inputs = new KeyInput[] { KeyInputUtil.CharWithControlToKeyInput('h') }; var list = _serviceRaw.FindConflictingCommandKeyBindings(_commandsSnapshot, new HashSet<KeyInput>(inputs)); Assert.Equal(1, list.Count); }
public void FindConflictingCommands4() { Create("::h, z"); var inputs = new KeyInput[] { KeyInputUtil.CharToKeyInput('z') }; var list = _serviceRaw.FindConflictingCommandKeyBindings(_commandsSnapshot, new HashSet<KeyInput>(inputs)); Assert.Equal(0, list.Count); }
public void Run(KeyInput keyInput) { Key key; ModifierKeys modifierKeys; if (!TryConvert(keyInput, out key, out modifierKeys)) { throw new Exception(String.Format("Couldn't convert {0} to Wpf keys", keyInput)); } try { _defaultKeyboardDevice.DownKeyModifiers = modifierKeys; if (PreProcess(keyInput, key, modifierKeys)) { return; } var text = keyInput.RawChar.IsSome() ? keyInput.Char.ToString() : String.Empty; Run(text, key, modifierKeys); } finally { _defaultKeyboardDevice.DownKeyModifiers = ModifierKeys.None; } }
public override bool HandleKeyPressInner(KeyInput e) { if (World == null) return false; if (World.LocalPlayer == null) return false; return ProcessInput(e); }
public override bool HandleKeyPress(KeyInput e) { if (e.Event == KeyInputEvent.Up) return false; if (e.KeyName == "return" || e.KeyName == "enter" ) { if (composing) { if (e.Modifiers.HasModifier(Modifiers.Shift)) { teamChat ^= true; return true; } composing = false; if (content != "") orderManager.IssueOrder(teamChat ? Order.TeamChat(content) : Order.Chat(content)); content = ""; LoseFocus(); return true; } else { TakeFocus(new MouseInput()); composing = true; if (Game.Settings.Game.TeamChatToggle) { teamChat ^= e.Modifiers.HasModifier(Modifiers.Shift); } else { teamChat = e.Modifiers.HasModifier(Modifiers.Shift); } return true; } } if (composing) { if (e.KeyName == "backspace") { if (content.Length > 0) content = content.Remove(content.Length - 1); return true; } else if (e.IsValidInput()) { content += e.UnicodeChar.ToString(); return true; } return false; } return false; }
public override bool HandleKeyPressInner(KeyInput e) { if (e.Event == KeyInputEvent.Up) return false; if (e.KeyChar == '\r') { if (composing) { if (e.Modifiers.HasModifier(Modifiers.Shift)) { teamChat ^= true; return true; } composing = false; if (content != "") orderManager.IssueOrder(teamChat ? Order.TeamChat(content) : Order.Chat(content)); content = ""; LoseFocus(); return true; } else { TakeFocus(new MouseInput()); composing = true; if (Game.Settings.Game.TeamChatToggle) { teamChat ^= e.Modifiers.HasModifier(Modifiers.Shift); } else { teamChat = e.Modifiers.HasModifier(Modifiers.Shift); } return true; } } if (composing) { if (e.KeyChar == '\b' || e.KeyChar == 0x7f) { if (content.Length > 0) content = content.Remove(content.Length - 1); return true; } else if (!char.IsControl(e.KeyChar)) { content += e.KeyChar; return true; } return false; } return base.HandleKeyPressInner(e); }
public void Equality1() { var i1 = new KeyInput('c', KeyModifiers.None); Assert.AreEqual(i1, new KeyInput('c', KeyModifiers.None)); Assert.AreNotEqual(i1, new KeyInput('d', KeyModifiers.None)); Assert.AreNotEqual(i1, new KeyInput('c', KeyModifiers.Shift)); Assert.AreNotEqual(i1, new KeyInput('c', KeyModifiers.Alt)); }
public void FindConflictingCommands6() { var util = Create("Global::ctrl+a", "Text Editor::ctrl+z"); var inputs = new KeyInput[] { KeyInputUtil.CharWithControlToKeyInput('a'), KeyInputUtil.CharWithControlToKeyInput('z') }; var list = util.FindConflictingCommandKeyBindings(new HashSet<KeyInput>(inputs)); Assert.AreEqual(2, list.Count); }
public EventManager(ActionCenter.ActionCenterInternalEventHandler dispatchData) { this._ki = new KeyInput(); this._mi = new MouseInput(); this.DispatchData = dispatchData; this.NormalizedPrecisionFactor = 4; this._neuroLog.WriteFormat("Initialization", "Normalized Precision Factor: {0}", this.NormalizedPrecisionFactor); //this._mi.MouseMove(1920, 1080); }
public override bool HandleKeyPress(KeyInput e) { switch (e.KeyName) { case "up": Keyboard = Keyboard.Set(ScrollDirection.Up, e.Event == KeyInputEvent.Down); return true; case "down": Keyboard = Keyboard.Set(ScrollDirection.Down, e.Event == KeyInputEvent.Down); return true; case "left": Keyboard = Keyboard.Set(ScrollDirection.Left, e.Event == KeyInputEvent.Down); return true; case "right": Keyboard = Keyboard.Set(ScrollDirection.Right, e.Event == KeyInputEvent.Down); return true; } return false; }
internal EditCommand( KeyInput input, EditCommandKind kind, Guid group, uint id) { _keyInput = input; EditCommandKind = kind; Group = group; Id = id; }
/// <summary> /// Is this KeyInput value to be discarded based on previous KeyInput values /// </summary> private bool IsDiscardedKeyInput(KeyInput keyInput) { // Check to see if we should be discarding this KeyInput value. If the KeyInput matches // then we mark the KeyInput as handled since it's the value we want to discard. In either // case though we clear out the discarded KeyInput value. This value is only meant to // last for a single key stroke. var isDiscarded = _bufferCoordinator.DiscardedKeyInput.IsSome(keyInput); _bufferCoordinator.DiscardedKeyInput = FSharpOption<KeyInput>.None; return isDiscarded; }
public KeyEventArgs CreateKeyEventArgs(KeyInput keyInput) { Key key; ModifierKeys modKeys; if (!TryGetKeyForKeyInput(keyInput, out key, out modKeys)) { throw new Exception(); } return CreateKeyEventArgs(key, modKeys); }
protected override bool OnHotkeyActivated(KeyInput e) { Game.Settings.Game.StatusBars = options[(options.IndexOf(Game.Settings.Game.StatusBars) + 1) % options.Length]; return(true); }
bool IKeyUtil.TryConvertSpecialToKeyInput(Key key, ModifierKeys modifierKeys, out KeyInput keyInput) { return(TryConvertToKeyInput(key, modifierKeys, out keyInput)); }
public override void ExecuteAction(IntPtr activeWnd, Point location) { //AutomationElement aeBrowser = AutomationElement.FromHandle((IntPtr)ActiveWnd); //int procId; //Win32.GetWindowThreadProcessId(ActiveWnd, out procId); //System.Diagnostics.Process foregroundProc = System.Diagnostics.Process.GetProcessById(procId); //StringBuilder longPath = new StringBuilder(500); //Win32.GetLongPathName(foregroundProc.MainModule.FileName, longPath, 500); //string prgPath = longPath.ToString().ToLower(); //Win32.SetForegroundWindow(ActiveWnd); //Win32.SetActiveWindow(ActiveWnd); //Win32.SetFocus(ActiveWnd); //Win32.SendMessage(ActiveWnd, Win32.WM_ACTIVATEAPP, Win32.WA_ACTIVE, 0); //Win32.SendMessage(ActiveWnd, Win32.WM_NCACTIVATE, Win32.WA_ACTIVE, 0); ////Win32.SendMessage(ActiveWnd, Win32.WM_MOUSEACTIVATE, ActiveWnd.ToInt32(), (Win32.HTCLIENT | (0x010000 * Win32.WM_LBUTTONDOWN))); //Win32.SendMessage(ActiveWnd, Win32.WM_ACTIVATE, Win32.WA_ACTIVE, 0); IntPtr hwnd = Win32.GetForegroundWindow(); if (hwnd != activeWnd) { Win32.SetForegroundWindow(activeWnd); Win32.SetActiveWindow(activeWnd); System.Threading.Thread.Sleep(100); } Thread threadExecuteInSta; string prefix = string.Empty; switch (this.Name) { case INTERNET_PAGE_NEXT: //KeyInput.ExecuteKeyInput(AllKeys.KEY_MENU_DOWN); //KeyInput.ExecuteKeyInput(AllKeys.KEY_RIGHT); //KeyInput.ExecuteKeyInput(AllKeys.KEY_MENU_UP); KeyInput.ExecuteKeyInput(AllKeys.KEY_BROWSER_FORWARD); //SendKeys.SendWait("%{RIGHT}"); break; case INTERNET_PAGE_BACK: //KeyInput.ExecuteKeyInput(AllKeys.KEY_MENU_DOWN); //KeyInput.ExecuteKeyInput(AllKeys.KEY_LEFT); //KeyInput.ExecuteKeyInput(AllKeys.KEY_MENU_UP); KeyInput.ExecuteKeyInput(AllKeys.KEY_BROWSER_BACK); //SendKeys.SendWait("%{LEFT}"); break; case INTERNET_PAGE_HOME: //KeyInput.ExecuteKeyInput(AllKeys.KEY_MENU_DOWN); //KeyInput.ExecuteKeyInput(AllKeys.KEY_HOME); //KeyInput.ExecuteKeyInput(AllKeys.KEY_MENU_UP); KeyInput.ExecuteKeyInput(AllKeys.KEY_BROWSER_HOME); //SendKeys.SendWait("%{HOME}"); break; case INTERNET_PAGE_RELOAD: //KeyInput.ExecuteKeyInput(AllKeys.KEY_F5); KeyInput.ExecuteKeyInput(AllKeys.KEY_BROWSER_REFRESH); //SendKeys.SendWait("{F5}"); break; case INTERNET_PAGE_STOP: //KeyInput.ExecuteKeyInput(AllKeys.KEY_ESCAPE); KeyInput.ExecuteKeyInput(AllKeys.KEY_BROWSER_STOP); //SendKeys.SendWait("{ESCAPE}"); break; case INTERNET_TAB_NEW: case INTERNET_TAB_REOPEN: case INTERNET_TAB_CLOSE: ExecuteKeyList(MouseAction.ModifierClick, location); break; case INTERNET_SEND_EMAIL: prefix = "mailto:"; goto case INTERNET_OPEN_WEBSITE; //break; case INTERNET_OPEN_WEBSITE: Process myProcess = new Process(); myProcess.StartInfo.FileName = prefix + this.Details; myProcess.Start(); break; case INTERNET_SEARCH_WEB: m_location = location; threadExecuteInSta = new Thread(new ThreadStart(SearchWeb)); threadExecuteInSta.SetApartmentState(ApartmentState.STA); threadExecuteInSta.Start(); break; } }
/// <summary> /// Try and process the KeyInput from the Exec method. This method decides whether or not /// a key should be processed directly by IVimBuffer or if should be going through /// IOleCommandTarget. Generally the key is processed by IVimBuffer but for many intellisense /// scenarios we want the key to be routed to Visual Studio directly. Issues to consider /// here are ... /// /// - How should the KeyInput participate in Macro playback? /// - Does both VsVim and Visual Studio need to process the key (Escape mainly) /// /// </summary> private bool TryProcessWithBuffer(KeyInput keyInput) { // If the IVimBuffer can't process it then it doesn't matter if (!_vimBuffer.CanProcess(keyInput)) { return(false); } // In the middle of a word completion session let insert mode handle the input. It's // displaying the intellisense itself and this method is meant to let custom intellisense // operate normally if (_vimBuffer.ModeKind == ModeKind.Insert && _vimBuffer.InsertMode.ActiveWordCompletionSession.IsSome()) { return(_vimBuffer.Process(keyInput).IsAnyHandled); } // The only time we actively intercept keys and route them through IOleCommandTarget // is when one of the IDisplayWindowBroker windows is active // // In those cases if the KeyInput is a command which should be handled by the // display window we route it through IOleCommandTarget to get the proper // experience for those features if (!_broker.IsAnyDisplayActive()) { // The one exception to this rule is R#. We can't accurately determine if // R# has intellisense active or not so we have to pretend like it always // does. We limit this to insert mode only though. if (!_resharperUtil.IsInstalled || _vimBuffer.ModeKind != ModeKind.Insert) { return(_vimBuffer.Process(keyInput).IsAnyHandled); } } // Next we need to consider here are Key mappings. The CanProcess and Process APIs // will automatically map the KeyInput under the hood at the IVimBuffer level but // not at the individual IMode. Have to manually map here and test against the // mapped KeyInput KeyInput mapped; if (!TryGetSingleMapping(keyInput, out mapped)) { return(_vimBuffer.Process(keyInput).IsAnyHandled); } // If the key actually being processed is a display window key and the display window // is active then we allow IOleCommandTarget to control the key if (IsDisplayWindowKey(mapped)) { return(false); } var handled = _vimBuffer.Process(keyInput).IsAnyHandled; // The Escape key should always dismiss the active completion session. However Vim // itself is mostly ignorant of display windows and typically won't dismiss them // as part of processing Escape (one exception is insert mode). Dismiss it here if // it's still active if (mapped.Key == VimKey.Escape && _broker.IsAnyDisplayActive()) { _broker.DismissDisplayWindows(); } return(handled); }
/// <summary> /// With Resharper installed we need to special certain keys like Escape. They need to /// process it in order for them to dismiss their custom intellisense but their processing /// will swallow the event and not propagate it to us. So handle, return and account /// for the double stroke in exec /// </summary> private CommandStatus?QueryStatusInResharper(KeyInput keyInput) { CommandStatus?status = null; var passToResharper = true; if (_vimBuffer.ModeKind.IsAnyInsert() && keyInput == KeyInputUtil.EscapeKey) { // Have to special case Escape here for insert mode. R# is typically ahead of us on the IOleCommandTarget // chain. If a completion window is open and we wait for Exec to run R# will be ahead of us and run // their Exec call. This will lead to them closing the completion window and not calling back into // our exec leaving us in insert mode. status = CommandStatus.Enable; } else if (_vimBuffer.ModeKind == ModeKind.ExternalEdit && keyInput == KeyInputUtil.EscapeKey) { // Have to special case Escape here for external edit mode because we want escape to get us back to // normal mode. However we do want this key to make it to R# as well since they may need to dismiss // intellisense status = CommandStatus.Enable; } else if ((keyInput.Key == VimKey.Back || keyInput == KeyInputUtil.EnterKey) && _vimBuffer.ModeKind != ModeKind.Insert) { // R# special cases both the Back and Enter command in various scenarios // // - Enter is special cased in XML doc comments presumably to do custom formatting // - Enter is supressed during debugging in Exec. Presumably this is done to avoid the annoying // "Invalid ENC Edit" dialog during debugging. // - Back is special cased to delete matched parens in Exec. // // In all of these scenarios if the Enter or Back key is registered as a valid Vim // command we want to process it as such and prevent R# from seeing the command. If // R# is allowed to see the command they will process it often resulting in double // actions status = CommandStatus.Enable; passToResharper = false; } // Only process the KeyInput if we are enabling the value. When the value is Enabled // we return Enabled from QueryStatus and Visual Studio will push the KeyInput back // through the event chain where either of the following will happen // // 1. R# will handle the KeyInput // 2. R# will not handle it, it will come back to use in Exec and we will ignore it // because we mark it as silently handled if (status.HasValue && status.Value == CommandStatus.Enable && _vimBuffer.Process(keyInput).IsAnyHandled) { // We've broken the rules a bit by handling the command in QueryStatus and we need // to silently handle this command if it comes back to us again either through // Exec or through the VsKeyProcessor _bufferCoordinator.DiscardedKeyInput = FSharpOption.Create(keyInput); // If we need to cooperate with R# to handle this command go ahead and pass it on // to them. Else mark it as Disabled. // // Marking it as Disabled will cause the QueryStatus call to fail. This means the // KeyInput will be routed to the KeyProcessor chain for the ITextView eventually // making it to our VsKeyProcessor. That component respects the SilentlyHandled // statu of KeyInput and will siently handle it status = passToResharper ? CommandStatus.Enable : CommandStatus.Disable; } return(status); }
public override bool HandleKeyPress(KeyInput e) { return(OnKeyPress(e)); }
internal EditCommand Create(KeyInput ki, EditCommandKind kind) { return(new EditCommand(ki, kind, Guid.Empty, 0)); }
public bool CanProcessNotDirectInsert(KeyInput value) { throw new NotImplementedException(); }
public bool CanProcess(KeyInput value) { throw new NotImplementedException(); }
bool IReportDesignerUtil.IsSpecialHandled(KeyInput keyInput) { return(IsSpecialHandled(keyInput)); }
private bool IsSpecialHandled(KeyInput keyInput) { return(s_specialHandledSet.Contains(keyInput)); }
bool IOrderGenerator.HandleKeyPress(KeyInput e) { return(false); }
public static Hotkey FromKeyInput(KeyInput ki) { return(new Hotkey(ki.Key, ki.Modifiers)); }
public IEnumerable <CommandShortcut> GetCommandShortcuts(object target) { if (!(target is ITextView)) { yield break; } yield return(CommandShortcut.Create(Key.Back, TextEditorIds.BACKSPACE.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.Back, TextEditorIds.BACKSPACE.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.Tab, TextEditorIds.BACKTAB.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.BOL.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.BOL_EXT.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.BOL_EXT_COL.ToCommandInfo()); yield return(CommandShortcut.Control(Key.PageDown, TextEditorIds.BOTTOMLINE.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.PageDown, TextEditorIds.BOTTOMLINE_EXT.ToCommandInfo())); yield return(CommandShortcut.Create(Key.Escape, TextEditorIds.CANCEL.ToCommandInfo())); yield return(CommandShortcut.Control(Key.L, TextEditorIds.CUTLINE.ToCommandInfo())); yield return(CommandShortcut.Create(Key.Delete, TextEditorIds.DELETE.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.DELETEBLANKLINES.ToCommandInfo()); yield return(CommandShortcut.CtrlShift(Key.L, TextEditorIds.DELETELINE.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.DELETETOBOL.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.DELETETOEOL.ToCommandInfo()); //yield return CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Control(Key.OemBackslash), TextEditorIds.DELETEWHITESPACE.ToCommandInfo()); yield return(CommandShortcut.Create(KeyInput.Control(Key.E), KeyInput.Create(Key.OemBackslash), TextEditorIds.DELETEWHITESPACE.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.E), KeyInput.Control(Key.OemBackslash), TextEditorIds.DELETEWHITESPACE.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Back, TextEditorIds.DELETEWORDLEFT.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Delete, TextEditorIds.DELETEWORDRIGHT.ToCommandInfo())); yield return(CommandShortcut.Create(Key.Down, TextEditorIds.DOWN.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.Down, TextEditorIds.DOWN_EXT.ToCommandInfo())); yield return(CommandShortcut.ShiftAlt(Key.Down, TextEditorIds.DOWN_EXT_COL.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.ECMD_CONVERTSPACESTOTABS.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.ECMD_CONVERTTABSTOSPACES.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.EditorLineFirstColumn.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.EditorLineFirstColumnExtend.ToCommandInfo()); yield return(CommandShortcut.Control(Key.End, TextEditorIds.END.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.End, TextEditorIds.END_EXT.ToCommandInfo())); yield return(CommandShortcut.Create(Key.End, TextEditorIds.EOL.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.End, TextEditorIds.EOL_EXT.ToCommandInfo())); yield return(CommandShortcut.ShiftAlt(Key.End, TextEditorIds.EOL_EXT_COL.ToCommandInfo())); yield return(CommandShortcut.Create(Key.Home, TextEditorIds.BOL.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.Home, TextEditorIds.BOL_EXT.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.FIRSTNONWHITENEXT.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.FIRSTNONWHITEPREV.ToCommandInfo()); yield return(CommandShortcut.Control(Key.OemCloseBrackets, TextEditorIds.GOTOBRACE.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.OemCloseBrackets, TextEditorIds.GOTOBRACE_EXT.ToCommandInfo())); yield return(CommandShortcut.Control(Key.G, TextEditorIds.GOTOLINE.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Home, TextEditorIds.HOME.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.Home, TextEditorIds.HOME_EXT.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.INDENT.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.LASTCHAR.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.LASTCHAR_EXT.ToCommandInfo()); yield return(CommandShortcut.Create(Key.Left, TextEditorIds.LEFT.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.Left, TextEditorIds.LEFT_EXT.ToCommandInfo())); yield return(CommandShortcut.ShiftAlt(Key.Left, TextEditorIds.LEFT_EXT_COL.ToCommandInfo())); yield return(CommandShortcut.Alt(Key.Down, TextEditorIds.MoveSelLinesDown.ToCommandInfo())); yield return(CommandShortcut.Alt(Key.Up, TextEditorIds.MoveSelLinesUp.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Enter, TextEditorIds.OPENLINEABOVE.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.Enter, TextEditorIds.OPENLINEBELOW.ToCommandInfo())); yield return(CommandShortcut.Create(Key.PageDown, TextEditorIds.PAGEDN.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.PageDown, TextEditorIds.PAGEDN_EXT.ToCommandInfo())); yield return(CommandShortcut.Create(Key.PageUp, TextEditorIds.PAGEUP.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.PageUp, TextEditorIds.PAGEUP_EXT.ToCommandInfo())); yield return(CommandShortcut.Create(Key.Enter, TextEditorIds.RETURN.ToCommandInfo())); yield return(CommandShortcut.Create(Key.Right, TextEditorIds.RIGHT.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.Right, TextEditorIds.RIGHT_EXT.ToCommandInfo())); yield return(CommandShortcut.ShiftAlt(Key.Right, TextEditorIds.RIGHT_EXT_COL.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.SCROLLBOTTOM.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.SCROLLCENTER.ToCommandInfo()); yield return(CommandShortcut.Control(Key.Down, TextEditorIds.SCROLLDN.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.SCROLLLEFT.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.SCROLLPAGEDN.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.SCROLLPAGEUP.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.SCROLLRIGHT.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.SCROLLTOP.ToCommandInfo()); yield return(CommandShortcut.Control(Key.Up, TextEditorIds.SCROLLUP.ToCommandInfo())); yield return(CommandShortcut.Control(Key.A, TextEditorIds.SELECTALL.ToCommandInfo())); yield return(CommandShortcut.Control(Key.W, TextEditorIds.SELECTCURRENTWORD.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.W, TextEditorIds.SELECTCURRENTWORD.ToCommandInfo())); yield return(CommandShortcut.Control(Key.U, TextEditorIds.SELLOWCASE.ToCommandInfo())); //yield return CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Control(Key.A), TextEditorIds.SELSWAPANCHOR.ToCommandInfo()); yield return(CommandShortcut.Create(KeyInput.Control(Key.E), KeyInput.Create(Key.A), TextEditorIds.SELSWAPANCHOR.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.E), KeyInput.Control(Key.A), TextEditorIds.SELSWAPANCHOR.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Q, TextEditorIds.SELTABIFY.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.SELTITLECASE.ToCommandInfo()); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.SELTOGGLECASE.ToCommandInfo()); yield return(CommandShortcut.CtrlShift(Key.Q, TextEditorIds.SELUNTABIFY.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.U, TextEditorIds.SELUPCASE.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.Enter, TextEditorIds.SmartBreakLine.ToCommandInfo())); yield return(CommandShortcut.Create(Key.Tab, TextEditorIds.TAB.ToCommandInfo())); yield return(CommandShortcut.Create(Key.Insert, TextEditorIds.TOGGLE_OVERTYPE_MODE.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.D8, TextEditorIds.TOGGLEVISSPACE.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.R), KeyInput.Control(Key.W), TextEditorIds.TOGGLEVISSPACE.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.E), KeyInput.Create(Key.S), TextEditorIds.TOGGLEVISSPACE.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.E), KeyInput.Control(Key.S), TextEditorIds.TOGGLEVISSPACE.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.E), KeyInput.Create(Key.W), TextEditorIds.TOGGLEWORDWRAP.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.E), KeyInput.Control(Key.W), TextEditorIds.TOGGLEWORDWRAP.ToCommandInfo())); yield return(CommandShortcut.Alt(Key.Right, TextEditorIds.COMPLETEWORD.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Space, TextEditorIds.COMPLETEWORD.ToCommandInfo())); //yield return CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Create(Key.W), TextEditorIds.COMPLETEWORD.ToCommandInfo()); //yield return CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Control(Key.W), TextEditorIds.COMPLETEWORD.ToCommandInfo()); yield return(CommandShortcut.CtrlAlt(Key.T, TextEditorIds.SHOWMEMBERLIST.ToCommandInfo())); yield return(CommandShortcut.Control(Key.J, TextEditorIds.SHOWMEMBERLIST.ToCommandInfo())); //yield return CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Create(Key.L), TextEditorIds.SHOWMEMBERLIST.ToCommandInfo()); //yield return CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Control(Key.L), TextEditorIds.SHOWMEMBERLIST.ToCommandInfo()); yield return(CommandShortcut.CtrlAlt(Key.Space, TextEditorIds.ToggleConsumeFirstCompletionMode.ToCommandInfo())); yield return(CommandShortcut.Control(Key.PageUp, TextEditorIds.TOPLINE.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.PageUp, TextEditorIds.TOPLINE_EXT.ToCommandInfo())); yield return(CommandShortcut.Control(Key.T, TextEditorIds.TRANSPOSECHAR.ToCommandInfo())); yield return(CommandShortcut.ShiftAlt(Key.T, TextEditorIds.TRANSPOSELINE.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.T, TextEditorIds.TRANSPOSEWORD.ToCommandInfo())); //TODO: yield return CommandShortcut.Control(Key.XXXXX, TextEditorIds.UNINDENT.ToCommandInfo()); yield return(CommandShortcut.Create(Key.Up, TextEditorIds.UP.ToCommandInfo())); yield return(CommandShortcut.Shift(Key.Up, TextEditorIds.UP_EXT.ToCommandInfo())); yield return(CommandShortcut.ShiftAlt(Key.Up, TextEditorIds.UP_EXT_COL.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Right, TextEditorIds.WORDNEXT.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.Right, TextEditorIds.WORDNEXT_EXT.ToCommandInfo())); yield return(CommandShortcut.CtrlShiftAlt(Key.Right, TextEditorIds.WORDNEXT_EXT_COL.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Left, TextEditorIds.WORDPREV.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.Left, TextEditorIds.WORDPREV_EXT.ToCommandInfo())); yield return(CommandShortcut.CtrlShiftAlt(Key.Left, TextEditorIds.WORDPREV_EXT_COL.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.OemPeriod, TextEditorIds.ZoomIn.ToCommandInfo())); yield return(CommandShortcut.Control(Key.OemPlus, TextEditorIds.ZoomIn.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Add, TextEditorIds.ZoomIn.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.OemComma, TextEditorIds.ZoomOut.ToCommandInfo())); yield return(CommandShortcut.Control(Key.OemMinus, TextEditorIds.ZoomOut.ToCommandInfo())); yield return(CommandShortcut.Control(Key.Subtract, TextEditorIds.ZoomOut.ToCommandInfo())); yield return(CommandShortcut.Control(Key.D0, TextEditorIds.ZoomReset.ToCommandInfo())); yield return(CommandShortcut.Control(Key.NumPad0, TextEditorIds.ZoomReset.ToCommandInfo())); yield return(CommandShortcut.Alt(Key.OemComma, TextEditorIds.DECREASEFILTER.ToCommandInfo())); yield return(CommandShortcut.Alt(Key.OemPeriod, TextEditorIds.INCREASEFILTER.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Create(Key.I), TextEditorIds.QUICKINFO.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Control(Key.I), TextEditorIds.QUICKINFO.ToCommandInfo())); yield return(CommandShortcut.CtrlShift(Key.Space, TextEditorIds.PARAMINFO.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Create(Key.P), TextEditorIds.PARAMINFO.ToCommandInfo())); yield return(CommandShortcut.Create(KeyInput.Control(Key.K), KeyInput.Control(Key.P), TextEditorIds.PARAMINFO.ToCommandInfo())); }
public override bool HandleKeyPress(KeyInput e) { var key = Hotkey.FromKeyInput(e); var ks = Game.Settings.Keys; if (key == ks.MapScrollUp) { keyboardDirections = keyboardDirections.Set(ScrollDirection.Up, e.Event == KeyInputEvent.Down); return(true); } if (key == ks.MapScrollDown) { keyboardDirections = keyboardDirections.Set(ScrollDirection.Down, e.Event == KeyInputEvent.Down); return(true); } if (key == ks.MapScrollLeft) { keyboardDirections = keyboardDirections.Set(ScrollDirection.Left, e.Event == KeyInputEvent.Down); return(true); } if (key == ks.MapScrollRight) { keyboardDirections = keyboardDirections.Set(ScrollDirection.Right, e.Event == KeyInputEvent.Down); return(true); } if (key == ks.MapPushTop) { worldRenderer.Viewport.Center(new WPos(worldRenderer.Viewport.CenterPosition.X, 0, 0)); return(false); } if (key == ks.MapPushBottom) { worldRenderer.Viewport.Center(new WPos(worldRenderer.Viewport.CenterPosition.X, worldRenderer.World.Map.ProjectedBottomRight.Y, 0)); return(false); } if (key == ks.MapPushLeftEdge) { worldRenderer.Viewport.Center(new WPos(0, worldRenderer.Viewport.CenterPosition.Y, 0)); return(false); } if (key == ks.MapPushRightEdge) { worldRenderer.Viewport.Center(new WPos(worldRenderer.World.Map.ProjectedBottomRight.X, worldRenderer.Viewport.CenterPosition.Y, 0)); } if (key == ks.ViewPortBookmarkSaveSlot1) { SaveCurrentPositionToBookmark(0); return(false); } if (key == ks.ViewPortBookmarkSaveSlot2) { SaveCurrentPositionToBookmark(1); return(false); } if (key == ks.ViewPortBookmarkSaveSlot3) { SaveCurrentPositionToBookmark(2); return(false); } if (key == ks.ViewPortBookmarkSaveSlot4) { SaveCurrentPositionToBookmark(3); return(false); } if (key == ks.ViewPortBookmarkUseSlot1) { JumpToSavedBookmark(0); return(false); } if (key == ks.ViewPortBookmarkUseSlot2) { JumpToSavedBookmark(1); return(false); } if (key == ks.ViewPortBookmarkUseSlot3) { JumpToSavedBookmark(2); return(false); } if (key == ks.ViewPortBookmarkUseSlot4) { JumpToSavedBookmark(3); return(false); } return(false); }
public KeyMappingResult GetKeyInputMapping(KeyInput value) { throw new NotImplementedException(); }
bool IKeyUtil.TryConvertSpecialToKeyInput(Key key, ModifierKeys modifierKeys, out KeyInput keyInput) { if (WpfKeyToKeyInputMap.TryGetValue(key, out keyInput)) { var keyModifiers = KeyboardMap.ConvertToKeyModifiers(modifierKeys); keyInput = KeyInputUtil.ApplyModifiers(keyInput, keyModifiers); return(true); } keyInput = null; return(false); }
public void SimulateProcessed(KeyInput value) { throw new NotImplementedException(); }
public ProcessResult Process(KeyInput value) { throw new NotImplementedException(); }
protected abstract bool OnHotkeyActivated(KeyInput e);
/// <summary> /// Try and convert the Visual Studio command to it's equivalent KeyInput /// </summary> internal bool TryConvert(Guid commandGroup, uint commandId, IntPtr variantIn, out KeyInput keyInput) { keyInput = null; EditCommand editCommand; if (!TryConvert(commandGroup, commandId, variantIn, out editCommand)) { return(false); } if (!editCommand.HasKeyInput) { return(false); } keyInput = editCommand.KeyInput; return(true); }
protected override bool OnHotkeyActivated(KeyInput e) { viewport.Center(selection.Actors); return(true); }
protected override bool OnHotkeyActivated(KeyInput e) { Game.Settings.Game.UsePlayerStanceColors ^= true; return(true); }
protected override bool OnHotkeyActivated(KeyInput e) { Game.TakeScreenshot(); return(true); }
public override bool HandleKeyPress(KeyInput e) { if (e.Event == KeyInputEvent.Down) { // Players to be included in the selection (the viewer or all players in "Disable shroud" / "All players" mode) var viewer = World.RenderPlayer ?? World.LocalPlayer; var isShroudDisabled = viewer == null || (World.RenderPlayer == null && World.LocalPlayer.Spectating); var isEveryone = viewer != null && viewer.NonCombatant && viewer.Spectating; var eligiblePlayers = isShroudDisabled || isEveryone ? World.Players : new[] { viewer }; if (SelectAllKey.IsActivatedBy(e) && !World.IsGameOver) { // Select actors on the screen which belong to the current player(s) var ownUnitsOnScreen = SelectActorsOnScreen(World, worldRenderer, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); // Check if selecting actors on the screen has selected new units if (ownUnitsOnScreen.Count > World.Selection.Actors.Count()) { Game.AddSystemLine("Selected across screen"); } else { // Select actors in the world that have highest selection priority ownUnitsOnScreen = SelectActorsInWorld(World, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); Game.AddSystemLine("Selected across map"); } World.Selection.Combine(World, ownUnitsOnScreen, false, false); } else if (SelectSameTypeKey.IsActivatedBy(e) && !World.IsGameOver) { if (!World.Selection.Actors.Any()) { return(false); } var ownedActors = World.Selection.Actors .Where(x => !x.IsDead && eligiblePlayers.Contains(x.Owner)) .ToList(); if (!ownedActors.Any()) { return(false); } // Get all the selected actors' selection classes var selectedClasses = ownedActors .Select(a => a.Trait <ISelectable>().Class) .ToHashSet(); // Select actors on the screen that have the same selection class as one of the already selected actors var newSelection = SelectActorsOnScreen(World, worldRenderer, selectedClasses, eligiblePlayers).ToList(); // Check if selecting actors on the screen has selected new units if (newSelection.Count > World.Selection.Actors.Count()) { Game.AddSystemLine("Selected across screen"); } else { // Select actors in the world that have the same selection class as one of the already selected actors newSelection = SelectActorsInWorld(World, selectedClasses, eligiblePlayers).ToList(); Game.AddSystemLine("Selected across map"); } World.Selection.Combine(World, newSelection, true, false); } } return(false); }
bool ProcessInput(KeyInput e) { if (e.Event == KeyInputEvent.Down) { var key = Hotkey.FromKeyInput(e); var ks = Game.Settings.Keys; if (key == ks.CycleBaseKey) { return(CycleBases()); } if (key == ks.CycleProductionBuildingsKey) { return(CycleProductionBuildings()); } if (key == ks.ToLastEventKey) { return(ToLastEvent()); } if (key == ks.ToSelectionKey) { return(ToSelection()); } // Put all functions that aren't unit-specific before this line! if (!world.Selection.Actors.Any()) { return(false); } if (key == ks.AttackMoveKey) { return(PerformAttackMove()); } if (key == ks.StopKey) { return(PerformStop()); } if (key == ks.ScatterKey) { return(PerformScatter()); } if (key == ks.DeployKey) { return(PerformDeploy()); } if (key == ks.StanceCycleKey) { return(PerformStanceCycle()); } if (key == ks.GuardKey) { return(PerformGuard()); } } return(false); }
public virtual bool HandleKeyPress(KeyInput e) { return(false); }
private void Update() { if (OnUpdate != null) { OnUpdate(); } if (m_trackUnityInput) { for (int i = 0; i < trackedUnityAxes.Count; i++) { trackedUnityAxes[i].value = Input.GetAxisRaw(trackedUnityAxes[i].Key); } for (int i = 0; i < trackedUnityButtons.Count; i++) { trackedUnityButtons[i].value = Input.GetButton(trackedUnityButtons[i].Key); } for (int i = 0; i < trackedUnityMouseButtons.Count; i++) { trackedUnityMouseButtons[i].value = Input.GetMouseButton(trackedUnityMouseButtons[i].Key); } } float lerpModifier = AxisLerpModifier * Time.deltaTime; for (int i = 0; i < axesList.Count; i++) { Axis axis = axesList[i]; axis.valueRaw = 0f; for (int j = axis.inputs.Count - 1; j >= 0; j--) { AxisInput input = axis.inputs[j]; if (input.value != 0f) { axis.valueRaw = input.value; break; } } axis.value = Mathf.Lerp(axis.value, axis.valueRaw, lerpModifier); if (axis.valueRaw == 0f && axis.value != 0f) { if (Mathf.Abs(axis.value) < 0.025f) { axis.value = 0f; } } } for (int i = 0; i < buttonsList.Count; i++) { Button button = buttonsList[i]; bool isDown = false; for (int j = button.inputs.Count - 1; j >= 0; j--) { ButtonInput input = button.inputs[j]; if (input.value) { isDown = true; break; } } if (isDown) { if (button.state == InputState.None || button.state == InputState.Released) { button.state = InputState.Pressed; } else { button.state = InputState.Held; } } else { if (button.state == InputState.Pressed || button.state == InputState.Held) { button.state = InputState.Released; } else { button.state = InputState.None; } } } for (int i = 0; i < mouseButtonsList.Count; i++) { MouseButton mouseButton = mouseButtonsList[i]; bool isDown = false; for (int j = mouseButton.inputs.Count - 1; j >= 0; j--) { MouseButtonInput input = mouseButton.inputs[j]; if (input.value) { isDown = true; break; } } if (isDown) { if (mouseButton.state == InputState.None || mouseButton.state == InputState.Released) { mouseButton.state = InputState.Pressed; } else { mouseButton.state = InputState.Held; } } else { if (mouseButton.state == InputState.Pressed || mouseButton.state == InputState.Held) { mouseButton.state = InputState.Released; } else { mouseButton.state = InputState.None; } } } for (int i = 0; i < keysList.Count; i++) { Key key = keysList[i]; bool isDown = false; for (int j = key.inputs.Count - 1; j >= 0; j--) { KeyInput input = key.inputs[j]; if (input.value) { isDown = true; break; } } if (isDown) { if (key.state == InputState.None || key.state == InputState.Released) { key.state = InputState.Pressed; } else { key.state = InputState.Held; } } else { if (key.state == InputState.Pressed || key.state == InputState.Held) { key.state = InputState.Released; } else { key.state = InputState.None; } } } }
/// <summary> /// Try and process the given KeyInput with the IVimBuffer. This is overridable by /// derived classes in order for them to prevent any KeyInput from reaching the /// IVimBuffer /// </summary> private bool TryProcess(KeyInput keyInput) { return(VimBuffer.CanProcessAsCommand(keyInput) && VimBuffer.Process(keyInput).IsAnyHandled); }
internal bool TryConvertToKeyInput(Key key, ModifierKeys modifierKeys, out KeyInput keyInput) { return(GetOrCreateKeyboardMap().TryGetKeyInput(key, modifierKeys, out keyInput)); }