Get the keyboard presence

I am creating a touch enabled app which switches to kiosk, full screen “Metro” mode when run on a tablet without a keyboard.

In order to detect the presence of the keyboard, I look into HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\kbdclass\Enum
for a key that starts by “HID\VID” or “ACPI” which are the values I found to show when the keyboard is plugged respectively in my desktop PC and in the Asus Transformer Book. VMWare reports ACPI on a Mac with the BlueTooth keyboard as well.

I tried to look the Internet to see if there are still other types of keyboards I should look for, but information is not very clear, beyond the fact that HID is the most common. If you could run the attached project and see what it reports, especially if there is anything other than HID\VID or ACPI, it would help me greatly adequately manage that keyboard presence detection. TIA.

isKeyboard.xojo_binary_project

I tried your code on Win.8.1 with USB keboard - reported HID OK…

and on Win.XP with PS/2 keyboard, and it reported, what looks OK to me…

Root\RDP_KBD\0000
2
2
ACPI\PNP0303\4&2c575acb&0

…also, a while ago I did some windows API work for device discovery and the code is at…

http://www.cmas-net.co.uk/rslug/Eg-5-Devicelist.rbp

In the UI, uncheck the USB-only box and you should just get a list of lots of devices, including keyboards, in the listbox.
( This code was primarily done for walking the USB trees, hence it defaulting to just looking there ).

To get just keyboards into the device array, just edit out the unwanted calls in the refresh device method called from form->open.

[quote=173387:@Chris Carter]I tried your code on Win.8.1 with USB keboard - reported HID OK…

and on Win.XP with PS/2 keyboard, and it reported, what looks OK to me…

Root\RDP_KBD\0000
2
2
ACPI\PNP0303\4&2c575acb&0

…also, a while ago I did some windows API work for device discovery and the code is at…

http://www.cmas-net.co.uk/rslug/Eg-5-Devicelist.rbp

In the UI, uncheck the USB-only box and you should just get a list of lots of devices, including keyboards, in the listbox.
( This code was primarily done for walking the USB trees, hence it defaulting to just looking there ).

To get just keyboards into the device array, just edit out the unwanted calls in the refresh device method called from form->open.[/quote]

This corroborates the results I got. Under XP, as well as in the tablet under Windows 8.1, the system reports a keyboard, even when a physical one is not plugged in.

What I am most concerned about is if there is a keyboard type I do not know about.

I downloaded DeviceList, but it reports a lot of errors, so I guess it is probably missing some external modules or plug ins.

Thank you.

It was a coding stupidity, which older versions of RS / Xojo ignored - now fixed ( well it works here ! )
The link should now give you the new version.

[quote=173411:@Chris Carter]It was a coding stupidity, which older versions of RS / Xojo ignored - now fixed ( well it works here ! )
The link should now give you the new version.[/quote]

Indeed most of the errors are gone, but it seems all the constants (or so I suppose) in basDevMenu are missing. All these lines show the basDevEnum.WinAPIxxx arguments as “Item does not exist”.

[code] call basDevEnum.gfintScanDevices( “Ports”, basDevEnum.WinAPI_GUID_DEVCLASS_PORTS )
call basDevEnum.gfintScanDevices( “Mice”, basDevEnum.WinAPI_GUID_DEVINTERFACE_MOUSE )
call basDevEnum.gfintScanDevices( “Keyboards”, basDevEnum.WinAPI_GUID_DEVINTERFACE_KEYBOARD )
call basDevEnum.gfintScanDevices( “Human Interface Devices”, basDevEnum.WinAPI_GUID_DEVINTERFACE_HID )
//x call basDevEnum.gfintScanDevices( “Storage”, basDevEnum.WinAPI_GUID_DEVINTERFACE_STORAGEPORT )
//x call basDevEnum.gfintScanDevices( “Network”, basDevEnum.WinAPI_GUID_DEVINTERFACE_NET )
call basDevEnum.gfintScanDevices( “Volumes”, basDevEnum.WinAPI_GUID_DEVINTERFACE_VOLUME )
call basDevEnum.gfintScanDevices( “Disks”, basDevEnum.WinAPI_GUID_DEVINTERFACE_DISK )
end if

call basDevEnum.gfintScanDevices( “USB”, basDevEnum.WinAPI_GUID_DEVINTERFACE_HUBCONTROLLER )
[/code]

Sorry: I’m having one of those days :frowning: … Corrected code is now uploaded.

The silly issue was that those basDevEnum.WinAPI... constants are not in that module at all, but are in another one - so quite why this worked under older versions despite this error is a bit strange !

[quote=173427:@Chris Carter]Sorry: I’m having one of those days :frowning: … Corrected code is now uploaded.

The silly issue was that those basDevEnum.WinAPI... constants are not in that module at all, but are in another one - so quite why this worked under older versions despite this error is a bit strange ![/quote]

Chris, I am sorry, but the constants are still missing…

Odd: I just downloaded the file from the web to my VM with Xojo2015r1on it and works OK for me…

Those constants are in basWinAPI_DEFS. - so the kind of line you see in msubRefrrshList
is like:-
call basDevEnum.gfintScanDevices( “Keyboards”, basWinAPI_DEFS.WinAPI_GUID_DEVINTERFACE_KEYBOARD )

[quote=173430:@Chris Carter]Odd: I just downloaded the file from the web to my VM with Xojo2015r1on it and works OK for me…

Those constants are in basWinAPI_DEFS. - so the kind of line you see in msubRefrrshList
is like:-
call basDevEnum.gfintScanDevices( “Keyboards”, basWinAPI_DEFS.WinAPI_GUID_DEVINTERFACE_KEYBOARD )[/quote]

The issue was that they were called as basDevEnum.WinAPI_GUID_DEVCLASS_PORTS instead of basWinAPI_DEFS.WinAPI_GUID_DEVCLASS_PORTS. I have corrected that and now the program runs.

Thank you :slight_smile: