Re: [AD] EVDEV mouse driver |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> > + /* Flush the files FIXME not alway flushed */
> > + for (n=0; n<NUM_FD; n++) {
> > + if (fd[n]!=-1) {
> > + while (read(fd[n], buffer_array[n], PACKET_SIZE) > 0)
> > + ;
> > + }
> > }
> >
> > Could you explain the FIXME ?
>
> After the end of the loop, when not moving a mouse, there are sometimes
> still data in one/some devices. So the progress bar begins to fill up
> without the user interaction.
Still not very clear for me...
Do you mean that mouse A, after having been flushed by the first iteration of
the loop, might be moved during the second iteration of the loop when mouse
B is being flushed, and thus might end up being _not_ flushed after the
whole loop? If so, yes, that makes sense.
Why not use the multiplexing capability of select() with a timeout set to 0?
> We open all the devices because we don't know which one is the mouse.
> We ask the user to move the mouse, which means that the mouse device file
> will be filled with data.
> Then, the "correct" device file is the one from which the most data have
> been read.
I guess that's ok. But a comment explaining the strategy would certainly not
be superfluous.
And wouldn't using select() be better here too (with a NULL timeout this
time) instead of constantly looping through the various open file
descriptors ?
> (4.1.9 without pthreads)
>
> #include <allegro.h>
> int main()
> {
> allegro_init();
> set_color_depth(16);
> set_gfx_mode(GFX_SAFE, 0, 0, 0, 0);
> install_mouse();
> install_keyboard();
> position_mouse(SCREEN_W/2-32, SCREEN_H/2-16);
> alert("ZZZZZZZZZZZ", "ZZZZZZZZZZZZZ", "ZZZZZZZZZZZZZ", "YYY", "YYY", 0,
> 0);
> return 0;
> }
> END_OF_MAIN()
Ah! position_mouse() appears to be the key... I can reproduce the problem
with pthreads too. Thanks for the testcase!
--
Eric Botcazou