6

I have simple RFID reader that actually behaves as keyboard and returns read values with return character at the end.

I want my application to listen only single (distinct) keyboard device (which i will choose/distinguish somehow) and to get the read value for me no meter where the focus is on the form/application.

Application is written with Qt C++

I'm wondering if this is possible and how?

  • As far as I know, there's no cross platform way to do this. Which OS are you targeting? – Karl Bielefeldt Mar 26 '13 at 20:28
  • Oh, sorry i forgot to mention that. Most likely it will be only windows. –  Mar 26 '13 at 20:48
  • 1
    I'm not a Windows user, so this isn't a complete answer -- if you know how to distinguish the RFID from the actual keyboard by means of Windows MSG events, then QCoreApplication::winEventFilter (or, in Qt 5, QCoreApplication::installNativeEventFilter) might help. – peppe Apr 03 '13 at 19:19
  • I'm not win user ether :D LOL –  Apr 03 '13 at 20:40

2 Answers2

1

Don't know if this helps, but we had a similar challenge of detecting input from a barcode scanner. The scanner just "typed" in some digits really fast; some scanners end it with a control character but since it's not universal we couldn't even rely on that.

I noticed that a QEvent::KeyboardLayoutChange would fire when the barcode scanner started its input, but I'm not sure if this applies in all the possible scenarios - but you might want to check for that.

We ended up installing an application-wide event filter (QApplication::installEventFilter) that checks for keystrokes (QEvent::ShortcutOverride or QEvent::KeyPress) and based on criteria such as contiguous digit sequence, very short time interval, etc. decides that it was a barcode input. It has obvious pitfalls, but if you need a very general solution you might be interested in something similar. Also, if the RFID input always returns a control character this might simplify this approach quite a bit.

Iosif Spulber
  • 405
  • 3
  • 11
0

This is possible for windows OS with help of WinAPI. I have never use QT so I dont know if some wrappers exists in QT classes for that purposes. You should use raw input. Check this link for quick reference: http://msdn.microsoft.com/en-us/library/windows/desktop/ms645536(v=vs.85).aspx (there is example there under Using Raw Input section

also take a look at this project http://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard I understand its writen on C#, but it may be helpful

Anton Semenov
  • 6,227
  • 5
  • 41
  • 69