12

I have written a small program in C# 2010 which can split input from different keyboards by making an array of devices using, in part, the following:


--This code works fine for non-unified keyboards--

InputDevice id;
NumberOfKeyboards = id.EnumerateDevices();
id = new InputDevice( Handle );
id.KeyPressed += new InputDevice.DeviceEventHandler( m_KeyPressed );
private void m_KeyPressed( object sender, InputDevice.KeyControlEventArgs e ) {
  lbDescription.Text = e.Keyboard.Name;
  // e.Keyboard.* has many useful strings, none work for me anymore.
}


Very happy with this, I ran out and bought 4 Logitech K230 keyboards which use the Unifying receiver. Sadly, all the keyboard data is now multiplexed and shows up in my code as a single keyboard!

How can I identify which "unified" keyboard the input is coming from? Ideally in C#, but I suppose I am willing to look at other languages if solutions exist.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
cdehaan
  • 394
  • 5
  • 10
  • I have seen a Linux driver that breaks the "unified" input apart so the HID layer can see different keyboards (and treat them differently.) This made me optimistic a Windows solution should exist too. – cdehaan Nov 12 '12 at 00:25
  • Sorry to add so many comments to my own question, but to anyone interested, this is the project where my original input splitting came from: http://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard – cdehaan Nov 12 '12 at 00:46
  • The USB dongle is a USB HID device, so all that traffic that you are seeing is basically generic HID traffic that has been generated by the USB dongle. Unless the specs have anything on the traffic that is generated holding metadata in them. I don't think its possible. You may be able to use [USBlyzer](http://www.usblyzer.com/download.htm) to sniff the usb traffic. If you can interface with the USB dongle you may be able to request information from it. – jduncanator Nov 12 '12 at 08:05
  • I am a little out of my area looking at Linux driver updates, but this is the article explaining that different keyboards, connected to the same unifying USB dongle, can be uniquely presented to the HID Layer. This gives me hope a solution exists in Windows. http://lwn.net/Articles/458418/ Also, this weekend I will try to capture and read the USB data, thanks for the link to that tool. – cdehaan Nov 13 '12 at 03:59
  • After a bit of research, the Logitech USB Dongle does send some data between itself and the logitech program to retrieve device names and information. This may be limited to connected devices though, and probably isn't sent on a Keypress by keypress basis. – jduncanator Nov 13 '12 at 04:59
  • I appreciate your research, but sadly if it isn't available for a particular keypress event, it won't be useful to split the input during runtime. Being limited to currently connected keyboards is no problem. They will all be connected from the start (and error catching does a re-scan if a new keyboard is heard.) – cdehaan Nov 14 '12 at 10:06
  • You may be able to write your own driver but that is a massive job. Maybe email Logitech for some help? – jduncanator Nov 16 '12 at 00:50

1 Answers1

1

I don't have unifying keyboard, but check if you can see multiple keyboards in Windows devices. Then you could try this http://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard and check output.

Arci
  • 588
  • 7
  • 20
  • 1
    Thank you for the comment, but unfortunately that link is what I originally used as a starting point (and was given in my second comment.) It worked fine for non-unified keyboard, but was unable to distinguish unified keyboards. – cdehaan Nov 17 '12 at 15:12