Qt distinguish two keyboards? (One is actually RFID reader)
Asked Answered
B

2

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?

Bethanybethe answered 26/3, 2013 at 20:16 Comment(4)
As far as I know, there's no cross platform way to do this. Which OS are you targeting?Impound
Oh, sorry i forgot to mention that. Most likely it will be only windows.Bethanybethe
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.Thrips
I'm not win user ether :D LOLBethanybethe
H
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.

Hoarhound answered 2/6, 2015 at 9:37 Comment(0)
C
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

Continence answered 8/4, 2013 at 7:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.