0

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?

2
  • Are you using SDL directly or through some bindings? Commented 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. Commented Jul 28, 2012 at 13:10

1 Answer 1

1

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; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.