public char?GetCharExclusiveJustDownAndSwallow(InputConsumer ic) { var shift = IsKeyDown(SKeys.ShiftAny); if (IsKeyExclusiveJustDown(SKeys.Space)) { SwallowKey(SKeys.Space, ic); return(' '); } for (SKeys chr = SKeys.A; chr < SKeys.Z; chr++) { if (IsKeyExclusiveJustDown(chr)) { SwallowKey(chr, ic); return((char)(chr - SKeys.A + (shift ? 'A' : 'a'))); } } if (IsKeyExclusiveJustDown(SKeys.D0)) { SwallowKey(SKeys.D0, ic); return('0'); } if (IsKeyExclusiveJustDown(SKeys.D1)) { SwallowKey(SKeys.D1, ic); return('1'); } if (IsKeyExclusiveJustDown(SKeys.D2)) { SwallowKey(SKeys.D2, ic); return('2'); } if (IsKeyExclusiveJustDown(SKeys.D3)) { SwallowKey(SKeys.D3, ic); return('3'); } if (IsKeyExclusiveJustDown(SKeys.D4)) { SwallowKey(SKeys.D4, ic); return('4'); } if (IsKeyExclusiveJustDown(SKeys.D5)) { SwallowKey(SKeys.D5, ic); return('5'); } if (IsKeyExclusiveJustDown(SKeys.D6)) { SwallowKey(SKeys.D6, ic); return('6'); } if (IsKeyExclusiveJustDown(SKeys.D7)) { SwallowKey(SKeys.D7, ic); return('7'); } if (IsKeyExclusiveJustDown(SKeys.D8)) { SwallowKey(SKeys.D8, ic); return('8'); } if (IsKeyExclusiveJustDown(SKeys.D9)) { SwallowKey(SKeys.D9, ic); return('9'); } return(null); }
private string FormatKey(SKeys k) { // ReSharper disable once SwitchStatementMissingSomeCases switch (k) { case SKeys.D0: case SKeys.D1: case SKeys.D2: case SKeys.D3: case SKeys.D4: case SKeys.D5: case SKeys.D6: case SKeys.D7: case SKeys.D8: case SKeys.D9: return(k.ToString().Substring(1)); case SKeys.AndroidBack: return("Back"); case SKeys.AndroidMenu: return("Menu"); default: return(k.ToString()); } }
public void SwallowKey(SKeys s, InputConsumer ic) { if (_consumedKeyEvts == null) { _consumedKeyEvts = new List <Tuple <SKeys, InputConsumer> >(); } _consumedKeyEvts.Add(Tuple.Create(s, ic)); }
public ButtonState Get(SKeys keys) { if ((keys & SKeys.MouseFlag) != SKeys.MouseFlag) { throw new ArgumentException("Invalid SKeys type"); } return _buttonStates[keys - SKeys.MouseOffset]; }
public bool IsKeyDown(SKeys key) { bool v; if (currentKeyState.TryGetValue(key, out v)) { return(v); } else { v = IsKeyDown(key, Keyboard, GamePad); currentKeyState.Add(key, v); return(v); } }
public bool IsKeyExclusiveJustDown(SKeys key) { if (_consumedKeyEvts != null && _consumedKeyEvts.Any(e => e.Item1 == key)) { return(false); } bool v; if (currentKeyState.TryGetValue(key, out v)) { return(v && !lastKeyState[key]); } else { v = IsKeyDown(key, Keyboard, GamePad); currentKeyState.Add(key, v); lastKeyState.Add(key, v); return(false); } }
private static bool IsKeyDown(SKeys key, KeyboardState ks, GamePadState gs) { // ReSharper disable once SwitchStatementMissingSomeCases switch (key) { case SKeys.ShiftAny: return(ks.IsKeyDown(Keys.LeftShift) || ks.IsKeyDown(Keys.RightShift)); case SKeys.ControlAny: return(ks.IsKeyDown(Keys.LeftControl) || ks.IsKeyDown(Keys.RightControl)); case SKeys.AltAny: return(ks.IsKeyDown(Keys.LeftAlt) || ks.IsKeyDown(Keys.RightAlt)); case SKeys.AndroidBack: return(gs.Buttons.Back == ButtonState.Pressed); default: return(ks.IsKeyDown((Keys)key)); } }
public bool IsShortcutExclusiveJustPressed(KeyModifier mod, SKeys key) { return(IsModifierDown(mod) && IsKeyExclusiveJustDown(key)); }
public static void AddPush(string parentIdent, string ident, ILifetimeObject owner, SKeys actionkey, KeyModifier mod, Action <DebugListener> listenerEvent = null) { var upperIdent = ident.ToUpper(); if (listeners.ContainsKey(upperIdent)) { listeners.Remove(upperIdent); } var result = new DebugListener(parentIdent, ident, owner, actionkey, mod, DebugListener.DebugListenerType.Push); if (listenerEvent != null) { result.SetEvent(listenerEvent); } listeners.Add(upperIdent, result); }
public static void AddSwitch(string parentIdent, string ident, ILifetimeObject owner, SKeys actionkey, KeyModifier mod, bool initial) { var upperIdent = ident.ToUpper(); if (listeners.ContainsKey(upperIdent)) { initial = listeners[upperIdent].SelfActive; listeners.Remove(upperIdent); } var result = new DebugListener(parentIdent, ident, owner, actionkey, mod, DebugListener.DebugListenerType.Switch); result.Set(initial); listeners.Add(upperIdent, result); }
public bool IsUp(SKeys key) { return Get(key) == ButtonState.Up; }
public bool IsReleased(SKeys key) { return Get(key) == ButtonState.Released; }
public bool IsPressed(SKeys key) { return Get(key) == ButtonState.Pressed; }
public bool IsDown(SKeys key) { return Get(key) == ButtonState.Down; }
public bool IsShortcutPressed(KeyModifier mod, SKeys key) { return(IsModifierDown(mod) && IsKeyDown(key)); }
public static KeyCombinationList C(SKeys key1, SKeys key2, SKeys key3) { return(new KeyCombinationList(new KeyCombination(key1, KeyModifier.None), new KeyCombination(key2, KeyModifier.None), new KeyCombination(key3, KeyModifier.None))); }
public static KeyCombinationList C(SKeys key1, KeyModifier mod1, SKeys key2, KeyModifier mod2) { return(new KeyCombinationList(new KeyCombination(key1, mod1), new KeyCombination(key2, mod2))); }
public KeyCombination(SKeys k, KeyModifier m) { Key = k; Mod = m; }
public DebugListener(string parentIdent, string ident, ILifetimeObject owner, SKeys actionkey, KeyModifier mod, DebugListenerType debugtype) { ParentIdentifier = parentIdent; Identifier = ident; keys = new KeyCombinationList(new KeyCombination(actionkey, mod)); Type = debugtype; Owner = owner; }