Help with SDL_Event

Hi, i’m working on a function that lets me check if the SDL_Event.type
argument passed, is equal to the one that is in the class.
Just dont know how to make something like this:

checkEvent(SDL_Event.type EventType);

Because i dont want to create another SDL_Event and set its type to
SDL_QUIT, for example, and then check, if this is possible.

Greetings.–
Leandro Ostera a.k.a Phantom Lord

Phantom Lord wrote:

Hi, i’m working on a function that lets me check if the SDL_Event.type
argument passed, is equal to the one that is in the class.
Just dont know how to make something like this:

checkEvent(SDL_Event.type EventType);

Because i dont want to create another SDL_Event and set its type to
SDL_QUIT, for example, and then check, if this is possible.

From SDL_Events.h:

/* Event enumerations /
typedef enum {
SDL_NOEVENT = 0, /
Unused (do not remove) /

SDL_EVENT_RESERVED7, /
Reserved for future use… /
/
Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use /
SDL_USEREVENT = 24,
/
This last event is only for bounding internal arrays
It is the number of bits in the event mask datatype – Uint32
*/
SDL_NUMEVENTS = 32
} SDL_EventType;

So, use something like

#define MYEVENT1 SDL_USEREVENT
#define MYEVENT2 (SDL_USEREVENT+1)

and if you still need your check function, it would look something like

SDL_bool isInternalEventType(SDL_EventType type) {
return (type >= 0 && type < SDL_USEREVENT);
}

As mentioned on this list recently, this still doesn’t protect you from
stepping on someone else’s user events, though, if you happen to use a
library that defines some user events itself.

-Christian

Thanx a lot.

2006/8/6, Christian Walther :>

Phantom Lord wrote:

Hi, i’m working on a function that lets me check if the SDL_Event.type
argument passed, is equal to the one that is in the class.
Just dont know how to make something like this:

checkEvent(SDL_Event.type EventType);

Because i dont want to create another SDL_Event and set its type to
SDL_QUIT, for example, and then check, if this is possible.

From SDL_Events.h:

/* Event enumerations /
typedef enum {
SDL_NOEVENT = 0, /
Unused (do not remove) /

SDL_EVENT_RESERVED7, /
Reserved for future use… /
/
Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use /
SDL_USEREVENT = 24,
/
This last event is only for bounding internal arrays
It is the number of bits in the event mask datatype – Uint32
*/
SDL_NUMEVENTS = 32
} SDL_EventType;

So, use something like

#define MYEVENT1 SDL_USEREVENT
#define MYEVENT2 (SDL_USEREVENT+1)

and if you still need your check function, it would look something like

SDL_bool isInternalEventType(SDL_EventType type) {
return (type >= 0 && type < SDL_USEREVENT);
}

As mentioned on this list recently, this still doesn’t protect you from
stepping on someone else’s user events, though, if you happen to use a
library that defines some user events itself.

-Christian


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Phantom Lord
Caelis Studios —> From Gods Hands To Yours