1vga_waitevent(3)              Svgalib User Manual             vga_waitevent(3)
2
3
4

NAME

6       vga_waitevent - wait for various I/O events
7

SYNOPSIS

9       #include <sys/time.h>
10       #include <sys/types.h>
11       #include <unistd.h>
12       #include <vga.h>
13
14       int  vga_waitevent(int  which,  fd_set  *input, fd_set *output , fd_set
15       *except, struct timeval *timeout)
16
17

DESCRIPTION

19       This is the only function allowing you to wait for keyboard  AND  mouse
20       events.  It  is  based  on  the select(2) library function, so for deep
21       understanding of vga_waitevent() look at select(2) as well.
22
23       which can be  0  or  logical  ored  together  from  VGA_MOUSEEVENT  and
24       VGA_KEYEVENT.   If  you  are interested in waiting for file descriptors
25       having input available or being ready for new write data or being in an
26       exceptional  condition  (urgent  data  arrived on a TCP stream) set the
27       corresponding bits in the fd_set structures passed (see select(3)).  If
28       you  want vga_waitevent() to return after a timeout value pass a struct
29       timeval with the desired value. If you are not interested in the corre‐
30       sponding events you may pass NULL for any of the pointers.
31
32       If  NULL  is  passed  for timeout vga_waitevent() will not time out but
33       block until any of the other events occurs.  If the integer returned is
34       <  0 an error occurred. Check the global variable errno for details. If
35       a  value  >=  0  is  returned  it  is  a  bitmask   constructed   using
36       VGA_MOUSEEVENT and VGA_KEYEVENT to show which of these events occured.
37
38       If  any  of  these  two  occured  the  appropriate update functions are
39       already called by vga_waitevent().vga_waitevent() operates  in  raw  as
40       well  as non-raw keyboard mode. In the latter case use vga_getch(3) not
41       vga_getkey(3) to read the newly arrived keys.
42
43       Any of the file related conditions being met will be signalled by  set‐
44       ting  exactly  the bits for files that met the conditions in the corre‐
45       sponding fd_set structures. If a non-NULL timeout is passed the remain‐
46       ing  time  is written into it on return.  If it is 0 a timeout occured.
47       (again: cf.  select(2)) Therefore, depending on context, vga_waitkey(3)
48       may return 0 if only special, non svgalib, events occured.
49
50

EXAMPLES

52       If  you  want  to  wait  blocking  for a keypress OR a mouse event use:
53       vga_waitevent(VGA_MOUSEEVENT | VGA_KEYEVENT, NULL, NULL, NULL, NULL);
54
55       If you want to wait for a keypress OR a mouse  event  but  non-blocking
56       use:
57
58       #include <sys/time.h>
59       #include <sys/types.h>
60       #include <unistd.h>
61       #include <vga.h>
62
63       struct timeval timeout;
64       timeout.tv_sec = 0;
65       timeout.tv_usec = 0;
66       vga_waitevent(VGA_MOUSEEVENT  |  VGA_KEYEVENT, NULL, NULL, NULL, &time‐
67       out);
68
69       You could do a similar thing by just calling
70
71       mouse_update();
72       keyboard_update();
73
74       though. There is no such counterpart for the first example.
75
76       Finally, there is a very nice eventtest(6) demo showing most  capabili‐
77       ties of vga_waitevent().
78
79

BUGS

81       This  function was introduced in 1.2.10. Unfortunately there was a typo
82       in the first implementation which broke the case where input was  NULL.
83       Though  fixed  in  1.2.11  for optimal portability pass an empty fd_set
84       instead of NULL as first argument.
85
86       When not running in background mode, that is, the svgalib applcation is
87       suspended  while  the  VC is switched away, it seems vga_waitevent gets
88       stuck and does no longer timeout. It is not clear if this is an svgalib
89       bug, kernel bug or general problem.
90
91

SEE ALSO

93       svgalib(7),  vgagl(7),  libvga.config(5),  eventtest(6), mouse_getposi‐
94       tion_6d(3),  mouse_getx(3),  mouse_update(3),   mouse_waitforupdate(3),
95       vga_getkey(3), vga_getch(3)
96
97

AUTHOR

99       This  manual  page  was  edited by Michael Weller <eowmob@exp-math.uni-
100       essen.de>. The exact source of the referenced function as  well  as  of
101       the original documentation is unknown.
102
103       It is very likely that both are at least to some extent are due to Harm
104       Hanemaayer <H.Hanemaayer@inter.nl.net>.
105
106       Occasionally this might be wrong. I hereby asked to be excused  by  the
107       original author and will happily accept any additions or corrections to
108       this first version of the svgalib manual.
109
110
111
112Svgalib (>= 1.2.11)              27 July 1997                 vga_waitevent(3)
Impressum