Re: [AD] keyboard autorepeat timer

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


> > I just want to add a third period 'idle', so that a typical working
> > sequence for the timer would be: idle - delay - rate - rate - rate... -
> > idle.
>
> I think there is a flaw in the src/timer.c file related to re-installation
> of timers. Here's the piece of code from install_timer_int():
>
>    if ((proc == _timer_queue[x].proc) || (proc ==
>                                         _timer_queue[x].param_proc))
>       _timer_queue[x].counter -= _timer_queue[x].speed;
>       _timer_queue[x].counter += speed;
>    }
>
> Suppose you installed a very long timer (say 1 second) and now you change
> its speed to 10 ms in the middle of a period, so that counter == 500.
After
> re-installing the timer, you end up with counter == -490.
> Therefore, on the next tick, the timer proc is called no less than 50
times!
>
> I'm proposing to change the code to:
>
>    if ((proc == _timer_queue[x].proc) || (proc ==
>                                         _timer_queue[x].param_proc))
>       _timer_queue[x].counter = speed;
>    }

Seems very sensible to me



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