site  contact  subhomenews

(SP1) Improved mouse detection

October 17, 2008 — BarryK
This is now the code in /etc/rc.d/rc.sysinit:

#recognise mouse... v411...

echo -n ' mouse' >/dev/console
PS2MOUSEDEV="";USBMOUSEDEV="";SERMOUSEDEV="";MOUSEDEV="nothing"
[ -f /etc/mousedevice ] && MOUSEDEV="`cat /etc/mousedevice`"
#v411 return of puppyserialdetect for usb/ps2 mouse detection only...
#[ "`cat /proc/bus/usb/devices 2>/dev/null | grep -i "Cls=03(HID ) Sub=01 Prot=02"`" != "" ] && USBMOUSEDEV="input/mice" #pakt.
PUPPYSERIALDETECT="`/sbin/puppyserialdetect -n`" #-n disables /dev/ttyS[0-4] probing.
[ "`echo "$PUPPYSERIALDETECT" | grep 'Type:USB-mouse'`" != "" ] && USBMOUSEDEV="input/mice"
[ "`echo "$PUPPYSERIALDETECT" | grep 'Type:PS2-mouse'`" != "" ] && PS2MOUSEDEV="psaux"
[ "`echo "$MOUSEDEV" | grep '^tty'`" != "" ] && SERMOUSEDEV="$MOUSEDEV" #fallback or manual choice.
MOUSECHOICES="${USBMOUSEDEV}|${SERMOUSEDEV}|${PS2MOUSEDEV}"
if [ "`echo -n "$MOUSECHOICES" | grep "$MOUSEDEV"`" = "" ];then
#MOUSEDEV is not one of the existing choices, so must choose an existing mouse...
NEWMOUSEDEV="`echo -n "$MOUSECHOICES" | cut -f 1 -d '|'`"
[ "$NEWMOUSEDEV" = "" ] && NEWMOUSEDEV="`echo -n "$MOUSECHOICES" | cut -f 2 -d '|'`"
[ "$NEWMOUSEDEV" = "" ] && NEWMOUSEDEV="`echo -n "$MOUSECHOICES" | cut -f 3 -d '|'`"
#as we don't probe for a serial mouse, if no usb or ps2 mouse, fallback to assuming there must be a serial mouse...
[ "$NEWMOUSEDEV" = "" ] && NEWMOUSEDEV="ttyS0"
#...opportunity later in Xorg Wizard to correct the com port if this guess is wrong.
echo -n "$NEWMOUSEDEV" > /etc/mousedevice
echo -n "MOUSEDEV" > /etc/oldmousedevice
ln -snf $NEWMOUSEDEV /dev/mouse
fi
#TODO: simplify above, use 'input/mice' for ps2 mouse also, but may need to modify Xorg/Xvesa/Input Wizards.
# (may also have to remove builtin psaux driver from kernel).


The above can be simplified enormously by using the HID /dev/input/mice for the PS/2 mouse as well, but there are repercussions elsewhere and 4.1.1 is strictly a bugfix release. Even so, I am being a bit daring by putting in a new utility at this stage.

Tags: puppy