using System; using System.Runtime.InteropServices; namespace SFML { namespace Window { //////////////////////////////////////////////////////////// /// /// Definition of key codes for keyboard events /// //////////////////////////////////////////////////////////// public enum KeyCode { A = 'a', B = 'b', C = 'c', D = 'd', E = 'e', F = 'f', G = 'g', H = 'h', I = 'i', J = 'j', K = 'k', L = 'l', M = 'm', N = 'n', O = 'o', P = 'p', Q = 'q', R = 'r', S = 's', T = 't', U = 'u', V = 'v', W = 'w', X = 'x', Y = 'y', Z = 'z', Num0 = '0', Num1 = '1', Num2 = '2', Num3 = '3', Num4 = '4', Num5 = '5', Num6 = '6', Num7 = '7', Num8 = '8', Num9 = '9', Escape = 256, LControl, LShift, LAlt, LSystem, // OS specific key (left side) : windows (Win and Linux), apple (MacOS), ... RControl, RShift, RAlt, RSystem, // OS specific key (right side) : windows (Win and Linux), apple (MacOS), ... Menu, LBracket, // [ RBracket, // ] SemiColon, // ; Comma, // , Period, // . Quote, // ' Slash, // / BackSlash, Tilde, // ~ Equal, // = Dash, // - Space, Return, Back, Tab, PageUp, PageDown, End, Home, Insert, Delete, Add, // + Subtract, // - Multiply, // * Divide, // / Left, // Left arrow Right, // Right arrow Up, // Up arrow Down, // Down arrow Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, Pause } //////////////////////////////////////////////////////////// /// /// Definition of button codes for mouse events /// //////////////////////////////////////////////////////////// public enum MouseButton { /// Left mouse button Left, /// Right mouse button Right, /// Center (wheel) mouse button Middle, /// First extra button XButton1, /// Second extra button XButton2 } //////////////////////////////////////////////////////////// /// /// Definition of joystick axis for joystick events /// //////////////////////////////////////////////////////////// public enum JoyAxis { /// X axis AxisX, /// Y axis AxisY, /// Z axis AxisZ, /// R axis AxisR, /// U axis AxisU, /// V axis AxisV, /// Point of view AxisPOV } //////////////////////////////////////////////////////////// /// /// Enumeration of the different types of events /// //////////////////////////////////////////////////////////// public enum EventType { /// Event triggered when a window is manually closed Closed, /// Event triggered when a window is resized Resized, /// Event triggered when a window loses the focus LostFocus, /// Event triggered when a window gains the focus GainedFocus, /// Event triggered when a valid character is entered TextEntered, /// Event triggered when a keyboard key is pressed KeyPressed, /// Event triggered when a keyboard key is released KeyReleased, /// Event triggered when the mouse wheel is scrolled MouseWheelMoved, /// Event triggered when a mouse button is pressed MouseButtonPressed, /// Event triggered when a mouse button is released MouseButtonReleased, /// Event triggered when the mouse moves within the area of a window MouseMoved, /// Event triggered when the mouse enters the area of a window MouseEntered, /// Event triggered when the mouse leaves the area of a window MouseLeft, /// Event triggered when a joystick button is pressed JoyButtonPressed, /// Event triggered when a joystick button is released JoyButtonReleased, /// Event triggered when a joystick axis moves JoyMoved } //////////////////////////////////////////////////////////// /// /// Keyboard event parameters /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct KeyEvent { /// Code of the key (see KeyCode enum) public KeyCode Code; /// Is the Alt modifier pressed? public int Alt; /// Is the Control modifier pressed? public int Control; /// Is the Shift modifier pressed? public int Shift; } //////////////////////////////////////////////////////////// /// /// Text event parameters /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct TextEvent { /// UTF-32 value of the character public uint Unicode; } //////////////////////////////////////////////////////////// /// /// Mouse move event parameters /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct MouseMoveEvent { /// X coordinate of the mouse cursor public int X; /// Y coordinate of the mouse cursor public int Y; } //////////////////////////////////////////////////////////// /// /// Mouse buttons event parameters /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct MouseButtonEvent { /// Code of the button (see MouseButton enum) public MouseButton Button; /// X coordinate of the mouse cursor public int X; /// Y coordinate of the mouse cursor public int Y; } //////////////////////////////////////////////////////////// /// /// Mouse wheel event parameters /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct MouseWheelEvent { /// Scroll amount public int Delta; /// X coordinate of the mouse cursor public int X; /// Y coordinate of the mouse cursor public int Y; } //////////////////////////////////////////////////////////// /// /// Joystick axis move event parameters /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct JoyMoveEvent { /// Index of the joystick which triggered the event public uint JoystickId; /// Joystick axis (see JoyAxis enum) public JoyAxis Axis; /// Current position of the axis public float Position; } //////////////////////////////////////////////////////////// /// /// Joystick buttons event parameters /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct JoyButtonEvent { /// Index of the joystick which triggered the event public uint JoystickId; /// Index of the button public uint Button; } //////////////////////////////////////////////////////////// /// /// Size event parameters /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct SizeEvent { /// New width of the window public uint Width; /// New height of the window public uint Height; } //////////////////////////////////////////////////////////// /// /// Event defines a system event and its parameters /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Explicit, Size = 20)] public struct Event { /// Type of event (see EventType enum) [FieldOffset(0)] public EventType Type; /// Arguments for key events (KeyPressed, KeyReleased) [FieldOffset(4)] public KeyEvent Key; /// Arguments for text events (TextEntered) [FieldOffset(4)] public TextEvent Text; /// Arguments for mouse move events (MouseMoved) [FieldOffset(4)] public MouseMoveEvent MouseMove; /// Arguments for mouse button events (MouseButtonPressed, MouseButtonReleased) [FieldOffset(4)] public MouseButtonEvent MouseButton; /// Arguments for mouse wheel events (MouseWheelMoved) [FieldOffset(4)] public MouseWheelEvent MouseWheel; /// Arguments for joystick axis events (JoyMoved) [FieldOffset(4)] public JoyMoveEvent JoyMove; /// Arguments for joystick button events (JoyButtonPressed, JoyButtonReleased) [FieldOffset(4)] public JoyButtonEvent JoyButton; /// Arguments for size events (Resized) [FieldOffset(4)] public SizeEvent Size; } } }