Detecting Keyboard Presence

i have a USB keyboard & its seems to be working fine at bringing in characters…however at some points in the program I need to query to see if a keyboard is actually present (right now I just blindly assume it is). Is there a way to tell? I do use a connected event which does some things when the keyboard is initially connected, but i’m talikng about much later. I suppose I could just set a flag, but seems like there should be some sort of query available at any point.

I did try GetDevices, but it just returns:

GHIElectronics.NETMF.USBHost.USBH_Device[]

Which doesn’t really show a keyboard is plugged in.

isn’t that just a list of devices connected?

Use a disconnect event as well as a connected event and handle it in your app, or iterate thru enumerated devices and figure out what one you’re interested in and deal with it not being there

Thanks, yeah, I had just realized this was telling me it was providing a list (of length 1, via debug)…so I printed out the only item in the getDevices list:

GHIElectronics.NETMF.USBHost.USBH_Device …not much better!! Seems a bit scarce on descriptive information…

so yes, I’ll just have to keep my own flag or state internally.

go to code site and look for a USB enumerator. That will help you.

do you mean this?

http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/f06d95f7-1a67-64c0-ea30-3408e8f9e019.htm

I went to the code wiki but didn’t find anything under enumeration or enumerator

http://code.tinyclr.com/project/164/usb-discovery-helper/

Thanks, it appers these are the main lines, the rest is conversion to text

   controller = new USBH_RawDevice(device);            
        // Get descriptors 
           USBH_Descriptors.Configuration cd = controller.GetConfigurationDescriptors(0);