Bug 1236058 - recognize bluetooth keyboard devices when determining whether to show an on-screen keyboard, r=masayuki,f=jaws
--- 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;
}