USB Keyboard Detect in WinCE 5.0

D

DrewCE

I have a Windows CE 5.0 based device. We have a touchscreen, joystick, and
hardware buttons. The joystick and hardware buttons are mapped to mouse
event and keyboard events respectively, using a custom driver.

We sometimes have a USB Keyboard attached and need to detect that case to
prevent he SIP from displaying.

I've searched and tried several solutions, but nothing has fit the bill yet.
Looking in the registry doesn't seem to work as there is no
"Software\Microsoft\Shell\HasKeyboard" key. Also, GetKeyboardStatus()
always returns 3 (has keyboard).

I'm guessing that I'm not the first person to need this and am hoping
someone can't point me in the right direction.

Thanks,

Drew
 
P

Paul G. Tobey [eMVP]

Does the SIP hide itself as soon as you press a key on the hardware
keyboard? I think that the OS should do that automatically. If so, good
enough?

Paul T.
 
D

DrewCE

Unfortunately, no. Our requirement is to only display the SIP if the
keyboard is not present.

Drew

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
 
P

Paul G. Tobey [eMVP]

You might try some of the bits hinted at by "USB Function Controller Driver
Bus Interface" in the Platform Builder help for CE5. Generally, though,
there's no interface to see if a given HID device is there or to talk to HID
devices, as there would be on the desktop.

Paul T.

DrewCE said:
Unfortunately, no. Our requirement is to only display the SIP if the
keyboard is not present.

Drew

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
Does the SIP hide itself as soon as you press a key on the hardware
keyboard? I think that the OS should do that automatically. If so, good
enough?

Paul T.
 
D

DrewCE

Thanks for the help.

Just to follow up a bit. I was able to partially acheive my goal.

I'm able to poll through the active drivers in the registry. If a keyboard
driver is present, I can assume that a keyboard is attached.

Here is the code I created:

/// <summary>

/// Polls the registry to see if any keyboard drivers are active. If yes,

/// then it assumes that there is a keyboard attached.

/// </summary>

/// <returns><see cref="true"/> if keyboard was detected.</returns>

public static bool IsPresent()

{

bool isPresent = false;

RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"Drivers\Active");

string[] activeDrivers = rk.GetSubKeyNames();

foreach (string subKeyName in activeDrivers)

{

RegistryKey subKey = rk.OpenSubKey(subKeyName);

try

{

string val = subKey.GetValue("key") as string;

if (val is string && val.EndsWith("Keyboard"))

{

isPresent = true;

break;

}

}

catch { } //no action

}

return isPresent;

}


No warranties implied,

Drew

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:u%[email protected]...
You might try some of the bits hinted at by "USB Function Controller
Driver Bus Interface" in the Platform Builder help for CE5. Generally,
though, there's no interface to see if a given HID device is there or to
talk to HID devices, as there would be on the desktop.

Paul T.

DrewCE said:
Unfortunately, no. Our requirement is to only display the SIP if the
keyboard is not present.

Drew

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:[email protected]...
Does the SIP hide itself as soon as you press a key on the hardware
keyboard? I think that the OS should do that automatically. If so,
good enough?

Paul T.

I have a Windows CE 5.0 based device. We have a touchscreen, joystick,
and hardware buttons. The joystick and hardware buttons are mapped to
mouse event and keyboard events respectively, using a custom driver.

We sometimes have a USB Keyboard attached and need to detect that case
to prevent he SIP from displaying.

I've searched and tried several solutions, but nothing has fit the bill
yet. Looking in the registry doesn't seem to work as there is no
"Software\Microsoft\Shell\HasKeyboard" key. Also, GetKeyboardStatus()
always returns 3 (has keyboard).

I'm guessing that I'm not the first person to need this and am hoping
someone can't point me in the right direction.

Thanks,

Drew
 
A

Albert Torras

Anyone knows where the XP equivalent keys are located?

I am not able to find them!

Thanks in advance
Albert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top