|
|
#include <sys/types.h> #include <sys/param.h> #include <sys/sysmacros.h> #include <sys/page.h> #include <sys/event.h> #include <mouse.h>int ev_open (dmask) dmask_t *dmaskp;
The bitmask is made of one or more of four classes of devices. The four classes are D_STRING, D_REL, D_ABS, or D_OTHER. D_STRING refers to character stream devices like the keyboard. D_REL refers to relative locator devices like mice. D_ABS refers to absolute locator devices like bitpads. These values are defined in <mouse.h>.
ev_open attempts to open devices of the types indicated in the argument and sets the mask to indicate the devices successfully opened. If no devices can be successfully opened, ev_open returns -1 as an error condition.
If ev_open succeeds in opening an event queue and devices, it returns a file descriptor for the event queue. The file descriptor is for use with the select system call and should not be used for reading or writing.
This is a program fragment that opens an event queue with a mouse and the keyboard attached:
main() { dmask_t dmask; /* device mask */ int qfd; /* event queue file descriptor */ev_init(); /* initialize event manager */ dmask = D_REL|D_STRING; /* device mask for mouse & kbd */ qfd = ev_open(&dmask); /* try to open event queue */ if ( qfd < 0 ) exit(1); /* error on open */
if (dmask != (D_REL | D_STRING)) exit(2); /* could not attach both devices */ /* event queue is open */ ... }
It returns -1 if there was a configuration error in the configuration files (see ev_init(S)). ev_open returns -2 if it does not find any devices to attach. It returns -3 if it is unable to open devices it finds. It returns -4 if it is unable to open an event queue.