Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » keuboard

This thread is locked; no one can reply to it. rss feed Print
keuboard
laught
Member #7,411
June 2006

hi!
how can i disable the repeat of the keyboard input ?
i've tryed with the set_keyboard_rate() function but it isnt working :/
an example of how to use it would be good ...

thanks!

neil dwyer
Member #7,237
May 2006

would clear_keybuf() work.

miran
Member #2,407
June 2002

From the manual:

Quote:

void set_keyboard_rate(int delay, int repeat);

Sets the keyboard repeat rate. Times are given in milliseconds. Passing zero times will disable the key repeat.

Example:

Works for me.

EDIT: Hmm, apparently not. ??? I remember this used to work when I was on Windows. Now I'm on Linux and just tried a simple test with the above code and it doesn't work. Like set_keyboard_rate() is completely ignored. ???

My full test:

1#include <allegro.h>
2 
3int main() {
4 allegro_init();
5 set_color_depth(32);
6 set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
7 install_keyboard();
8 set_keyboard_rate(1500, 500);
9 
10 int y = 0;
11 while (!key[KEY_ESC]) {
12 while (keypressed()) {
13 int c = readkey();
14 textprintf_ex(screen, font, 0, y, -1, -1, scancode_to_name(c>>8));
15 y += 8;
16 if (y >= SCREEN_H) {
17 clear_to_color(screen, 0);
18 y = 0;
19 }
20 }
21 }
22 
23 return 0;
24}
25END_OF_MAIN()

--
sig used to be here

Go to: