Jump to content
  • Advertisement
Sign in to follow this  
Mizipzor

sdl getch

This topic is 4719 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!