Francois Gouget : testbot/SetWinLocale: Get the keyboard ids from the registry when possible.

Alexandre Julliard julliard at winehq.org
Sun Dec 26 10:40:17 CST 2021


Module: tools
Branch: master
Commit: 12422d941f2da8f9065c39b5e3e16a763fe3b668
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=12422d941f2da8f9065c39b5e3e16a763fe3b668

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Fri Dec 24 09:44:36 2021 +0100

testbot/SetWinLocale: Get the keyboard ids from the registry when possible.

The information is available on Windows 10.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/bin/SetWinLocale | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale
index 0355d41..e611966 100755
--- a/testbot/bin/SetWinLocale
+++ b/testbot/bin/SetWinLocale
@@ -376,7 +376,7 @@ while (@ARGV)
 }
 
 # Check and untaint parameters
-my ($KeyboardIds, $CountryId);
+my $CountryId;
 if (!defined $Usage)
 {
   if (!defined $OptHostName)
@@ -397,18 +397,6 @@ if (!defined $Usage)
   $OptLocale ||= $OptDefault;
   $OptSystem ||= $OptDefault;
   $OptMUI ||= $OptDefault;
-  $OptKeyboard ||= $OptDefault;
-  if (defined $OptKeyboard)
-  {
-    if (!exists $Keyboards{$OptKeyboard})
-    {
-      # intl.cpl automatically pick the appropriate keyboard but, unlike
-      # for Windows' initial installation, it does not make it the
-      # default since the system has a keyboard already.
-      Warning("unknown keyboard '$OptKeyboard'. Letting intl.cpl use its default.\n");
-    }
-    $KeyboardIds = $Keyboards{$OptKeyboard};
-  }
   if (!defined $OptCountry and defined $OptDefault and
       $OptDefault =~ /-([A-Z]{2})$/)
   {
@@ -561,7 +549,7 @@ sub GetWinSettings($)
     $Settings->{Country} = $Values->{Nation};
     $Settings->{CountryName} = $Values->{Name};
   }
-  if ($OptKeyboard or $All)
+  if (($OptKeyboard || $OptDefault) or $All)
   {
     $Settings->{InputMethod} = RegGetValue($HKCU_USER_PROFILE, "InputMethodOverride");
   }
@@ -660,9 +648,32 @@ sub GetLCID($)
   return $WinLCIDs{$Locale};
 }
 
+sub GetKeyboardIds($)
+{
+  my ($Locale) = @_;
+  return undef if (!$Locale);
+
+  GetWinKeyboardIds($Locale) if (!$WinKeyboardIds{$Locale});
+  return $WinKeyboardIds{$Locale};
+}
+
 my $LCIDLocale = GetLCID($OptLocale);
 my $LCIDSystem = GetLCID($OptSystem);
 
+my $KeyboardIds = GetKeyboardIds($OptKeyboard || $OptDefault);
+if (!$KeyboardIds and ($OptKeyboard or $OptDefault))
+{
+  if ($OptKeyboard)
+  {
+    FatalError("no known keyboard for the $OptKeyboard locale\n");
+  }
+  # intl.cpl automatically pick the appropriate keyboard but, unlike
+  # for Windows' initial installation, it does not make it the
+  # default since the system has a keyboard already.
+  Warning("no known keyboard for the $OptDefault locale. Letting intl.cpl use its default.\n");
+}
+$OptKeyboard ||= $OptDefault;
+
 
 #
 # Generate the intl.cpl configuration
@@ -824,9 +835,9 @@ if ($OptLocale)
   CheckSetting($Settings, "Locale", "0000$LCIDLocale", "for --locale $OptLocale", 1);
   CheckSetting($Settings, "LocaleName", $OptLocale, "for --locale $OptLocale");
 }
-if ($OptKeyboard)
+if ($KeyboardIds)
 {
-  CheckSetting($Settings, "InputMethod", $Keyboards{$OptKeyboard}->[0], "for --keyboard $OptKeyboard", 1);
+  CheckSetting($Settings, "InputMethod", $KeyboardIds->[0], "for --keyboard $OptKeyboard", 1);
 }
 if ($OptMUI)
 {




More information about the wine-cvs mailing list