Bug 1236058 - recognize bluetooth keyboard devices when determining whether to show an on-screen keyboard, r=masayuki,f=jaws draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 18 Jan 2016 13:07:55 +0000
changeset 324310 17f3303f8b351f82a920def8a8db6443830aa58c
parent 324309 3b2ed8b2afdcb24a033e8426fe39e2f3d7a0268d
child 513358 c8c37518a7e15dbf2c5eff10b002ad3c6d17b8f4
push id9881
push usergijskruitbosch@gmail.com
push dateFri, 22 Jan 2016 13:08:10 +0000
reviewersmasayuki
bugs1236058
milestone46.0a1
Bug 1236058 - recognize bluetooth keyboard devices when determining whether to show an on-screen keyboard, r=masayuki,f=jaws
widget/windows/WinIMEHandler.cpp
--- a/widget/windows/WinIMEHandler.cpp
+++ b/widget/windows/WinIMEHandler.cpp
@@ -665,17 +665,17 @@ IMEHandler::IsKeyboardPresentOnSlate()
   //    or a normal laptop and assume that there is a keyboard.
 
   // 2. If the device supports auto rotation, then we get its platform role
   //    and check the system metric SM_CONVERTIBLESLATEMODE to see if it is
   //    being used in slate mode. If yes then we return false here to ensure
   //    that the OSK is displayed.
 
   // 3. If step 1 and 2 fail then we check attached keyboards and return true
-  //    if we find ACPI\* or HID\VID* keyboards.
+  //    if we find ACPI\*, HID\VID* or bluetooth keyboards.
 
   typedef BOOL (WINAPI* GetAutoRotationState)(PAR_STATE state);
   GetAutoRotationState get_rotation_state =
     reinterpret_cast<GetAutoRotationState>(::GetProcAddress(
       ::GetModuleHandleW(L"user32.dll"), "GetAutoRotationState"));
 
   if (get_rotation_state) {
     AR_STATE auto_rotation_state = AR_ENABLED;
@@ -758,22 +758,28 @@ IMEHandler::IsKeyboardPresentOnSlate()
 
     // Get the device ID.
     wchar_t device_id[MAX_DEVICE_ID_LEN];
     CONFIGRET status = ::CM_Get_Device_ID(device_info_data.DevInst,
                                           device_id,
                                           MAX_DEVICE_ID_LEN,
                                           0);
     if (status == CR_SUCCESS) {
+      static const std::wstring BT_HID_DEVICE = L"HID\\{00001124";
+      static const std::wstring BT_HOGP_DEVICE = L"HID\\{00001812";
       // To reduce the scope of the hack we only look for ACPI and HID\\VID
       // prefixes in the keyboard device ids.
       if (IMEHandler::WStringStartsWithCaseInsensitive(device_id,
                                                        L"ACPI") ||
           IMEHandler::WStringStartsWithCaseInsensitive(device_id,
-                                                       L"HID\\VID")) {
+                                                       L"HID\\VID") ||
+          IMEHandler::WStringStartsWithCaseInsensitive(device_id,
+                                                       BT_HID_DEVICE) ||
+          IMEHandler::WStringStartsWithCaseInsensitive(device_id,
+                                                       BT_HOGP_DEVICE)) {
         // The heuristic we are using is to check the count of keyboards and
         // return true if the API's report one or more keyboards. Please note
         // that this will break for non keyboard devices which expose a
         // keyboard PDO.
         Preferences::SetString(kOskDebugReason,
                                L"IKPOS: Keyboard presence confirmed.");
         return true;
       }