SDL 1.3 event filtering

Hi

Does anyone have an example of how to use the SDL_SetEventFilter on SDL 1.3 ?
Google is no help, and nothing I do seems to work. Example code greatly appreciated!

Cheers
Ed

Saying “nothing I do seems to work” doesn’t help much unless
we know what it is you’re trying to do…

Mason________________________________
From: e_byard@yahoo.co.uk (Edward Byard)
Subject: [SDL] SDL 1.3 event filtering

Hi

Does anyone have an example of how to use the SDL_SetEventFilter on SDL 1.3 ?
Google is no help, and nothing I do seems to work. Example code greatly
appreciated!

Cheers
Ed

Mason

Yeah I just got frustrated. In short, I am trying to remove all non SDL_MOUSEBUTTONDOWN events from the event queue.

The problem I have is that I have to do a lot of rendering and using SDL_PumpEvents and SDL_PollEvent introduces very noticable juddering in the rendering,
so I just need to know that a mouse button is pressed and react to that. Nothing else.

Thanks
Ed

Well I’m trying to use SDL_PeepEvents to see if there’s a SDL_MOUSEBUTTONDOWN event, well you can see the code here:

Code:

if (SDL_PeepEvents(this->eventArray,1,SDL_PEEKEVENT,SDL_MOUSEMOTION,SDL_MOUSEBUTTONDOWN))
{
	if (eventArray[0].type == SDL_MOUSEBUTTONDOWN)
	{
		SDL_FlushEvents(SDL_FIRSTEVENT,SDL_LASTEVENT);
		return true;
	}
}

SDL_PeepEvents always returns 0.

Any ideas??

Are you calling SDL_PumpEvents()?> SDL_PeepEvents always returns 0.

Any ideas??

The problem I have is that I have to do a lot of rendering and using SDL_PumpEvents and SDL_PollEvent introduces very noticable juddering in the rendering,
so I just need to know that a mouse button is pressed and react to that. Nothing else.

I’m curious how you’re polling the events.
Why can’t you do that between frames?
What platform are you on?

Linux, OSX: SDL_PumpEvents is a no-op.
[Well, I’m not using it and events still get thru]
You may need it if you’re reading events from a different thread.On 21/02/2011, at 3:00 AM, ebyard wrote:


john skaller
@john_skaller

I’m using Win32. If I add SDL_PumpEvents then for some reason, as I said, rendering becomes jerky and the game looks horrendous. It’s like flicking a light switch, take it away, and all is fine. I’m only running at 60fps, so there should be plenty of time between frames. I’ll do some measuring to see just how long SDL_PumpEvents takes…

You cannot avoid using SDL_PumpEvents() on the windows platform; but
it shouldn’t cause jerky animation.

It would be interesting to see what kind of events are being
generated… perhaps you have some odd piece of hardware that
generates spurious events? I cannot see any reason for
SDL_PumpEvents() to take a long time.

The only other think I can think of is that a non deterministic amount
of time being spent in your event loop is causing you to randomly miss
your 16 millisecond rendering deadline, and if your game logic is
linked to frame rate that is going to cause some odd looking
rendering. Look out for spikes as well as measuring the average time
it takes to process events.On 21 February 2011 09:52, ebyard <e_byard at yahoo.co.uk> wrote:

I’m using Win32. If I add SDL_PumpEvents then for some reason, as I said,
rendering becomes jerky and the game looks horrendous. It’s like flicking a
light switch, take it away, and all is fine. I’m only running at 60fps, so
there should be plenty of time between frames. I’ll do some measuring to see
just how long SDL_PumpEvents takes…

I’m using Win32. If I add SDL_PumpEvents then for some reason, as I said, rendering becomes jerky and the game looks horrendous. It’s like flicking a light switch, take it away, and all is fine. I’m only running at 60fps, so there should be plenty of time between frames. I’ll do some measuring to see just how long SDL_PumpEvents takes…

I’m no expert, but I think SDL_PumpEvents simply grabs events from the standard
windows event queue and puts them in the SDL queue. That shouldn’t be slow:
the queue is in user space. The SDL queue is protected by a mutex though.
Maybe locking is triggering a task switch.

What happens if you reduce the frame rate to 20 fps? [20 fps is enough to completely
fool the eye. I used to kill Diablo at 1 fps :]On 21/02/2011, at 8:52 PM, ebyard wrote:


john skaller
@john_skaller