kbd_queue Function (tigcc.a)

system.h

void *kbd_queue (void);

Returns a pointer to the keyboard queue.

kbd_queue returns a pointer to the queue used in TIOS for keyboard handling. It may be used as an argument to other queue-related functions. The main purpose of accessing to keyboard queue is to make a fast replacement for ngetchx and kbhit functions. This may be achieved using OSdequeue function. For example, suppose that you have the following declarations:

void *kbq = kbd_queue ();
unsigned short key;
Then, statements like
if (kbhit ())
{
  key = ngetchx ();
  // Do something with key
}
may be replaced with the much faster equivalent:
if (!OSdequeue (&key, kbq))
{
  // Do something with key
}
Note: On the first look, it seems that the key repetition feature does not work with OSdequeue. But, Marcos Lopez informed me that this is not exactly true. Key repetition feature works even with OSdequeue, but it will not return the keycode itself for the repeated key, but add the KB_AUTOREPEAT "auto-repeat" bit to the keycode (more exactly, KB_AUTOREPEAT is OR'd with the keycode), so value becomes value + 0x800. If you use the standard ngetchx function, this additional bit is masked out and your program will get the keycodes it expects. But, it is very simple to mask out this bit manually and make the key repetition feature work even with OSdequeue.


See also: OSdequeue, kbd.h