/* * Copyright 1989 O'Reilly and Associates, Inc. * See ../Copyright for complete rights and liability information. */ #include #include #include #include #include "serial_sgi.h" #include #include /*#include "../bitmaps/icon_bitmap"*/ #define BITMAPDEPTH 1 #define SMALL 1 #define OK 0 #define BUF_SIZE 2000 #define MAX(x,y) (x>y ? x : y) #define MIN(x,y) (x>2)<<2) | 0x1; if (sendright) outbuf[0] = ((outbuf[0]>>2)<<2) | 0x2; Serial_Write(port,outbuf,3); Serial_Write(port,outbuf,3); Serial_Write(port,outbuf,3); } } /* Came back over edge */ else if (((sendleft && sendingstate && rootx == display_width-1) || (sendright && sendingstate && rootx == 0)) && !((maskreturn&Button1Mask) || (maskreturn&Button2Mask) || (maskreturn&Button3Mask))) { sendingstate=0; XUngrabPointer(display,CurrentTime); XUngrabKeyboard(display, CurrentTime); xwarp = abs(display_width - 10 - rootx); XWarpPointer(display, None, RootWindow(display, screen), 0, 0, display_width, display_height, xwarp, savey); prevx=xwarp; prevy=savey; /* set mouse back to orig speed */ XChangePointerControl(display,1,1,orig_num,orig_den,orig_thr); /* move the mouse to the edge of screen */ if (sendleft) outbuf[0] = ((outbuf[0]>>2)<<2) | 0x1; if (sendright) outbuf[0] = ((outbuf[0]>>2)<<2) | 0x2; Serial_Write(port,outbuf,3); Serial_Write(port,outbuf,3); Serial_Write(port,outbuf,3); } /* Currently sending commands */ else if (sendingstate) { if (rootx!=prevx || rooty!=prevy || prevmask != maskreturn) { /* printf ("got motion: %d %d : %d %d %d\n", rootx, rooty, (maskreturn&Button1Mask), (maskreturn&Button2Mask), (maskreturn&Button3Mask) );*/ /* serial code */ tmpint=(rootx-prevx)*sendmult; v1=MAX(MIN(tmpint,127),-127); tmpint=(rooty-prevy)*sendmult; v2=MAX(MIN(tmpint,127),-127); outbuf[0]=0x40; if (maskreturn&Button1Mask) outbuf[0] |= 0x20; if (maskreturn&Button3Mask) outbuf[0] |= 0x10; if (maskreturn&Button2Mask) outbuf[0] |= 0x30; outbuf[0] |= ((v2 & 0xC0)>>4); outbuf[0] |= ((v1 & 0xC0)>>6); outbuf[1] = (v1 & 0x3F); outbuf[2] = (v2 & 0x3F); /* printf ("Outgoing buf: %x %x %x\n",(unsigned int)outbuf[0], (unsigned int)outbuf[1], (unsigned int) outbuf[2]);*/ Serial_Write(port,outbuf,3); } /* check for border conditions */ if (rooty==0 || rooty==display_height-1 || (sendleft && rootx==0) || (sendright && rootx==display_width-1)) { if (rooty==0) rooty=100; if (rooty==display_height-1) rooty = display_height-100; if (rootx==0) rootx=100; if (rootx==display_width-1) rootx = display_width-100; XWarpPointer(display, None, RootWindow(display, screen), 0, 0, display_width, display_height, rootx, rooty); } /* update prev buffers */ prevmask = maskreturn; prevx=rootx; prevy=rooty; } } } }