l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
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:
Fl::add_handler(my_event_handler);
//and
SDL_Init(SDL_INIT_VIDEO);

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

//fl::run();

while(fl::check()) {
   if (SDL_PollEvent(&sdlevent))
       my_event_handler(0);
   }
return(0)
}

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

jan

=====
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
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.
http://promo.yahoo.com/sbc/
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
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:
EDGE Tech Corp.
For donating some give-aways for our meetings.