Exemple #1
0
        private static void ProcessMouseEvent(SdlEvent evt)
        {
            if (ButtonPosEventPoolEnabled)
            {
                var button = TranslatePlatformMouseButton(evt.button.button);

                switch (evt.type)
                {
                case SdlEventType.SdlMousemotion:
                    MouseMove(evt.motion.x, evt.motion.y);
                    break;

                case SdlEventType.SdlMousebuttondown:
                    MouseDown(button);
                    break;

                case SdlEventType.SdlMousebuttonup:
                    MouseUp(button);
                    break;
                }
            }

            if (evt.type == SdlEventType.SdlMousewheel)
            {
                _mWheelValue = evt.wheel.y * 120;
            }
        }
Exemple #2
0
        private static void ProcessWindowEvent(SdlEvent evt)
        {
            // Window Focus
            if (evt.window.windowEvent == SdlWindowEventId.SdlWindoweventFocusGained)
            {
                Engine.Active = true;

                if (!OsxUseSpaces)
                {
                    SDL_SetWindowFullscreen(
                        _window,
                        Engine.Fullscreen ?
                        (uint)SdlWindowFlags.SdlWindowFullscreenDesktop :
                        0
                        );
                }

                // Disable the screensaver when we're back.
                SDL_DisableScreenSaver();
            }
            else if (evt.window.windowEvent == SdlWindowEventId.SdlWindoweventFocusLost)
            {
                Engine.Active = false;

                if (!OsxUseSpaces)
                {
                    SDL_SetWindowFullscreen(_window, 0);
                }

                SDL_EnableScreenSaver();
            }

            // Window Resize
            else if (evt.window.windowEvent == SdlWindowEventId.SdlWindoweventSizeChanged)
            {
                var w = evt.window.data1;
                var h = evt.window.data2;
                _displayW = w;
                _displayH = h;

                Engine.HandleWindowResize();
            }

            else if (evt.window.windowEvent == SdlWindowEventId.SdlWindoweventExposed)
            {
                Engine.RunningGame.Tick();
            }

            else if (evt.window.windowEvent == SdlWindowEventId.SdlWindoweventEnter)
            {
                SDL_DisableScreenSaver();
                MouseEnter?.Invoke();
            }
            else if (evt.window.windowEvent == SdlWindowEventId.SdlWindoweventLeave)
            {
                SDL_EnableScreenSaver();
                MouseLeave?.Invoke();
            }
        }
Exemple #3
0
 private static void ProcessGamePadEvent(SdlEvent evt)
 {
     if (evt.type == SdlEventType.SdlControllerdeviceadded)
     {
         AddGamePadInstance(evt.cdevice.which);
     }
     else if (evt.type == SdlEventType.SdlControllerdeviceremoved)
     {
         RemoveGamePadInstance(evt.cdevice.which);
     }
 }
Exemple #4
0
        public static void PreLookForGamepads()
        {
            var evt = new SdlEvent[1];

            SDL_PumpEvents();
            while (SDL_PeepEvents(
                       evt,
                       1,
                       SdlEventaction.SdlGetevent,
                       SdlEventType.SdlControllerdeviceadded,
                       SdlEventType.SdlControllerdeviceadded
                       ) == 1)
            {
                AddGamePadInstance(evt[0].cdevice.which);
            }
        }
Exemple #5
0
 private extern static int SDL_SendAppEvent(SdlEvent sdlEvent);
Exemple #6
0
		private extern static int SDL_SendAppEvent(SdlEvent sdlEvent);