summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-09-15 21:26:17 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-09-15 21:26:17 +0000
commitdb9344149320870fd92d24b704f673e4880b2b6a (patch)
treef6fd72d7e22e728fb3f188e0f21e3ac38eaab479
parent851338fe8bf4c8d057984431b542b333cbad4b8e (diff)
downloaddrakx-backup-do-not-use-db9344149320870fd92d24b704f673e4880b2b6a.tar
drakx-backup-do-not-use-db9344149320870fd92d24b704f673e4880b2b6a.tar.gz
drakx-backup-do-not-use-db9344149320870fd92d24b704f673e4880b2b6a.tar.bz2
drakx-backup-do-not-use-db9344149320870fd92d24b704f673e4880b2b6a.tar.xz
drakx-backup-do-not-use-db9344149320870fd92d24b704f673e4880b2b6a.zip
no_comment
-rw-r--r--perl-install/ChangeLog13
-rw-r--r--perl-install/detect_devices.pm8
-rw-r--r--perl-install/install2.pm2
-rw-r--r--perl-install/install_steps_interactive.pm9
-rw-r--r--perl-install/interactive.pm11
-rw-r--r--perl-install/mouse.pm204
6 files changed, 153 insertions, 94 deletions
diff --git a/perl-install/ChangeLog b/perl-install/ChangeLog
index f85d0bac3..0fbf73a8c 100644
--- a/perl-install/ChangeLog
+++ b/perl-install/ChangeLog
@@ -1,5 +1,18 @@
2000-09-15 Pixel <pixel@mandrakesoft.com>
+ * mouse.pm: reworked quite a lot. Now sorts/categorize nicely the mice.
+
+ * install_steps_interactive.pm (selectMouse): adapted for reworked mouse.pm
+
+ * install2.pm (selectMouse): adapted for mouse::read now returning
+ an hash ref
+
+ * detect_devices.pm (hasMousePS2): remove hasMouseMacUSB, do it in
+ one function (now takes the device in the parameter)
+
+ * interactive.pm (ask_from_treelistf): added (just like
+ ask_from_listf, but with a tree)
+
* Xconfigurator.pm: the reference is now nbuttons to
know wether to put Emulate3Buttons or ZAxisMapping.
* Xconfigurator.pm (cardConfiguration): install Glide_V3-DRI on
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index 8ae0ca346..319975db3 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -307,12 +307,8 @@ sub hasModem($) {
$serialprobe{$_[0]} and $serialprobe{$_[0]}{CLASS} eq 'MODEM' and $serialprobe{$_[0]}{DESCRIPTION};
}
-sub hasMousePS2() {
- my $t; sysread(tryOpen("psaux") || return, $t, 256) != 1 || $t ne "\xFE";
-}
-
-sub hasMouseMacUSB {
- my $t; sysread(tryOpen("usbmouse") || return, $t, 256) != 1 || $t ne "\xFE";
+sub hasMousePS2 {
+ my $t; sysread(tryOpen($_[0]) || return, $t, 256) != 1 || $t ne "\xFE";
}
#-######################################################################################
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index 9d9e30dfa..5cf71174b 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -213,7 +213,7 @@ sub selectMouse {
$::live and return;
my ($clicked) = $_[0];
- add2hash($o->{mouse} ||= {}, { mouse::read($o->{prefix}) }) if $o->{isUpgrade} && !$clicked;
+ add2hash($o->{mouse} ||= {}, mouse::read($o->{prefix})) if $o->{isUpgrade} && !$clicked;
$o->selectMouse($clicked);
addToBeDone { mouse::write($o->{prefix}, $o->{mouse}) } 'installPackages';
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index ab32dc452..d679ca432 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -151,9 +151,12 @@ sub selectMouse {
my ($o, $force) = @_;
$force ||= $o->{mouse}{unsafe} || $::expert;
-
- $o->{mouse} = $o->ask_from_listf_('', _("Please, choose the type of your mouse."),
- sub { $_[0]{FULLNAME} }, [ mouse::list ], $o->{mouse}) if $force;
+
+ my $prev = $o->{mouse}{type} . '|' . $o->{mouse}{name};
+ $o->{mouse} = mouse::fullname2mouse(
+ $o->ask_from_treelistf('', _("Please, choose the type of your mouse."), '|',
+ sub { join '|', map { translate($_) } split '\|', $_[0] },
+ [ mouse::fullnames ], $prev)) if $force;
if ($force && $o->{mouse}{device} eq "ttyS") {
$o->set_help('selectSerialPort');
diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm
index 60a0fb419..b797b8fc5 100644
--- a/perl-install/interactive.pm
+++ b/perl-install/interactive.pm
@@ -154,6 +154,17 @@ sub ask_from_list2_with_help($$$$$;$) {
$o->ask_from_list_with_helpW($title, [ deref($message) ], $l, $help, $def || $l->[0]);
}
+sub ask_from_treelistf {
+ my ($o, $title, $message, $separator, $f, $l, $def) = @_;
+ my (@l,%l); my $i = 0; foreach (@$l) {
+ my $v = $f->($_, $i++);
+ push @l, $v;
+ $l{$v} = $_;
+ }
+ my $r = ask_from_treelist($o, $title, $message, $separator, \@l, defined $def ? $f->($def) : $def) or return;
+ $l{$r};
+}
+
sub ask_from_treelist {
my ($o, $title, $message, $separator, $l, $def) = @_;
$o->ask_from_treelistW($title, [ deref($message) ], $separator, [ sort @$l ], $def || $l->[0]);
diff --git a/perl-install/mouse.pm b/perl-install/mouse.pm
index b9b9e7052..cc9c3b948 100644
--- a/perl-install/mouse.pm
+++ b/perl-install/mouse.pm
@@ -15,65 +15,74 @@ use commands;
use modules;
use log;
-my @mouses_fields = qw(nbuttons device MOUSETYPE XMOUSETYPE FULLNAME);
-my @mouses = (
-arch() =~ /^sparc/ ? (
- [ 3, "sunmouse", "sun", "sun", __("Sun - Mouse") ],
-) : arch() eq "ppc" ? (
- [ 1, "adbmouse", "Busmouse", "BusMouse", __("Apple ADB Mouse") ],
- [ 2, "adbmouse", "Busmouse", "BusMouse", __("Apple ADB Mouse (2 Buttons)") ],
- [ 3, "adbmouse", "Busmouse", "BusMouse", __("Apple ADB Mouse (3+ Buttons)") ],
- [ 1, "usbmouse", "imps2", "IMPS/2", __("Apple USB Mouse") ],
- [ 2, "usbmouse", "imps2", "IMPS/2", __("Apple USB Mouse (2 Buttons)") ],
- [ 3, "usbmouse", "imps2", "IMPS/2", __("Apple USB Mouse (3+ Buttons)") ],
-) : (
- [ 2, "psaux", "ps/2", "PS/2", __("Generic Mouse (PS/2)") ],
- [ 3, "psaux", "ps/2", "PS/2", __("Logitech MouseMan/FirstMouse (ps/2)") ],
- [ 3, "psaux", "ps/2", "PS/2", __("Generic 3 Button Mouse (PS/2)") ],
- [ 2, "psaux", "ps/2", "GlidePointPS/2", __("ALPS GlidePoint (PS/2)") ],
- [ 5, "psaux", "ps/2", "MouseManPlusPS/2", __("Logitech MouseMan+/FirstMouse+ (PS/2)") ],
- [ 5, "psaux", "ps/2", "ThinkingMousePS/2", __("Kensington Thinking Mouse (PS/2)") ],
- [ 5, "psaux", "ps/2", "NetMousePS/2", __("ASCII MieMouse (PS/2)") ],
- [ 5, "psaux", "netmouse", "NetMousePS/2", __("Genius NetMouse (PS/2)") ],
- [ 5, "psaux", "netmouse", "NetMousePS/2", __("Genius NetMouse Pro (PS/2)") ],
- [ 5, "psaux", "netmouse", "NetScrollPS/2", __("Genius NetScroll (PS/2)") ],
- [ 5, "psaux", "imps2", "IMPS/2", __("Microsoft IntelliMouse (PS/2)") ],
- [ 2, "atibm", "Busmouse", "BusMouse", __("ATI Bus Mouse") ],
- [ 2, "inportbm", "Busmouse", "BusMouse", __("Microsoft Bus Mouse") ],
- [ 3, "logibm", "Busmouse", "BusMouse", __("Logitech Bus Mouse") ],
- [ 2, "usbmouse", "ps/2", "PS/2", __("USB Mouse") ],
- [ 5, "usbmouse", "ps/2", "IMPS/2", __("USB Mouse (3 buttons or more)") ],
-),
- [ 0, "none", "none", "Microsoft", __("No Mouse") ],
- [ 2, "ttyS", "pnp", "Auto", __("Microsoft Rev 2.1A or higher (serial)") ],
- [ 3, "ttyS", "logim", "MouseMan", __("Logitech CC Series (serial)") ],
- [ 5, "ttyS", "pnp", "IntelliMouse", __("Logitech MouseMan+/FirstMouse+ (serial)") ],
- [ 5, "ttyS", "ms3", "IntelliMouse", __("ASCII MieMouse (serial)") ],
- [ 5, "ttyS", "ms3", "IntelliMouse", __("Genius NetMouse (serial)") ],
- [ 5, "ttyS", "ms3", "IntelliMouse", __("Microsoft IntelliMouse (serial)") ],
- [ 2, "ttyS", "MMSeries", "MMSeries", __("MM Series (serial)") ],
- [ 2, "ttyS", "MMHitTab", "MMHittab", __("MM HitTablet (serial)") ],
- [ 3, "ttyS", "Logitech", "Logitech", __("Logitech Mouse (serial, old C7 type)") ],
- [ 3, "ttyS", "MouseMan", "MouseMan", __("Logitech MouseMan/FirstMouse (serial)") ],
- [ 2, "ttyS", "Microsoft", "Microsoft", __("Generic Mouse (serial)") ],
- [ 2, "ttyS", "Microsoft", "Microsoft", __("Microsoft compatible (serial)") ],
- [ 3, "ttyS", "Microsoft", "Microsoft", __("Generic 3 Button Mouse (serial)") ],
- [ 3, "ttyS", "Microsoft", "ThinkingMouse", __("Kensington Thinking Mouse (serial)") ],
- [ 2, "ttyS", "MouseSystems", "MouseSystems", __("Mouse Systems (serial)") ],
+my @mouses_fields = qw(nbuttons MOUSETYPE XMOUSETYPE name);
+
+my %mice =
+ arch() =~ /^sparc/ ?
+(
+ 'sunmouse' =>
+ [ [ 'sunmouse' ],
+ [ [ 3, 'sun', 'sun', __("Sun - Mouse") ]
+ ]]
+) :
+(
+ 'PS/2' =>
+ [ [ 'psaux' ],
+ [ [ 2, 'ps/2', 'PS/2', __("Standard") ],
+ [ 5, 'ps/2', 'MouseManPlusPS/2', __("Logitech MouseMan+") ],
+ [ 5, 'imps2', 'IMPS/2', __("Microsoft IntelliMouse") ],
+ [ 5, 'ps/2', 'GlidePointPS/2', __("GlidePoint") ],
+ '',
+ [ 5, 'ps/2', 'ThinkingMousePS/2', __("Kensington Thinking Mouse") ],
+ [ 5, 'netmouse', 'NetMousePS/2', __("Genius NetMouse") ],
+ [ 5, 'netmouse', 'NetScrollPS/2', __("Genius NetScroll") ],
+ ]],
+
+ 'USB' =>
+ [ [ 'usbmouse' ],
+ [ [ 2, 'ps/2', 'PS/2', __("Generic") ],
+ [ 5, 'ps/2', 'IMPS/2', __("Wheel") ],
+ ]],
+
+ __("serial") =>
+ [ [ map { "ttyS$_" } 0..3 ],
+ [ [ 2, 'Microsoft', 'Microsoft', __("Generic 2 Button Mouse") ],
+ [ 3, 'Microsoft', 'Microsoft', __("Generic 3 Button Mouse") ],
+ [ 5, 'ms3', 'IntelliMouse', __("Microsoft IntelliMouse") ],
+ [ 3, 'MouseMan', 'MouseMan', __("Logitech MouseMan") ],
+ [ 2, 'MouseSystems', 'MouseSystems', __("Mouse Systems") ],
+ '',
+ [ 3, 'logim', 'MouseMan', __("Logitech CC Series") ],
+ [ 5, 'pnp', 'IntelliMouse', __("Logitech MouseMan+/FirstMouse+") ],
+ [ 5, 'ms3', 'IntelliMouse', __("Genius NetMouse") ],
+ [ 2, 'MMSeries', 'MMSeries', __("MM Series") ],
+ [ 2, 'MMHitTab', 'MMHittab', __("MM HitTablet") ],
+ [ 3, 'Logitech', 'Logitech', __("Logitech Mouse (serial, old C7 type)") ],
+ [ 3, 'Microsoft', 'ThinkingMouse', __("Kensington Thinking Mouse") ],
+ ]],
+
+ 'busmouse' =>
+ [ [ arch() eq 'ppc' ? 'adbmouse' : ('atibm', 'inportbm', 'logibm') ],
+ [ [ 2, 'Busmouse', 'BusMouse', __("2 buttons") ],
+ [ 3, 'Busmouse', 'BusMouse', __("3 buttons") ],
+ ]],
+
+ 'none' =>
+ [ [ 'none' ],
+ [ [ 0, 'none', 'Microsoft', __("No mouse") ],
+ ]],
);
-map_index {
- my %l; @l{@mouses_fields} = @$_;
- $mouses[$::i] = \%l;
-} @mouses;
-
-#- xmousetypes must be sorted as found in /usr/include/X11/extensions/xf86misc.h
-#- so that first mean "0", etc
-my @xmousetypes = (
+
+
+sub xmouse2xId {
+ #- xmousetypes must be sorted as found in /usr/include/X11/extensions/xf86misc.h
+ #- so that first mean "0", etc
+ my @xmousetypes = (
"Microsoft",
"MouseSystems",
"MMSeries",
"Logitech",
- "BusMouse",
+ "BusMouse", #MouseMan,
"Logitech",
"PS/2",
"MMHittab",
@@ -91,23 +100,45 @@ my @xmousetypes = (
"AceCad",
"WSMouse",
"USB",
-#MouseMan,
-);
-sub xmouse2xId { my ($id) = @_; my $i; map_index { $_ eq $id and $i = $::i } @xmousetypes; $i }
+ );
+ my ($id) = @_;
+ $id = 'BusMouse' if $id eq 'MouseMan';
+ my $i; map_index { $_ eq $id and $i = $::i } @xmousetypes; $i;
+}
-sub names { map { $_->{FULLNAME} } @mouses }
-sub list { @mouses }
+sub raw2mouse {
+ my ($type, $raw) = @_;
+ $raw or return;
-sub name2mouse {
- my ($name) = @_;
- foreach (@mouses) {
- $name eq $_->{FULLNAME} and return $_;
- }
- die "$name not found";
+ my %l; @l{@mouses_fields} = @$raw;
+ +{ %l, type => $type };
}
-sub X2nbuttons {
- first(map { $_->{nbuttons} } grep { $_->{XMOUSETYPE} eq $_[0] } @mouses);
+sub fullnames {
+ map_each {
+ my $type = $::a;
+ grep {$_} map {
+ if ($_) {
+ my $l = raw2mouse($type, $_);
+ "$type|$l->{name}";
+ } else {
+ $type .= '|_' . _("Other");
+ '';
+ }
+ } @{$::b->[1]}
+ } %mice;
+}
+
+sub fullname2mouse {
+ my ($fname, %opts) = @_;
+ my ($type, @l) = split '\|', $fname;
+ my ($name) = pop @l;
+ $opts{device} ||= $mice{$type}[0][0];
+ foreach (@{$mice{$type}[1]}) {
+ my $l = raw2mouse($type, $_);
+ $name eq $l->{name} and return { %$l, %opts };
+ }
+ die "$fname not found ($type, $name)";
}
sub serial_ports() { map { "ttyS$_" } 0..3 }
@@ -116,16 +147,19 @@ sub serial_port2text {
"$_[0] / COM" . ($1 + 1);
}
-sub read($) {
+sub read {
my ($prefix) = @_;
my %mouse = getVarsFromSh "$prefix/etc/sysconfig/mouse";
+ add2hash_(\%mouse, fullname2mouse($mouse{FULLNAME}));
$mouse{device} = readlink "$prefix/dev/mouse" or log::l("reading $prefix/dev/mouse symlink failed");
- %mouse;
+ $mouse{nbuttons} = $mouse{XEMU3} eq "yes" ? 2 : $mouse{WHEEL} eq "yes" ? 5 : 3;
+ \%mouse;
}
-sub write($;$) {
+sub write {
my ($prefix, $mouse) = @_;
- local $mouse->{FULLNAME} = qq("$mouse->{FULLNAME}"); #-"
+ local $mouse->{FULLNAME} = qq("$mouse->{type}|$mouse->{name}");
+ local $mouse->{XEMU3} = bool2yesno($mouse->{nbuttons} < 3);
local $mouse->{WHEEL} = bool2yesno($mouse->{nbuttons} > 3);
setVarsInSh("$prefix/etc/sysconfig/mouse", $mouse, qw(MOUSETYPE XMOUSETYPE FULLNAME XEMU3 WHEEL device));
symlinkf $mouse->{device}, "$prefix/dev/mouse" or log::l("creating $prefix/dev/mouse symlink failed");
@@ -143,11 +177,11 @@ sub mouseconfig {
if ($t->{CLASS} eq 'MOUSE') {
$t->{MFG} ||= $t->{MANUFACTURER};
- $mouse = name2mouse("Microsoft IntelliMouse (serial)") if $t->{MFG} eq 'MSH' && $t->{MODEL} eq '0001';
- $mouse = name2mouse("Logitech MouseMan/FirstMouse (serial)") if $t->{MFG} eq 'LGI' && $t->{MODEL} =~ /^80/;
- $mouse = name2mouse("Genius NetMouse (serial)") if $t->{MFG} eq 'KYE' && $t->{MODEL} eq '0003';
+ $mouse = fullname2mouse("serial|Microsoft IntelliMouse") if $t->{MFG} eq 'MSH' && $t->{MODEL} eq '0001';
+ $mouse = fullname2mouse("serial|Logitech MouseMan") if $t->{MFG} eq 'LGI' && $t->{MODEL} =~ /^80/;
+ $mouse = fullname2mouse("serial|Genius NetMouse") if $t->{MFG} eq 'KYE' && $t->{MODEL} eq '0003';
- $mouse ||= name2mouse("Generic Mouse (serial)"); #- generic by default.
+ $mouse ||= fullname2mouse("serial|Generic 2 Button Mouse"); #- generic by default.
$mouse->{device} = "ttyS$_";
last;
} elsif ($t->{CLASS} eq "PEN" || $t->{MANUFACTURER} eq "WAC") {
@@ -158,27 +192,29 @@ sub mouseconfig {
}
sub detect() {
- return name2mouse("Sun - Mouse") if arch() =~ /^sparc/;
-
+ if (arch() =~ /^sparc/) {
+ return fullname2mouse("sunmouse|Sun - Mouse");
+ }
if (arch() eq "ppc") {
- return name2mouse("Apple USB Mouse") if detect_devices::hasMouseMacUSB;
- # No need to search for an ADB mouse. If I did, the PPC kernel would
- # find one whether or not I had one installed! So.. default to it.
- return name2mouse("Apple ADB Mouse");
+ return fullname2mouse(detect_devices::hasMousePS2("usbmouse") ?
+ "USB|Generic" :
+ # No need to search for an ADB mouse. If I did, the PPC kernel would
+ # find one whether or not I had one installed! So.. default to it.
+ "busmouse|2 buttons");
}
#- probe serial device to make sure a wacom has been detected.
eval { commands::modprobe("serial") };
my ($r, $wacom) = mouseconfig(); return ($r, $wacom) if $r;
- detect_devices::hasMousePS2 and return { %{name2mouse("Generic Mouse (PS/2)")}, unsafe => 1 }, $wacom;
+ 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 name2mouse("USB Mouse"), $wacom;
+ !$@ && detect_devices::tryOpen("usbmouse") and return fullname2mouse("USB|Generic"), $wacom;
eval {
modules::unload("mousedev");
modules::unload("usbmouse");
@@ -194,5 +230,5 @@ sub detect() {
#- defaults to generic serial mouse on ttyS0.
#- Oops? using return let return a hash ref, if not using it, it return a list directly :-)
- return { %{name2mouse("Generic Mouse (serial)")}, device => "ttyS0", unsafe => 1 };
+ return fullname2mouse("serial|Generic 2 Button Mouse", unsafe => 1);
}