[comp.windows.x] Remapping the keyboard to emulate mouse button

mgsmith@hplabsb.HP.COM (Michael Smith) (02/15/91)

My wrists have started to hurt (probably due to Repetitive Stresss
Syndrom as I believe it is called) so I have made a couple of changes.
One is that I borrowed a track ball to see how I like it but it seems
to be pretty much of a joke because it is really difficult to cut
and paste using it.  Basically it is difficult to move the pointer
while holding down one of the mouse buttons.  Therefore I would
like to remap the keyboard such that one of the keyboard buttons
(the lower left [Enter] button for example) can be used by the left
hand for button1 of the mouse while the right hand would actually
move the trackball.  I looked at xmodmap but it didn't prove fruitful.
Any ideas out there? My wrists would really appreciate it.

Mike Smith
HP Labs

mouse@lightning.mcrcim.mcgill.EDU (02/16/91)

> [...] Therefore I would like to remap the keyboard such that one of
> the keyboard buttons (the lower left [Enter] button for example) can
> be used by the left hand for button1 of the mouse while the right
> hand would actually move the trackball.

> I looked at xmodmap but it didn't prove fruitful.

Right.  The core protocol does not support "confusing" keyboard keys
and mouse buttons.  (Arguably it should - there is no obvious a priori
reason to make a distinction between buttons on the mouse and buttons
on the keyboard.  Most likely nobody even considered the possibility of
"confusing" them....)

> Any ideas out there?

I think that for the most part you're out of luck.  The obvious thing
to do would be to hack on the server.  If you can't do that for some
reason you could build a protocol filter than converts KeyPress and
KeyRelease events for certain keycodes into ButtonPress and
ButtonRelease events.  However, this will interact badly with grabs, so
it is at best a somewhat broken solution.  (I don't think a mere
protocol filter can diddle grab requests sufficiently to fix the
problem entirely.)

If it's enough for this to happen in just certain applications, you may
be able to do things with the Translations mechanisms, or something
analogous, depending on how configurable the application is.

If the hardware is yours and you're not afraid of a soldering gun, you
*might* consider opening things up and rewiring a couple of keyboard
key switches so they actually do mouse presses instead.

That's about all I have to suggest, I'm afraid.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

adri@dutncp8.tudelft.nl (A.B. van Woerkom) (02/22/91)

mgsmith@hplabsb.HP.COM (Michael Smith) writes:

>[...]  Therefore I would
>like to remap the keyboard such that one of the keyboard buttons
>(the lower left [Enter] button for example) can be used by the left
>hand for button1 of the mouse while the right hand would actually
>move the trackball.  I looked at xmodmap but it didn't prove fruitful.
>Any ideas out there? My wrists would really appreciate it.

>Mike Smith
>HP Labs

The following probably only applies to HP-equipment (I am on a HP9000/360),
but seeing Mike's sig this shouldn't be a problem:

The HP window server (or at least the one on my machine) looks in the file
/usr/lib/X11/X?devices (? stands for the display number, e.g. if you are on
thingy:0 X0devices is used) to see which devices to use as its keyboard and
pointer.  To use a keypoard as pointer it should contain the lines:

first	keyboard keyboard	#use first keyboard on HP-HIL as keyboard
first	keyboard pointer	#use same also a pointer
first	trackball	other	#trackerball also moves pointer

When a keyboard is given for a pointer a device the server will also examine
the file /usr/lib/X11/X?pointerkeys to find out which keys will move the
pointer and which keys will be used for buttons. E.g. you can specify that
the first three function keys will act as buttons by adding the lines:

pointer_button1_key	f1
pointer_button2_key	f2
pointer_button2_key	f2

For more details look in the files mentioned, the shouldy contain pretty
detailed instructions.

Hope this helps,
Adri.
--
A.B. van Woerkom, adri@dutncp6.tudelft.nl
Delft University of Technology, Faculty of Applied Physics, Physics
Informatics Group, section Computational Physics, Lorentzweg 1,
2628 CJ  DELFT, The Netherlands
________________________________________________________________________
"Unfortunately, the current generation of mail programs do not have checkers
 to see if the sender knows what he is talking about" (A.S. Tanenbaum)