Thursday, August 27, 2009

How to check a hardware keyboard in Windows Mobile

Windows Mobile keeps a status of hardware keyboard in the registry.


A software keyboard can pop-up  if a device doesn't have a hardware keyboard.
However, in the case that the device has a slide-out keyboard, it depends on the status of the slide-out keyboard.

For example:

1) if the keyboard does not slide out, the HasKeyboard value has to be "0"
2) if the keyboard slides out, the HasKeyboard value has to be "1"

However, the above registry value, HasKeyboard, always returns 1 because it doesn't consider the status of slide-out keyboard.

Windows Mobile doesn't provide a standard API for detecting a status of slide-out keyboard, so each device maker uses its own hidden or public API.

In the case of Samsung Windows Mobile devices, they provide Windows Mobile SDK through the Samsung Mobile Innovator site. Therefore, we can get a state of the slide-out keyboard.

However, HTC doesn't provide any document on how to use device APIs.

As a result, some hackers had tried to find out how to use hidden APIs for using hardware features of HTC devices, but there is no API about slide-out keyboard.

Fennec has a bug related with detecting the state of slide-out keyboard.

Actually, this bug seemed easy to solve. At least, it was easy for my i780, but my first patch couldn't support HTC touch pro which has a side-out keyboard.

I tried to check the most of registry values if there is any change.
Finally, I found the value from  HKEY_LOCAL_MACHINE\System\GDI\Rotation\Slidekey

My patch was applied to the mainline of Mozilla and then this cumbersome bug has been fixed.

I am happy to contribute my patch to Mozilla.