l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2004 May 18 20:03

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] fltk + SDL and questions about handling events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] fltk + SDL and questions about handling events

Hi all:

I have a question about events structs with fltk and SDL:

here's the guts of my main function:

int main(int argc, char **argv)
// I have two functions defined to handle events:

//and I have SDL_Event *sdlevent pointer defined
// To allow fltk to share events with SDL, instead of then 
// going into fl::run(), I made a custom event loop:


while(fl::check()) {
   if (SDL_PollEvent(&sdlevent))

The only thing left out is that i copy sdlevent.key.keysym.sym to my local key
char variable, and my other matching events (Shift, control, mouseclick) into
the FL equivalents such that they will fall into points in the switch{} in the
global event handler, my_event_handler.  It works nicely now, with multiple
windows all sharing events...

I know that fltk stores its event in static structures, and that SDL uses a
completely different model to handle events (FL::event() is an integer,
SDL_PollEvent fills the struct SDL_Event with current event data).  In fltk,
the event structures are defined when they are created, and fl::run() passes
the current events onto the ones defined (callbacks for button clicks, etc). 
That's why I substitute the call from run to check, because check() just the
checks the queue once, not looping forever.  This gives me a chance to call
PollEvent, and thus checking the two queues using the same event loop.

My question is this: is this a good way to do it?  Has anyone had experience
with handling events from multiple windows/libraries/event structs?  I just
need my code to be cross platform portable and reliable (i haven't tried it on
anything beside x86 linux)...

Any other tips or tricks?

--thanks in advance


EDUCATION, n. That which discloses to the wise and disguises from the
foolish their lack of understanding.

Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.