Using the event manager API

Using the event queue

The event manager API allows an application to obtain sequential input from any number of event devices. Devices like mice, trackballs, bitpads, and the keyboard can be assigned to one or more terminals or multiscreens. When a process opens an event queue with more than one device attached, input from all the devices is intermixed in the event queue. This allows a process to ``sleep on multiple devices'' without recourse to the select(S) system call.

An application makes a call to a library routine to open an event queue. That call attaches the event devices to the event queue. In general, an application may be using multiple devices. For example, an application would typically want to use a mouse and the keyboard. In cases where there are several devices attached to the terminal, for example multiple mice, calls are provided for listing the attached devices and including them or excluding them on an individual basis.

The event driver maintains a circular queue of events. ``Circular'' means that if the total number of events in the queue exceeds the maximum number of events storable, that the oldest event is removed from the queue and an error condition is returned.

The event queue is ``fed'' by all the devices attached to the queue. An input mask may also be set which prevents certain classes of events from being inserted into the queue. For example, you may wish to exclude button events or movement events during some portions of your program.

The application program reads the event queue by getting a pointer to the next event. When the application has copied or finished examining the event, it pops the event queue using the ev_pop(S) routine. The next ev_read(S) call will return a pointer to the next event in the queue, or NULL if the queue is empty. Multiple reads that are not separated by a call to pop the queue return the same pointer.

Next topic: Event manager calls
Previous topic: Event generating hardware

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003