Hi,
For various reasons, I’m using a simple co-operative multitasking
scheme in my program whereby all I/O is done through a single
multiplexer that calls select() (or poll(), or whatever the win32
equivalent is).
I wonder if its possible to use SDL in such a setup
yep
– I’d need to be able to grab the file descriptor(s) SDL reads from
for input events,
nope
There are no file descriptors associated with any SDL events at all.
Keep in mind this doesn’t included extended SDL events, which are not
generated by SDL, but SDL is kind enough to let arbitrary events be put
into its event queue by other libraries. So if there’s a networking
library out there (maybe SDL_net already does this) written for use
with SDL, then it probably DOES have some file descriptor associated
with the source / cause of certain SDL events.
You’re barking up the wrong tree. The select() fuction (when not being
used as portable high-precision sleep, coughSDL_Delaycough) is for
use with I/O streams, be they files or sockets or devices or pipes or
any other kind of I/O stream there is.
Most (if not all) of the events represented by the SDL_Event are
generally generated by the system invoking SDL callback functions, or
by SDL rummaging an event queue, perhaps not dissimilar to its own.
This of course depends on the platform, and the SDL implementation
being used.
So far, just the facts. Now for my opinion.
It sounds to me like you want to unify the components of your program
responsible for I/O and event handling. Instead, why don’t you set up
I/O availability so that it throws a custom SDL event into the
SDL_Event queue?
To put it simply, instead of merging event handling into your I/O
handling, you’d be doing it the other way around.
On the other hand, maybe unity isn’t what you want at all, and you just
have a boner for unix’s style of I/O management. I can relate to this
feeling, in which case, again, you’re barking up the wrong tree.
I hope some other SDL mailing list members will confirm (one way or the
other) some of the possibilities I inconclusively mentioned (such as
whether or not SDL_net puts custom SDL events into the SDL event
queue.)
Good luck.On Nov 20, 2004, at 2:20 PM, Slava Pestov wrote: