Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL_SetEventFilter not working

Started by nrgyzer Oct 3, 2010 at 5:30 AM 1 replies 1.6k views
Original Post
nrgyzer
nrgyzer
Hey guys,

I try to add an event filter, but it always returns the same event-type - the event code is always 80.

My code looks like this:
SDL_Event evt;...void main() {	SDL_SetEventFilter(cast(SDL_EventFilter) &_filter);	...	while(...) {		checkEvents();	}}void checkEvents() {	while(SDL_PollEvent(&evt)) {		switch(evt.type) {						case SDL_MOUSEBUTTONUP:				// do something				break;						default:				break;		}	}}int _filter(SDL_Event *e) {	if (e.type == SDL_MOUSEBUTTONUP) {		writefln(e.type);		return 1;	}	return 0;}...

Please note, that the game will be created with the programming language d and writefln(e.type) is always 80.

I hope anyone know what's the problem :)

[Edited by - nrgyzer on October 3, 2010 5:47:39 AM]
rip-off
rip-off
I don't know D, but I am suspicious that you require a cast when creating the filter. Perhaps the calling conventions are different and inside _filter the "event" type isn't where the compiler thinks it is.
nrgyzer
nrgyzer
Without the explicit cast to SDL_EventFilter, I get the following error:

"Error: cannot implicitly convert expression (& _filter) of type int function(SDL_Event* e) to SDL_EventFilter"

\\ Edit: I solved the problem by using extern(C) for the filter - thanks rip-off for your reply :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.