summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-07-30 19:42:33 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-07-30 19:42:33 +0000
commitd498565fa66347fe9f65d28864ee002b4c8ef5f2 (patch)
treef8ad99a1cda11d228735b668ad3b61beb8e2633a
parent755319c9db0feabeeba27d0e007388652e423394 (diff)
downloaddrakx-d498565fa66347fe9f65d28864ee002b4c8ef5f2.tar
drakx-d498565fa66347fe9f65d28864ee002b4c8ef5f2.tar.gz
drakx-d498565fa66347fe9f65d28864ee002b4c8ef5f2.tar.bz2
drakx-d498565fa66347fe9f65d28864ee002b4c8ef5f2.tar.xz
drakx-d498565fa66347fe9f65d28864ee002b4c8ef5f2.zip
use usb keyboard bCountryCode to choose the right keyboard
-rw-r--r--perl-install/c/stuff.xs.pl4
-rw-r--r--perl-install/detect_devices.pm14
-rw-r--r--perl-install/install_steps.pm2
-rw-r--r--perl-install/install_steps_interactive.pm8
-rw-r--r--perl-install/keyboard.pm61
5 files changed, 34 insertions, 55 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index d2377d8f9..ce2977f40 100644
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -354,8 +354,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\t%s",
- e->vendor, e->device, usb_class2text(e->class_), e->module ? e->module : "unknown", e->text);
+ snprintf(buf, sizeof(buf), "%04x\t%04x\t%s\t%s\t%s\t%d\t%d",
+ e->vendor, e->device, usb_class2text(e->class_), e->module ? e->module : "unknown", e->text, e->pci_bus, e->pci_device);
PUSHs(sv_2mortal(newSVpv(buf, 0)));
}
pciusb_free(&entries);
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index 7ffd92252..a80fb29c9 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -348,11 +348,11 @@ sub pci_probe {
}
sub usb_probe {
- -e "/proc/bus/usb/devices" or return ();
+ -e "/proc/bus/usb/devices" or return;
add_addons($usbtable_addons, map {
my %l;
- @l{qw(vendor id media_type driver description)} = split "\t";
+ @l{qw(vendor id media_type driver description pci_bus pci_device)} = split "\t";
$l{$_} = hex $l{$_} foreach qw(vendor id);
$l{bus} = 'USB';
\%l
@@ -490,6 +490,16 @@ sub usbWacom { grep { $_->{driver} =~ /Tablet:wacom/ } usb_probe() }
sub usbKeyboards { grep { $_->{media_type} =~ /\|Keyboard/ } usb_probe() }
sub usbStorage { grep { $_->{media_type} =~ /Mass Storage\|/ } usb_probe() }
+sub usbKeyboard2country_code {
+ my ($usb_kbd) = @_;
+ local *F;
+ my $tmp;
+ sysopen(F, sprintf("/proc/bus/usb/%03d/%03d", $usb_kbd->{pci_bus}, $usb_kbd->{pci_device}), 0) and
+ sysseek F, 0x28, 0 and
+ sysread F, $tmp, 1 and
+ unpack("C", $tmp);
+}
+
sub whatUsbport() {
# The printer manufacturer and model names obtained with the usb_probe()
# function were very messy, once there was a lot of noise around the
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index 973c8999c..33df88586 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -95,7 +95,7 @@ sub selectLanguage {
if ($o->{keyboard_unsafe} || !$o->{keyboard}) {
$o->{keyboard_unsafe} = 1;
- $o->{keyboard} = keyboard::lang2keyboard($o->{lang});
+ $o->{keyboard} = keyboard::from_usb() || keyboard::lang2keyboard($o->{lang});
keyboard::setup($o->{keyboard}) if !$::live;
}
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index ffbc9ad82..4ac7778e7 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -197,14 +197,14 @@ For any question on this document, please contact MandrakeSoft S.A.
sub selectKeyboard {
my ($o, $clicked) = @_;
+ my $from_usb = keyboard::from_usb();
my $l = keyboard::lang2keyboards(lang::langs($o->{langs}));
- #- good guess, don't ask
+ #- good guess, don't ask ($o->{keyboard} already set)
return install_steps::selectKeyboard($o)
- if !$::expert && !$clicked && $l->[0][1] >= 90 && listlength(lang::langs($o->{langs})) == 1;
+ if !$::expert && !$clicked && ($from_usb || $l->[0][1] >= 90) && listlength(lang::langs($o->{langs})) == 1;
- my @best = map { $_->[0] } @$l;
- push @best, 'us_intl' if !member('us_intl', @best);
+ my @best = uniq(if_($from_usb, $from_usb), (map { $_->[0] } @$l), 'us_intl');
my $format = sub { translate(keyboard::keyboard2text($_[0])) };
my $other;
diff --git a/perl-install/keyboard.pm b/perl-install/keyboard.pm
index fe2e0f3b0..d99cfafd1 100644
--- a/perl-install/keyboard.pm
+++ b/perl-install/keyboard.pm
@@ -148,44 +148,13 @@ my %lang2keyboard =
# USB kbd table
# The numeric values are the bCountryCode field (5th byte) of HID descriptor
-my %usb2drakxkbd =
+my @usb2keyboard =
(
- 0x00 => undef, #- the keyboard don't tell its layout
-#-0x01 => 'ar',
- 0x02 => 'be',
-#-0x03 => 'ca', #- "Canadian bilingual" ??
- 0x04 => 'qc', #- Canadian French
- 0x05 => 'cz',
- 0x06 => 'dk',
- 0x07 => 'fi',
- 0x08 => 'fr',
- 0x09 => 'de',
- 0x0a => 'gr',
- 0x0b => 'il',
- 0x0c => 'hu',
- 0x0d => 'us_intl', #- "international ISO" ??
- 0x0e => 'it',
- 0x0f => 'jp',
- 0x10 => 'kr', #- Korean
- 0x11 => 'la',
- 0x12 => 'nl',
- 0x13 => 'no',
- 0x14 => 'ir',
- 0x15 => 'pl',
- 0x16 => 'pt',
- 0x17 => 'ru',
- 0x18 => 'sk',
- 0x19 => 'es',
- 0x1a => 'se',
- 0x1b => 'ch_de',
- 0x1c => 'ch_de',
- 0x1d => 'ch_de', #- USB spec says just "Swiss"
-#-0x1e => 'tw', # Taiwan
- 0x1f => 'tr_q',
- 0x20 => 'uk',
- 0x21 => 'us',
- 0x22 => 'yu',
- 0x23 => 'tr_f',
+ qw(SKIP ar_SKIP be ca_SKIP qc cz dk fi fr de gr il hu us_intl it jp),
+#- 0x10
+ qw(kr la nl no ir pl pt ru sk es se ch_de ch_de ch_de tw_SKIP tr_q),
+#- 0x20
+ qw(uk us yu tr_f),
#- higher codes not attribued as of 2002-02
);
@@ -370,14 +339,13 @@ sub lang2keyboard {
my $kb = lang2keyboards($l)->[0][0];
$keyboards{$kb} ? $kb : "us"; #- handle incorrect keyboard mapping to us.
}
-sub usb2drakxkbd {
- my ($cc) = @_;
- my $kb = $usb2drakxkbd{$cc};
-#- TODO: detect when undef is returned because it is actualy not defined
-#- ($cc == 0) and when it is because of an unknown/not listed number;
-#- in that last case it would be nice to display a dialog telling the
-#- user to report the number to us.
- $kb;
+
+sub from_usb {
+ return if $::noauto;
+ my ($usb_kbd) = detect_devices::usbKeyboards() or return;
+ my $country_code = detect_devices::usbKeyboard2country_code($usb_kbd) or return;
+ my $keyboard = $usb2keyboard[$country_code];
+ $keyboard !~ /SKIP/ && $keyboard;
}
sub load {
@@ -520,7 +488,8 @@ sub check {
$keyboards{$_->[0]} or $err->("invalid keyboard $_->[0] in $lang2keyboard{$lang} for $lang in \%lang2keyboard keyboard.pm");
}
}
- !$_ || $keyboards{$_} or $err->("invalid keyboard $_ in \%usb2drakxkbd keyboard.pm") foreach values %usb2drakxkbd;
+ /SKIP/ || $keyboards{$_} or $err->("invalid keyboard $_ in \@usb2keyboard keyboard.pm") foreach @usb2keyboard;
+ $usb2keyboard[0x21] eq 'us' or $err->("\@usb2keyboard is badly modified, 0x21 is not us keyboard");
my @xkb_groups = map { if_(/grp:(\S+)/, $1) } cat_('/usr/lib/X11/xkb/rules/xfree86.lst');
$err->("invalid xkb group toggle '$_' in \%kbdgrptoggle") foreach difference2([ keys %kbdgrptoggle ], \@xkb_groups);