Re: [AD] Proposal for an input model

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


"Eric Botcazou" <ebotcazou@xxxxxxxxxx> writes:

> Do you mean only when the *user* calls al_poll_keyboard() ? If so, that's
> not exactly what I'd call asynchronous input. Otherwise, it's the job of the
> asynchronous framework (i.e the input thread) to call the callbacks, but it
> could of course instruct al_poll_keyboard() to do it on its behalf, and only
> call al_poll_keyboard() in the thread function.

Some platforms may call callbacks directly when there is input
available, some platforms will call callbacks only from
al_poll_input.  Usually, users will call al_poll_input once per frame,
and if frame rate is good, most applications will not notice
synchronous nature of these asynchronous callbacks in second case.

Calling al_poll_input from input thread on platforms that can block
until there is something to input is not good, because al_poll_input
is callable by user and user may call it when there is nothing to
read.  For such platforms it would be better to have noop
al_poll_input (maybe not exactly noop, if it returns something, but it
should not try to read input state) and update input state from input
thread.

If timers will stay in Allegro, and any Allegro functions may be
called from timer callback, then we may add timer callback that will
call al_poll_input periodically.  Though, it will add dependency
between input and timer.  IMHO, this is not necessary.  We may use
implicit polling if al_poll_input was not called and add counter to do
this polling only after some number of input related functions
were called without al_poll_input, this counter will be reset in
al_poll_input.  This will remove dependency between input and other
subsystems and will allow to work without al_poll_input, which might
be good when *writing* programs with Allegro.

BTW, it might be possible to have input thread in X (with some
limitations), but I think it is not possible to have it block when
there is no data with core Xlib functions.

-- 
Michael Bukin



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/