Ejemplo n.º 1
0
        /// <summary>
        /// Process events for the current window
        /// </summary>
        public virtual void ProcessEvent(SDL.SDL_Event e)
        {
            switch (e.type)
            {
            case SDL.SDL_EventType.SDL_QUIT:
                // When SDL sends a SDL_QUIT message, we have actually clicked on the close button.
                CloseActions?.Invoke();
                break;

            case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN:
                PointerButtonPressActions?.Invoke(e.button);
                break;

            case SDL.SDL_EventType.SDL_MOUSEBUTTONUP:
                PointerButtonReleaseActions?.Invoke(e.button);
                break;

            case SDL.SDL_EventType.SDL_MOUSEMOTION:
                MouseMoveActions?.Invoke(e.motion);
                break;

            case SDL.SDL_EventType.SDL_MOUSEWHEEL:
                MouseWheelActions?.Invoke(e.wheel);
                break;

            case SDL.SDL_EventType.SDL_KEYDOWN:
                KeyDownActions?.Invoke(e.key);
                break;

            case SDL.SDL_EventType.SDL_KEYUP:
                KeyUpActions?.Invoke(e.key);
                break;

            case SDL.SDL_EventType.SDL_TEXTEDITING:
                TextEditingActions?.Invoke(e.edit);
                break;

            case SDL.SDL_EventType.SDL_TEXTINPUT:
                TextInputActions?.Invoke(e.text);
                break;

            case SDL.SDL_EventType.SDL_JOYDEVICEADDED:
                JoystickDeviceAdded?.Invoke(e.jdevice.which);
                break;

            case SDL.SDL_EventType.SDL_JOYDEVICEREMOVED:
                JoystickDeviceRemoved?.Invoke(e.jdevice.which);
                break;

            case SDL.SDL_EventType.SDL_FINGERMOTION:
                FingerMoveActions?.Invoke(e.tfinger);
                break;

            case SDL.SDL_EventType.SDL_FINGERDOWN:
                FingerPressActions?.Invoke(e.tfinger);
                break;

            case SDL.SDL_EventType.SDL_FINGERUP:
                FingerReleaseActions?.Invoke(e.tfinger);
                break;

            case SDL.SDL_EventType.SDL_WINDOWEVENT:
            {
                switch (e.window.windowEvent)
                {
                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED:
                    ResizeBeginActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESIZED:
                    ResizeEndActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
                    CloseActions?.Invoke();
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SHOWN:
                    ActivateActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_HIDDEN:
                    DeActivateActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MINIMIZED:
                    MinimizedActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MAXIMIZED:
                    MaximizedActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESTORED:
                    RestoredActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                    MouseEnterActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                    MouseLeaveActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                    FocusGainedActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                    FocusLostActions?.Invoke(e.window);
                    break;
                }
                break;
            }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Process events for the current window
        /// </summary>
        public virtual void ProcessEvent(Event e)
        {
            switch ((EventType)e.Type)
            {
            case EventType.Quit:
                // When SDL sends a SDL_QUIT message, we have actually clicked on the close button.
                CloseActions?.Invoke();
                break;

            case EventType.Mousebuttondown:
                PointerButtonPressActions?.Invoke(e.Button);
                break;

            case EventType.Mousebuttonup:
                PointerButtonReleaseActions?.Invoke(e.Button);
                break;

            case EventType.Mousemotion:
                MouseMoveActions?.Invoke(e.Motion);
                break;

            case EventType.Mousewheel:
                MouseWheelActions?.Invoke(e.Wheel);
                break;

            case EventType.Keydown:
                KeyDownActions?.Invoke(e.Key);
                break;

            case EventType.Keyup:
                KeyUpActions?.Invoke(e.Key);
                break;

            case EventType.Textediting:
                TextEditingActions?.Invoke(e.Edit);
                break;

            case EventType.Textinput:
                TextInputActions?.Invoke(e.Text);
                break;

            case EventType.Joydeviceadded:
                JoystickDeviceAdded?.Invoke(e.Jdevice.Which);
                break;

            case EventType.Joydeviceremoved:
                JoystickDeviceRemoved?.Invoke(e.Jdevice.Which);
                break;

            case EventType.Fingermotion:
                FingerMoveActions?.Invoke(e.Tfinger);
                break;

            case EventType.Fingerdown:
                FingerPressActions?.Invoke(e.Tfinger);
                break;

            case EventType.Fingerup:
                FingerReleaseActions?.Invoke(e.Tfinger);
                break;

            case EventType.Dropfile:
                DropFileActions?.Invoke(Silk.NET.Core.Native.SilkMarshal.PtrToString((IntPtr)e.Drop.File, Silk.NET.Core.Native.NativeStringEncoding.UTF8));
                break;

            case EventType.Windowevent:
            {
                switch ((WindowEventID)e.Window.Event)
                {
                case WindowEventID.WindoweventSizeChanged:
                    ResizeBeginActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventResized:
                    ResizeEndActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventClose:
                    CloseActions?.Invoke();
                    break;

                case WindowEventID.WindoweventShown:
                    ActivateActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventHidden:
                    DeActivateActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventMinimized:
                    MinimizedActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventMaximized:
                    MaximizedActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventRestored:
                    RestoredActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventEnter:
                    MouseEnterActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventLeave:
                    MouseLeaveActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventFocusGained:
                    FocusGainedActions?.Invoke(e.Window);
                    break;

                case WindowEventID.WindoweventFocusLost:
                    FocusLostActions?.Invoke(e.Window);
                    break;
                }
                break;
            }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Process events for the current window
        /// </summary>
        public virtual void ProcessEvent(SDL.SDL_Event e)
        {
            switch (e.type)
            {
            case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN:
                PointerButtonPressActions?.Invoke(e.button);
                break;

            case SDL.SDL_EventType.SDL_MOUSEBUTTONUP:
                PointerButtonReleaseActions?.Invoke(e.button);
                break;

            case SDL.SDL_EventType.SDL_MOUSEMOTION:
                MouseMoveActions?.Invoke(e.motion);
                break;

            case SDL.SDL_EventType.SDL_MOUSEWHEEL:
                MouseWheelActions?.Invoke(e.wheel);
                break;

            case SDL.SDL_EventType.SDL_KEYDOWN:
                KeyDownActions?.Invoke(e.key);
                break;

            case SDL.SDL_EventType.SDL_KEYUP:
                KeyUpActions?.Invoke(e.key);
                break;

            case SDL.SDL_EventType.SDL_TEXTEDITING:
                TextEditingActions?.Invoke(e.edit);
                break;

            case SDL.SDL_EventType.SDL_TEXTINPUT:
                TextInputActions?.Invoke(e.text);
                break;

            case SDL.SDL_EventType.SDL_WINDOWEVENT:
            {
                switch (e.window.windowEvent)
                {
                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED:
                    ResizeBeginActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESIZED:
                    ResizeEndActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
                    CloseActions?.Invoke();
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SHOWN:
                    ActivateActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_HIDDEN:
                    DeActivateActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MINIMIZED:
                    MinimizedActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MAXIMIZED:
                    MaximizedActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESTORED:
                    RestoredActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                    MouseEnterActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                    MouseLeaveActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                    FocusGainedActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                    FocusLostActions?.Invoke(e.window);
                    break;
                }
                break;
            }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Process events for the current window
        /// </summary>
        public virtual void ProcessEvent(SDL.SDL_Event e)
        {
            switch (e.type)
            {
            case SDL.SDL_EventType.SDL_QUIT:
                // When SDL sends a SDL_QUIT message, we have actually clicked on the close button.
                CloseActions?.Invoke();
                break;

            case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN:
                PointerButtonPressActions?.Invoke(e.button);
                break;

            case SDL.SDL_EventType.SDL_MOUSEBUTTONUP:
                PointerButtonReleaseActions?.Invoke(e.button);
                break;

            case SDL.SDL_EventType.SDL_MOUSEMOTION:
                MouseMoveActions?.Invoke(e.motion);
                break;

            case SDL.SDL_EventType.SDL_MOUSEWHEEL:
                // To match the Windows behavior we multiply the value by 120
                e.wheel.x *= 120;
                e.wheel.y *= 120;
                MouseWheelActions?.Invoke(e.wheel);
                break;

            case SDL.SDL_EventType.SDL_KEYDOWN:
                KeyDownActions?.Invoke(e.key);
                break;

            case SDL.SDL_EventType.SDL_KEYUP:
                KeyUpActions?.Invoke(e.key);
                break;

            case SDL.SDL_EventType.SDL_TEXTEDITING:
                TextEditingActions?.Invoke(e.edit);
                break;

            case SDL.SDL_EventType.SDL_TEXTINPUT:
                TextInputActions?.Invoke(e.text);
                break;

            case SDL.SDL_EventType.SDL_WINDOWEVENT:
            {
                switch (e.window.windowEvent)
                {
                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED:
                    ResizeBeginActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESIZED:
                    ResizeEndActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
                    CloseActions?.Invoke();
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SHOWN:
                    ActivateActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_HIDDEN:
                    DeActivateActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MINIMIZED:
                    MinimizedActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MAXIMIZED:
                    MaximizedActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESTORED:
                    RestoredActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                    MouseEnterActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                    MouseLeaveActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                    FocusGainedActions?.Invoke(e.window);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                    FocusLostActions?.Invoke(e.window);
                    break;
                }
                break;
            }
            }
        }