Differences between version 2 and predecessor to the previous major change of SDL_Event(3).
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 2 | Last edited on Monday, June 3, 2002 6:53:42 pm | by perry | Revert |
Older page: | version 1 | Last edited on Monday, June 3, 2002 6:53:42 pm | by perry | Revert |
@@ -15,19 +15,19 @@
typedef union{
Uint8 type;
-SDL_ActiveEvent active;
-SDL_KeyboardEvent key;
-SDL_MouseMotionEvent motion;
-SDL_MouseButtonEvent button;
-SDL_JoyAxisEvent jaxis;
-SDL_JoyBallEvent jball;
-SDL_JoyHatEvent jhat;
-SDL_JoyButtonEvent jbutton;
-SDL_ResizeEvent resize;
-SDL_QuitEvent quit;
-SDL_UserEvent user;
+SDL_!
ActiveEvent active;
+SDL_!
KeyboardEvent key;
+SDL_!
MouseMotionEvent motion;
+SDL_!
MouseButtonEvent button;
+SDL_!
JoyAxisEvent jaxis;
+SDL_!
JoyBallEvent jball;
+SDL_!
JoyHatEvent jhat;
+SDL_!
JoyButtonEvent jbutton;
+SDL_!
ResizeEvent resize;
+SDL_!
QuitEvent quit;
+SDL_!
UserEvent user;
SDL_SywWMEvent syswm;
} SDL_Event;
!!STRUCTURE DATA
@@ -89,54 +89,54 @@
__SDL_ACTIVEEVENT__
-__SDL_ActiveEvent__
+__SDL_!
ActiveEvent__
__SDL_KEYDOWN/UP__
-__SDL_KeyboardEvent__
+__SDL_!
KeyboardEvent__
__SDL_MOUSEMOTION__
-__SDL_MouseMotionEvent__
+__SDL_!
MouseMotionEvent__
__SDL_MOUSEBUTTONDOWN/UP__
-__SDL_MouseButtonEvent__
+__SDL_!
MouseButtonEvent__
__SDL_JOYAXISMOTION__
-__SDL_JoyAxisEvent__
+__SDL_!
JoyAxisEvent__
__SDL_JOYBALLMOTION__
-__SDL_JoyBallEvent__
+__SDL_!
JoyBallEvent__
__SDL_JOYHATMOTION__
-__SDL_JoyHatEvent__
+__SDL_!
JoyHatEvent__
__SDL_JOYBUTTONDOWN/UP__
-__SDL_JoyButtonEvent__
+__SDL_!
JoyButtonEvent__
-__SDL_QUIT SDL_QuitEvent__
+__SDL_QUIT SDL_!
QuitEvent__
__SDL_SYSWMEVENT__
@@ -146,15 +146,15 @@
__SDL_VIDEORESIZE__
-__SDL_ResizeEvent__
+__SDL_!
ResizeEvent__
__SDL_USEREVENT__
-__SDL_UserEvent__
+__SDL_!
UserEvent__
!!USE
The __SDL_Event__ structure has two uses
@@ -166,27 +166,27 @@
Placing events on the event queue
Reading events from the event queue is done with either
-__SDL_PollEvent__ or __SDL_PeepEvents__. We'll use
-__SDL_PollEvent__ and step through an
+__SDL_!
PollEvent__ or __SDL_!
PeepEvents__. We'll use
+__SDL_!
PollEvent__ and step through an
example.
First off, we create an empty __SDL_Event__
structure.
SDL_Event test_event;
-__SDL_PollEvent__ removes the next event from the event queue, if there are no events on the queue it returns ____ otherwise it returns __1__. We use a __while__ loop to process each event in turn.
+__SDL_!
PollEvent__ removes the next event from the event queue, if there are no events on the queue it returns ____ otherwise it returns __1__. We use a __while__ loop to process each event in turn.
-while(SDL_PollEvent(
-The __SDL_PollEvent__ function take a pointer to an __SDL_Event__ structure that is to be filled with event information. We know that if __SDL_PollEvent__ removes an event from the queue then the event information will be placed in our __test_event__ structure, but we also know that the ''type'' of event will be placed in the __type__ member of __test_event__. So to handle each event __type__ seperately we use a __switch__ statement.
+while(SDL_!
PollEvent(
+The __SDL_!
PollEvent__ function take a pointer to an __SDL_Event__ structure that is to be filled with event information. We know that if __SDL_!
PollEvent__ removes an event from the queue then the event information will be placed in our __test_event__ structure, but we also know that the ''type'' of event will be placed in the __type__ member of __test_event__. So to handle each event __type__ seperately we use a __switch__ statement.
switch(test_event.type) {
-We need to know what kind of events we're looking for ''and'' the event __type__'s of those events. So lets assume we want to detect where the user is moving the mouse pointer within our application. We look through our event types and notice that __SDL_MOUSEMOTION__ is, more than likely, the event we're looking for. A little ''more'' research tells use that __SDL_MOUSEMOTION__ events are handled within the __SDL_MouseMotionEvent__ structure which is the __motion__ member of __SDL_Event__. We can check for the __SDL_MOUSEMOTION__ event __type__ within our __switch__ statement like so:
+We need to know what kind of events we're looking for ''and'' the event __type__'s of those events. So lets assume we want to detect where the user is moving the mouse pointer within our application. We look through our event types and notice that __SDL_MOUSEMOTION__ is, more than likely, the event we're looking for. A little ''more'' research tells use that __SDL_MOUSEMOTION__ events are handled within the __SDL_!
MouseMotionEvent__ structure which is the __motion__ member of __SDL_Event__. We can check for the __SDL_MOUSEMOTION__ event __type__ within our __switch__ statement like so:
case SDL_MOUSEMOTION:
All we need do now is read the information out of the __motion__ member of __test_event__.
@@ -196,9 +196,9 @@
It is also possible to push events onto the event queue and
so use it as a two-way communication path. Both
-__SDL_PushEvent__ and __SDL_PeepEvents__ allow you to
+__SDL_!
PushEvent__ and __SDL_!
PeepEvents__ allow you to
place events onto the event queue. This is usually used to
place a __SDL_USEREVENT__ on the event queue, however you
could use it to post fake input events if you wished.
Creating your own events is a simple matter of choosing the
@@ -211,11 +211,11 @@
user_event.type=SDL_USEREVENT;
user_event.user.code=2;
user_event.user.data1=NULL;
user_event.user.data2=NULL;
-SDL_PushEvent(
+SDL_!
PushEvent(
!!SEE ALSO
-__SDL_PollEvent__, __SDL_PushEvent__,
-__SDL_PeepEvents__
+__SDL_!
PollEvent__, __SDL_!
PushEvent__,
+__SDL_!
PeepEvents__
----