A couple years ago, I had to implement touch features in an application, but my company was still using Scientific Linux 6.4, which did not natively support touch, not to mention multi-touch. Fortunately, I was able to upgrade the kernel to 2.6.32-754, which gave me access to multi-touch events, and while they were not natively handled, I was able to write my own "driver" in the application that would read the /dev/input/event file and use the input_event class in the kernel to capture touch events and translate them to application behavior.
Now, two years later, we're finally moving on to RedHat 8, and obviously there's now native touch support. Pretty much all my code is still required as it's highly specific to this application, and I don't see much point in re-writing anything. However, because touch events are now natively recognized, I'm seeing some issues where touch press events will be registered twice -- once from the OS, and once from my driver. The touch press events from my driver are required because they're being tracked and handled by my driver.
Is there a way I can update my driver to ignore the OS native touch events that are interfering with my driver without affecting my driver's operation? This is especially prevalent with the on-screen keyboard which is causing it to type the same character twice when the button is pressed.
The simple answer to this problem seemed to be to use xinput to disable the touchscreen device input, which gave me the behavior I wanted. The reason I don't want to re-write the code handling it is because it would be a lot of effort and time for no difference in behavior or performance. I can't just use the native touch because the UI doesn't just use single touch actions, it uses custom gestures that are interpreted by my driver.
Related
We have a kiosk system running on Win7 with application written using VS2010 C++. As with kiosk systems, the system is locked down so that the user cannot access the windows system itself, but must do all work using our application.
Unfortunately, we have had one issue so far where a windows system-level dialog has popped up requiring a response. It popped up behind the GUI of our application, so that the user didn't even know it was there, and since it was modal, it blocked further use of the system.
These dialog was the well-known "system needs to be restored" dialog. Since this is a kiosk system, we are wanting to find a way to handle these types of situations in an automated fashion.
I have looked into setting a low level hook using SetWinEventHook() to capture EVENT_SYSTEM_ALERT events. The first problem of course is that I am not sure how to test this, since these events are not common. The second problem is that I am not sure how to handle the information, since there could be a number of different system alert events that pop up modal windows, and so automating a response might get us into more trouble than we might foresee.
My real question here is, if you were in this exact situation, what would be your line of attack. I am concerned I may be going about this the wrong way by trying to capture alerts and somehow automate a response to the resulting system alert window.
Any clues as to a useful direction here would be much appreciated.
I am writing an C++ Application and have to read if an arrow key is pressed or not.
I only found some function that are only working on Windows.
You have such problem because you just ask the wrong question. If you application is a command line tool and is accessible from a terminal, than it's just impossible to know which keys are pressed at the moment because the terminal can be far away from the machine where your application runs and which is more important, there is no reason for terminal to send you the arrow key presses because terminal can use them for text navigation.
So you may search how to make the terminal to send you key presses. Not every terminal will support it, but, I think, most of modern terminals in modern OS do.
If you has a gui application that is for running locally and assuming that you control it from the keyboard that is plugged in. Than you should search for the documentation for your gui toolkit. (Qt, wxWidgets, raw xorg, windows API, etc.)
So there are just no native C++ solution for this problem because you question just has no sense in many situations.
So you can use some console library like ncurses or gui toolkit like Qt or search for a native solution in your particular situation, but don't expect this last way will work without any additional code on other machines.
Or just search for other libraries that can allow you to do it.
As you say you only found material for Windows, I assume you are looking for a Linux-Unix way. Old dinosaurs like me remember the time when we only had true consoles (only a keyboard and a 80x25 display). And in these early times existed low-level libraries to interpret keypad transmitted keys and position cursor on screen on almost any terminal, and higher level ones to use the screen as a (text only) GUI.
You should look for curses or ncurses for high level libraries, and terminfo for the low-level capabilities.
I'm trying to learn the basics of the windows API by making a program that, when the PRINTSCREEN button is pressed, will save a .jpeg and instantly upload it to imgur. Currently, while I'm playing most games or just browsing the desktop, this program works fine.
Some games, however, seem to block my ability to use this hotkey. (Dark Souls 2 specifically does this.) I currently use
RegisterHotKey(NULL, 1, 0, VK_SNAPSHOT)
to assign the button to my program. However, when some games are running, neither the above RegisterHotKey nor the below GetAsyncKeyState work when the key is pressed.
GetAsyncKeyState(VK_SNAPSHOT)
(I don't want to use GetAsyncKeyState due to the fact that it will keep bugging the windows API and make the program unnecessarily slow, it was just for test.)
Does anyone know of a way to stop this from happening?
(and, on an unrelated note: If it is a simple task, how would I take a screenshot spanning multiple monitor(s)? Mine currently works on only my primary monitor...)
If the application is using raw input for its keyboard mapping, then the keyboard processing code bypasses the hotkey checker. I personally have no idea if Dark Souls does this or not, but I am familiar with the Windows kernel code that does keyboard processing.
I have coded up a low level keyboard hook using SetWindowsHookEX() on Windows CE 4.2 and it seems to work just fine. I am able to see key events using the keyboard and a barcode scanner in notepad and other applications as desired, but I do not see the barcode scanner events in the one application that I want to collect the keys in. I still see events from the keyboard, however, so I know that the keyboard hook is still working and in the hook chain. I have even tried inserting my hook in the chain every millisecond just to see if it would make a difference, but no dice. If I flip back to notepad, it's back to working the way I want it.
I'm not sure what the other application is doing to gain control of the scanner when that application is active that prevents it from acting like a keyboard any more. Any thoughts on this would be greatly appreciated. I've done a bunch of searches without any success. I looked into trying to use RAWINPUT, but it doesn't seem to be supported in Windows CE 4.2 from what I can tell as I don't see the user32.dll in the SDK.
There are two ways to get barcode data on most WEC devices.
The keyboard wedge (where data comes in as as keyboard events)
An OEM specific barcode reader API
If this other app your looking at uses option #2 then there is no keyboard data to retrieve, so it makes sense you wouldn't see any. That said, you might read this article to see if it offers any tips for your keyboard hook.
Functions exported by user32.dll in big Windows are generally found in coredll.dll in WEC/WEH.
-PaulH
I bought a physical button and hooked it up to my computer, using the Arduino it communicates over USB serial to a C++ program I'm writing. Now I want to make the button simulate a keypress on my computer so I could use it as an alternative controller for the games I play.
If you are not familiar with Arduino, don't mind it, my problem lies completely in C++
The solution for this is pretty simple, it basically boils down to using SendMessage to a window with keystrokes, or many alternative methods like sendKeys and what not.
I have tried every single library or windows function that could handle something like this, but none of them actually simulates a keystroke being pressed by a keyboard.
Everything I tried so far has worked in many programs like Notepad and Chrome but none works with a game that doesn't listen to windows messages to handle key input.
My guess is that these games use GetAsyncKeyState which is communicating with the physical keyboard in a direct manner.
How could I resolve this? What API provides such functionality?
I need something very low level here, maybe even a program that emulates a new keyboard so windows thinks I have plugged in a physical one.
This would help me ALOT I've encountered this problem numerous times and I will keep encountering it in the near future with other projects.
I hope someone can help,
Thanks!
Use keybd_event() or SendInput()