SDL doesn't stop moving mouse when it does not have focus - SDL C?

Up vote 1 down vote favorite share g+ share fb share tw.

I want my game engine to stop moving the mouse to the center (for yaw and pitch camera calculations). I wrote up some code which should have taken care of it but the mouse still moves when minimized. Void mainLoop() { // This is the main logic portion of the engine bool done = false; bool visible = true; SDL_Event event; // Check to make sure we are supposed to quit while(! done) { // Check for SDL events while( SDL_PollEvent(& event) ) { // Figure out which event the user has triggered switch ( event.

Type ) { case SDL_QUIT : done = true; break; case SDL_ACTIVEEVENT: if( event.active. State & SDL_APPACTIVE ) { //If the application is no longer active if(event.active. Gain == 0) { visible = false; } else { visible = true; } } case SDL_KEYDOWN : // Check for user input switch(event.key.keysym.

Sym) { // Escape - end the program case SDLK_ESCAPE : done = true; break; // Plus key - increase the speed of the camera case SDLK_PLUS : case SDLK_KP_PLUS : if(camera. WalkSpeed 2.0f) {camera. WalkSpeed -= 1.0f; } break; // F1 - save a TGA screenshot case SDLK_F1: saveScreenshot(); break; // All other unassigned keys default: break; } } } // All events have been handled, now handle logic and rendering if(visible) { updateFrame(); renderFrame(); } } } When the app has lost focus, it should set the visible flag to false which should stop the update and rendering functions.

Any ideas? C++ sdl link|improve this question asked Feb 25 at 0:19Pladnius Brooks1876 80% accept rate.

Try this: #include #include using namespace std; int main( int argc, char** argv ) { SDL_Init( SDL_INIT_EVERYTHING ); SDL_SetVideoMode( 640, 480, 32, SDL_ANYFORMAT ); bool visible = true; bool done = false; while(!done ) { SDL_Event event; while( SDL_PollEvent(& event) ) { switch ( event. Type ) { case SDL_QUIT : done = true; break; case SDL_ACTIVEEVENT: if( event.active. State & SDL_APPACTIVE || event.active.

State & SDL_APPINPUTFOCUS ) { visible = (event.active. Gain == 1); } } } if(visible) { static unsigned int frame = 0; frame++; cout.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions