Path: utzoo!utgpu!cs.utexas.edu!asuvax!hrc!xroads!beagle!chandler From: chandler@beagle.UUCP (Jim Chandler) Newsgroups: alt.sources Subject: bus mouse driver for ESIX Keywords: ESIX logitech C9 busmouse Message-ID: <442@beagle.UUCP> Date: 27 Jan 91 07:30:08 GMT Organization: The Beagle System Lines: 838 Here is a driver for a bus mouse for ESIX. I compiled it with gcc 1.39 with no problems and it works with VPIX 1.2 with no problems. ENJOY! #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'README' <<'END_OF_FILE' X14-Jan-1991 X XI wrote this Logitech bus mouse driver for ISC 2.x a long time ago, before XISC provided one in their distribution. (The last date of modification of Xthe driver source is May 29, 1989). Back in Dec '89 my system suffered a Xmajor disk crash resulting in the lose of my entire /usr/local directory Xtree. It was pure luck that I happened to have an extra copy of the driver Xsource elsewhere. Any/all Makefiles, install scripts, and miscellaneousness Xnotes were unfortunately lost. Have never taken the time to recreate them. X XSo, ... you're totally on your own. Here's a quick summary of the files Xenclosed, (the following assumes an ISC directory strcture for installing Xdevice drivers, don't know if ESIX follows the same conventions): X X lmouse.c -- Driver source. After compiled the object file needs X to be placed in /etc/conf/pack.d/lmouse/Driver.o X X lmouse.node -- Copy this file to /etc/conf/node.d/lmouse X X lmouse.sdevice -- Copy this file to /etc/conf/sdevice.d/lmouse X X mt.c and mt2.c -- Test programs. X XFinally, you'll need to add the following line to the X/etc/conf/kconfig.d/description file, (note that the fields are separated Xby tabs not spaces): X Xlmouse 0 19 io lmouse My Logitech Bus Mouse Driver X XGood luck and happy hacking... X X-- Mark X XMark W. Snitily Consulting Services: X894 Brookgrove Lane Graphics, Operating Systems, Compilers XCupertino, CA 95014 (408) 252-0456 Xmark@zok.uucp West Coast UUCP X11 archive site X XIf your mailer doesn't like the .uucp domain, these also work: X...!{mips,sgi}!zok!mark, mark%zok@mips.com, mark%zok@sgi.com X X Addendum for ESIX Rev. D 26 Jan 91 X X This driver works for ESIX Rev. D with no problem as long as the X X window system is not installed. This is because the driver for the mouse X will conflict with the driver for X. Since I am working on Roell's X11R4 X server, then I it won't matter once I get that server up and running since X I will be able to use the bus mouse with that server. ESIX has no X kconfig.d directory so ignore the description file. The only info not given X is what to put in /etc/conf/cf.d/mdevice. Here is the line that I put in X mine and it seems to work: X X lmouse Iioc icH logm 0 23 1 1 -1 X X Good luck and email with questions or problems. Special thanks to Mark, X who did 99% of the work. X X Jim Chandler X asuvax!xroads!beagle!chandler X chandler@beagle.uucp X END_OF_FILE if test 2477 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'lmouse.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'lmouse.c'\" else echo shar: Extracting \"'lmouse.c'\" \(12403 characters\) sed "s/^X//" >'lmouse.c' <<'END_OF_FILE' X#define VPIX X X#include "sys/param.h" X#include "sys/types.h" X#include "sys/sysmacros.h" X#include "sys/dir.h" X#include "sys/signal.h" X#include "sys/user.h" X#include "sys/errno.h" X X/* Definitions for Logitech Mouse */ X X/* Base I/O addresses of mouse registers */ X#define DATA_REG 0x23c /* Data register (read only) */ X#define SIGNATURE_REG 0x23d /* Signature register (read/write) */ X#define INTERRUPT_REG 0x23e /* Interrupt register (read only) */ X#define CONTROL_REG 0x23e /* Control register (write only) */ X#define CONFIG_REG 0x23f /* Configuration register (read/write) */ X X/* Definitions of bits in interrupt register. */ X#define IRQ5 0x01 X#define IRQ4 0x02 X#define IRQ3 0x04 X#define IRQ2 0x08 X X/* Definitions of bits in control register. */ X#define DINT 0x10 /* Disable Interrupts */ X#define SHL 0x20 /* Select Hi/Lo (0/1) nibble */ X#define SXY 0x40 /* Select X/Y (0/1) counter */ X#define HC 0x80 /* Hold Counters (latch counters on 0->1 edge) */ X X/* Magic number needed for configuration register. */ X#define CONFIG_BYTE 0x91 X X#define BUT3STAT 0x01 X#define BUT2STAT 0x02 X#define BUT1STAT 0x04 X X#define BUT3CHNG 0x08 X#define BUT2CHNG 0x10 X#define BUT1CHNG 0x20 X#define MOVEMENT 0x40 X X#define BUTSTATMASK 0x07 X#define BUTCHNGMASK 0x38 X Xstruct mouseinfo X{ unsigned char status; X char xmotion, ymotion; X}; X X/* Ioctl definitions */ X#define MOUSEIOC ('M'<<8) X#define MOUSEIOCREAD (MOUSEIOC|60) X X#ifdef VPIX X#define VPC_MOUSE_READ MOUSEIOCREAD X#endif /* VPIX */ X X#ifdef VPIX X#include "sys/immu.h" X#include "sys/region.h" X#include "sys/proc.h" X#include "sys/tss.h" X#include "sys/v86.h" X#endif /* VPIX */ X Xstatic char mousepresent; Xstatic char mouseinuse; Xstatic char mousemode; Xstatic char last_buttons; Xstatic char mousestatus; Xstatic int xmotion, ymotion; X#ifdef VPIX Xstatic struct proc *ectproc; Xstatic char rupted; X#endif /* VPIX */ X X#define UPPERLIM 127 X#define LOWERLIM -128 X#define ONEBYTE(x) ((x)>UPPERLIM ? UPPERLIM : (x)> 5) & 0x07; X changed_buttons = buttons ^ last_buttons; X last_buttons = buttons; X X /* Combine high and low X nibbles. */ X dy = (char) (((hi & 0x0F) << 4) | lo); /* force dy to be signed */ X X /* This code emulates the Microsoft bus mouse status (except for the MOTION X bit which is set in the ioctl routine). State changes are or'ed over X any number of interrupts, but the buttons bits are always set to the X current state. (The state changes are cleared when read in the ioctl X routine.) */ X mousestatus = buttons | (mousestatus & ~BUTSTATMASK) X | (changed_buttons << 3); X X /* Reset HC to 0. */ X outb(CONTROL_REG, 0); X X /* If nothing has changed, nothing needs to be done, so return. */ X if (!(dx || dy || changed_buttons)) return; X X /* Update global variables with info just read. */ X xmotion += dx; X ymotion += dy; X#ifdef DEBUG X printf("logmintr: dx = %d, dy = %d, buttons = %d\n", dx, dy, buttons); X#endif /* DEBUG */ X X#ifdef VPIX X /* Send a pseudorupt if this is an ECT and the mouse has been read since X the last pseudorupt. */ X if (ectproc && ectproc->p_v86 && !rupted) { X v86setint(ectproc->p_v86, V86VI_MOUSE); X rupted = 1; X } X#endif /* VPIX */ X X} /* logmintr */ END_OF_FILE if test 12403 -ne `wc -c <'lmouse.c'`; then echo shar: \"'lmouse.c'\" unpacked with wrong size! fi # end of 'lmouse.c' fi if test -f 'lmouse.node' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'lmouse.node'\" else echo shar: Extracting \"'lmouse.node'\" \(18 characters\) sed "s/^X//" >'lmouse.node' <<'END_OF_FILE' Xlmouse lmouse c 0 END_OF_FILE if test 18 -ne `wc -c <'lmouse.node'`; then echo shar: \"'lmouse.node'\" unpacked with wrong size! fi # end of 'lmouse.node' fi if test -f 'lmouse.sdevice' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'lmouse.sdevice'\" else echo shar: Extracting \"'lmouse.sdevice'\" \(29 characters\) sed "s/^X//" >'lmouse.sdevice' <<'END_OF_FILE' Xlmouse N 1 6 1 5 23c 23f 0 0 END_OF_FILE if test 29 -ne `wc -c <'lmouse.sdevice'`; then echo shar: \"'lmouse.sdevice'\" unpacked with wrong size! fi # end of 'lmouse.sdevice' fi if test -f 'mt.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mt.c'\" else echo shar: Extracting \"'mt.c'\" \(2677 characters\) sed "s/^X//" >'mt.c' <<'END_OF_FILE' X/*--------------------------*/ X#include "sys/param.h" X#include "sys/types.h" X#include "sys/sysmacros.h" X#include "sys/dir.h" X#include "sys/signal.h" X#include "sys/user.h" X#include "sys/errno.h" X#include "sys/inline.h" X/*--------------------------*/ X#include X#include X#include X Xstatic int _fd = -1; X Xextern int errno; X X/*---------------------------------------------------------------------------*/ Xint ms_init() X{ X struct mouseinfo pkt; X X if ((_fd = open("/dev/lmouse", O_RDONLY)) == -1) { X printf("errno = %d\n", errno); X perror("ms_init: open"); X return -1; X } X/* X else if (ioctl(_fd, MOUSEIOCREAD, &pkt) == -1 ) { X perror("ms_init: ioctl"); X close(_fd ); X return -1; X } X*/ X return 0; X} /* ms_init */ X X/*---------------------------------------------------------------------------*/ Xint ms_ioctl(cmd) Xint cmd; X{ X struct mouseinfo pkt; X X if (cmd == 25) { X if (ioctl(_fd, MOUSEIOCREAD, &pkt) == -1 ) { X perror("ms_init: ioctl"); X/* close(_fd ); */ X return -1; X } X printf("ms_ioctl: status = 0x%x, xmotion = %d, ymotion = %d\n", X pkt.status, pkt.xmotion, pkt.ymotion); X } X else if (ioctl(_fd, cmd, &pkt) == -1 ) { X perror("ms_ioctl: ioctl"); X/* close(_fd ); */ X return -1; X } X X return 0; X} /* ms_ioctl */ X X/*---------------------------------------------------------------------------*/ Xint ms_close() X{ X int rc = -1; X X if (_fd != -1) { X rc = close(_fd ); X _fd = -1; X } X return rc; X} /* ms_close */ X X#ifdef NOT_NOW X X/* X * FUNCTION: BMSEMD_READ X * a routine to call when mouse data is available X * X * INPUT PARAMETERS X * none X * OUTPUT PARAMETERS X * none X */ Xvoid bmsemd_read() X{ X MSEPKT pkt; X X if ( _fd == -1 || ioctl(_fd,VPC_MOUSE_READ,&pkt) == -1 ) X { X#ifdef DEBUG X v86error(VERR_WARNING,"unable to get mouse data"); X#endif X return; X } X X if ( pkt.status & MOVEMENT ) /* if the mouse moved */ X xy_bmouse( pkt.xmotion, pkt.ymotion ); X X if ( pkt.status & BUT1CHNG ) /* if button 1 changed */ X btn_bmouse( 0, (int)(pkt.status & BUT1STAT) ); X X if ( pkt.status & BUT2CHNG ) /* if button 2 changed */ X btn_bmouse( 1, (int)(pkt.status & BUT2STAT) ); X X if ( pkt.status & BUT3CHNG ) /* if button 3 changed */ X btn_bmouse( 2, (int)(pkt.status & BUT3STAT) ); X} X#endif /* NOT_NOW */ X Xmain() X{ X char str[80]; X int cmd; X X ms_init(); X for (cmd = 0; 0 <= cmd && cmd <= 25;) { X printf("cmd? (0-25) > "); X (void) gets(str); X cmd = atoi(str); X printf("mt: cmd = %d\n", cmd); X if (0 <= cmd && cmd <= 25) ms_ioctl(cmd); X else printf("exiting\n"); X } X ms_close(); X} END_OF_FILE if test 2677 -ne `wc -c <'mt.c'`; then echo shar: \"'mt.c'\" unpacked with wrong size! fi # end of 'mt.c' fi if test -f 'mt2.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mt2.c'\" else echo shar: Extracting \"'mt2.c'\" \(2675 characters\) sed "s/^X//" >'mt2.c' <<'END_OF_FILE' X/*--------------------------*/ X#include "sys/param.h" X#include "sys/types.h" X#include "sys/sysmacros.h" X#include "sys/dir.h" X#include "sys/signal.h" X#include "sys/user.h" X#include "sys/errno.h" X#include "sys/inline.h" X/*--------------------------*/ X#include X#include X#include X Xstatic int _fd = -1; X Xextern int errno; X X/*---------------------------------------------------------------------------*/ Xint ms_init() X{ X struct mouseinfo pkt; X X if ((_fd = open("/dev/logi", O_RDONLY)) == -1) { X printf("errno = %d\n", errno); X perror("ms_init: open"); X return -1; X } X/* X else if (ioctl(_fd, MOUSEIOCREAD, &pkt) == -1 ) { X perror("ms_init: ioctl"); X close(_fd ); X return -1; X } X*/ X return 0; X} /* ms_init */ X X/*---------------------------------------------------------------------------*/ Xint ms_ioctl(cmd) Xint cmd; X{ X struct mouseinfo pkt; X X if (cmd == 25) { X if (ioctl(_fd, MOUSEIOCREAD, &pkt) == -1 ) { X perror("ms_init: ioctl"); X/* close(_fd ); */ X return -1; X } X printf("ms_ioctl: status = 0x%x, xmotion = %d, ymotion = %d\n", X pkt.status, pkt.xmotion, pkt.ymotion); X } X else if (ioctl(_fd, cmd, &pkt) == -1 ) { X perror("ms_ioctl: ioctl"); X/* close(_fd ); */ X return -1; X } X X return 0; X} /* ms_ioctl */ X X/*---------------------------------------------------------------------------*/ Xint ms_close() X{ X int rc = -1; X X if (_fd != -1) { X rc = close(_fd ); X _fd = -1; X } X return rc; X} /* ms_close */ X X#ifdef NOT_NOW X X/* X * FUNCTION: BMSEMD_READ X * a routine to call when mouse data is available X * X * INPUT PARAMETERS X * none X * OUTPUT PARAMETERS X * none X */ Xvoid bmsemd_read() X{ X MSEPKT pkt; X X if ( _fd == -1 || ioctl(_fd,VPC_MOUSE_READ,&pkt) == -1 ) X { X#ifdef DEBUG X v86error(VERR_WARNING,"unable to get mouse data"); X#endif X return; X } X X if ( pkt.status & MOVEMENT ) /* if the mouse moved */ X xy_bmouse( pkt.xmotion, pkt.ymotion ); X X if ( pkt.status & BUT1CHNG ) /* if button 1 changed */ X btn_bmouse( 0, (int)(pkt.status & BUT1STAT) ); X X if ( pkt.status & BUT2CHNG ) /* if button 2 changed */ X btn_bmouse( 1, (int)(pkt.status & BUT2STAT) ); X X if ( pkt.status & BUT3CHNG ) /* if button 3 changed */ X btn_bmouse( 2, (int)(pkt.status & BUT3STAT) ); X} X#endif /* NOT_NOW */ X Xmain() X{ X char str[80]; X int cmd; X X ms_init(); X for (cmd = 0; 0 <= cmd && cmd <= 25;) { X printf("cmd? (0-25) > "); X (void) gets(str); X cmd = atoi(str); X printf("mt: cmd = %d\n", cmd); X if (0 <= cmd && cmd <= 25) ms_ioctl(cmd); X else printf("exiting\n"); X } X ms_close(); X} END_OF_FILE if test 2675 -ne `wc -c <'mt2.c'`; then echo shar: \"'mt2.c'\" unpacked with wrong size! fi # end of 'mt2.c' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Jim Chandler asuvax!xroads!beagle!chandler chandler@beagle.uucp