Not the best title, but, what is the relation between SDL_Event and all the SDL events, like SDL_QuitEvent, SDL_ActiveEvent etc...? I'm using an SDL binding for C#, and can't figure out what type to use for the type system when dealing with them; they are not subclasses of SDL_Event. Should I just use object, or is there some better way?
- Are you using SDL directly or through some bindings?Piotr Praszmo– Piotr Praszmo2012-07-28 08:05:23 +00:00Commented Jul 28, 2012 at 8:05
- Oh, actually, this question is obsolete since I'm not working on this anymore, but for anyone who needs this, yes, I'm using Tao.Sdl.Jwosty– Jwosty2012-07-28 13:10:35 +00:00Commented Jul 28, 2012 at 13:10
Add a comment |
1 Answer
Old question, but just for long-tail searches:
an SDL_Event is just a big collection of structs (SDL_QuitEvent etc.). Depending on the SDL_Event::type, you set or look into different sub-structs and their data.
from SDL_events.h in SDL1.2:
typedef union SDL_Event { Uint8 type; SDL_ActiveEvent active; SDL_KeyboardEvent key; SDL_MouseMotionEvent motion; SDL_MouseButtonEvent button; . . . SDL_SysWMEvent syswm; } SDL_Event; from SDL_events.h in SDL2:
typedef union SDL_Event { Uint32 type; /**< Event type, shared with all events */ SDL_CommonEvent common; /**< Common event data */ SDL_WindowEvent window; /**< Window event data */ SDL_KeyboardEvent key; /**< Keyboard event data */ . . . } SDL_Event;