private void Form_MouseDown(object sender, MouseEventArgs e) { Input.Keys key = Input.Keys.None; switch (e.Button) { case MouseButtons.Left: key = Input.Keys.LeftButton; break; case MouseButtons.Right: key = Input.Keys.RightButton; break; case MouseButtons.Middle: key = Input.Keys.MiddleButton; break; case MouseButtons.XButton1: key = Input.Keys.MouseButtonX1; break; case MouseButtons.XButton2: key = Input.Keys.MouseButtonX2; break; } Game.InputDevice.NotifyMouseDown(key, e.X, e.Y); }
public void KeyDown(Input.Keys key) => this.Input.KeyDown(key);
public void KeyUp(Input.Keys key) => this.Input.KeyUp(key);
//[MethodImpl(MethodImplOptions.AggressiveInlining)] //public static global::SFML.Graphics.IntRect ToSFML(this SadRogue.Primitives.Rectangle rectangle) => // new global::SFML.Graphics.IntRect(rectangle.X, rectangle.Y, rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height); //[MethodImpl(MethodImplOptions.AggressiveInlining)] //public static global::SFML.Graphics.Color ToSFML(this SadRogue.Primitives.Color color) => // new global::SFML.Graphics.Color(color.R, color.G, color.B, color.A); //[MethodImpl(MethodImplOptions.AggressiveInlining)] //public static SFML.System.Vector2i ToSFML(this SadRogue.Primitives.Point position) => // new SFML.System.Vector2i(position.X, position.Y); public static SFMLKeys ToSFML(this Input.Keys key) { // A-Z if (key >= Input.Keys.A && key <= Input.Keys.Z) { return((SFMLKeys)(key - Input.Keys.A)); } // NUMPAD if (key >= Input.Keys.NumPad0 && key <= Input.Keys.NumPad9) { return((SFMLKeys)(key - ((int)Input.Keys.NumPad0 - (int)SFMLKeys.Numpad0))); } // F-KEYS if (key >= Input.Keys.F1 && key <= Input.Keys.F15) { return((SFMLKeys)(key - ((int)Input.Keys.F1 - (int)SFMLKeys.F1))); } // Numbers if (key >= Input.Keys.D0 && key <= Input.Keys.D9) { return((SFMLKeys)(key - ((int)Input.Keys.D0 - (int)SFMLKeys.Num0))); } return(key switch { Input.Keys.Back => SFMLKeys.Backspace, Input.Keys.Tab => SFMLKeys.Tab, Input.Keys.Enter => SFMLKeys.Enter, Input.Keys.Escape => SFMLKeys.Escape, Input.Keys.Space => SFMLKeys.Space, Input.Keys.PageUp => SFMLKeys.PageUp, Input.Keys.PageDown => SFMLKeys.PageDown, Input.Keys.End => SFMLKeys.End, Input.Keys.Home => SFMLKeys.Home, Input.Keys.Left => SFMLKeys.Left, Input.Keys.Up => SFMLKeys.Up, Input.Keys.Right => SFMLKeys.Right, Input.Keys.Down => SFMLKeys.Down, Input.Keys.Insert => SFMLKeys.Insert, Input.Keys.Delete => SFMLKeys.Delete, Input.Keys.Multiply => SFMLKeys.Multiply, Input.Keys.Add => SFMLKeys.Add, Input.Keys.Subtract => SFMLKeys.Subtract, Input.Keys.Decimal => SFMLKeys.Period, Input.Keys.Divide => SFMLKeys.Divide, Input.Keys.LeftShift => SFMLKeys.LShift, Input.Keys.RightShift => SFMLKeys.RShift, Input.Keys.LeftControl => SFMLKeys.LControl, Input.Keys.RightControl => SFMLKeys.RControl, Input.Keys.LeftAlt => SFMLKeys.LAlt, Input.Keys.RightAlt => SFMLKeys.RAlt, Input.Keys.OemSemicolon => SFMLKeys.Semicolon, Input.Keys.OemPlus => SFMLKeys.Equal, Input.Keys.OemComma => SFMLKeys.Comma, Input.Keys.OemMinus => SFMLKeys.Hyphen, Input.Keys.OemPeriod => SFMLKeys.Period, Input.Keys.OemQuestion => SFMLKeys.Slash, Input.Keys.OemTilde => SFMLKeys.Tilde, Input.Keys.OemOpenBrackets => SFMLKeys.LBracket, Input.Keys.OemPipe => SFMLKeys.Backslash, Input.Keys.OemCloseBrackets => SFMLKeys.RBracket, Input.Keys.OemQuotes => SFMLKeys.Quote, Input.Keys.OemBackslash => SFMLKeys.Backslash, Input.Keys.Pause => SFMLKeys.Pause, _ => SFMLKeys.Unknown });