Re: [AD] keyboard autorepeat timer

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


> I'm thinking of two possible solutions:
> - install the keyboard autorepeat timer the first time a key is struck and
> keep it with a fixed period (250 ms is currently the default) until
> remove_keyboard() is called. When no keys are pressed, the timer proc
simply
> does nothing.

I like this one, no overloading creating and deleting more and more timers
just
because a key is pressed

> - install the keyboard autorepeat timer the first time a key is struck and
> change its period on demand: when keys are pressed, set the period
according
> to the autorepeat rate, otherwise set it to a lengthy one in order to
waste
> as few cycles as possible.

I don't see why we should await for a key to be pressed to install a timer
since
we all be can almost sure the user will press a key sonner or l8tr =)

sooo, i would go with option number 1
maybe there could be something done to enable the pause between
first keystroke and repetitions?
think that we want the key to wait for repetitions until 250msecs have
passed and we want to repeat the keystroke after each 50msecs
maybe we could install a timer for each 50msecs and have a counter
that when the key is on hold and the counter have reached 5 (50 * 5 =
250msecs)
then repeat the keystroke
that counter if used for each key would take more than 256 bytes

it would be somthing like

install_timer(bla bla bla, 50msecs)

unsigned char key_count[256];

if (!key[MYKEY])
   key_count[MYKEY] = 0;
else if (key[MYKEY]) {
   if (key_count[MYKEY] >= 5)
      instert_in_the_buffer(MYKEY);
   else
        key_count[MYKEY]++;
}

that way we only need one timer created and we solve many problems
wat do you think?



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