Ejemplo n.º 1
0
bool SdlLibrary::HasPendingEvents() const
{
	//TODO replace this with returning an "empty" event?
	SDL_PumpEvents();
	if (SDL_HasEvents(SDL_KEYDOWN, SDL_KEYUP)) return true;
	if (SDL_HasEvents(SDL_MOUSEMOTION, SDL_MOUSEWHEEL)) return true;
	return false;
}
Ejemplo n.º 2
0
/*
 * SDL.hasEvents(min, max)
 *
 * Arguments:
 *	min the minimum event type
 *	max the maximum event type
 *
 * Returns:
 *	True if has events
 */
static int
l_event_hasEvents(lua_State *L)
{
	int min = luaL_checkinteger(L, 1);
	int max = luaL_checkinteger(L, 2);

	return commonPush(L, "b", SDL_HasEvents(min, max));
}
Ejemplo n.º 3
0
static mrb_value
mrb_sdl2_input_has_events(mrb_state *mrb, mrb_value self)
{
  mrb_int min, max;
  int const argc = mrb_get_args(mrb, "i|i", &min, &max);
  SDL_bool has_event;
  if (1 == argc) {
    has_event = SDL_HasEvent(min);
  } else {
    has_event = SDL_HasEvents(min, max);
  }
  return (SDL_FALSE == has_event) ? mrb_false_value() : mrb_true_value();
}
Ejemplo n.º 4
0
bool
GHOST_SystemSDL::processEvents(bool waitForEvent)
{
	// Get all the current events -- translate them into
	// ghost events and call base class pushEvent() method.

	bool anyProcessed = false;

	do {
		GHOST_TimerManager *timerMgr = getTimerManager();

		if (waitForEvent && m_dirty_windows.empty() && !SDL_HasEvents(SDL_FIRSTEVENT, SDL_LASTEVENT)) {
			GHOST_TUns64 next = timerMgr->nextFireTime();

			if (next == GHOST_kFireTimeNever) {
				SDL_WaitEventTimeout(NULL, -1);
				//SleepTillEvent(m_display, -1);
			}
			else {
				GHOST_TInt64 maxSleep = next - getMilliSeconds();

				if (maxSleep >= 0) {
					SDL_WaitEventTimeout(NULL, next - getMilliSeconds());
					// SleepTillEvent(m_display, next - getMilliSeconds()); // X11
				}
			}
		}

		if (timerMgr->fireTimers(getMilliSeconds())) {
			anyProcessed = true;
		}

		SDL_Event sdl_event;
		while (SDL_PollEvent(&sdl_event)) {
			processEvent(&sdl_event);
			anyProcessed = true;
		}

		if (generateWindowExposeEvents()) {
			anyProcessed = true;
		}
	} while (waitForEvent && !anyProcessed);

	return anyProcessed;
}