Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!cornell!uw-beaver!ubc-vision!fornax!bby-bc!john From: john@bby-bc.UUCP (john) Newsgroups: comp.sys.ibm.pc,comp.unix.questions,comp.unix.xenix Subject: Re: serial port (tty1) problem with microport 2.2 Message-ID: <146@bby-bc.UUCP> Date: Sun, 19-Jul-87 15:37:41 EDT Article-I.D.: bby-bc.146 Posted: Sun Jul 19 15:37:41 1987 Date-Received: Tue, 21-Jul-87 03:38:04 EDT Organization: Burnaby, British Columbia, Canada Lines: 72 Xref: mnetor comp.sys.ibm.pc:5843 comp.unix.questions:3252 comp.unix.xenix:487 A week or so ago I posted a request for help with connecting a mouse on a Microport SysV system. Several people sent mail asking how I got it to work so I thought I would post the solution since it is very short. Mice run at 1200 baud, no parity, 1 stop bit and one packet of information is 5 bytes b dx1 dy1 dx2 dy2 where dx{n} and dy{n} are signed 8 bit numbers and b has the format 1 0 0 0 0 b1 b2 b3 and b{n} == 1 if the button is UP. I don't claim the code below is great, it could easily be improved, but it works. john ----- /* sinmple mouse routines */ #include#include #include static int mfd; MouseInit() { struct termio t; int i; mfd = open("/dev/tty1",O_RDONLY); if (mfd < 1) fprintf(stderr," couldn't open mouse \n"); i=ioctl(mfd,TCGETA, &t); if (i < 0 ) fprintf(stderr,"ioctl error\n"); t.c_iflag = t.c_iflag & ~(IXON|IXOFF|ISTRIP|INLCR|IGNCR|ICRNL|IUCLC|INPCK); t.c_cflag = B1200 | CS8 | CLOCAL | CREAD ; t.c_lflag = 0; i=ioctl(mfd,TCSETA, &t); if (i < 0 ) fprintf(stderr,"ioctl error\n"); } /* wait for mouse to send something then return change in x, y and the status of the buttons with bn==1 if the button is down */ MouseRead(dx, dy, b1, b2, b3) int *dx, *dy, *b1, *b2, *b3; { unsigned char b; char bs[4]; int j; for (b=0; (b&0370) != 0200 ; ) read(mfd, &b, 1); /* get here with button byte */ for (j=0; j<4; j++) read(mfd,&(bs[j]),1); /* get coords */ *b3 = (~b) & 1; *b2 = (~(b>>1)) & 1; *b1 = (~(b>>2)) & 1; *dx = (int ) bs[0]; *dy = (int ) bs[1]; *dx = *dx + (int ) bs[2]; *dy = *dy + (int ) bs[3]; }