/// <summary>Fixed the update.</summary> public override void FixedUpdate() { for (int i = 0; i < KeyboardsValues.Length; i++) { TempKey = Enum.Parse <SFML.Window.Keyboard.Key>(KeyboardsNames[i]); if (SFML.Window.Keyboard.IsKeyPressed(TempKey)) { if (!Keys.Contains(KeyboardsValues[i])) { Keys.Add(KeyboardsValues[i]); PressDown(KeyboardsValues[i]); OnPressDownKey.Invoke(this, KeyboardsValues[i]); } PressKey(KeyboardsValues[i]); OnPressKey.Invoke(this, KeyboardsValues[i]); } else { if (Keys.Contains(KeyboardsValues[i])) { Keys.Remove(KeyboardsValues[i]); PressUp(KeyboardsValues[i]); OnReleaseKey.Invoke(this, KeyboardsValues[i]); } } } }
public override void KeyPress(SFML.Window.Keyboard.Key key, bool pressed) { if (!EditMode) { return; } switch (key) { case Keyboard.Key.Left: if (pressed) { CaretPosition--; } break; case Keyboard.Key.Right: if (pressed) { CaretPosition++; } break; case Keyboard.Key.LShift: capsmode = pressed; break; case Keyboard.Key.End: CaretPosition = Text.Length; break; case Keyboard.Key.Home: CaretPosition = 0; break; } }
/// <summary> /// Shortcut to get the <see cref="AsciiKey"/> for a specific MonoGame/XNA <see cref="Keys"/> type. /// </summary> /// <param name="key">The key.</param> /// <param name="shiftPressed">If shift should be considered pressed or not.</param> /// <returns>The <see cref="AsciiKey"/> of the <see cref="Keys"/>.</returns> public static AsciiKey Get(Keys key, bool shiftPressed) { AsciiKey asciiKey = new AsciiKey(); asciiKey.Fill(key, shiftPressed); return(asciiKey); }
/// <summary> /// Shortcut to get the <see cref="AsciiKey"/> for a specific MonoGame/XNA <see cref="Keys"/> type. Shift is considered not pressed. /// </summary> /// <param name="key">The key.</param> /// <returns>The <see cref="AsciiKey"/> of the <see cref="Keys"/>.</returns> public static AsciiKey Get(Keys key) { AsciiKey asciiKey = new AsciiKey(); asciiKey.Fill(key, false); return(asciiKey); }
public void move(SFML.Window.Keyboard.Key key) { switch (key) { case Keyboard.Key.W: case Keyboard.Key.Up: case Keyboard.Key.Space: if (isShot == false) { MyGlobals.dir = MyGlobals.Direction.Shot; MyGlobals.playerVelocity = new Vector2f(0, 0); isShot = true; chain.Position = new Vector2f(player.Position.X + 32, MyGlobals.floorLevel); } break; case Keyboard.Key.A: case Keyboard.Key.Left: MyGlobals.dir = MyGlobals.Direction.Left; MyGlobals.playerVelocity = new Vector2f(-1, 0); break; case Keyboard.Key.D: case Keyboard.Key.Right: MyGlobals.dir = MyGlobals.Direction.Right; MyGlobals.playerVelocity = new Vector2f(1, 0); break; } }
internal Keys Decode(SFML.Window.Keyboard.Key sfmlKey) { var index = (int)sfmlKey; if (index >= 0 && index < sfmlKeyMap.Length) { return(sfmlKeyMap[index]); } return(Keys.NoKey); }
public ConsoleViewInputHandler() { CanMoveWithRightButton = false; CanMoveWithLeftButton = false; CanMoveWithKeyboard = false; MoveUpKey = Keys.Up; MoveDownKey = Keys.Down; MoveLeftKey = Keys.Left; MoveRightKey = Keys.Right; _mouseDown = false; _mouseLastLocation = new Point(); }
private bool CheckKey(SFML.Window.Keyboard.Key key, byte hexKey) { if (SFML.Window.Keyboard.IsKeyPressed(key)) { if (inputDelay != 0) { System.Threading.Thread.Sleep((int)inputDelay); } return(true); } return(false); }
public void switchDirection(SFML.Window.Keyboard.Key x) { string y = x.ToString(); if (y == "A") { if (direction != new Vector2f(50, 0)) { direction = new Vector2f(-50, 0); d_x = -1; d_y = 0; } } else if (y == "D") { if (direction != new Vector2f(-50, 0)) { direction = new Vector2f(50, 0); d_x = 1; d_y = 0; } } else if (y == "W") { if (direction != new Vector2f(0, 50)) { direction = new Vector2f(0, -50); d_x = 0; d_y = -1; } } else if (y == "S") { if (direction != new Vector2f(0, -50)) { direction = new Vector2f(0, 50); d_x = 0; d_y = 1; } } }//zmiana kierunku
/// <summary> /// Returns true if the key is in the <see cref="KeysDown"/> collection. /// </summary> /// <param name="key">The key to check.</param> /// <returns>True when the key is being pressed.</returns> public bool IsKeyDown(Keys key) { return(KeysDown.Contains(AsciiKey.Get(key))); }
public static WTKey Convert(SFMLKey Key) { if ((int)Key >= (int)SFMLKey.A && (int)Key <= (int)SFMLKey.Z) { int KeyOffset = (int)Key - (int)SFMLKey.A; return((WTKey)(KeyOffset + (int)WTKey.A)); } if ((int)Key >= (int)SFMLKey.Num0 && (int)Key <= (int)SFMLKey.Num9) { int KeyOffset = (int)Key - (int)SFMLKey.Num0; return((WTKey)(KeyOffset + (int)WTKey.D0)); } if ((int)Key >= (int)SFMLKey.Numpad0 && (int)Key <= (int)SFMLKey.Numpad9) { int KeyOffset = (int)Key - (int)SFMLKey.Numpad0; return((WTKey)(KeyOffset + (int)WTKey.NumPad0)); } if ((int)Key >= (int)SFMLKey.F1 && (int)Key <= (int)SFMLKey.F15) { int KeyOffset = (int)Key - (int)SFMLKey.F1; return((WTKey)(KeyOffset + (int)WTKey.F1)); } WTKey TheRest = (int)Key switch { (int)SFMLKey.Escape => WTKey.Escape, (int)SFMLKey.LControl => WTKey.LControlKey, (int)SFMLKey.LShift => WTKey.LShiftKey, (int)SFMLKey.LAlt => WTKey.LAltKey, (int)SFMLKey.LSystem => WTKey.LSystemKey, (int)SFMLKey.RControl => WTKey.RControlKey, (int)SFMLKey.RShift => WTKey.RShiftKey, (int)SFMLKey.RAlt => WTKey.RAltKey, (int)SFMLKey.RSystem => WTKey.RSystemKey, (int)SFMLKey.Menu => WTKey.Menu, (int)SFMLKey.Semicolon => WTKey.Semicolon, (int)SFMLKey.Comma => WTKey.Comma, (int)SFMLKey.Period => WTKey.Period, (int)SFMLKey.Quote => WTKey.Quote, (int)SFMLKey.Slash => WTKey.Question, (int)SFMLKey.Backslash => WTKey.Backslash, (int)SFMLKey.Tilde => WTKey.Tilde, (int)SFMLKey.Equal => WTKey.Equal, (int)SFMLKey.Hyphen => WTKey.Minus, (int)SFMLKey.Space => WTKey.Space, (int)SFMLKey.Enter => WTKey.Enter, (int)SFMLKey.Backspace => WTKey.Backspace, (int)SFMLKey.Tab => WTKey.Tab, (int)SFMLKey.PageUp => WTKey.PageUp, (int)SFMLKey.PageDown => WTKey.PageDown, (int)SFMLKey.End => WTKey.End, (int)SFMLKey.Home => WTKey.Home, (int)SFMLKey.Insert => WTKey.Insert, (int)SFMLKey.Delete => WTKey.Delete, (int)SFMLKey.Add => WTKey.Add, (int)SFMLKey.Subtract => WTKey.Subtract, (int)SFMLKey.Multiply => WTKey.Multiply, (int)SFMLKey.Divide => WTKey.Divide, (int)SFMLKey.Up => WTKey.Up, (int)SFMLKey.Down => WTKey.Down, (int)SFMLKey.Left => WTKey.Left, (int)SFMLKey.Right => WTKey.Right, (int)SFMLKey.Pause => WTKey.Pause, _ => WTKey.None, };
private short KeyToCode(SFMLKey key) { short k; if (!KeyMap.TryGetValue(key, out k)) return short.MaxValue; return k; }
/// <summary> /// Fills out the fields based on the MonoGame/XNA key. /// </summary> /// <param name="key">The key.</param> /// <param name="shiftPressed">Helps identify which <see cref="Character"/> to use while the key is pressed. For example, if <see cref="Keys.A"/> is used the <see cref="Character"/> field will be either 'A' if <paramref name="shiftPressed"/> is true or 'a' if false.</param> public void Fill(Keys key, bool shiftPressed) { this.XnaKey = key; switch (key) { case Keys.A: if (shiftPressed) { this.Character = (char)65; } else { this.Character = (char)97; } break; case Keys.B: if (shiftPressed) { this.Character = (char)66; } else { this.Character = (char)98; } break; case Keys.C: if (shiftPressed) { this.Character = (char)67; } else { this.Character = (char)99; } break; case Keys.D: if (shiftPressed) { this.Character = (char)68; } else { this.Character = (char)100; } break; case Keys.E: if (shiftPressed) { this.Character = (char)69; } else { this.Character = (char)101; } break; case Keys.F: if (shiftPressed) { this.Character = (char)70; } else { this.Character = (char)102; } break; case Keys.G: if (shiftPressed) { this.Character = (char)71; } else { this.Character = (char)103; } break; case Keys.H: if (shiftPressed) { this.Character = (char)72; } else { this.Character = (char)104; } break; case Keys.I: if (shiftPressed) { this.Character = (char)73; } else { this.Character = (char)105; } break; case Keys.J: if (shiftPressed) { this.Character = (char)74; } else { this.Character = (char)106; } break; case Keys.K: if (shiftPressed) { this.Character = (char)75; } else { this.Character = (char)107; } break; case Keys.L: if (shiftPressed) { this.Character = (char)76; } else { this.Character = (char)108; } break; case Keys.M: if (shiftPressed) { this.Character = (char)77; } else { this.Character = (char)109; } break; case Keys.N: if (shiftPressed) { this.Character = (char)78; } else { this.Character = (char)110; } break; case Keys.O: if (shiftPressed) { this.Character = (char)79; } else { this.Character = (char)111; } break; case Keys.P: if (shiftPressed) { this.Character = (char)80; } else { this.Character = (char)112; } break; case Keys.Q: if (shiftPressed) { this.Character = (char)81; } else { this.Character = (char)113; } break; case Keys.R: if (shiftPressed) { this.Character = (char)82; } else { this.Character = (char)114; } break; case Keys.S: if (shiftPressed) { this.Character = (char)83; } else { this.Character = (char)115; } break; case Keys.T: if (shiftPressed) { this.Character = (char)84; } else { this.Character = (char)116; } break; case Keys.U: if (shiftPressed) { this.Character = (char)85; } else { this.Character = (char)117; } break; case Keys.V: if (shiftPressed) { this.Character = (char)86; } else { this.Character = (char)118; } break; case Keys.W: if (shiftPressed) { this.Character = (char)87; } else { this.Character = (char)119; } break; case Keys.X: if (shiftPressed) { this.Character = (char)88; } else { this.Character = (char)120; } break; case Keys.Y: if (shiftPressed) { this.Character = (char)89; } else { this.Character = (char)121; } break; case Keys.Z: if (shiftPressed) { this.Character = (char)90; } else { this.Character = (char)122; } break; #if MONOGAME case Keys.OemComma: #elif SFML case Keys.Comma: #endif if (shiftPressed) { this.Character = (char)60; } else { this.Character = (char)44; } break; #if MONOGAME case Keys.OemMinus: #elif SFML case Keys.Dash: #endif if (shiftPressed) { this.Character = (char)95; } else { this.Character = (char)45; } break; #if MONOGAME case Keys.OemOpenBrackets: #elif SFML case Keys.LBracket: #endif if (shiftPressed) { this.Character = (char)91; } else { this.Character = (char)123; } break; #if MONOGAME case Keys.OemCloseBrackets: #elif SFML case Keys.RBracket: #endif if (shiftPressed) { this.Character = (char)93; } else { this.Character = (char)125; } break; #if MONOGAME case Keys.OemPeriod: #elif SFML case Keys.Period: #endif if (shiftPressed) { this.Character = (char)62; } else { this.Character = (char)46; } break; #if MONOGAME case Keys.OemBackslash: case Keys.OemPipe: #elif SFML case Keys.BackSlash: #endif if (shiftPressed) { this.Character = (char)124; } else { this.Character = (char)92; } break; #if MONOGAME case Keys.OemPlus: #elif SFML case Keys.Equal: #endif if (shiftPressed) { this.Character = (char)43; } else { this.Character = (char)61; } break; #if MONOGAME case Keys.OemQuestion: #elif SFML case Keys.Slash: #endif if (shiftPressed) { this.Character = (char)63; } else { this.Character = (char)47; } break; #if MONOGAME case Keys.OemQuotes: #elif SFML case Keys.Quote: #endif if (shiftPressed) { this.Character = (char)34; } else { this.Character = (char)39; } break; #if MONOGAME case Keys.OemSemicolon: #elif SFML case Keys.SemiColon: #endif if (shiftPressed) { this.Character = (char)58; } else { this.Character = (char)59; } break; #if MONOGAME case Keys.OemTilde: #elif SFML case Keys.Tilde: #endif if (shiftPressed) { this.Character = (char)126; } else { this.Character = (char)96; } break; case Keys.Space: this.Character = ' '; break; #if MONOGAME case Keys.Decimal: this.Character = (char)46; break; #endif case Keys.Divide: this.Character = (char)47; break; case Keys.Multiply: this.Character = (char)42; break; case Keys.Subtract: this.Character = (char)45; break; case Keys.Add: this.Character = (char)43; break; #if MONOGAME case Keys.D0: case Keys.NumPad0: #elif SFML case Keys.Num0: case Keys.Numpad0: #endif if (shiftPressed) { this.Character = (char)41; } else { this.Character = (char)48; } break; #if MONOGAME case Keys.D1: case Keys.NumPad1: #elif SFML case Keys.Num1: case Keys.Numpad1: #endif if (shiftPressed) { this.Character = (char)33; } else { this.Character = (char)49; } break; #if MONOGAME case Keys.D2: case Keys.NumPad2: #elif SFML case Keys.Num2: case Keys.Numpad2: #endif if (shiftPressed) { this.Character = (char)64; } else { this.Character = (char)50; } break; #if MONOGAME case Keys.D3: case Keys.NumPad3: #elif SFML case Keys.Num3: case Keys.Numpad3: #endif if (shiftPressed) { this.Character = (char)35; } else { this.Character = (char)51; } break; #if MONOGAME case Keys.D4: case Keys.NumPad4: #elif SFML case Keys.Num4: case Keys.Numpad4: #endif if (shiftPressed) { this.Character = (char)36; } else { this.Character = (char)52; } break; #if MONOGAME case Keys.D5: case Keys.NumPad5: #elif SFML case Keys.Num5: case Keys.Numpad5: #endif if (shiftPressed) { this.Character = (char)37; } else { this.Character = (char)53; } break; #if MONOGAME case Keys.D6: case Keys.NumPad6: #elif SFML case Keys.Num6: case Keys.Numpad6: #endif if (shiftPressed) { this.Character = (char)94; } else { this.Character = (char)54; } break; #if MONOGAME case Keys.D7: case Keys.NumPad7: #elif SFML case Keys.Num7: case Keys.Numpad7: #endif if (shiftPressed) { this.Character = (char)38; } else { this.Character = (char)55; } break; #if MONOGAME case Keys.D8: case Keys.NumPad8: #elif SFML case Keys.Num8: case Keys.Numpad8: #endif if (shiftPressed) { this.Character = (char)42; } else { this.Character = (char)56; } break; #if MONOGAME case Keys.D9: case Keys.NumPad9: #elif SFML case Keys.Num9: case Keys.Numpad9: #endif if (shiftPressed) { this.Character = (char)40; } else { this.Character = (char)57; } break; default: this.Character = (char)0; break; } }
public void AddInputEvent(SFML.Window.Keyboard.Key key, Action action) { rend.Register(key, action); }
/// <summary> /// Returns true when they is in the <see cref="KeysReleased"/> collection. /// </summary> /// <param name="key">The key to check.</param> /// <returns>True when the key was released this update frame.</returns> public bool IsKeyReleased(Keys key) { return(KeysReleased.Contains(AsciiKey.Get(key))); }
public static Keys decode(SFK input) { return conversion_array[(int)input]; }
internal static Keys[] ConstructSFMLKeyMap() { var maxValue = Enums.IterateValues <Keys>().Max(); var table = new Keys[(int)maxValue + 1]; for (Keys i = 0; i <= maxValue; i++) { table[(int)i] = Keys.NoKey; } for (SFK key = SFK.A; key <= SFK.Z; key++) { table[(int)key] = (Keys)((int)Keys.A + (int)(key - SFK.A)); } for (SFK key = SFK.Num0; key <= SFK.Num9; key++) { table[(int)key] = (Keys)((int)Keys.Alpha0 + (int)(key - SFK.Num0)); } for (SFK key = SFK.F1; key <= SFK.F12; key++) { table[(int)key] = (Keys)((int)Keys.F1 + (int)(key - SFK.F1)); } table[(int)SFK.Return] = Keys.Enter; table[(int)SFK.Space] = Keys.Space; table[(int)SFK.RAlt] = Keys.RAlt; table[(int)SFK.RControl] = Keys.RCtrl; table[(int)SFK.RShift] = Keys.RShift; table[(int)SFK.LAlt] = Keys.LAlt; table[(int)SFK.LControl] = Keys.LCtrl; table[(int)SFK.LShift] = Keys.LShift; table[(int)SFK.Tab] = Keys.Tab; table[(int)SFK.Left] = Keys.Left; table[(int)SFK.Right] = Keys.Right; table[(int)SFK.Up] = Keys.Up; table[(int)SFK.Down] = Keys.Down; table[(int)SFK.BackSpace] = Keys.Backspace; table[(int)SFK.Delete] = Keys.Delete; table[(int)SFK.Escape] = Keys.Escape; table[(int)SFK.Numpad0] = Keys.Pad0; table[(int)SFK.Numpad1] = Keys.Pad1; table[(int)SFK.Numpad2] = Keys.Pad2; table[(int)SFK.Numpad3] = Keys.Pad3; table[(int)SFK.Numpad4] = Keys.Pad4; table[(int)SFK.Numpad5] = Keys.Pad5; table[(int)SFK.Numpad6] = Keys.Pad6; table[(int)SFK.Numpad7] = Keys.Pad7; table[(int)SFK.Numpad8] = Keys.Pad8; table[(int)SFK.Numpad9] = Keys.Pad9; table[(int)SFK.Add] = Keys.PadPlus; table[(int)SFK.Subtract] = Keys.PadMinus; table[(int)SFK.LBracket] = Keys.LeftBracket; table[(int)SFK.RBracket] = Keys.RightBracket; table[(int)SFK.SemiColon] = Keys.Semicolon; table[(int)SFK.Quote] = Keys.Apostrophe; table[(int)SFK.Comma] = Keys.Comma; table[(int)SFK.Period] = Keys.Period; table[(int)SFK.Slash] = Keys.Slash; table[(int)SFK.BackSlash] = Keys.Backslash; table[(int)SFK.Equal] = Keys.Equals; // table[(int)SFK.Subtract] = Keys.Subtract; return(table); }