set_keyboard_rate
Serial H

Hi,
I have a problem with the function set_keyboard_rate.
It works when I use set_keyboard_rate(0,0) to disable the repeat key, but I just want to slow down the repeat key.
when I use
set_keyboard_rate(1000,0)
it doesn't work.
Thanks.

Matt Smith

As far as I can recall (I've not been paying attention recently) this function only works in DOS because it calls the BIOS function. In other O/S the repeat rate is set by the O/S for all programs and allegro (deliberately?) refrains from changing system-wide parameters, as this would affect other users and programs.

Birdeeoh

This function works just great under Windows and Linux. Reread the docs on it - the order of the parameters is
set_keyboard_rate( int delay, int rate );
set_keyboard_rate(1000,0), as was your example, sets the delay to 1000ms but a repeat rate of 0 - that's disabled.

The repeat rate is "number of milliseconds between each key repeat"

Here's some examples -

//delay of 500ms, repeats 1000 times per second
set_keyboard_rate( 500, 1 );

//delay of 100ms, repeats 10 times per second
set_keyboard_rate( 100, 100 );

//delay of 1ms, repeats twice per second
set_keyboard_rate( 1, 500 );

Good luck!

Thread #568816. Printed from Allegro.cc