From 3046f71c667d50c89a6f26f5c16a183d435b5a1b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 12 Apr 2003 19:00:56 +0000 Subject: [PATCH] add SDL_GetEvent --- stepmania/src/SDL_utils.cpp | 16 ++++++++++++++++ stepmania/src/SDL_utils.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/stepmania/src/SDL_utils.cpp b/stepmania/src/SDL_utils.cpp index e525ace15b..f47f35290c 100644 --- a/stepmania/src/SDL_utils.cpp +++ b/stepmania/src/SDL_utils.cpp @@ -488,3 +488,19 @@ int FindSurfaceTraits(const SDL_Surface *img) // if(WhiteOnly) ret |= TRAIT_WHITE_ONLY; return ret; } + +bool SDL_GetEvent(SDL_Event &event, int mask) +{ + /* SDL_PeepEvents returns error if video isn't initialized. */ + if(!SDL_WasInit(SDL_INIT_VIDEO)) + return false; + + switch(SDL_PeepEvents(&event, 1, SDL_GETEVENT, mask)) + { + case 1: return true; + case 0: return false; + case -1: RageException::Throw("SDL_PeepEvents returned unexpected error: %s", SDL_GetError()); + } +} + + diff --git a/stepmania/src/SDL_utils.h b/stepmania/src/SDL_utils.h index f0283cd71d..8da20e9397 100644 --- a/stepmania/src/SDL_utils.h +++ b/stepmania/src/SDL_utils.h @@ -32,6 +32,9 @@ SDL_Surface *SDL_CreateRGBSurfaceSane void FixHiddenAlpha(SDL_Surface *img); +/* Check for an event; return true if one was waiting. */ +bool SDL_GetEvent(SDL_Event &event, int mask); + /* The surface contains no transparent pixels and/or never uses its color * key, so it doesn't need any alpha bits at all. */ #define TRAIT_NO_TRANSPARENCY 0x0001 /* 0alpha */