Subject: wscons input multiplexor
To: None <>
From: Lennart Augustsson <>
List: tech-kern
Date: 07/23/1999 05:22:46
Executive summary

I've added a multiplexor pseudo-device to wscons.  It makes it
possible to use several mice and keyboard for the same console.
Furthermore, it enables dynamic attach and detach of keyboards and
mice, without user intervention.  Plug it in, and "it just works".

I'd like comments on it before (if?) I commit it.

How to use it

The idea is that each wsmouse sends its events to a mux, which mux is
determined by the ``mux'' locator.  If the locator is left out the
device will not use a mux.  As long as the mux is not open the
ordinary device can be opened as usual.  X will then open this mux to
get the events from all the mice.

In a similar way each wskbd sends its events to another mux.  The
exception is the console keyboard which is still "glued" to its
display.  They keyboard mux can be attached to a display by using
wsconscfg (which has been extended with a new -m flag),

The wsdisplay device can now have several keyboards, or muxes,
attached to it.  Internally, this accomplished by having an anonymous
mux associated with each wsdisplay.

If a device is dynamically attached and it has a mux locator it will
join that mux automagically.  If it is detached it will leave the mux
(of course).  The upshot of this is that with a suitable config file
mice and keyboards can be hot plugged and they just work.  Regardless
if you are using a window system or not.

Here's an excerpt of my config file:
pckbc0 at isa?   # pc keyboard controller
pckbd* at pckbc?  # PC keyboard
pms*  at pckbc?  # PS/2 mouse for wsmouse
vga*  at pci?
wsdisplay0 at vga? console ?
wskbd0 at pckbd? console ?    # no mux for the console
wsmouse0 at pms? mux 0

ums* at uhub? port ? configuration ? interface ?
wsmouse* at ums? mux 0

ukbd* at uhub? port ? configuration ? interface ?
wskbd* at ukbd? console ? mux 1

pseudo-device wsmux 2

And in /dev I have
  /dev/wsmouse  is mux 0
  /dev/wskbd  is mux 1

More technicalities

Through ioctl() is is possible to add and remove devices from a mux.
The inputs to a mux can be an arbitrary combimnation of wskbd,
wsmouse, and wsmux devices.

There is also an ioctl() to inject events into a wsmux.  My plan is to
port the FreeBSD moused deamon that handles mice on serial ports and
let it inject the events into /dev/wsmouse.  In this way it will (on
an ordinary system) always be /dev/mouse that should be used as the
mouse in X; no more messing around trying to figure out how to set it
right.  (You might need som flags to moused though.)


I've implemented it and I'm testing it right now.  I'll make the
diffs available tomorrow if people want to have a look and comment.

Please send me any comments you have on this idea.  I'd like to
get it commited fairly soon so it will make it into 1.5.  Without
something like this USB keyboards and mice are not at all as much fun.


        -- Lennart