
Next: main Up: Mastering SDL Previous: main ? Contents ? Index
startsection section10in-0.25Input and Event Processing SDL uses the notion of events to report the user's input and window-management actions. For instance, events are produced whenever the user moves the mouse, presses a key, or resizes the SDL video window. A program may use an event loop to listen to SDL's events. SDL stores unprocessed events in an internal list known as the event queue. This queue allows SDL to collect as many events as possible each time it performs an event update.
There are four main categories of events: keyboard events, mouse events (movement and button clicks), window events (gaining and losing focus, as well as ``exit'' requests), and system-dependent events (raw messages from the windowing system that SDL otherwise would ignore). SDL provides a structure type for recording each kind of event, and these are wrapped by the SDL_Event union. The type member indicates the particular type of event stored by a SDL_Event structure. Most SDL applications use a switch statement to identify and process the various types of events.
- [Structure] SDL_Event
- [Synopsis] Structure for receiving events from SDL. More specifically, a union of all possible event types.
- [Members]
- [type]--enum indicating the type of event. Each event type corresponds to a specialized event structure in the SDL_Event union. See SDL_events.h in the SDL API for a list of event types and their corresponding entries in SDL_Event; there are quite a few.
Because every event represents some sort of interaction with the application's main window or console, the SDL event subsystem is closely tied to the video subsystem. Since the two subsystems cannot logically be separated from one another, they are both initialized with the SDL_INIT_VIDEO parameter to SDL_Init. It would not make sense to use the event subsystem separately from the video subsystem.
Subsections

Next: main Up: Mastering SDL Previous: main ? Contents ? Index
Mika Myllynen 2003-02-19