We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1076 - Migrating SDL_PeepEvents From SDL 1.2.14 to SDL 1.3
Summary: Migrating SDL_PeepEvents From SDL 1.2.14 to SDL 1.3
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: x86 Mac OS X 10.6
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-14 10:22 UTC by JP1971
Modified: 2011-01-24 16:20 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description JP1971 2010-11-14 10:22:24 UTC
I'm porting an OS X application written in C++ with the SDL 1.2 framework to iOS using the SDL 1.3 framework.  There have been some changes to the methods, and I am having trouble rewriting a couple of pieces of code. Here are the comments and declarations for the SDL_PeepEvents method from 1.2.14:

    /**
     *  Checks the event queue for messages and optionally returns them.
     *
     *  If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
     *  the back of the event queue.
     *  If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
     *  of the event queue, matching 'mask', will be returned and will not
     *  be removed from the queue.
     *  If 'action' is SDL_GETEVENT, up to 'numevents' events at the front 
     *  of the event queue, matching 'mask', will be returned and will be
     *  removed from the queue.
     *
     *  @return
     *  This function returns the number of events actually stored, or -1
     *  if there was an error.
     *
     *  This function is thread-safe.
     */
    extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents,
    				SDL_eventaction action, Uint32 mask);

Here is the declaration for the same method in 1.3:

    /**
     *  Checks the event queue for messages and optionally returns them.
     *  
     *  If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
     *  the back of the event queue.
     *  
     *  If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
     *  of the event queue, within the specified minimum and maximum type,
     *  will be returned and will not be removed from the queue.
     *  
     *  If \c action is ::SDL_GETEVENT, up to \c numevents events at the front 
     *  of the event queue, within the specified minimum and maximum type,
     *  will be returned and will be removed from the queue.
     *  
     *  \return The number of events actually stored, or -1 if there was an error.
     *  
     *  This function is thread-safe.
     */
    extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
                                               SDL_eventaction action,
                                               Uint32 minType, Uint32 maxType);

Finally, here is the method I am trying to rewrite:

    /**
     * Returns true if the queue is empty of events that match 'mask'. 
     */
     bool EventHandler::timerQueueEmpty() {
        SDL_Event event;
    
        if (SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_EVENTMASK(SDL_USEREVENT)))
            return false;
        else
            return true;
    }

It currently throws the following error when compiling - 'SDL_EVENTMASK' was not declared in this scope.  I fully understand that the error is occurring because SDL_EVENTMASK is no longer a parameter of the SDL_PeepEvents function.  I also understand that Uint32Mask has been replaced by Uint32 minType, Uint32 maxType.  I just having a hard time understanding how to rewrite the code with these new parameters.
Comment 1 Sam Lantinga 2011-01-24 16:20:18 UTC
I think what you want is this:
    /**
     * Returns true if the queue is empty of events that match 'mask'. 
     */
     bool EventHandler::timerQueueEmpty() {
        SDL_Event event;

        if (SDL_PeepEvents(&event, 1, SDL_PEEKEVENT,
SDL_USEREVENT, SDL_USEREVENT))
            return false;
        else
            return true;
    }

You'll probably get faster response for these kinds of questions on the SDL mailing list or forum.  If you want to post on the forum, please make sure you read the welcome message for instructions on how to gain access.

Mailing list:
http://www.libsdl.org/mailing-list.php

Forums:
http://forums.libsdl.org/