[tools 2/2] testbot/SetWinLocale: Get the keyboard ids from the registry when possible.

Francois Gouget fgouget at codeweavers.com
Fri Dec 24 02:44:36 CST 2021


The information is available on Windows 10.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/bin/SetWinLocale | 43 +++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale
index 135c7b9b48..e7ae3c0ced 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)
 {
-- 
2.30.2



More information about the wine-devel mailing list