site  contact  subhomenews

(SP1) Mouse detection fix

October 16, 2008 — BarryK
Rerwin discovered a logic problem in the mouse detection code in /etc/rc.d/rc.sysinit. I just moved the 'fi' down to the end of this code block:

#recognise mouse... v411...

echo -n ' mouse' >/dev/console
PS2MOUSEDEV="psaux";USBMOUSEDEV="";SERMOUSEDEV="";MOUSEDEV="nothing"
[ -f /etc/mousedevice ] && MOUSEDEV="`cat /etc/mousedevice`"
[ "`cat /proc/bus/usb/devices 2>/dev/null | grep -i "Cls=03(HID ) Sub=01 Prot=02"`" != "" ] && USBMOUSEDEV="input/mice"
[ "`echo "$MOUSEDEV" | grep '^tty'`" != "" ] && SERMOUSEDEV="$MOUSEDEV" #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 '|'`"
echo -n "$NEWMOUSEDEV" > /etc/mousedevice
echo -n "MOUSEDEV" > /etc/oldmousedevice
ln -snf $NEWMOUSEDEV /dev/mouse
fi


As you can see from the above code, only a USB mouse is postively detected. In the absence of a USB mouse, the fallback is to a PS/2 mouse. When the Xorg Wizard is run at first boot, the user is offered to modify that choice and may manually choose any three, and that choice gets remembered at next boot (in /etc/mousedevice).
Note though, if you are using a USB mouse, but at next boot it is unplugged, the code will drop down to using a PS/2 mouse. This is a common situation with a laptop. On the other hand, manual choice of either PS/2 or serial mouse remains fixed.

However, this is just a patch-up for SP1 and 4.1.1. The devnode /dev/input/mice works for both PS/2 and USB mouse -- on my laptop right now for example, both the exernal USB and the internal touchpad (PS/2 mouse) work simultaneously. So, as I have already done for the keyboard, there is no need to distinguish between them. The only special case is the serial mouse. Thus, the above code can be greatly simplified in the future, but some corresponding simplification is also required in the Xorg Wizard (and probably the Xvesa Wizard).

Regarding release of Service Pack 1 (SP1) and Puppy 4.1.1 (4.1 with SP1 applied), I intend to release SP1 about the 28th, then 4.1.1 about the 30th of this month.

Comments

USB mouse override
Username: BarryK
Actually, thinking about it some more. If a USB mouse is detected, wouldn't you [b]always[/b] be wanting to choose it? So, perhaps I should modify the above code so that if USB mouse detected, choose that regardless of any earlier choice. If no USB mouse, the default will be to fall back to PS/2, but if the user manually chooses a serial mouse in the Xorg Wizard, or later in the Input/mouse Wizard, that will stick permanently. Anyone got any thoughts on this? I could probably quite easily modify the code in accordance with the above reasoning.

USB mouse override
Username: dogone
"I suggest falling back in order of technological devolution. That is, USB -> PS/2 -> serial. When detected, a touch pad should remain enabled as well unless prevented by the BIOS. While the ideal strategy is to detect the pointing device wherever/whenever it's connected, the above seems logical and practical.

usb/ps2 mouse detection
Username: BarryK
"Great! Jesse will be creating a little usb and ps/2 mouse detection utility, probably this weekend. After getting ps/2 mouse detection, I'll rewrite the above mouse detection code in rc.sysinit. It should be safe enough for this to go into SP1 and 4.1.1.


Tags: puppy