The problem IS that SDL_Event was binded as a struct ! And in the real
code
(SDL is a C library) the management of the SDL_Event type was made with
implicit assertions about its "union nature". Now that it is binded as
a
struct, the fields which would have been are not updated anymore !
I explain. SDL_Event structure is the following (in the original SDL.h)
/* General event structure */
typedef union {
Uint8 type;
SDL_ActiveEvent active;
SDL_KeyboardEvent key;
/* ... lots of events more */
} SDL_Event;
What you must know is that SDL_ActiveEvent and SDL_KeyboardEvent which
are
"typedef struct" both have a first field which is called "type" and
which
is of type "Uint8".
So, in your code, when you have a SDL_Event "e", you can make this
(and it
is done like this in hundreds of lines of code) :
if (e.type == SDL_KEYDOWN || e.type == SDL_KEYUP)
{
manage_key (e.key); // this function does something with the key
event
}
else
{
// go on with the tests
}
Of course, you can use "switch .. case" statements but its not the
purpose
of the discussion here.
manage_key() will have to react to the fact that it is a key pressed or
released and so, it will look into SDL_KeyboardEvent.type field which
is,
thanks to the "union system", the same as the SDL_Event.type field.
Am I clearer ? I know that when I don't explain it is hard to
understand
me :p