ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/driver.h
Revision: 1.3
Committed: Wed Oct 25 15:37:12 1989 UTC (34 years, 6 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.2: +7 -3 lines
Log Message:
modified interface to independent drivers

File Contents

# Content
1 /* Copyright (c) 1987 Regents of the University of California */
2
3 /* SCCSid "$SunId$ LBL" */
4
5 /*
6 * driver.h - header file for interactive device drivers.
7 *
8 * 2/2/87
9 */
10
11 struct driver { /* driver functions */
12 int (*close)(); /* close device */
13 int (*clear)(); /* clear device */
14 int (*paintr)(); /* paint rectangle */
15 int (*getcur)(); /* get cursor position */
16 int (*comout)(); /* command line output */
17 int (*comin)(); /* command line input */
18 int xsiz, ysiz; /* device size */
19 int inpready; /* input ready on device */
20 };
21
22 extern int stderr_v(); /* error vectors */
23 extern int (*wrnvec)(), (*errvec)(), (*cmdvec)();
24
25 extern struct driver *comm_init(); /* stream interface */
26 /* magic numbers for verification */
27 #define COM_SENDM 0x6f37
28 #define COM_RECVM 0x51da
29 /* stream commands */
30 #define COM_CLEAR 0
31 #define COM_PAINTR 1
32 #define COM_GETCUR 2
33 #define COM_COMOUT 3
34 #define COM_COMIN 4
35 #define NREQUESTS 5 /* number of valid requests */
36
37 struct device { /* interactive device */
38 char *name; /* device name */
39 char *descrip; /* description */
40 struct driver *(*init)(); /* initialize device */
41 };
42
43 extern struct device devtable[]; /* supported devices */
44
45 #define MB1 ('\n') /* mouse button 1 */
46 #define MB2 ('\r') /* mouse button 2 */
47 #define MB3 (' ') /* mouse button 3 */
48 #define ABORT ('C'-'@') /* abort key */
49
50 #define MAXRES 4000 /* preposterous display resolution */
51
52 /*
53 * struct driver *
54 * dname_init(name, id)
55 * char *name, *id;
56 * {
57 * Initialize device and return pointer to driver
58 * functions. Returns NULL if an error occurred.
59 * The name string identifies the driver,
60 * and the id string identifies the client.
61 * A device can be open by at most one client.
62 * Be verbose in error reports; call stderr_v().
63 * If device has its own error output, set errvec,
64 * cmdvec and wrnvec.
65 * }
66 * (*dev->close)()
67 * {
68 * Close the device. Reset error vectors.
69 * }
70 * (*dev->clear)(xres, yres)
71 * int xres, yres;
72 * {
73 * Clear the device for xres by yres output. This call will
74 * be made prior to any output.
75 * }
76 * (*dev->paintr)(col, xmin, ymin, xmax, ymax)
77 * COLOR col;
78 * int xmin, ymin, xmax, ymax;
79 * {
80 * Paint a half-open rectangle from (xmin,ymin) to (xmax,ymax)
81 * with the color col. Can call repaint() if necessary.
82 * }
83 * (*dev->getcur)(xp, yp)
84 * int *xp, *yp;
85 * {
86 * Get the cursor position entered by the user via mouse,
87 * joystick, etc. Return the key hit by the user (usually
88 * MB1 or MB2). Return ABORT to cancel.
89 * Can be NULL for devices without this capability.
90 * }
91 * (*dev->comout)(out)
92 * char *out;
93 * {
94 * Print the string out on the device command line. If the
95 * string ends with '\n', the message is considered complete,
96 * and the next call can erase it.
97 * }
98 * (*dev->comin)(in)
99 * char *in;
100 * {
101 * Read an edited input string from the command line. If
102 * an unrecognized control character is entered, terminate
103 * input and return the string with only that character.
104 * The input string should not contain a newline.
105 * Must work in consort with comout.
106 * }
107 * xsiz, ysiz
108 * The maximum allowable x and y dimensions. If any
109 * size is allowable, these should be set to MAXRES.
110 * inpready
111 * This variable should be made positive asynchronously
112 * when characters are ready on the input. (Often easiest
113 * to check for input during calls to paintr.)
114 */