1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/usr/bin/perl
use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
use common;
use interactive;
use modules;
use mouse;
use c;
$::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\w+) (\w+)/;
local $_ = join '', @ARGV;
/-h/ and die "usage: mousedrake [--auto] [--testing]\n";
$::auto = /-auto/;
$::testing = /-testing/;
my $in = 'interactive'->vnew('su', 'mouse');
undef $::Plug;
begin:
my $mouse = mouse::read();
if (!$::noauto) {
my $probed_mouse = mouse::detect();
$mouse = $probed_mouse if !$mouse->{XMOUSETYPE} || !$probed_mouse->{unsafe};
}
$::isEmbedded and kill USR2, $::CCPID;
if (!$mouse || !$::auto) {
$mouse ||= mouse::fullname2mouse("serial|Generic 2 Button Mouse");
if ($::isEmbedded && $in->isa('interactive::gtk')) {
#- HACK: waiting for the ask_from_treelistf to attach itself
#- and adding the nice test mouse to it
Gtk->timeout_add(100, sub {
defined $::Plug && defined $::Plug->child or return 1;
mouse::test_mouse_standalone($mouse,$::Plug->child);
0;
});
}
my $name = $in->ask_from_treelistf('mousedrake', _("Please, choose the type of your mouse."), '|',
sub { join '|', map { translate($_) } split '\|', $_[0] },
[ mouse::fullnames ],
$mouse->{type} . '|' . $mouse->{name});
$name or $::isEmbedded ? do { kill(USR1, $::CCPID); goto begin } : $in->exit(0);
my $mouse_chosen = mouse::fullname2mouse($name);
$mouse = $mouse_chosen if !($mouse->{type} eq $mouse_chosen->{type} && $mouse->{name} eq $mouse_chosen->{name});
if ($mouse->{device} eq "usbmouse") {
modules::mergein_conf('/etc/modules.conf') if -r '/etc/modules.conf';
modules::load_category('bus/usb') or die _("no serial_usb found\n");
eval { modules::load('serial_usb') };
}
$mouse->{XEMU3} = 'yes' if $mouse->{nbuttons} < 3 && (!$::noauto || $in->ask_yesorno('', _("Emulate third button?"), 1));
$mouse->{device} = $in->ask_from_listf(_("Mouse Port"),
_("Please choose on which serial port your mouse is connected to."),
\&mouse::serial_port2text,
[ mouse::serial_ports ],
$mouse->{device},
) || goto begin if $mouse->{type} eq 'serial';
}
mouse::write_conf($mouse, 1);
system('service', 'gpm', 'restart') if -e '/var/lock/subsys/gpm';
$::isEmbedded ? kill(USR1, $::CCPID) : $in->exit(0);
goto begin;
|