Sign in to follow this  

sdl getch

This topic is 4356 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im doing a test program for my A*, I use to use getch() for stepping through programs... but since this program uses SDL I dont want to shift between the console window and the sdl window, I made this function to wait for the user to press "s" (s for step that is [smile] hehe). But it doesnt work, when I reach this loop the program stands still and nothing happens. And, yes, Ive tried to press "s", lol.
	Uint8 *keystate;	// check the keyboard

	while(1) {	// wait for input to break
		keystate = SDL_GetKeyState(NULL);
		if(keystate[SDLK_s])
			return;
	}

Seemed to be to simple to fail. :S What am I doing wrong?

Share this post


Link to post
Share on other sites
Problem solved, instead of checking the keyboard I just check for a keypress.


SDL_Event event;

while(1) { // wait for input to break
SDL_PollEvent(&event);
if(event.type == SDL_KEYDOWN)
return;
}

Share this post


Link to post
Share on other sites

This topic is 4356 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this