Sun Microsystems 800-1256-04 — Sun Microsystems 800-1256-04 SunCGI Reference Manual PDF (EN)

Appendix E - Sample Programs 139 0 #include #define DEVNUM 1 /* device number*/ /* trigger number*/ #define MOUSE_POSITION 5 #define TIMEOUT (5 * 1000 * 1000) /* timeout in microseconds*/ Ccoor ulc = {1000, 2000); Ccoor lrc = {2000, 1000); main() { Cint name; Cvwsurf device; Cawresult stat; Cinrep sample; Ccoor samp; Cint trigger; /* device measure value*/ /* LOCATOR'S x,y position*/ /* trigger number*/ NORMAL_VWSURF(device, PIXWINDD); sample.xypt = &samp; samp.x = O; samp.y = 27000;.

open_cgi () ; open_vws(&name, &device); set_global_drawing_mode(XOR); initialize_lid(IC_LOCATOR, DEVNUM, &sample); associate(MOUSE_POSITION, IC_LOCATOR, DEVNUM); rectangle(&lrc, &ulc); /* draw first rectangle*/ /* wait TIMEOUT micro-seconds for-input and check the status*/ while (request_input(IC_LOCATOR, DEVNUM, TIMEOUT, &stat, &sample, &trigger), (stat•• VALID_DATA)) if ((sample.xypt->x != ulc.x) I I (sample.xypt->y lrc.y) ) { rectangle(&lrc, &ulc); lrc.y = sample.xypt->y; /* move to new location*/ lrc.x = (sample.xypt->x + 1000); ulc.x = sample.xypt->x; ulc.y {sample.xypt->y + 1000); rectangle(&lrc, &ulc); 0 dissociate(MOUSE_POSITION, IC_LOCATOR, DEVNUM); release_input_device(IC_LOCATOR, DEVNUM); close_vws(name); close_cgi () ; 0 Figure E-2 Tracking Box Example Program Version C of 17 March 1986