vga_waitevent - wait for various I/O events
int vga_waitevent(int which, fd_set *input,
fd_set *output , fd_set *except, struct timeval
This is the only function allowing you to wait for keyboard AND mouse events. It
is based on the select
(2) library function, so for deep understanding
look at select
(2) as well.
can be 0 or logical ored together from VGA_MOUSEEVENT
. If you are interested in waiting for file descriptors
having input available or being ready for new write data or being in an
exceptional condition (urgent data arrived on a TCP stream) set the
corresponding bits in the fd_set
structures passed (see
(3)). If you want vga_waitevent()
to return after a
timeout value pass a struct timeval
with the desired value. If you are
not interested in the corresponding events you may pass NULL
for any of
is passed for timeout vga_waitevent()
will not time
out but block until any of the other events occurs. If the integer returned is
< 0 an error occurred. Check the global variable errno
If a value >= 0 is returned it is a bitmask constructed using
to show which of these events
If any of these two occured the appropriate update functions are already called
operates in raw as well as
non-raw keyboard mode. In the latter case use vga_getch
(3) to read the newly arrived keys.
Any of the file related conditions being met will be signalled by setting
exactly the bits for files that met the conditions in the corresponding
structures. If a non-NULL timeout
is passed the
remaining time is written into it on return. If it is 0 a timeout occured.
(again: cf. select
(2)) Therefore, depending on context,
(3) may return 0 if only special, non svgalib, events
If you want to wait blocking for a keypress OR a mouse event use:
vga_waitevent(VGA_MOUSEEVENT | VGA_KEYEVENT, NULL, NULL, NULL, NULL);
If you want to wait for a keypress OR a mouse event but non-blocking use:
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
vga_waitevent(VGA_MOUSEEVENT | VGA_KEYEVENT, NULL, NULL, NULL,
You could do a similar thing by just calling
though. There is no such counterpart for the first example.
Finally, there is a very nice eventtest
(6) demo showing most capabilities
This function was introduced in 1.2.10. Unfortunately there was a typo in the
first implementation which broke the case where input
Though fixed in 1.2.11 for optimal portability pass an empty fd_set
instead of NULL
as first argument.
When not running in background mode, that is, the svgalib applcation is
suspended while the VC is switched away, it seems vga_waitevent
stuck and does no longer timeout. It is not clear if this is an svgalib bug,
kernel bug or general problem.
This manual page was edited by Michael Weller
<firstname.lastname@example.org>. The exact source of the referenced
function as well as of the original documentation is unknown.
It is very likely that both are at least to some extent are due to Harm
Occasionally this might be wrong. I hereby asked to be excused by the original
author and will happily accept any additions or corrections to this first
version of the svgalib manual.