From c3822da244887ef19b2ef7bba5812d18bc6ea8db Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Sat, 16 Dec 2000 18:25:37 +0000 Subject: use ldetect-lst for usb => now auto detects mice types :) --- perl-install/Makefile | 4 +--- perl-install/c/stuff.xs.pm | 4 ++-- perl-install/detect_devices.pm | 22 +++++++--------------- perl-install/install2.pm | 6 +++--- perl-install/live_install | 6 +++--- perl-install/modules.pm | 4 ++-- perl-install/mouse.pm | 22 +++++++++++++--------- perl-install/pkgs.pm | 1 + 8 files changed, 32 insertions(+), 37 deletions(-) diff --git a/perl-install/Makefile b/perl-install/Makefile index 71c0cf648..beffbaec4 100644 --- a/perl-install/Makefile +++ b/perl-install/Makefile @@ -16,7 +16,7 @@ tar-drakxtools: clean $(MAKE) -C ../tools clean cd .. ; rm -rf drakxtools ; cp -af perl-install drakxtools ; cp -af tools/ddcprobe tools/serial_probe drakxtools cd ../drakxtools ; rm -rf install* pkgs.pm ftp.pm t.pm */CVS ; mv Makefile.drakxtools Makefile ; mv -f standalone/* . - cd .. ; tar cfI drakxtools.tar.bz2 --exclude CVS $(patsubst %,drakxtools/%,Makefile Makefile.config share/MonitorsDB share/Cards+ share/CardsNames Newt c ddcprobe serial_probe share/po sbus_probing resize_fat share/diskdrake.rc share/isdndb.net $(STANDALONEPMS) icons *.pm) + cd .. ; tar cfI drakxtools.tar.bz2 --exclude CVS $(patsubst %,drakxtools/%,Makefile Makefile.config Newt c ddcprobe serial_probe share/po sbus_probing resize_fat share/diskdrake.rc share/isdndb.net $(STANDALONEPMS) icons *.pm) cd .. ; rm -rf drakxtools $(DIRS): @@ -118,9 +118,7 @@ endif cd share ; cp -a modparm.lst $(DEST)/usr/share cd share ; cp -a consolefonts $(DEST)/usr/share cd share ; cp template.in/*.in $(DEST)/usr/share - cd share ; cp MonitorsDB Cards+ CardsNames $(DEST)/usr/X11R6/lib/X11 cd share ; cp *.xpm $(DEST)/usr/share - cd share ; cp isdndb.net $(DEST)/usr/share/isdn_db.txt cd share ; cp -a themes $(DEST)/usr/share/gtk cd share ; cp compssUsers compssUsers.desktop rpmsrate $(ROOTDEST)/Mandrake/base diff --git a/perl-install/c/stuff.xs.pm b/perl-install/c/stuff.xs.pm index 4eab2b172..c115a8b0e 100644 --- a/perl-install/c/stuff.xs.pm +++ b/perl-install/c/stuff.xs.pm @@ -228,8 +228,8 @@ usb_probe() EXTEND(SP, entries.nb); for (i = 0; i < entries.nb; i++) { struct pciusb_entry e = entries.entries[i]; - snprintf(buf, sizeof(buf), "%04x\t%04x\t%s\t%s", - e.vendor, e.device, e.module ? e.module : "unknown", e.text); + snprintf(buf, sizeof(buf), "%04x\t%04x\t%s\t%s\t%s", + e.vendor, e.device, usb_class2text(e.class), e.module ? e.module : "unknown", e.text); PUSHs(sv_2mortal(newSVpv(buf, 0))); } pciusb_free(entries); diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index 802110185..438cf301b 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -185,9 +185,11 @@ sub pci_probe { } sub usb_probe { + -e "/proc/bus/usb/devices" or return (); + map { my %l; - @l{qw(vendor id driver description)} = split "\t"; + @l{qw(vendor id type driver description)} = split "\t"; $l{$_} = hex $l{$_} foreach qw(vendor id); $l{bus} = 'USB'; \%l @@ -233,20 +235,6 @@ sub syslog { `dmesg`; } -sub hasUsb { - my ($class, $prot) = @_; - foreach (cat_("/proc/bus/usb/devices")) { - if (/^P/ .. /^I/) { - my ($c, $p) = /Cls=(\d+).*Prot=(\d+)/; - $c == $class && ($prot < 0 || $prot == $p) and log::l("found usb $c $p"), return 1; - } - } - 0; -} -sub hasUsbKeyboard { hasUsb(3, 1) } -sub hasUsbMouse { hasUsb(3, 2) } -sub hasUsbZip { hasUsb(8, -1) } - sub hasSMP { c::detectSMP() } sub hasUltra66 { @@ -277,6 +265,10 @@ sub whatParport() { @res; } +sub usbMice { grep { $_->{type} =~ /\|Mouse/ } usb_probe() } +sub usbKeyboards { grep { $_->{type} =~ /\|Keyboard/ } usb_probe() } +sub usbZips { grep { $_->{type} =~ /Mass Storage\|/ } usb_probe() } + sub whatUsbport() { my ($i, $elem, @res) = (0, {}); local *F; open F, "/proc/bus/usb/devices" or return; diff --git a/perl-install/install2.pm b/perl-install/install2.pm index 5aadf8382..e59c96fac 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -353,9 +353,9 @@ sub miscellaneous { my $f = "$o->{prefix}/etc/sysconfig/usb"; output $f, "USB=yes -MOUSE=" . bool2yesno(detect_devices::hasUsbMouse()) . " -KEYBOARD=" . bool2yesno(detect_devices::hasUsbKeyboard()) . " -STORAGE=" . bool2yesno(detect_devices::hasUsbZip()) . " +MOUSE=" . bool2yesno(detect_devices::usbMice()) . " +KEYBOARD=" . bool2yesno(detect_devices::usbKeyboards()) . " +STORAGE=" . bool2yesno(detect_devices::usbZips()) . " VISOR=no " if modules::get_alias("usb-interface") && ! -e $f; diff --git a/perl-install/live_install b/perl-install/live_install index de92f054f..11252d791 100755 --- a/perl-install/live_install +++ b/perl-install/live_install @@ -42,10 +42,10 @@ if [ -x "/tmp/drakx/mdkinst/usr/bin/perl-install/live_install2" ]; then for i in MonitorsDB CardsNames Cards+ do - if [ -e /usr/X11R6/lib/X11/$i ]; then - /bin/mv /usr/X11R6/lib/X11/$i /tmp/drakx/mdkinst + if [ -e /usr/share/ldetect-lst/$i ]; then + /bin/mv /usr/share/ldetect-lst/X11/$i /tmp/drakx/mdkinst fi - /bin/cp -a /tmp/drakx/mdkinst/usr/X11R6/lib/X11/$i /usr/X11R6/lib/X11/$i + /bin/cp -a /tmp/drakx/mdkinst/usr/share/ldetect-lst/X11/$i /usr/share/ldetect-lst/X11/$i done # gtk ressource for live. diff --git a/perl-install/modules.pm b/perl-install/modules.pm index 4494e366c..dfdebd6cd 100644 --- a/perl-install/modules.pm +++ b/perl-install/modules.pm @@ -497,7 +497,7 @@ sub load_raw { require fs; fs::mount('/proc/bus/usb', '/proc/bus/usb', 'usbdevfs'); #- ensure keyboard is working, the kernel must do the job the BIOS was doing sleep 2; - load_multi("usbkbd", "keybdev") if detect_devices::hasUsbKeyboard(); + load_multi("usbkbd", "keybdev") if detect_devices::usbKeyboards(); } } } @@ -612,7 +612,7 @@ sub load_thiskind { } get_that_type($type), $type =~ /scsi/ && arch() !~ /sparc/ ? (map { +{ driver => $_, description => $_, try => 1 } } - detect_devices::hasUsbZip() ? "usb-storage" : (), "imm", "ppa") : (); + detect_devices::usbZips() ? "usb-storage" : (), "imm", "ppa") : (); } sub get_that_type { diff --git a/perl-install/mouse.pm b/perl-install/mouse.pm index 2bc5d5efa..7d0cb80c4 100644 --- a/perl-install/mouse.pm +++ b/perl-install/mouse.pm @@ -215,15 +215,19 @@ sub detect() { detect_devices::hasMousePS2("psaux") and return fullname2mouse("PS/2|Standard", unsafe => 1), $wacom; } - if (modules::get_alias("usb-interface") && detect_devices::hasUsbMouse()) { - eval { - modules::load("usbmouse"); - modules::load("mousedev"); - }; - !$@ && detect_devices::tryOpen("usbmouse") and return fullname2mouse("USB|Generic"), $wacom; - eval { - modules::unload("mousedev"); - modules::unload("usbmouse"); + if (modules::get_alias("usb-interface")) { + if (my (@l) = detect_devices::usbMice()) { + log::l("found usb mouse $_->{driver} $_->{description} ($_->{type})") foreach @l; + eval { + modules::load("usbmouse"); + modules::load("mousedev"); + }; + !$@ && detect_devices::tryOpen("usbmouse") and + return fullname2mouse($l[0]{driver} =~ /Mouse:(.*)/ ? $1 : "USB|Generic"), $wacom; + eval { + modules::unload("mousedev"); + modules::unload("usbmouse"); + } } } diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index 7df6cf8ab..dab75625e 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -8,6 +8,7 @@ use common qw(:common :file :functional :system); use install_any; use commands; use run_program; +use detect_devices; use log; use pkgs; use fs; -- cgit v1.2.1