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?
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.
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
Related
I can not find any documentation or code that describe what SIGEMT was originally invented for.
All the code I can find (e.g. with debian code search) seems to just handle it like all the other signals that terminate the process or just map the signal number to a name (or name to number).
From the short descriptions it looks like this is used in some kind or instruction emulation that has a kernel and a user space part. Is there any software that actually uses this?
I could find code in the linux kernel that might emit the signal, but it's not documented either.
I would like to know Why we need to compile the program of progress 4GL? Really what is happening behind there? Why we are getting .r file after compiled the program? When we check the syntax if its correct then we will get one message box 'Syntax is correct' how its finding the errors and showing the messages.Any explanations welcome and appreciated.
Benefits of compiled r-code include:
Syntax checking
Faster execution (r-code executes faster)
Security (r-code is not "human readable" and tampering with it will likely be noticed)
Licensing (r-code runtime licenses are much less expensive)
For "how its finding the errors and showing the messages" -- at a high level it is like any compiler. It evaluates the provided source against a syntax tree and lets you know when you violate the rules. Compiler design and construction is a fairly advanced topic that probably isn't going to fit into a simple SO question -- but if you had something more specific that could stand on its own as a question someone might be able to help.
The short answer is that when you compile, you're translating your program to a language the machine understands. You're asking two different questions here, so let me give you a simple answer to the first: you don't NEED to compile if you're the only one using the program, for example. But in order to have your program optimized (since it's already at the machine language level) and guarantee no one is messing with your logic, we compile the code and usually don't allow regular users to access the source code.
The second question, how does the syntax checker work, I believe it would be better for you to Google and choose some articles to read about compilers. They're complex, but in a nutshell what they do is take what Progress expects as full, operational commands, and compare to what you do. For example, if you do a
Find first customer where customer.active = yes no-error.
Progress will check if customer is a table, if customer.active is a field in that table, if it's the logical type, since you are filtering if it is yes, and if your whole conditions can be translated to one single true or false Boolean value. It goes on to check if you specified a lock (and default to shared if you haven't, like in my example, which is a no-no, by the way), what happens if there are multiple records (since I said first, then get just the first one) and finally what happens if it fails. If you check the find statement, there are more options to customize it, and the compiler will simply compare your use of the statement to what Progress can have for it. And collect all errors if it can't. That's why sometimes compilers will give you generic messages. Since they don't know what you're trying to do, all they can do is tell you what's basically wrong with what you wrote.
Hope this helps you understand.
I've a friend who wants to learn web programming. He's a physically handicapped person. Actually he uses computer with a trackball and he can press keys one by one and only with one hand. So, I think that his greatest problem will be trying to write special characters that require the use of two hands (such as >,!,#, etc.). First I thought in Visual Studio (Intelissense can be a great help) but does anybody know about tools that can make even easier programming?
I know is an odd question but I'll really appreciate if someone could give me a hand here :)
Thanks in advance
Several companies make programmable keyboards, keypads and footswitches that would make for easy access to those characters normally accessed with the shift key. Some are used as supplements to a standard keyboard, others replace the standard keyboard.
They're designed so you can apply your own labels to the keys according to the functions you assign. Some have software that lets you assign multi-step macros to single keys.
Lots of examples of such products here: http://www.fentek-ind.com/program.htm (just the first page I found with Google)
Another feature worth being aware of is Sticky Keys - on Windows, hit SHIFT 5 times in a row fairly rapidly to turn it on. When Sticky Keys is on, modifier keys like SHIFT, CTRL, and ALT 'stick' until the next key is pressed: so if you want to type the ! character, you can do so by pressing SHIFT and then pressing 1, without having to press both at the same time.
(Note that Sticky Keys turns itself off automatically if you do hold down SHIFT and another key at the same time - but you can turn this feature off so that it stays on all the time via the control panel.)
Not sure how useful speech-to-text will be; it tends to be fine-tuned for English words that you'd find in a dictionary, I'm not sure that it would cope very well with either the heavy use of symbols or the use of non-english text found in most languages (eg printf!).
This answer may seem a bit late, but I hope it will be usefull to many:
A very good program to know, allowing one to input with only 2 movement (be it with a mouse, a joystick, a finger, a toe, the head, eyeballs, etc), and which could allow one to type quite fast once used to it : dasher (wikipedia page), that you can find on : dasher official site
It's surprisingly easy to learn and get into : you "aim" for the next letter, and it grows while going toward your pointer. Once you enter it, on the far side you see the next letters appear, with the most probable ones much bigger than the others (ex: "e" is usually the biggest for the first letter, but once in it, "n" will be quite big as it's a probable next letter. When you have crossed through "ente", "r" will be very big and easy/fast to aim. If you "exit" (by going above or below or by going back) the current letter, it deletes it and therefore you can select another one to replace it. See the wikipedia page for a nice animation showing how it's done.
You can have Dasher use (and train on) specialized dictionnaries to have the most useful letters bigger and therefore easier to "type" (usefull if you intend to do programming, for example. By default the dictionnary is to write letters/mails/etc)
another quick question, I want to make simple console based game, nothing too fancy, just to have some weekend project to get more familiar with C. Basically I want to make tetris, but I end up with one problem:
How to let the game engine go, and in the same time wait for input? Obviously cin or scanf is useless for me.
You're looking for a library such as ncurses.
Many Rogue-like games are written using ncurses or similar.
There's two ways to do it:
The first is to run two threads; one waits for input and updates state accordingly while the other runs the game.
The other (more common in game development) way is to write the game as one big loop that executes many times a second, updating game state, redrawing the screen, and checking for input.
But instead of blocking when you get key input, you check for the presence of pending keypresses, and if nothing has happened, you just continue through your loop. If you have multiple input sources (keyboard, network, etc.) they all get put there in the loop, checking one after another.
Yes, it's called polling. No, it's not efficient. But high-end games are usually all about pulling the maximum performance and framerates out of the computer, not running cool.
For added efficiency, you can optionally block with a timeout -- saying "wait for a keypress, but no longer than 300 milliseconds" so you can continue on with your loop.
select() comes to mind, but there are other ways of waiting or checking for input as well.
You could work out how to change stdin to non-blocking, which would enable you to write something like tetris, but the game might be more directly expressed in an event-driven paradigm. Maybe it's a good excuse to learn windows programming.
Anyway, if you want to go the console route, if you are using the microsoft compiler, then you should have kbhit() available (via conio.h) which can tell you whether a call to fgetc on stdin would block.
Actually should mention that the MinGW gcc compiler 3.4.5 also supports kbhit().
We have a device that has an analog camera. We have a card that samples it and digitizes it. This is all done in directx. At this point in time, replacing hardware is not an option, but we need to code such that we can see this video feed real-time regardless of any hardware or underlying operating system changes occur in the future.
Along this line, we've chosen Qt to implement a GUI to view this camera feed. However, if we move to a linux or other embedded platform in the future and change other hardware (including the physical device where the camera/video sampler lives), we will need to change the camera display software as well, and that's going to be a pain because we need to integrate it into our GUI.
What i proposed was migrating to a more abstract model where data is sent over a socket to the GUI and the video is displayed live after being parsed from the socket stream.
First, is this a good idea or a bad idea?
Secondly, how would you implement such a thing? How do the video samplers usually give usable output? How can I push this output over a socket? Once I am on the receiving end parsing the output, how do I know what to do with the output (as in how to get the output to render)? The only thing I can think of would be to write each sample to a file and then to display the contents of the file every time a new sample arrives. This seems like an inefficient solution to me, if it would work at all.
How do you recommend I handle this? Are there any cross-platform libraries available for such a thing?
Thank you.
edit: i am willing to accept suggestions of something different rather than what is listed above.
Have you looked at QVision? It is a Qt based framework for managing video and video processing. You don't need the processing, but I think it will do what you want.
Anything that duplicates the video stream is going to cost you in performance, especially in an embedded space. In most situations for video, I think you're better off trying to use local hardware acceleration to blast the video directly to the screen. With some proper encapsulation, you should be able to use Qt for the GUI surrounding the video, and have a class that is platform specific that you use to control the actual video drawing to the screen (where to draw, and how big, etc.).
Edit:
You may also want to look at the Phonon library. I haven't looked at it much, but it appears to support showing video that may be acquired from a range of different sources.