ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/driver.h
Revision: 1.5
Committed: Tue Jan 30 11:37:34 1990 UTC (34 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.4: +10 -7 lines
Log Message:
fixed bug where drivers would send commands inappropriately

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 double pixaspect; /* pixel aspect ratio */
19 int xsiz, ysiz; /* device size */
20 int inpready; /* input ready on device */
21 };
22
23 extern int stderr_v(); /* error vectors */
24 extern int (*wrnvec)(), (*errvec)(), (*cmdvec)();
25
26 extern struct driver *comm_init(); /* stream interface */
27 /* magic numbers for verification */
28 #define COM_SENDM 0x6f37
29 #define COM_RECVM 0x51da
30 /* stream commands */
31 #define COM_CLEAR 0
32 #define COM_PAINTR 1
33 #define COM_GETCUR 2
34 #define COM_COMOUT 3
35 #define COM_COMIN 4
36 #define NREQUESTS 5 /* number of valid requests */
37
38 extern struct device { /* interactive device */
39 char *name; /* device name */
40 char *descrip; /* description */
41 struct driver *(*init)(); /* initialize device */
42 } devtable[]; /* supported devices */
43
44 #define MB1 ('\n') /* mouse button 1 */
45 #define MB2 ('\r') /* mouse button 2 */
46 #define MB3 (' ') /* mouse button 3 */
47 #define ABORT ('C'-'@') /* abort key */
48
49 /*
50 * struct driver *
51 * dname_init(name, id)
52 * char *name, *id;
53 * {
54 * Initialize device and return pointer to driver
55 * functions. Returns NULL if an error occurred.
56 * The name string identifies the driver,
57 * and the id string identifies the client.
58 * A device can be open by at most one client.
59 * Be verbose in error reports; call stderr_v().
60 * If device has its own error output, set errvec,
61 * cmdvec and wrnvec.
62 * }
63 * (*dev->close)()
64 * {
65 * Close the device. Reset error vectors.
66 * }
67 * (*dev->clear)(xres, yres)
68 * int xres, yres;
69 * {
70 * Clear the device for xres by yres output. This call will
71 * be made prior to any output.
72 * }
73 * (*dev->paintr)(col, xmin, ymin, xmax, ymax)
74 * COLOR col;
75 * int xmin, ymin, xmax, ymax;
76 * {
77 * Paint a half-open rectangle from (xmin,ymin) to (xmax,ymax)
78 * with the color col. Can call repaint() if necessary.
79 * }
80 * (*dev->getcur)(xp, yp)
81 * int *xp, *yp;
82 * {
83 * Get the cursor position entered by the user via mouse,
84 * joystick, etc. Return the key hit by the user (usually
85 * MB1 or MB2). Return ABORT to cancel.
86 * Can be NULL for devices without this capability.
87 * }
88 * (*dev->comout)(out)
89 * char *out;
90 * {
91 * Print the string out on the device command line. If the
92 * string ends with '\n', the message is considered complete,
93 * and the next call can erase it.
94 * }
95 * (*dev->comin)(in, prompt)
96 * char *in, *prompt;
97 * {
98 * Print a prompt then read an edited input command line
99 * assuming the in buffer is big enough. Unless prompt is NULL,
100 * the driver may substitute its own rview command. This is
101 * the most reliable way to repaint areas of the screen.
102 * If the user enters an unrecognized control character is entered,
103 * terminate input and return the string with only that character.
104 * The input string should not contain a newline. The routines in
105 * editline.c may be useful. Comin 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 */