(SDL2) Attempt to fix missing events issue

This commit is contained in:
Higor Eurípedes 2014-08-10 19:57:17 -03:00
parent f53b67aab7
commit 0e5305b10f
3 changed files with 12 additions and 12 deletions

View File

@ -473,7 +473,9 @@ error:
static void check_window(sdl2_video_t *vid)
{
SDL_Event event;
while (SDL_PollEvent(&event))
SDL_PumpEvents();
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_QUIT, SDL_WINDOWEVENT) > 0)
{
switch (event.type)
{
@ -482,12 +484,8 @@ static void check_window(sdl2_video_t *vid)
break;
case SDL_WINDOWEVENT:
switch (event.window.event)
{
case SDL_WINDOWEVENT_RESIZED:
vid->should_resize = true;
break;
}
if (event.window.event == SDL_WINDOWEVENT_RESIZED)
vid->should_resize = true;
break;
default:

View File

@ -224,8 +224,7 @@ static void sdl2_input_free(void *data)
return;
// Flush out all pending events.
SDL_Event event;
while (SDL_PollEvent(&event));
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
sdl2_input_t *sdl = (sdl2_input_t*)data;
@ -268,7 +267,8 @@ static void sdl2_input_poll(void *data)
SDL_Event event;
while (SDL_PollEvent(&event))
SDL_PumpEvents();
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEWHEEL, SDL_MOUSEWHEEL) > 0)
{
if (event.type == SDL_MOUSEWHEEL)
{

View File

@ -113,6 +113,8 @@ static bool sdl2_joypad_init(void)
return false;
}
SDL_JoystickEventState(SDL_ENABLE);
// TODO: Add SDL_GameController support.
// if (SDL_Init(SDL_INIT_GAMECONTROLLER) < 0)
// RARCH_LOG("[SDL]: Failed to initialize game controller interface: %s\n",
@ -222,10 +224,10 @@ static int16_t sdl2_joypad_axis(unsigned port, uint32_t joyaxis)
static void sdl2_joypad_poll(void)
{
// SDL_JoystickUpdate();
SDL_Event event;
while (SDL_PollEvent(&event))
SDL_PumpEvents();
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED) > 0)
{
if (event.type == SDL_JOYDEVICEADDED)
{