while (1) { SDL_Event event; Delay();  mouse->hide(); mouse_update = 0;  while (SDL_PollEvent(&event)) switch (event.type) { case SDL_MOUSEBUTTONUP: if (event.button.button == 1) { x = event.button.x >> scale; y = event.button.y >> scale; return (1); } break; case SDL_MOUSEMOTION: mouse->move(event.motion.x >> scale, event.motion.y >> scale); mouse_update = 1; break; case SDL_KEYDOWN: { int c = event.key.keysym.sym; if (c == SDLK_ESCAPE) return (0); if (chr) { *chr = (event.key.keysym.mod & KMOD_SHIFT) ? toupper(c) : c; return (1); } break; } case SDL_KEYUP: switch (event.key.keysym.sym) { case SDLK_RALT: case SDLK_RMETA: altkeys &= ~1; break; case SDLK_LALT: case SDLK_LMETA: altkeys &= ~2; break; default: break; } break; } mouse->show();  if (!gwin->show() && mouse_update) mouse->blit_dirty(); } return (0);
if (chr) *chr = 0; Mouse::Mouse_shapes saveshape = mouse->get_shape(); if (shape != Mouse::dontchange) mouse->set_shape(shape); mouse->show(); gwin->show(1); int ret = Get_click(x, y, chr); mouse->set_shape(saveshape); return (ret);
static int Get_click	(	int& x, int& y,	char *chr			// Char. returned if not null.	)	{	while (1)		{		SDL_Event event;		Delay();		// Wait a fraction of a second.		mouse->hide();		// Turn off mouse.		mouse_update = 0;		while (SDL_PollEvent(&event))			switch (event.type)				{			case SDL_MOUSEBUTTONUP:				if (event.button.button == 1)					{					x = event.button.x >> scale;					y = event.button.y >> scale;					return (1);					}				break;			case SDL_MOUSEMOTION:				mouse->move(event.motion.x >> scale, 						event.motion.y >> scale);				mouse_update = 1;				break;			case SDL_KEYDOWN:				{				int c = event.key.keysym.sym;				if (c == SDLK_ESCAPE)					return (0);				if (chr)// Looking for a character?					{					*chr = (event.key.keysym.mod & 							KMOD_SHIFT)						? toupper(c) : c;					return (1);					}				break;				}			case SDL_KEYUP:				switch (event.key.keysym.sym)					{				case SDLK_RALT:		// Right alt.				case SDLK_RMETA:					altkeys &= ~1;	// Clear flag.					break;				case SDLK_LALT:				case SDLK_LMETA:					altkeys &= ~2;					break;				default:					break;					}				break;				}		mouse->show();		// Turn on mouse.		if (!gwin->show() &&	// Blit to screen if necessary.		    mouse_update)			mouse->blit_dirty();		}	return (0);			// Shouldn't get here.	}