public virtual float GetValue(InputManagerBase manager) { float value = 0.0f; foreach (var virtualButton in Items) { float newValue = virtualButton != null?virtualButton.GetValue(manager) : 0.0f; // In case of a || (disjunction) set, we return the latest non-zero value. if (IsDisjunction) { if (newValue != 0.0f) { value = newValue; } } else { // In case of a && (conjunction) set, we return the last non-zero value unless there is a zero value. if (newValue == 0.0f) { return(0.0f); } value = newValue; } } return(value); }
public override void Initialize() { base.Initialize(); input = Services.GetServiceAs<InputManager>(); Enabled = true; Visible = false; if (Game != null) // thumbnail system has no game { Game.Activated += OnApplicationResumed; Game.Deactivated += OnApplicationPaused; } }
public virtual float GetValue(InputManagerBase inputManager, object name) { float value = 0.0f; List <VirtualButtonBinding> bindingsPerName; if (mapBindings.TryGetValue(name, out bindingsPerName)) { foreach (var virtualButtonBinding in bindingsPerName) { float newValue = virtualButtonBinding.GetValue(inputManager); if (Math.Abs(newValue) > Math.Abs(value)) { value = newValue; } } } return(value); }
private void InterpretKey(Keys key, InputManagerBase input) { // delete and back space have same behavior when there is a selection if (SelectionLength > 0 && (key == Keys.Delete || key == Keys.Back)) { SelectedText = ""; return; } // backspace with caret if (key == Keys.Back) { selectionStart = Math.Max(0, selectionStart - 1); SelectedText = ""; return; } // delete with caret if (key == Keys.Delete) { SelectionLength = 1; SelectedText = ""; return; } // select backward if (key == Keys.Left && (input.IsKeyDown(Keys.LeftShift) || input.IsKeyDown(Keys.RightShift))) { if (caretAtStart || selectionStart == selectionStop) Select(selectionStart - 1, SelectionLength + 1, true); else Select(selectionStart, SelectionLength - 1); return; } // select forward if (key == Keys.Right && (input.IsKeyDown(Keys.LeftShift) || input.IsKeyDown(Keys.RightShift))) { if (caretAtStart && selectionStart != selectionStop) Select(selectionStart + 1, SelectionLength - 1, true); else Select(selectionStart, SelectionLength + 1); return; } // move backward if (key == Keys.Left) { CaretPosition = CaretPosition - 1; return; } // move forward if (key == Keys.Right) { CaretPosition = CaretPosition + 1; return; } // validate the text with "enter" or "escape" if (key == Keys.Enter || key == Keys.Escape) { IsSelectionActive = false; return; } // try to convert the key to character and insert it at the caret position or replace the current selection var character = '\0'; if (TryConvertKeyToCharacter(key, input.IsKeyDown(Keys.LeftShift) || input.IsKeyDown(Keys.RightShift), ref character)) SelectedText = new string(character, 1); }
public abstract float GetValue(InputManagerBase manager);