How enter inner while loop?

Docs say SDL_PollEvent returns 1 if there is pending event. In the code below shouldn’t the inner loop get executed when a key is pressed? If I was to add
SDL_GetKeyboard_State (I feel I need to) I would have to put it in the inner loop - but that loop never gets executed. Can someone tell me how to get the inner loop to execute? Thanks. Bill S.

#include <SDL2/SDL.h>
#include <stdio.h>
#include

int main()
{
SDL_Init(SDL_INIT_EVERYTHING);

while(1)
{SDL_Event e1;
while(SDL_PollEvent(&e1))
{printf(“OK event ocurred\n”);
SDL_Delay(2000);
}
printf(“no event ocurred\n”);
}
SDL_Quit();
}

Did you leave some lines out…? There may exceptions on some
platforms, but generally, you need to create a window to do much at
all - including receive input events.

SDL_GetKeyboardState() is just an alternative way of handling keyboard
input, and it won’t work if there are no keyboard events in the first
place.On Sat, Mar 7, 2015 at 9:56 AM, bilsch01 wrote:

Docs say SDL_PollEvent returns 1 if there is pending event. In the code
below shouldn’t the inner loop get executed when a key is pressed? If I was
to add
SDL_GetKeyboard_State (I feel I need to) I would have to put it in the inner
loop - but that loop never gets executed. Can someone tell me how to get the
inner loop to execute? Thanks. Bill S.

#include
#include
#include

int main()
{
SDL_Init(SDL_INIT_EVERYTHING);

while(1)
{SDL_Event e1;
while(SDL_PollEvent(&e1))
{printf(“OK event ocurred\n”);
SDL_Delay(2000);
}
printf(“no event ocurred\n”);
}
SDL_Quit();
}


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://consulting.olofson.net http://olofsonarcade.com |
’---------------------------------------------------------------------’