Page 1 of 2

HID Enhancements

Posted: Mon Jul 16, 2007 3:57 pm
by kingtd
I've got a Logitech DiNovo set on a few computers here at home, and I'm using EventGhost instead of the standard HID service to drive the extra buttons on the keyboards. There are a few quirks about these types of devices though, and it would be awesome if EventGhost had some way to cope with them.

1. The Logitech devices appear 3-5 times each in the HID list. This is not an EventGhost problem - it also appears for everything else that can use HID devices directly. But they all have the same name in the list. Each time I add EventGhost to a computer, or uninstall/reinstall, or make other similar changes, EG gets confused about which one to talk to. I have to manually go in and select the proper device once to set it, and then it stays for a while but eventually gets confused again.

- When multiple HID devices with the same name appear, could they be registered with (1) (2) (3), etc so that automatic selection will work?

2. My bluetooth dongles are on hubs that are powered off at night to save electricity. When this happens I get a message like this:
12:09 AM Error reading HID device: Logitech Bluetooth Keyboard
Once this happens, I need to disable and re-enable the HID plugin in EG in order for it to work again.

-It would be great if there was some way to see that the list of plugged devices on the PC has changed in EG so that I can automate this process.

I'm sure these aren't ultra-high priority, but they take some of the automation out of my home automation systems. =) If you can squeeze in a way to fix them, that would be awesome.

Thanks for a great program.
-K

Re: HID Enhancements

Posted: Mon Jul 16, 2007 4:21 pm
by Bitmonster
Bartman is the inventor of the HID plugin. I'm sure he will say something about this soon.

@Bartman
Regarding point 2. I guess RegisterDeviceNotification would be the way to go. I should handle this from inside the System plugin, so you could attach your plugin with eg.Bind() to device arrival and device remove messages.

Re: HID Enhancements

Posted: Mon Jul 16, 2007 4:23 pm
by Bartman
1) Numbers could be added but they would only be automatically added and are not useful to identify it.
The devices have a vendor id and a product id. When connected windows assigns a rather cryptic but unique devicepath to the device which is used to talk to it. The devicepath however changes if you plug the device in another port but it is the only way to distinguish between multiple devices with the same vendor and product id. This is why you got problems on an other machine or if you change the port the device is connected to.
I haven't found anything about a guaranteed order in which the devices get listed by the OS.
My Desktop MX shows the same behaviour by the way.

2) This could be solved by supporting hot plug. Windows sends messages, when an arbitrary device gets connected. The plugin has to listen to the notifications and see if a selected device reappears.

Re: HID Enhancements

Posted: Mon Jul 16, 2007 4:49 pm
by Bitmonster
@Bartman
Wouldn't it be a possible assumption, that if the HID plugin is only configured to one device with the same vendor/product id (monitored by keeping a dict for all instances) and the system has only one device with this vendor/product id, that you can choose this device? It might conflict if more equal devices are used and single ones are not connected every time, but one could give a checkbox option like "assume only a single device of that type is connected at once" or something like that.

Re: HID Enhancements

Posted: Mon Jul 16, 2007 5:00 pm
by Bartman
If there is only one device per vendor/product id combination then there is no problem even if you plug it in another port (and therefore gets a different devicepath).
The Logitech keyboard however seems to have multiple device with the same product id. When the plugin finds multiple uniform devices it only uses them if there is a device which has the same devicepath as the time the device was selected.
I don't know how Logitech distinguishes between the parts of the device but they install filter driver if i remember correctly.

Re: HID Enhancements

Posted: Mon Jul 16, 2007 5:27 pm
by kingtd
There's no question that Logitech's software is as bad as their hardware is good. Part of the reason I use EventGhost is to avoid running Setpoint. =)

It doesn't seem like it matters which of the Logitech devices you hook to - they all generate the same result codes when a button is pushed. I tested this out this morning by choosing one of the "other" keyboards in the list and it still seemed to work fine.

So maybe something that just matches to the first device available with the proper description? Even if this was just a checkbox and no promises that it would work, I think it would do fine for Logitech users.

-K

Re: HID Enhancements

Posted: Tue Jul 17, 2007 4:25 pm
by Bartman
kingtd wrote:There's no question that Logitech's software is as bad as their hardware is good. Part of the reason I use EventGhost is to avoid running Setpoint. =)
This was one reason I looked into HID programming for me ;)
kingtd wrote:It doesn't seem like it matters which of the Logitech devices you hook to - they all generate the same result codes when a button is pushed. I tested this out this morning by choosing one of the "other" keyboards in the list and it still seemed to work fine.
Ok, with my Desktop MX you have to select the right device.
kingtd wrote:So maybe something that just matches to the first device available with the proper description? Even if this was just a checkbox and no promises that it would work, I think it would do fine for Logitech users.
This could be done. Do you get the "Multiple devices found. Don't know which to use." error message?

Re: HID Enhancements

Posted: Tue Jul 17, 2007 10:17 pm
by kingtd
Yep, exactly. Red message that says it couldn't figure out the right device. Right-click>Configure>OK, and it fixes it.

Re: HID Enhancements

Posted: Thu Jul 19, 2007 4:05 pm
by Bartman
I added a checkbox which tells the plugin to always use the first found HID device with matching vendor und product id.
I have attached the code below and it will be in the next beta.

Adding hot plug support will take a little bit longer.
@Bitmonster
any general support for plugins to the RegisterDeviceNotification message or should any plugin wait for that message itself?

Re: HID Enhancements

Posted: Thu Jul 19, 2007 4:23 pm
by Bitmonster
Bartman wrote:@Bitmonster
any general support for plugins to the RegisterDeviceNotification message or should any plugin wait for that message itself?
I think I will add the events System.DeviceRemoved and System.DeviceArrived for HID devices. Then you can use eg.Bind("System.DeviceAttached", self.MyCallback) in your __start__ method to get informed and eg.UnBind("System.DeviceAttached", self.MyCallback) in your __stop__ method. I hope I can add the GUID of the device as payload.

But I have to try it out. Maybe we have to use some other way (registering for a specific device for example).

Re: HID Enhancements

Posted: Thu Jul 19, 2007 4:28 pm
by Bartman
Bitmonster wrote:I hope I can add the GUID of the device as payload.
The only GUID I use is the GUID of the whole HID device class. So a general Device will be good enough.

Re: HID Enhancements

Posted: Thu Jul 19, 2007 5:21 pm
by Bitmonster
0.3.6.1041 has these events. It is not the GUID but this odd string. You know what I mean if you see it.

Re: HID Enhancements

Posted: Thu Jul 19, 2007 5:50 pm
by kingtd
Thanks guys, I've just rebuilt a desktop that has the logitech kit on it, so I'll try the new beta on it this evening.

Edit: I just tried it with no luck - I got the same error when I moved my XML file from one machine to another. These two systems are identically configured and have the same Logitech DiNovo kit plugged into the same USB port on the machine.

I've got the new checkbox labeled "Use first device found" checked. And after it fails, if I go into the list, select the first item and click OK, it works fine after that.

Is there anything I can send over to help debug?

-K

Re: HID Enhancements

Posted: Thu Jul 19, 2007 8:31 pm
by Bartman
You still get the multiple device error message after you selected the checkbox, saved the configuration and transfered it to another computer?
I tried with my Desktop MX and it seems to quite randomly choose one of the devices.

Re: HID Enhancements

Posted: Fri Jul 20, 2007 3:03 am
by kingtd
Well, I don't get the "multiple device" error at first anymore. I get "Error opening HID device: Logitech Bluetooth Mediapad". If I go in and open the configuration page, THEN the "multiple device" error pops up. But if I select the first one, and click OK, and save, it then works fine. Again, I can select any of the 5 "Bluetooth Mediapad"s in the list if I do it manually, so it shouldn't matter which one it's locking onto.

It dawned on me this afternoon that the HID plugin code is written in Python just like all of the others, so I'll take a look at it as well and see if I can sort out what's going wrong. =)

-K