Newsgroups: comp.os.linux.announce
From: mike@starbug.apana.org.au (Mike Battersby)
Subject: Microsoft Busmouse mini-HOWTO
Message-ID: <1994Mar23.182737.4796@cs.cornell.edu>
Date: Wed, 23 Mar 1994 18:27:37 GMT
Approved: linux-announce@tc.cornell.edu (Matt Welsh)

[ At the moment this is specific to Microsoft busmice, however I would like
  to upgrade it to include other kinds of busmice.  Then it can graduate to
  being a "real" HOWTO document.  If you or someone you know has a busmouse
  other than Microsoft which they have gotten to work with Linux, get in
  touch with me so I can grill you for the relevant details.  - mike ]

	    The Microsoft Busmouse mini-HOWTO v0.3, 26 Feb 94
	      by Mike Battersby <mike@starbug.apana.org.au>

INDEX

	0.	Introduction
	0.1	Disclaimer
	0.2	Where to find help
	0.3	Feedback
	0.4	Acknowledgements

	1.	Getting things going
	1.1	How do I know if I have a Microsoft busmouse?
	1.2	Setting the mouse interrupt.
	1.3	Compiling the kernel
	1.4	/dev/mouse
	1.5	Testing your mouse
	1.6	Using selection
	1.7	Using Xfree86
	1.8	Xfree86 and selection

------------------------------------------------------------------------------
0.	Introduction

	This document is a guide to getting your Microsoft busmouse working
	with Linux.  I've written this in the hope that the ten people a
	week who post "how do I get my busmouse to work" questions in
	comp.os.linux.announce will read it first, though I won't be
	holding my breath.  Busmouse support has been in the kernel for as
	long as I can remember, and hasn't changed in a long time (at least
	as of now, 0.99.15), so this document should work with any version
	of Linux you're likely to have.  In the near future this document
	will likely be merged into a full busmouse howto.

0.1	Disclaimer

	The information in this document is correct to the best of my
	knowledge, but there's a always a chance I've made some mistakes,
	so don't follow everything too blindly, especially if it seems wrong.
	Nothing here should have a detrimental effect on your computer, but
	just in case I take no responsibility for any damages incurred from
	the use of the information contained herein.

	Microsoft(R) is a Trademark of Microsoft Corporation.

0.2	Where to find help

	If you've pored over this document hundreds of times and still can't
	get your mouse to work, feel free to contact me any time at
	<mike@starbug.apana.org.au> and I'll see if I can help you out.
	The comp.os.linux.help newsgroup is the appropriate forum for
	discussion and/or questions regarding mice - please don't post
	questions to other groups, and especially don't crosspost
	questions to two or more of the Linux groups, they are more than
	cluttered enough as it is!

0.3	Feedback

	If you find any mistakes in this document, have any comments about
	its contents or an update or addition, send them to me at the
	address listed in section 0.2.

0.4	Acknowledgements

	The following people have been invaluable in the production and
	updating of this mini-HOWTO.

	    Daniel R Barlow		<Daniel.Barlow@sjc.ox.ac.uk>
	    Thomas B. Fox		<lestat@deeptht.armory.com>


------------------------------------------------------------------------------
1.	Getting things going

1.1	How do I know if I have a Microsoft busmouse?

	Microsoft mice are relatively easy to recognize.  They are two
	button mice with the left button bigger than the right, a rounded
	"ergonomic" shape that I have been told looks like a bar of "dove"
	soap (at least to Americans :-), and in most cases the word
	"Microsoft" written on the top.  If you follow the mouse cord to
	the back of the machine and it ends in a small round detachable
	plug, about 9mm in diameter, with 9 pins and a notch in one side,
	its a good bet you've got a Microsoft busmouse.  (Note: I have
	heard that there are new teardrop shaped Microsoft busmice. If
	anyone has one of these beasties, please get in touch with me.)

1.2	Setting the mouse interrupt

	First things, you'll need to know which interrupt number your
	mouse is using, and make sure it doesn't conflict with any other
	peripherals you have installed.  If you open up your computers
	case and look at the card which your mouse plugs into, you should
	notice a block of jumpers near the bottom middle of the card
	labeled "INTERRUPT" with positions for interrupt (otherwise
	known as IRQ) numbers 2,3,4 and 5.  You should make sure that
	your mouse is not trying to use the same interrupt as any of your
	other devices, and change the interrupt by moving the jumper to an
	unused interrupt setting if it does.

	***************************************************
	***	MAKE SURE YOUR COMPUTER IS TURNED OFF	***
	***	BEFORE CHANGING THE JUMPERS AROUND.	***
	***************************************************

	In most cases IRQ4 is used for the first serial port (/dev/ttyS0),
	IRQ3 for the second (/dev/ttyS1), and IRQ5 for some SCSI adaptors.
	Check the documentation for all your peripherals to see which
	interrupt they use.  In my experience, IRQ2 seems to cause the least
	hassle in most cases.

1.3	Compiling the kernel

	In order for your Microsoft busmouse to operate correctly you
	will need to recompile your kernel with the busmouse support
	compiled in.  Change to your kernel directory (here assumed to
	be '/usr/src/linux') and do a

	    make config

	and answer 'y' to the 

	    Microsoft busmouse support (CONFIG_MS_BUSMOUSE) [n]

	question.
	Next, edit the file '/usr/src/linux/include/linux/busmouse.h',
	and change the line which says

	    #define MOUSE_IRQ               5

	to reflect the interrupt number for your mouse (see section 1.3
	for details on finding your interrupt number).  Due to the
	vagaries of the PC architecture, if you have set your mouse to
	use interrupt 2, you must set the #define to use interrupt 9.

	Examples

	    For a mouse on interrupt 3, you should change the line to
	    read

	    #define MOUSE_IRQ               3

	    For a mouse on interrupt 2, you should change the line to
	    read

	    #define MOUSE_IRQ               9

	Next, compile your kernel as per the instructions which come
	with it, and boot from the new kernel.  You should now have
	the busmouse support correctly compiled in.

1.4	/dev/mouse

	The Microsoft busmouse device is accessed through the
	/dev/bmousems device (on some machines you may have a
	/dev/importbm instead - if so, simply substitute that for
	bmousems for the rest of this section), major 10 minor 2.  If
	you don't have such a device, you can make one by changing to
	the /dev directory and executing the following command as 'root'.

	    mknod /dev/bmousems c 10 2

	You should then make a symbolic link from this device to
	/dev/mouse, and use that to refer to the mouse from then on. The
	link can be made with the following command (again as 'root')

	    ln -fs /dev/bmousems /dev/mouse

1.5	Testing your mouse

	Get the file 'selection-1.5.tar.gz' from your local Linux ftp
	site and compile the program 'test-mouse' within it, according
	to the instructions (all you should need to do is type 'make
	test-mouse').  Run the program like this

	    test-mouse -t bm

	If your mouse is working correctly, you should be able to
	paint on the screen by holding down the right or left mouse
	button and dragging the mouse.  Push both mouse buttons together
	to exit the program.

1.6	Using selection

	Selection is a program which allows you to do mouse based 'cut-
	and-paste' between virtual console under Linux.  Selection can
	be found as the file 'selection-1.5.tar.gz' at your friendly
	Linux FTP site (such as sunsite.unc.edu), and contains instructions
	for getting it compiled.  Once compiled, selection should be run
	like this:

	    selection -t bm &

	You should then be able to cut and paste text between virtual
	consoles using the mouse buttons.  Read the documentation with
	selection, or do a 'man selection' for more information on how
	to operate it.

1.7	Using Xfree86

	To use your Microsoft busmouse under Xfree86, your Xconfig file
	should contain the following lines which pertain to mouse support.
	You should comment out any other mouse related lines.

	    Busmouse        "/dev/mouse"
	    Emulate3Buttons

	To emulate the use of the middle mouse button on three button
	mice, press both mouse buttons simultaneously.

1.8	Xfree86 and selection

	Unlike serial mice, you cannot share busmice between processes.
	This means you will have to kill any copies of 'selection' (see
	section 1.6) you have running before you start up Xfree86.  If
	you try to run X with selection running, you will get errors
	like the following

	    Fatal server error:
	    Cannot open mouse (Device or resource busy)

	The following script is a short wrapper around selection which
	will record its process ID in '/etc/selection.pid'.

	----------------------------- CUT HERE ----------------------------
	#!/bin/sh
	#
	# startselection	A selection wrapper script to save the pid.
	#

	echo $$ > /etc/selection.pid
	exec /usr/sbin/selection $*

	----------------------------- CUT HERE ----------------------------

	I have this script installed as 'startselection' in /usr/sbin
	(the same directory as selection), and my rc.local file includes
	the following line

	/usr/sbin/startselection -t bm &
	
	When you are starting up X, you can easily kill selection by
	doing

	    kill `cat /etc/selection.pid` && rm -f /etc/selection.pid

	(the last part being to remove the pid file, since we aren't using
	it any more).  You will probably want to add this to your startx
	script or some other appropriate place (such as an rc.* file).

------------------------------- END mini-HOWTO -------------------------------
-- 
  Mike Battersby   <mike@starbug.apana.org.au>   <mib@bruce.cs.monash.edu.au>
          CompSci honours student, Linux user and part time beggar.
           GCS d-(--) p c++ l++(+++) u+ e+ m+@ s+/- n+(---) h--(*)
                           f(+) !g w+ t++@ r(+) y?

