void run() { SDL_Event event; handler_type *hptr = 0; while(SDL_WaitEvent(&event) >=0) { if(event.type == SDL_QUIT) { boost::system::error_code ec( boost::system::errc::operation_canceled, boost::system::system_category()); for(auto i = queue_.begin(); i != queue_.end(); ++i) { while( (*i)->pop(hptr) ) { (*hptr)(ec, boost::ref(*this), SDL_Event()); delete hptr; } } break; } else { if (queue_[event.type]->pop(hptr)) { (*hptr)(boost::system::error_code(), boost::ref(*this), event); delete hptr; } } } }
SDL_Event MessagePump::receiveLastMessage() { MutexManager::lockMutex( mutex_event ); SDL_Event temp = SDL_Event(); temp = messageList->back(); messageList->pop_back(); MutexManager::unlockMutex( mutex_event ); return temp; }
void Loop(bool(*inputs)(SDL_Event e), void(*update)()) { //Main loop flag bool quit = false; //Event handler SDL_Event ev = SDL_Event(); //While application is running while (!quit) { if (inputs(ev)) quit = true; update(); } }
end_position_collector(const size_t time) : event_node(time, SDL_Event()), state_(), units_() { }
#include "global.h" SDL_Surface* global::screen = NULL; SDL_Surface* global::background = NULL; SDL_Event global::event = SDL_Event();
int main(int argc, char **argv) { if (argc == 2) { gridDim = atoi(argv[1]); if (gridDim != 0) { if (gridDim > 128) { printf("Grid dimension must be 128 or less.\n"); } else if (gridDim < 0) { printf("Grid dimension must be a positive number.\n"); } else { printf("Using user-specified grid dimension of %d.\n", gridDim); userDim = true; } } else { printf("Invalid grid dimension: %d\n", gridDim); } } SDL_Surface *screen = NULL; SDL_FreeSurface(screen); int done; // Initialize SDL_Init(SDL_INIT_VIDEO); // TODO: Remove. #ifndef __OGL3 glutInit(&argc, argv); #endif // Enable double-buffering SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); // Create a OpenGL window screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, SDL_OPENGL | SDL_RESIZABLE); if( ! screen ) { printf("Couldn't set %dx%d GL video mode: %s\n", WIDTH, HEIGHT, SDL_GetError()); SDL_Quit(); exit(2); } SDL_WM_SetCaption(WINDOW_TITLE, WINDOW_TITLE); // ##### INSERT ANY ARGUMENT (PARAMETER) PARSING CODE HERE // Initialize the OpenGL context init(screen->w, screen->h); generate(); // The main loop done = 0; while(!done) { SDL_Event event = SDL_Event(); // Respond to any events that occur while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_VIDEORESIZE: screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_OPENGL|SDL_RESIZABLE); if(screen) { reshape(screen->w, screen->h); } else { ; // Oops, we couldn't resize for some reason. This should never happen } break; case SDL_QUIT: done = 1; break; // ##### INSERT CODE TO HANDLE ANY OTHER EVENTS HERE ##### case SDL_KEYDOWN: switch(event.key.keysym.sym){ case SDLK_a: showGrid = !showGrid; break; // Check for escape case SDLK_q: done = 1; break; default: break; } } } // Draw the screen render(); } // Clean up and quit delete vol; glDeleteBuffers(1, &vboId); SDL_Quit(); return 0; }
void InputManager::ResetMouseInput() { mouseEvent = SDL_Event(); }
int m3_Input::mWheel = -7; float m3_Input::mUpPosition = -0.5f; POINT m3_Input::mLastPosition = POINT(); POINT m3_Input::mCurrentPosition = POINT(); POINT m3_Input::mDeltaPosition = POINT(); bool m3_Input::mRightClick = false; bool m3_Input::mRightDown = false; bool m3_Input::mLeftClick = false; bool m3_Input::mLeftDown = false; bool m3_Input::enableLight = false; bool m3_Input::enableNormal = false; bool m3_Input::saveToObj = false; int m3_Input::meshIndex = 0; SDL_Event m3_Input::event = SDL_Event(); bool m3_Input::ePressForward = false; bool m3_Input::ePressBackward = false; bool m3_Input::ePressLeft = false; bool m3_Input::ePressRight = false; bool m3_Input::ePressRotateLeft = false; bool m3_Input::ePressRotateRight = false; bool m3_Input::exitEvent = false; void m3_Input::Update() { while ( SDL_PollEvent(&event) ) { switch(event.type)