void COpenGLDemo::HandleEvents() { SDL_Event ev; while ( SDL_PollEvent( &ev )) { switch( ev.type ) { case SDL_QUIT: OnQuit( ev.quit ); break; case SDL_KEYDOWN: OnKeyDown( ev.key ); break; case SDL_KEYUP: OnKeyUp( ev.key ); break; case SDL_MOUSEMOTION: OnMouseMotion( ev.motion ); break; case SDL_MOUSEBUTTONUP: OnMouseRelease( ev.button ); break; case SDL_MOUSEBUTTONDOWN: OnMousePress( ev.button ); break; } } }
void EmuWindow_SDL2::PollEvents() { SDL_Event event; // SDL_PollEvent returns 0 when there are no more events in the event queue while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_MAXIMIZED: case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_MINIMIZED: OnResize(); break; case SDL_WINDOWEVENT_CLOSE: is_open = false; break; } break; case SDL_KEYDOWN: case SDL_KEYUP: OnKeyEvent(static_cast<int>(event.key.keysym.scancode), event.key.state); break; case SDL_MOUSEMOTION: OnMouseMotion(event.motion.x, event.motion.y); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: OnMouseButton(event.button.button, event.button.state, event.button.x, event.button.y); break; case SDL_QUIT: is_open = false; break; } } }
void CSDL_EventHandler::HandleEvents() { OnPreEvents(); while(::SDL_PollEvent(&event)) { switch (event.type) { case SDL_ACTIVEEVENT: switch(event.active.state) { case SDL_APPMOUSEFOCUS: OnAppMouseFocus(event.active.gain); break; case SDL_APPINPUTFOCUS: OnAppInputFocus(event.active.gain); break; case SDL_APPACTIVE: if(event.active.gain) { OnRestore(); } else { OnMinimize(); } break; } break; case SDL_KEYDOWN: case SDL_KEYUP: OnKeypress(event.key, event.key.keysym.mod); break; case SDL_MOUSEMOTION: OnMouseMotion(event.motion); break; case SDL_MOUSEBUTTONDOWN: break; case SDL_MOUSEBUTTONUP: break; case SDL_JOYAXISMOTION: break; case SDL_JOYBALLMOTION: break; case SDL_JOYHATMOTION: break; case SDL_JOYBUTTONDOWN: break; case SDL_JOYBUTTONUP: break; case SDL_QUIT: OnQuit(); break; case SDL_SYSWMEVENT: break; case SDL_VIDEORESIZE: break; case SDL_VIDEOEXPOSE: break; case SDL_USEREVENT: break; default: break; } } OnPostEvents(); } // HandleEvents()
void Control::NotificationMouseMotion(const SDL_MouseMotionEvent& motionEvent) { OnMouseMotion(motionEvent); }
void Events::Poll() { GamePad::Clear(); Joystick::Clear(); Keyboard::Clear(); Mouse::Clear(); while (SDL_PollEvent(&mEvent)) { switch (mEvent.type) { case SDL_QUIT: OnQuit(); break; case SDL_APP_TERMINATING: OnAppTerminating(); break; case SDL_APP_LOWMEMORY: OnAppLowMemory(); break; case SDL_APP_WILLENTERBACKGROUND: OnAppWillEnterBackground(); break; case SDL_APP_DIDENTERBACKGROUND: OnAppDidEnterBackground(); break; case SDL_APP_WILLENTERFOREGROUND: OnAppWillEnterForeground(); break; case SDL_APP_DIDENTERFOREGROUND: OnAppDidEnterForeground(); break; case SDL_WINDOWEVENT: OnWindowEvent(); break; case SDL_SYSWMEVENT: OnSysWMEvent(); break; case SDL_KEYDOWN: OnKeyDown(mEvent.key.keysym.sym, mEvent.key.keysym.mod, mEvent.key.repeat); Keyboard::SetKey(mEvent.key.keysym.sym, true); break; case SDL_KEYUP: OnKeyUp(mEvent.key.keysym.sym, mEvent.key.keysym.mod, mEvent.key.repeat); Keyboard::SetKey(mEvent.key.keysym.sym, false); break; case SDL_TEXTEDITING: OnTextEditing(); break; case SDL_TEXTINPUT: OnTextInput(); break; case SDL_MOUSEMOTION: OnMouseMotion(mEvent.motion.x, mEvent.motion.y, mEvent.motion.xrel, mEvent.motion.yrel); Mouse::SetPosition(mEvent.motion.x, mEvent.motion.y); break; case SDL_MOUSEBUTTONDOWN: switch(mEvent.button.button) { case SDL_BUTTON_LEFT: OnMouseLeftButtonDown(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_RIGHT: OnMouseRightButtonDown(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_MIDDLE: OnMouseMiddleButtonDown(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_X1: OnMouseLeftButtonDown(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_X2: OnMouseLeftButtonDown(mEvent.button.x, mEvent.button.y); break; } break; case SDL_MOUSEBUTTONUP: switch(mEvent.button.button) { case SDL_BUTTON_LEFT: OnMouseLeftButtonUp(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_RIGHT: OnMouseRightButtonUp(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_MIDDLE: OnMouseMiddleButtonUp(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_X1: OnMouseLeftButtonUp(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_X2: OnMouseLeftButtonUp(mEvent.button.x, mEvent.button.y); break; } break; case SDL_MOUSEWHEEL: OnMouseWheel(mEvent.wheel.x, mEvent.wheel.y); Mouse::SetScroll(mEvent.wheel.x, mEvent.wheel.y); break; case SDL_JOYAXISMOTION: OnJoyAxisMotion(); break; case SDL_JOYBALLMOTION: OnJoyBallMotion(); break; case SDL_JOYHATMOTION: OnJoyHatMotion(); break; case SDL_JOYBUTTONDOWN: OnJoyBallButtonDown(); break; case SDL_JOYBUTTONUP: OnJoyBallButtonUp(); break; case SDL_JOYDEVICEADDED: OnJoyDeviceAdded(); break; case SDL_JOYDEVICEREMOVED: OnJoyDeviceRemoved(); break; case SDL_CONTROLLERAXISMOTION: OnControllerAxisMotion(mEvent.caxis.axis, mEvent.caxis.value, mEvent.caxis.which); GamePad::SetAxis(mEvent.caxis.axis, mEvent.caxis.value, mEvent.caxis.which); break; case SDL_CONTROLLERBUTTONDOWN: OnControllerButtonDown(mEvent.cbutton.button, mEvent.cbutton.which); GamePad::SetButton(mEvent.cbutton.button, true, mEvent.cbutton.which); break; case SDL_CONTROLLERBUTTONUP: OnControllerButtonUp(mEvent.cbutton.button, mEvent.cbutton.which); GamePad::SetButton(mEvent.cbutton.button, false, mEvent.cbutton.which); break; case SDL_CONTROLLERDEVICEADDED: OnControllerDeviceAdded(mEvent.cdevice.which); GamePad::Add(mEvent.cdevice.which); break; case SDL_CONTROLLERDEVICEREMOVED: OnControllerDeviceRemoved(mEvent.cdevice.which); GamePad::Remove(mEvent.cdevice.which); break; case SDL_CONTROLLERDEVICEREMAPPED: OnControllerDeviceRemapped(mEvent.cdevice.which); break; case SDL_FINGERDOWN: OnFingerDown(); break; case SDL_FINGERUP: OnFingerUp(); break; case SDL_FINGERMOTION: OnFingerMotion(); break; case SDL_DOLLARGESTURE: OnDollarGesture(); break; case SDL_DOLLARRECORD: OnDollarRecord(); break; case SDL_MULTIGESTURE: OnMultiGesture(); break; case SDL_CLIPBOARDUPDATE: OnClipboardUpdate(); break; case SDL_DROPFILE: OnDropFile(); break; case SDL_USEREVENT: OnUserEvent(); break; default: OnUndefined(); break; } } }