2

I would like to create an external pushbutton to use with one of my applications. My question does not focus on the hardware itself (that's why I'm asking it here), but on the software/communication side. What would be the best and most straightforward way to do? A good speed is important, so it should not differ too much from the latency of a normal keyboard.

The following solutions come to my mind:

  • let the hardware be a modified keyboard, or at least it should be recognized by the system as a keyboard. Pro: no extra work from software-side required. Con: what if I need to use a normal keyboard as well? Ok, not so bad, with today's USB keyboards...
  • Communicate through serial port. This would be the most straightforward approach, or better yet, it would have been like 10 years ago. Now most computers don't even have one, of course, there are plenty of serial-usb converters around.
  • Let it be a standard USB device. I don't like the idea, with installing drivers, and having to care about different OS, etc.

Does anything better come to your minds?

vsz
  • 4,811
  • 7
  • 41
  • 78

1 Answers1

1

The USB keyboard class HID seems the best to me. You can use different scancodes than standard keyboards, or less often used like those used for app-specific buttons on some keyboards. (Note that current X.Org drivers are still limited to scancodes < 256.)

Probably it's not hard to find a reference HID keyboard implementation for your device, too.

Serial ports are rare in modern PCs and especially notebooks; even if the system board has RS232 circuitry it has no external connector.

Writing a custom driver for the PC side means much more work and more space for bugs. You're far safer using a time-proven standard driver.

9000
  • 39,899
  • 9
  • 66
  • 104