summaryrefslogtreecommitdiffstats
path: root/perl-install/share/step-red-click.xpm
blob: ea0101259078b6044cc9b143759b04586436c96c (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/* XPM */
static char * step_red_click_xpm[] = {
"21 21 221 2",
"  	c None",
". 	c #4B62AB",
"+ 	c #435794",
"@ 	c #35426A",
"# 	c #293047",
"$ 	c #20232C",
"% 	c #1B1B1C",
"& 	c #455896",
"* 	c #374570",
"= 	c #20232D",
"- 	c #1A1A1A",
"; 	c #1B1B1B",
"> 	c #202020",
", 	c #2A2C34",
"' 	c #3F4D78",
") 	c #333F64",
"! 	c #1A1A1B",
"~ 	c #1E1E1E",
"{ 	c #242424",
"] 	c #282828",
"^ 	c #2A2A2A",
"/ 	c #2C2C2C",
"( 	c #303030",
"_ 	c #343434",
": 	c #424C6D",
"< 	c #303A5A",
"[ 	c #272626",
"} 	c #766D6C",
"| 	c #B69F9D",
"1 	c #D5A9A5",
"2 	c #D39590",
"3 	c #B16E68",
"4 	c #7A4843",
"5 	c #443D3C",
"6 	c #3F3F3F",
"7 	c #434343",
"8 	c #4A5370",
"9 	c #3F3A3A",
"0 	c #B6A6A5",
"a 	c #FEDDDA",
"b 	c #FFC7C2",
"c 	c #FDACA5",
"d 	c #F9938A",
"e 	c #F2756A",
"f 	c #E6483A",
"g 	c #A9261B",
"h 	c #5F4745",
"i 	c #4F4F4F",
"j 	c #525459",
"k 	c #4D619E",
"l 	c #302E2D",
"m 	c #B79895",
"n 	c #FFCECA",
"o 	c #FFB2AB",
"p 	c #FF857B",
"q 	c #FB6356",
"r 	c #F55546",
"s 	c #ED493B",
"t 	c #E22E1E",
"u 	c #D91706",
"v 	c #AC362C",
"w 	c #615959",
"x 	c #5E5E5E",
"y 	c #59627F",
"z 	c #272727",
"A 	c #7D5D5B",
"B 	c #FEABA4",
"C 	c #FF9D95",
"D 	c #FF6C5F",
"E 	c #FD3D2C",
"F 	c #F72614",
"G 	c #EE210F",
"H 	c #E62211",
"I 	c #DD1806",
"J 	c #D81A09",
"K 	c #DA291A",
"L 	c #93544F",
"M 	c #6A6A6A",
"N 	c #696C76",
"O 	c #242730",
"P 	c #252525",
"Q 	c #333333",
"R 	c #B96760",
"S 	c #FC8176",
"T 	c #FC675A",
"U 	c #FA3625",
"V 	c #F61A07",
"W 	c #F01400",
"X 	c #E81200",
"Y 	c #E01301",
"Z 	c #DA1301",
"` 	c #D91B0A",
" .	c #DC2D1E",
"..	c #BA4F47",
"+.	c #7A7A7A",
"@.	c #7B7B7D",
"#.	c #272829",
"$.	c #2F2F2F",
"%.	c #3C3C3C",
"&.	c #D04D42",
"*.	c #F44030",
"=.	c #F2210E",
"-.	c #ED1300",
";.	c #E21200",
">.	c #DC1200",
",.	c #D71301",
"'.	c #D91D0C",
").	c #DD3123",
"!.	c #CC4F45",
"~.	c #878787",
"{.	c #888888",
"].	c #33363F",
"^.	c #383838",
"/.	c #444444",
"(.	c #C72A1C",
"_.	c #E92717",
":.	c #EA2413",
"<.	c #E71705",
"[.	c #E41200",
"}.	c #E01200",
"|.	c #D81200",
"1.	c #D71503",
"2.	c #DA2111",
"3.	c #DE382B",
"4.	c #CF564C",
"5.	c #949494",
"6.	c #939494",
"7.	c #3F465C",
"8.	c #404040",
"9.	c #4A4A4A",
"0.	c #AD2E23",
"a.	c #DF1706",
"b.	c #DF1503",
"c.	c #DE1301",
"d.	c #DA1200",
"e.	c #D71200",
"f.	c #D81908",
"g.	c #DB2B1C",
"h.	c #DF4134",
"i.	c #C96861",
"j.	c #A0A0A0",
"k.	c #999BA0",
"l.	c #47547D",
"m.	c #494949",
"n.	c #525252",
"o.	c #884641",
"p.	c #DB2313",
"q.	c #DA200F",
"r.	c #D81605",
"s.	c #D81504",
"t.	c #DB2617",
"u.	c #DE392C",
"v.	c #E1483D",
"w.	c #BF8884",
"x.	c #ADADAD",
"y.	c #9398AA",
"z.	c #4B5F9C",
"A.	c #51545B",
"B.	c #5A5A5A",
"C.	c #686060",
"D.	c #B6453B",
"E.	c #DC3122",
"F.	c #DC2C1E",
"G.	c #DB2718",
"H.	c #DA2515",
"I.	c #DC2E1F",
"J.	c #DE3B2E",
"K.	c #E0483C",
"L.	c #D17069",
"M.	c #BAB2B2",
"N.	c #B8B8B8",
"O.	c #7381AE",
"P.	c #515F8A",
"Q.	c #616161",
"R.	c #6B6B6B",
"S.	c #85706F",
"T.	c #BF5850",
"U.	c #DE4235",
"V.	c #DF3F33",
"W.	c #DF3E32",
"X.	c #DF4033",
"Y.	c #E04539",
"Z.	c #E14A3F",
"`.	c #D4746C",
" +	c #C5B2B1",
".+	c #C2C2C2",
"++	c #A6ABBB",
"@+	c #5F677F",
"#+	c #757575",
"$+	c #828282",
"%+	c #928B8B",
"&+	c #B47D78",
"*+	c #CA6A63",
"=+	c #D56057",
"-+	c #D76259",
";+	c #D2746D",
">+	c #CC9591",
",+	c #C7C0C0",
"'+	c #C9C9C9",
")+	c #B5B8C4",
"!+	c #5A6EAE",
"~+	c #647095",
"{+	c #86878C",
"]+	c #979797",
"^+	c #A2A2A2",
"/+	c #ACACAC",
"(+	c #B3B3B3",
"_+	c #BBBBBB",
":+	c #C8C8C8",
"<+	c #CACBCB",
"[+	c #B0B5C4",
"}+	c #5B6FAF",
"|+	c #5669A7",
"1+	c #7C85A3",
"2+	c #9B9EA8",
"3+	c #AFB0B2",
"4+	c #B9B9B9",
"5+	c #C0C0C1",
"6+	c #BEBFC4",
"7+	c #ABB0C2",
"8+	c #7D8BB7",
". . . . . . . . . . . . . . . . . . . . . ",
". . . . . . . . . . . . . . . . . . . . . ",
". . . . . . + @ # $ % $ # @ & . . . . . . ",
". . . . . * = - - - - - ; > , ' . . . . . ",
". . . . ) ! - - - ~ { ] ^ / ( _ : . . . . ",
". . . < ! - - [ } | 1 2 3 4 5 6 7 8 . . . ",
". . + = - - 9 0 a b c d e f g h i j k . . ",
". . @ - - l m n o p q r s t u v w x y . . ",
". . # ; z A B C D E F G H I J K L M N . . ",
". . O P Q R S T U V W X Y Z `  ...+.@.. . ",
". . #.$.%.&.r *.=.-.X ;.>.,.'.).!.~.{.. . ",
". . ].^./.(._.:.<.[.}.>.|.1.2.3.4.5.6.. . ",
". . 7.8.9.0.a.b.c.>.d.e.,.f.g.h.i.j.k.. . ",
". . l.m.n.o.p.q.` r.1.s.J t.u.v.w.x.y.. . ",
". . z.A.B.C.D.E.F.G.H.t.I.J.K.L.M.N.O.. . ",
". . . P.Q.R.S.T.U.V.W.X.Y.Z.`. +.+++. . . ",
". . . . @+#+$+%+&+*+=+-+;+>+,+'+)+!+. . . ",
". . . . . ~+{+]+^+/+(+_+.+:+<+[+}+. . . . ",
". . . . . . |+1+2+3+4+5+6+7+8+. . . . . . ",
". . . . . . . . . . . . . . . . . . . . . ",
". . . . . . . . . . . . . . . . . . . . . "};
href='#n473'>473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
package mouse; # $Id$

#use diagnostics;
#use strict;

#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use modules;
use detect_devices;
use run_program;
use devices;
use modules;
use any;
use log;

my @mouses_fields = qw(nbuttons MOUSETYPE XMOUSETYPE name);

my %mice = 
 arch() =~ /^sparc/ ? 
(
 'sunmouse' =>
 [ [ 'sunmouse' ],
   [ [ 3, 'sun', 'sun', N_("Sun - Mouse") ]
   ] ]
) :
(
 'PS/2' => 
 [ [ 'psaux' ],
   [ [ 2, 'ps/2', 'PS/2', N_("Standard") ],
     [ 5, 'ps/2', 'MouseManPlusPS/2', N_("Logitech MouseMan+") ],
     [ 5, 'imps2', 'IMPS/2', N_("Generic PS2 Wheel Mouse") ],
     [ 5, 'ps/2', 'GlidePointPS/2', N_("GlidePoint") ],
     '',
     [ 5, 'ps/2', 'ThinkingMousePS/2', N_("Kensington Thinking Mouse") ],
     [ 5, 'netmouse', 'NetMousePS/2', N_("Genius NetMouse") ],
     [ 5, 'netmouse', 'NetScrollPS/2', N_("Genius NetScroll") ],
     [ 7, 'ps/2', 'ExplorerPS/2', N_("Microsoft Explorer") ],
   ] ],
     
 'USB' =>
 [ [ 'usbmouse' ],
   [ [ 1, 'ps/2', 'IMPS/2', N_("1 button") ],
     [ 2, 'ps/2', 'IMPS/2', N_("Generic 2 Button Mouse") ],
     [ 3, 'ps/2', 'IMPS/2', N_("Generic") ],
     [ 5, 'ps/2', 'IMPS/2', N_("Wheel") ],
     [ 7, 'ps/2', 'ExplorerPS/2', N_("Microsoft Explorer") ],
   ] ],

 N_("serial") =>
 [ [ map { "ttyS$_" } 0..3 ],
   [ [ 2, 'Microsoft', 'Microsoft', N_("Generic 2 Button Mouse") ],
     [ 3, 'Microsoft', 'Microsoft', N_("Generic 3 Button Mouse") ],
     [ 5, 'ms3', 'IntelliMouse', N_("Microsoft IntelliMouse") ],
     [ 3, 'MouseMan', 'MouseMan', N_("Logitech MouseMan") ],
     [ 2, 'MouseSystems', 'MouseSystems', N_("Mouse Systems") ],     
     '',
     [ 3, 'logim', 'MouseMan', N_("Logitech CC Series") ],
     [ 5, 'pnp', 'IntelliMouse', N_("Logitech MouseMan+/FirstMouse+") ],
     [ 5, 'ms3', 'IntelliMouse', N_("Genius NetMouse") ],
     [ 2, 'MMSeries', 'MMSeries', N_("MM Series") ],
     [ 2, 'MMHitTab', 'MMHittab', N_("MM HitTablet") ],
     [ 3, 'Logitech', 'Logitech', N_("Logitech Mouse (serial, old C7 type)") ],
     [ 3, 'Microsoft', 'ThinkingMouse', N_("Kensington Thinking Mouse") ],
   ] ],

 N_("busmouse") =>
 [ [ arch() eq 'ppc' ? 'adbmouse' : ('atibm', 'inportbm', 'logibm') ],
   [ if_(arch() eq 'ppc', [ 1, 'Busmouse', 'BusMouse', N_("1 button") ]),
     [ 2, 'Busmouse', 'BusMouse', N_("2 buttons") ],
     [ 3, 'Busmouse', 'BusMouse', N_("3 buttons") ],
   ] ],

 N_("none") =>
 [ [ 'none' ],
   [ [ 0, 'none', 'Microsoft', N_("No mouse") ],
   ] ],
);


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", #MouseMan,
		   "Logitech",
		   "PS/2",
		   "MMHittab",
		   "GlidePoint",
		   "IntelliMouse",
		   "ThinkingMouse",
		   "IMPS/2",
		   "ThinkingMousePS/2",
		   "MouseManPlusPS/2",
		   "GlidePointPS/2",
		   "NetMousePS/2",
		   "NetScrollPS/2",
		   "SysMouse",
		   "Auto",
		   "AceCad",
		   "ExplorerPS/2",
		   "USB",
    );
    my ($id) = @_;
    $id = 'BusMouse' if $id eq 'MouseMan';
    $id = 'IMPS/2' if $id eq 'ExplorerPS/2' && $::isInstall;
    eval { find_index { $_ eq $id } @xmousetypes } || 0;
}

my %mouse_btn_keymap = (
    0   => "NONE",
    67  => "F9",
    68  => "F10",
    87  => "F11",
    88  => "F12",
    85  => "F13",
    89  => "F14",
    90  => "F15",
    56  => "L-Option/Alt",
    125 => "L-Command (Apple)",
    98  => "Num: /",
    55  => "Num: *",
    117 => "Num: =",
    96 => "Enter",
);
sub ppc_one_button_keys() { keys %mouse_btn_keymap }
sub ppc_one_button_key2text { $mouse_btn_keymap{$_[0]} }

sub raw2mouse {
    my ($type, $raw) = @_;
    $raw or return;

    my %l; @l{@mouses_fields} = @$raw;
    +{ %l, type => $type };
}

sub fullnames() { 
    map_each { 
	my $type = $::a;
	grep { $_ } map {
	    if ($_) {
		my $l = raw2mouse($type, $_);
		"$type|$l->{name}";
	    } else { 
		$type .= "|[" . N("Other") . "]";
		'';
	    }
	} @{$::b->[1]}
    } %mice;
}

sub fullname2mouse {
    my ($fname, %opts) = @_;
    my ($type, @l) = split '\|', $fname;
    my ($name) = pop @l;
  search:
    $opts{device} ||= $mice{$type}[0][0];
    foreach (@{$mice{$type}[1]}) {
	my $l = raw2mouse($type, $_);
	$name eq $l->{name} and return { %$l, %opts };
    }
    if ($name eq '1 Button' || $name eq '1 button') {
	$name = "Generic 2 Button Mouse";
	goto search;
    }
    die "$fname not found ($type, $name)";
}

sub serial_ports() { map { "ttyS$_" } 0..7 }
sub serial_port2text {
    $_[0] =~ /ttyS(\d+)/ ? "$_[0] / COM" . ($1 + 1) : $_[0];
}

sub read() {
    my %mouse = getVarsFromSh "$::prefix/etc/sysconfig/mouse";
    eval { add2hash_(\%mouse, fullname2mouse($mouse{FULLNAME})) };
    $mouse{nbuttons} ||= $mouse{XEMU3} eq "yes" ? 2 : $mouse{WHEEL} eq "yes" ? 5 : 3;
    \%mouse;
}

sub write {
    my ($in, $mouse) = @_;
    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));
    any::devfssymlinkf($mouse, 'mouse');

    #- we should be using input/mice directly instead of usbmouse, but legacy...
    symlinkf 'input/mice', "$::prefix/dev/usbmouse" if $mouse->{device} eq "usbmouse";

    any::devfssymlinkf($mouse->{auxmouse}, 'mouse1') if $mouse->{auxmouse};


    various_xfree_conf($in, $mouse);

    if (arch() =~ /ppc/) {
	my $s = join('',
	  "dev.mac_hid.mouse_button_emulation = " . to_bool($mouse->{button2_key} || $mouse->{button3_key}) . "\n",
	  if_($mouse->{button2_key}, "dev.mac_hid.mouse_button2_keycode = $mouse->{button2_key}\n"),
	  if_($mouse->{button3_key}, "dev.mac_hid.mouse_button3_keycode = $mouse->{button3_key}\n"),
	);
	substInFile { 
	    $_ = '' if /^\Qdev.mac_hid.mouse_button/;
	    $_ .= $s if eof;
	} "$::prefix/etc/sysctl.conf";
    }
}

sub mouseconfig() {
    my ($t, $mouse, @wacom);

    #- Whouah! probing all devices from ttyS0 to ttyS3 once a time!
    detect_devices::probeSerialDevices();

    #- check new probing methods keep everything used here intact!
    foreach (0..3) {
	$t = detect_devices::probeSerial("/dev/ttyS$_") or next;
	if ($t->{CLASS} eq 'MOUSE') {
	    $t->{MFG} ||= $t->{MANUFACTURER};

	    $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 ||= fullname2mouse("serial|Generic 2 Button Mouse"); #- generic by default.
	    $mouse->{device} = "ttyS$_";
	    last;
	} elsif ($t->{CLASS} eq "PEN" || $t->{MANUFACTURER} eq "WAC") {
	    push @wacom, "ttyS$_";
	}
    }
    $mouse, @wacom;
}

sub detect() {
    if (arch() =~ /^sparc/) {
	return fullname2mouse("sunmouse|Sun - Mouse");
    }
    if (arch() eq "ppc") {
        return fullname2mouse(detect_devices::hasMousePS2("usbmouse") ? 
			      "USB|1 button" :
			      # 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|1 button");
    }

    my @wacom;
    my $fast_mouse_probe = sub {
	my $auxmouse = detect_devices::hasMousePS2("psaux") && fullname2mouse("PS/2|Standard", unsafe => 1);

	#- workaround for some special case were mouse is openable 1/2.
	unless ($auxmouse) {
	    $auxmouse = detect_devices::hasMousePS2("psaux") && fullname2mouse("PS/2|Generic PS2 Wheel Mouse", unsafe => 0);
	    $auxmouse and detect_devices::hasMousePS2("psaux"); #- fake another open in order for XFree to see the mouse.
	}

	if (modules::get_probeall("usb-interface")) {
	    if (my (@l) = detect_devices::usbMice()) {
		log::l(join('', "found usb mouse $_->{driver} $_->{description} (", if_($_->{type}, $_->{type}), ")")) foreach @l;
		eval { modules::load(qw(hid mousedev usbmouse)) };
		if (!$@ && detect_devices::tryOpen("usbmouse")) {
		    my $mouse = fullname2mouse($l[0]{driver} =~ /Mouse:(.*)/ ? $1 : "USB|Wheel");
		    $auxmouse and $mouse->{auxmouse} = $auxmouse; #- for laptop, we kept the PS/2 as secondary (symbolic).
		    return $mouse;
		}
		eval { modules::unload(qw(usbmouse mousedev hid)) };
	    }
	} else {
	    log::l("no usb interface found for mice");
	}
	$auxmouse;
    };

    if (modules::get_probeall("usb-interface")) {
	my $keep_mouse;
	if (my (@l) = detect_devices::usbWacom()) {
	    log::l("found usb wacom $_->{driver} $_->{description} ($_->{type})") foreach @l;
	    eval { modules::load("wacom", "evdev") };
	    unless ($@) {
		foreach (0..$#l) {
		    detect_devices::tryOpen("input/event$_") and $keep_mouse = 1, push @wacom, "input/event$_";
		}
	    }
	    $keep_mouse or eval { modules::unload("evdev", "wacom") };
	}
    } else {
	log::l("no usb interface found for wacom");
    }

    #- at this level, not all possible mice are detected so avoid invoking serial_probe
    #- which takes a while for its probe.
    if ($::isStandalone) {
	my $mouse = $fast_mouse_probe->();