[c.s.wanted] Re: mouse interface for Sun

Philip H. Dye pd1h+ at andrew.cmu.edu
Tue Apr 10 16:01:13 AEST 1990


Archive-name: sun_mouse/10-Apr-90
Original-posting-by: pd1h+ at andrew.cmu.edu (Philip H. Dye)
Original-subject: Re: mouse interface for Sun
Reposted-by: emv at math.lsa.umich.edu (Edward Vielmetti)

[This is an experimental alt.sources re-posting from the newsgroup(s)
comp.sources.wanted. Comments on this service to emv at math.lsa.umich.edu 
(Edward Vielmetti).]


Some example code for direct access of the sun mouse.  It works
fine here under SunOS 3.5 on Sun 3/60's with three button mice.

files:

    readme          - message header (this file)
    sun_mouse.txt   - dicussion of sun mouse native byte stream
    Makefile        - makefile to build mreset, mstat, and mtest
    mreset.c        - reset the mouse fo no owner and native format
    mstat.c         - show the current owner and format of the mouse
    mtest.c         - show changes in the mouse buttons or position
    sun_mouse.h     - header file for sun_mouse.c
    sun_mouse.c     - access routines see sun_mouse.h or the examples
                      for usage information.

The examples should be easy to understand.  The programs mreset, mstat,
and mtest all have the same calling format.

    % <program>             - act on the default mouse device '/dev/mouse'
    % <program> mouse ...   - act on each of the listed devices

The code was intended to be a simple example in response to a question
from a net user.  For a more further examples of direct sun mouse see the
source code for Carnegie Mellon's Andrew Window Manager, Chris Newman's
niftyterm-console, or MGR.  (The sun X11 server source code uses the virtual
user interface mode for the mouse device.)

Please send any questions/comments/criticism to me at one of the following
email addresses.

------------------------------------------------------------------------------
| Philip H. Dye                   | Internet:   pd1h at andrew.cmu.edu          |
| Physics & Mathematics           |     UUCP:   psuvax1!andrew.cmu.edu!pd1h  |
| Carnegie Mellon University      |   Bitnet:   pd1h%andrew.cmu.edu at cmccvb   |
|---------------------------------|------------------------------------------|
| P.O. Box 190, CMU               | Network support of remote authentication |
| Pittsburgh, PA 15213            | using any form of transmitted key is     |
| (412) 683-3728                  | insecure.         - Random DOD Document  |
------------------------------------------------------------------------------

------------------------------ cut here ------------------------------

: This is a shar archive.  Extract with sh, not csh.
echo x - Makefile
sed -e 's/^X//' > Makefile << '!Funky!Stuff!'
X#
X# Makefile for sun mouse examples
X#
X
XCFLAGS = -g
X
XALL         	= mstat mtest
X
Xall:		${ALL}
X
X#----------------------------------------------------------------------
X
Xmstat_obj	= mstat.o
X
Xmstat:		${mstat_obj}
X		cc ${CFLAGS} -o $@ ${mstat_obj}
X
X#----------------------------------------------------------------------
X
Xmtest_obj   	= mtest.o sun_mouse.o
X
Xmtest:		${mtest_obj}
X		cc ${CFLAGS} -o $@ ${mtest_obj}
X
X#----------------------------------------------------------------------
X
Xmstat.o:	sun_mouse.h mstat.c
Xmtest.o:	sun_mouse.h mtest.c
Xsun_mouse.o:	sun_mouse.h sun_mouse.c
X
X#----------------------------------------------------------------------
X
Xclean:
X		rm *.o ${ALL} *.CKP *.BAK *~ a.out
X
X#----------------------------------------------------------------------
!Funky!Stuff!
echo x - mreset.c
sed -e 's/^X//' > mreset.c << '!Funky!Stuff!'
X/* file:  mreset.c */
X/*
X    Sun 3 mouse reset (tested on a Sun 3/60)
X
X    Philip H. Dye, 03 APR 1990					phdye at cs.cmu.edu
X
X    P.O. Box 190, CMU             | Internet:   pd1h at andrew.cmu.edu
X    Pittsburgh, PA 15213          |     UUCP:   psuvax1!andrew.cmu.edu!pd1h
X    (412) 683-3728                |   Bitnet:   pd1h%andrew.cmu.edu at cmccvb
X
X    If you use most or all of this code please include the this notice.
X*/
X
X#include <stdio.h>
X
X#include "sun_mouse.h"
X
Xvoid reset_mouse();
X
Xmain(argc,argv)
X    int     argc;
X    char    **argv;
X{
X    if (argc < 2)
X        reset_mouse(M_DEFAULT_DEVICE);
X    else    
X        while (*(++argv))
X            reset_mouse(*argv);
X}
X
Xvoid reset_mouse(path)
X    char    *path;
X{
X    int     fd;
X
X    fd = open(path, 0);
X
X    if ( fd < 0)
X    {
X        fprintf(stderr,"error opening mouse device '%s'\n",path);
X        perror("open()");
X        exit(1);
X    }
X
X    if (m_reset(fd) < 0)
X        m_perror("m_reset()");
X
X    close(fd);
X}
X
X/* end of file mreset.c */
!Funky!Stuff!
echo x - mstat.c
sed -e 's/^X//' > mstat.c << '!Funky!Stuff!'
X/* file:  mstat.c */
X/*
X    Sun 3 mouse status (tested on a Sun 3/60)
X
X    Philip H. Dye, 03 APR 1990					phdye at cs.cmu.edu
X
X    P.O. Box 190, CMU             | Internet:   pd1h at andrew.cmu.edu
X    Pittsburgh, PA 15213          |     UUCP:   psuvax1!andrew.cmu.edu!pd1h
X    (412) 683-3728                |   Bitnet:   pd1h%andrew.cmu.edu at cmccvb
X
X    If you use most or all of this code please include the this notice.
X*/
X
X#include <stdio.h>
X#include <errno.h>
X#include <sgtty.h>
X#include <sys/fcntl.h>
X#include <sys/ioctl.h>
X#include <sys/types.h>
X#include <sys/time.h>
X#include <sundev/vuid_event.h>
X
Xtypedef struct sgttyb sgtty;
X
X#include "sun_mouse.h"
X
Xmain(argc,argv)
X    int     argc;
X    char    **argv;
X{
X    if (argc < 2)
X        mouse_status(M_DEFAULT_DEVICE);
X    else    
X        while (*(++argv))
X            mouse_status(*argv);
X}
X
Xmouse_status(path)
X    char    *path;
X{
X    int     fd;
X    sgtty   sg;
X
X    fd = open(M_DEFAULT_DEVICE, 0);
X
X    if ( fd >= 0)
X    {
X		int temp;
X
X		if (ioctl(fd,VUIDGFORMAT,&temp) < 0)
X		{
X			fprintf(stderr,"error fetching mouse byte stream temp\n");
X			perror("ioctl()");
X		}
X		else
X		{
X			fputs("stream format =  ",stdout);
X			switch (temp)
X			{
X				case VUID_NATIVE :
X					fputs("VUID_NATIVE\n",stdout);
X					break;
X				case VUID_FIRM_EVENT :
X					fputs("VUI_FIRM_EVENT\n",stdout);
X					break;
X				default:
X					printf("UNKNOWN (0x%X)\n",temp);
X					break;
X			}
X		}
X
X		if ((temp = fcntl(fd,F_GETOWN,NULL)) == -1)
X		{
X			fprintf(stderr,"error fetching owner\n");
X			perror("fcntl()");
X		}
X		else
X		{
X			if (temp < 0)
X				printf("     group id =  %d\n", -temp);
X			else
X				printf("   process id =  %d\n",temp);
X		}
X    }
X}
X
X/* end of file mstat.c */
!Funky!Stuff!
echo x - mtest.c
sed -e 's/^X//' > mtest.c << '!Funky!Stuff!'
X/* file:  mtest.c */
X/*
X    test the sun mouse initialization and sampling
X
X    Philip H. Dye, 03 APR 1990					phdye at cs.cmu.edu
X
X    P.O. Box 190, CMU             | Internet:   pd1h at andrew.cmu.edu
X    Pittsburgh, PA 15213          |     UUCP:   psuvax1!andrew.cmu.edu!pd1h
X    (412) 683-3728                |   Bitnet:   pd1h%andrew.cmu.edu at cmccvb
X
X	if use most or all of this code please include the this notice.
X*/
X
X#include <stdio.h>
X#include <sgtty.h>
X
Xtypedef struct sgttyb   sgtty;
X
X#include <errno.h>
X
Xextern int errno;
X
X#include <sys/fcntl.h>
X#include <sys/ioctl.h>
X
X#include "sun_mouse.h"
X
Xstatic int	state	= 0;
X
X#define PRINT(state,f,s)        \
X{                               \
X    if (state)                  \
X        fputs(", ",stdout);     \
X                                \
X	state++;                    \
X                                \
X	printf(f,s);                \
X}
X
Xmain(argc,argv)
X    int     argc;
X    char    **argv;
X{
X    sgtty   old, new;
X
X    /* make stdin non-blocking */
X
X    if (fcntl(0,F_SETFL,FNDELAY) < 0)
X    {
X        fprintf(stderr,"unable to make stdin non-blocking\n");
X        exit(1);
X    }
X
X    if (ioctl(0, TIOCGETP, &old) < 0)
X    {
X        fprintf(stderr,"unable to get stdin's sgtty mode\n");
X        perror("ioctl()");
X        exit(1);
X    }
X
X    new             = old;
X    old.sg_flags    = (RAW | ANYP);
X
X    if (ioctl(0, TIOCSETP, &new) < 0)
X    {
X        fprintf(stderr,"unable to set stdin's sgtty mode\n");
X        perror("ioctl()");
X        exit(1);
X    }
X
X    if (argc < 2)
X        m_test(M_DEFAULT_DEVICE);
X    else
X        while (*(++argv))
X            m_test(*argv);    
X
X    /* restore stdin sgtty mode */
X
X    if (ioctl(0, TIOCSETP, &old) < 0)
X    {
X        fprintf(stderr,"unable to restore stdin's sgtty mode\n");
X        perror("ioctl()");
X    }
X
X    if (ioctl(0,TIOCFLUSH,0) < 0)
X    {
X        fprintf(stderr,"unable to flush i/o buffers\n");
X        perror("ioctl()");
X    }
X}
X
Xm_test(path)
X    char    *path;
X{
X    int     fd, buttons, x, y;
X	int		change, test, state;
X    char    trash;
X
X    fd = open(path,0);
X    if (fd < 0)
X    {
X        fprintf(stderr,"Error:  unable to open sun mouse '%s'\n",path);
X        return(-1);
X    }
X
X    if (m_init(fd) < 0)
X    {
X        fprintf(stderr,"Error:  unable to initialize sun mouse '%s'\n",path);
X        return(-1);
X    }
X
X	fprintf(stderr,"[sampling sun mouse device '%s']\n",path);
X	fprintf(stderr,"[press any key to stop this program]\n");
X
X    buttons = m_buttons;
X
X    while ((read(0,&trash,1)==-1)&&(errno==EWOULDBLOCK)&&(m_sample(fd)>=0))
X    {
X        change = CHANGED(buttons,m_buttons);
X		if (change)
X		{
X			if (change & M_RIGHT)
X				PRINT(state,"right  %s", STRANSITION(M_RIGHT,change,buttons));
X
X			if (change & M_MIDDLE)
X				PRINT(state,"middle %s", STRANSITION(M_MIDDLE,change,buttons));
X
X			if (change & M_LEFT)
X				PRINT(state,"left   %s", STRANSITION(M_LEFT,change,buttons));
X
X			buttons = m_buttons;
X		}
X		if (m_x != 0)
X		{
X			PRINT(state,"dx = %d", (char*) m_x);
X			m_x = 0;
X		}
X		if (m_y != 0)
X		{
X			PRINT(state,"dy = %d", (char*) m_y);
X			m_y = 0;
X		}
X		if (state)
X		{
X			putchar('\n');
X			state = 0;
X		}
X    }
X    m_reset(fd);
X	close(fd);
X}
X
X/* end of file mtest.c */
!Funky!Stuff!
echo x - readme
sed -e 's/^X//' > readme << '!Funky!Stuff!'
XSome example code for direct access of the sun mouse.  It works
Xfine here under SunOS 3.5 on Sun 3/60's with three button mice.
X
Xfiles:
X
X    readme          - message header (this file)
X    sun_mouse.txt   - dicussion of sun mouse native byte stream
X    Makefile        - makefile to build mreset, mstat, and mtest
X    mreset.c        - reset the mouse fo no owner and native format
X    mstat.c         - show the current owner and format of the mouse
X    mtest.c         - show changes in the mouse buttons or position
X    sun_mouse.h     - header file for sun_mouse.c
X    sun_mouse.c     - access routines see sun_mouse.h or the examples
X                      for usage information.
X
XThe examples should be easy to understand.  The programs mreset, mstat,
Xand mtest all have the same calling format.
X
X    % <program>             - act on the default mouse device '/dev/mouse'
X    % <program> mouse ...   - act on each of the listed devices
X
XThe code was intended to be a simple example in response to a question
Xfrom a net user.  For a more further examples of direct sun mouse see the
Xsource code for Carnegie Mellon's Andrew Window Manager, Chris Newman's
Xniftyterm-console, or MGR.  (The sun X11 server source code uses the virtual
Xuser interface mode for the mouse device.)
X
XPlease send any questions/comments/criticism to me at one of the following
Xemail addresses.
X
X------------------------------------------------------------------------------
X| Philip H. Dye                   | Internet:   pd1h at andrew.cmu.edu          |
X| Physics & Mathematics           |     UUCP:   psuvax1!andrew.cmu.edu!pd1h  |
X| Carnegie Mellon University      |   Bitnet:   pd1h%andrew.cmu.edu at cmccvb   |
X|---------------------------------|------------------------------------------|
X| P.O. Box 190, CMU               | Network support of remote authentication |
X| Pittsburgh, PA 15213            | using any form of transmitted key is     |
X| (412) 683-3728                  | insecure.         - Random DOD Document  |
X------------------------------------------------------------------------------
X
X------------------------------ cut here ------------------------------
!Funky!Stuff!
echo x - sun_mouse.c
sed -e 's/^X//' > sun_mouse.c << '!Funky!Stuff!'
X/* sun_mouse.c */
X/*
X    Sun 3 mouse input (tested on a Sun 3/60)
X
X    Philip H. Dye, 03 APR 1990					phdye at cs.cmu.edu
X
X    P.O. Box 190, CMU             | Internet:   pd1h at andrew.cmu.edu
X    Pittsburgh, PA 15213          |     UUCP:   psuvax1!andrew.cmu.edu!pd1h
X    (412) 683-3728                |   Bitnet:   pd1h%andrew.cmu.edu at cmccvb
X
X    If you use most or all of this code please include the this notice.
X*/
X
X/* notes:
X
X    - should be split up into individual files for each function
X
X    - only the sun 3 button mouse is supported
X
X	- see sun_mouse.txt for information on decoding the sun mouse
X	  device native byte stream
X*/
X
X#include <stdio.h>
X#include <errno.h>
X
Xextern int errno;
X
X#include <sgtty.h>
X
Xtypedef struct sgttyb sgtty;
X
X#include <sys/fcntl.h>
X#include <sys/ioctl.h>
X#include <sys/types.h>
X#include <sys/time.h>
X#include <sundev/vuid_event.h>
X
X#include "sun_mouse.h"
X
Xm_codes m_error     = M_ERROR_NONE;
Xchar    m_buttons   = 0;
Xchar    m_x         = 0;
Xchar    m_y         = 0;
X
Xtypedef struct
X{
X    char    *string;
X    char    *proc;
X} s_error;
X
Xstatic s_error m_strings[] =
X{
X    {"no error",NULL},
X    {"invalid file descriptor",NULL},
X    {"unable to get mouse stream format","ioctl()"},
X    {"unable to set mouse stream format","ioctl()"},
X    {"mouse byte stream format is not VUID_NATIVE",NULL},
X	{"M_ERROR_IOCTL_TIOCSETP","?()"},
X	{"M_ERROR_FCNTL_GETOWN","?()"},
X	{"M_ERROR_FCNTL_SETOWN","?()"},
X	{"M_ERROR_OWNER","?()"},
X	{"M_ERROR_FCNTL_SETFL","?()"},
X	{"M_ERROR_READ","?()"},
X	{"M_ERROR_INPUT","?()"}
X};
X
X/*  value = m_busy()    - see if the mouse device is in use
X
X    return value        = -1    - an error occurred, m_error will be non-zero
X                           0    - device available
X                           1    - device busy
X*/
Xint m_perror()
X{
X    s_error *p;
X
X    fprintf(stderr,"MOUSE ERROR:  %s\n",m_strings[(int)m_error].string);
X
X    if (m_strings[(int)m_error].proc)
X        perror(m_strings[(int)m_error].proc);
X
X    return (1);
X}
X
X/*  value = m_busy()    - see if the mouse device is in use
X
X    return value        = -1    - an error occurred, m_error will be non-zero
X                           0    - device available
X                           1    - device busy
X*/
Xint m_busy(fd)
X	int fd;
X{
X	int temp;
X
X    if ( fd < 0)
X    {
X        m_error = M_ERROR_INVALID_FD;
X        return (-1);
X    }
X
X	/*	if the mouse device is not currently in VUID_NATIVE mode
X		it is in use by another process
X	*/
X	if (ioctl(fd,VUIDGFORMAT,&temp) < 0)
X	{
X		m_error = M_ERROR_IOCTL_VUIDGFORMAT;
X		return (-1);
X	}
X
X	if (temp != VUID_NATIVE)
X	{
X		m_error = M_ERROR_FORMAT;
X		return (-1);
X	}
X
X	/*	check the mouse device is owned by another process */
X
X	if ((temp = fcntl(fd,F_GETOWN)) == -1)
X	{
X		m_error = M_ERROR_FCNTL_GETOWN;
X		return (-1);
X	}
X
X	if (temp != 0)
X	{
X		m_error = M_ERROR_OWNER;
X		return (1);
X	}
X
X	return (0);
X}
X
X/*
X    value = m_reset()   - reset the mouse device
X
X    return value        = -1    - an error occurred, m_error will be non-zero
X                           0    - device reset
X*/
Xint m_reset(fd)
X	int fd;
X{
X	int temp = VUID_NATIVE;
X
X	if (ioctl(fd,VUIDSFORMAT,&temp) < 0)
X	{
X		m_error = M_ERROR_IOCTL_VUIDSFORMAT;
X		return (-1);
X	}
X
X	if ((temp = fcntl(fd,F_SETOWN,0)) == -1)
X	{
X		m_error = M_ERROR_FCNTL_SETOWN;
X		return (-1);
X	}
X
X	return (0);
X}
X
X/*  value = m_init()    - intialize the mouse device
X
X    return value        = -1    - an error occurred, m_error will be non-zero
X                           0    - it was initialized properly
X*/
Xint m_init(fd)
X    int fd;
X{
X    sgtty   sg;
X
X    if ( fd < 0)
X    {
X        m_error = M_ERROR_INVALID_FD;
X        return (-1);
X    }
X
X    /* assume that the mouse is not in use by another process */
X
X    if (fcntl(fd,F_SETOWN,getpid()) < 0)
X	{
X		m_error = M_ERROR_FCNTL_SETOWN;
X		return (-1);
X	}
X
X	if (fcntl(fd,F_SETFL,FNDELAY) < 0)
X	{
X		m_error = M_ERROR_FCNTL_SETFL;
X		return (-1);
X	}
X
X	/*	- this is the baud rate used locally, other
X          baud rates may be available
X    	- see /usr/include/sundev/msio.h for information
X		  on determining the device's speed limit
X	*/
X    sg.sg_ispeed = sg.sg_ospeed = 9;	/* 1200 Baud */
X
X    sg.sg_flags     = (RAW | ANYP);
X
X    if (ioctl(fd, TIOCSETP, &sg) < 0)
X    {
X        m_error = M_ERROR_IOCTL_TIOCSETP;
X        return (-1);
X    }
X
X    return (0);
X}
X
X/*
X	value = m_sample()      - sample a mouse device
X
X    returns value;          -1      -> error, m_Error will be non-zero
X                             0      -> no packets available
X                             1      -> packet was available and one read
X*/
Xint m_sample(fd)
X    int fd;
X{
X    static char buffer[M_BUFFER_SIZE];
X    static int  items = 0;
X    static char *p;
X
X    if ( fd < 0)
X    {
X        m_error = M_ERROR_INVALID_FD;
X        return (-1);
X    }
X
X    if (items == 0)
X    {
X        items = read(fd, buffer, sizeof(buffer));
X        if (items < 0)
X        {
X			if (errno == EWOULDBLOCK)
X			{
X				items = 0;
X				return (0);
X			}
X
X            m_error = M_ERROR_READ;
X            return (-1);
X        }
X		/*
X			- the i/o buffer should be flushed before more
X		      data is read as it may have partial packets
X		      remaining
X		*/
X        if ( (items % M_PACKET_SIZE) != 0)
X        {
X            m_error = M_ERROR_INPUT;
X            return (-1);
X        }
X        p = buffer;
X    }
X
X    if (items > 0)
X    {
X		register incr;
X
X        m_buttons   = M_BUTTON(*(p++));
X        m_x         = *(p++);
X        m_y			= *(p++);
X
X        items  -= M_PACKET_SIZE;
X
X        return (1);
X    }
X
X    return (0);
X}
X
X/* end of file mouse.c */
!Funky!Stuff!
echo x - sun_mouse.h
sed -e 's/^X//' > sun_mouse.h << '!Funky!Stuff!'
X/* file:  sun_mouse.h */
X/*
X    Sun 3 mouse input (tested on a Sun 3/60)
X
X    Philip H. Dye, 03 APR 1990					phdye at cs.cmu.edu
X
X    P.O. Box 190, CMU             | Internet:   pd1h at andrew.cmu.edu
X    Pittsburgh, PA 15213          |     UUCP:   psuvax1!andrew.cmu.edu!pd1h
X    (412) 683-3728                |   Bitnet:   pd1h%andrew.cmu.edu at cmccvb
X
X    If you use most or all of this code please include the this notice.
X*/
X
X/* -------------------- standard defines -------------------- */
X
X#ifndef FALSE
X#define FALSE	0
X#define TRUE	1
X#endif TRUE
X
X/* -------------------- miscellaneous -------------------- */
X
X#define M_DEFAULT_DEVICE    "/dev/mouse"
X
X/*
X    The buffer size should be a factor of M_PACKET_SIZE since the mouse data
X    is encoded in a M_PACKET_SIZE bytes
X*/
X
X#define M_PACKET_SIZE		3
X#define M_BUFFER_SIZE       (M_PACKET_SIZE * 20)
X
X/* -------------------- errors -------------------- */
X
Xtypedef enum
X{
X	M_ERROR_NONE,
X    M_ERROR_INVALID_FD,
X	M_ERROR_IOCTL_VUIDGFORMAT,
X	M_ERROR_IOCTL_VUIDSFORMAT,
X	M_ERROR_FORMAT,
X	M_ERROR_IOCTL_TIOCSETP,
X	M_ERROR_FCNTL_GETOWN,
X	M_ERROR_FCNTL_SETOWN,
X	M_ERROR_OWNER,
X	M_ERROR_FCNTL_SETFL,
X	M_ERROR_READ,
X	M_ERROR_INPUT,
X} m_codes;
X
Xextern m_codes m_error;			/* last error encountered */
X
X/* -------------------- change of position -------------------- */
X
Xextern char m_x;
Xextern char m_y;
X
X/* -------------------- three button mouse -------------------- */
X
Xextern char m_buttons;					/* buttons raised (bit 0 left, etc) */
X
X/* for a three button mouse:  invert & mask three bits */
X
X#define M_BUTTON(x)			(~(x) & 0x07)
X#define M_LEFT				0x01
X#define M_MIDDLE			0x02
X#define M_RIGHT				0x04
X#define CHANGED(old,new)				( (old) ^ (new) )   /* -> change */
X#define TRANSITION(button,change,old)	( (change) & (buttons) & (old) )
X#define STRANSITION(button,change,old)	( TRANSITION(button,change,old)	? \
X											"up" : "down" )
X
X/* -------------------- FUNCTIONS -------------------- */
X
Xint m_busy();
X/*
X    arguements:     int fd;         - file descriptor for mouse open
mouse device
X
X    return value:   int result;     error                   -> -1
X                                    mouse device busy		-> TRUE
X                                    mouse device free		-> FALSE
X*/
X
Xint m_init();
X/*
X    arguements:     int fd;         - file descriptor for mouse open
mouse device
X
X    return value:   int fd;         (fd >= 0)	-> file descriptor for mouse
X                                    (fd == -1)	-> error
X*/
X
Xint m_simple();
X/*
X    arguements:     int fd;         - file descriptor for mouse open
mouse device
X
X    return value:   int result;     no events available		-> FALSE
X                                    events found			-> TRUE
X                                    error					-> -1
X*/
X
X/* end of file sun_mouse.h */
!Funky!Stuff!
echo x - sun_mouse.txt
sed -e 's/^X//' > sun_mouse.txt << '!Funky!Stuff!'
XThe following information is valid for SunOS 3.5 on Sun 3/50 and 3/60's.
XIt may or may not be valid for other configurations.
X(Though I believe that is should be valid.)
X
XPhilip H. Dye, 04 APR 1990
X
X----------------------------------------------------------------------
X
XThe SunOS Kernal Mouse driver has two byte stream formats:
X
X	Native :	- character stream
X				- mouse information comes in three character packets
X				  (to be safe, flush input buffer before begining i/o)
X
X		char 0	= position data (buttons:  0 = down, 1 = up)
X
X				bit 	 0   : right button
X						 1   : middle button
X						 2   : left button
X						3-6  : 0
X						 7   : 1
X
X		char 1  : x position change (signed value, delta x)
X
X		char 2  : y position change (signed value, delta y)
X
X
X		* The deltas are signed quantities, with the mouse pad in front of
X		  you, moving the mouse left or toward you on the mousepad generates
X		  a negetive value, moving right or away from you generates a
X		  positive value.		  
X
X
X		* Client software normally multplies a constant by the deltas
X		  to determine the resolution of the deltas.
X
X	Virtual User Interface mode:
X
X		Used by all Sun Systems Graphics Applications (I believe) including
X		the X11 server.  This multiplexes all user i/o over a single stream.
X
X----------------------------------------------------------------------
X
XSoftware which accesses the mouse device directly should be well behaved
Xand determine if the 
X
XWhen allocating the workstation mouse one should always save the current
Xstate of the mouse and restore it when done.  A process may set an
Xexeclusive lock on the mouse to prevent other processes from changing
Xthe state of the mouse device.
X
XOne might also only use it if the it is in native mode and owned by root.
XThen place an exclusive lock on it, change the owner, and remove the 
Xexclusive lock.  
X
X	- mouse's owner
X	- sgttyb structure
X	- byte stream format	(See /usr/include/sundev/vuid_event.h)
X
X----------------------------------------------------------------------
X
XImplemenations:
X
X	suntools	- uses VUI calls of course
X
X	X11			- the X11 server written at Sun Systems uses VUI calls
X
X	mgr			- provides a very general sun mouse support sampler
X				  allowing up to five buttons (native byte stream)
X				- makes the current process the 
X
X	wm			- Carnegie Mellon University's Andrew Window Manager
X				  uses the native byte stream
X
X	this		- this example uses the native byte stream
X
X----------------------------------------------------------------------
!Funky!Stuff!
exit



More information about the Alt.sources mailing list