summaryrefslogtreecommitdiffstats
path: root/perl-install/mouse.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/mouse.pm')
-rw-r--r--perl-install/mouse.pm204
1 files changed, 120 insertions, 84 deletions
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);
}