I'm writing an application now and i need to include inputs to this app. I'm confused now a bit. I heard about four options.
1. Basic windows messages system,
2. DirectInput8,
3. RawInput,
4. XInput.
I need to distinguish:
1. uppercase letters from lowercase letters,
2. arrows and special keys from other chars (i mean left arrow key is translated to % when usgin translate message and it's problem coz i need to dostingush them),
3. it would be good if it would be possible proceed data as messages.
Now, my question is: Which one of these four would you use to implement input? Maybe you have another good way to do this?
PS. I need to handle mouse and keyboard.
If you don't need joystick gamepad support plain window messages work for everything.
To read character data that will be displayed on screen like text being entered into an input box use WM_CHAR, WM_CHAR will return different codes for a and A.
For input keys like left/right arrows etc. you can use WM_KEYDOWN / WM_KEYUP.
Windows messages work well for mouse clicks too and for mouse position I prefer to use GetCursorPos and translate it into the client window coordinates.
For other input devices XInput is the prefered choice.
Related
I would like to know how to detect the keyboard adapter on Windows when using two keyboards, that a key eg. W was pressed on first or on the second keyboard.
Can anybody help me how to do it?
I would like to use a cheap solution for macros. I would plan to bind macros for entrie second keyboard, when somebody press key W (just for example), keybaord would type a world uint8_t.
I'm using Qt4.8.6 develop a Application. Is there any way to add two screen keyboard to the application.
I want to add two vritual keyboard in my Application.One of keyboard is QWERTY keyboard,and another is num keyboard ,it can only input numbers.
Is there any way to do it ?
We had a similar requirement once and we ended up writing our own dialog which served as a keyboard. You can also do the same. I am afraid Qt does not provide just a numeric keyboard by itself which will pop up automatically upon placing a cursor in an input field.
I need to get scan codes of keyboard buttons (or any other codes) in layout-independent way. More specific, let's say I have QEditText and catching keystrokes from it. Now I'm starting to press a single button, and when the layout is English it has keycode=X, then I'm switching layout to Russian (German, French, whatever) and keycode becomes Y - but the physical button is the same. So I need to know code of that physical button, how to do this?
I am not sure if you will be able to do this only from code itself by some qt/x11 methods, but there is a tool that helps in similar situations: xbindkeys. You can read more here:
https://unix.stackexchange.com/questions/91355/shortcut-keys-that-are-independent-to-keyboard-layout
If you can't use xbindkeys, you can still check its code and see how the author achieved this.
I'm trying to write a Keyboard class that can read in the keyboard buttons. I have looked at this link - http://www.daniweb.com/software-development/cpp/code/216732/reading-scan-codes-from-the-keyboard But as stated on there, it is not very accurate for all computers (I don't know if this is even true). Therefore, my question is whats the best method in implementing my keyboard class? This will be used for Windows
Many thanks
There are three ways to read keyboard input:
By reading input from a console window as described in your link. It's true that it's hard to get this to work correctly, for starters because it's reading ANSI characters and not Unicode characters, but there are other issues. Console input/output is kind of obscure, as is the documentation for it
By handling UI events associated with a normal window. In this case you would handle the WM_KEYDOWN message in a window procedure
By going deep into the Win32 API with functions like SetWindowsHookEx. In this case you don't even need a window (normal or console), and you can read keystrokes pressed in any application or in the desktop
It's hard to suggest which one to use without knowing how you intend to use this Keyboard class.
I am doing a VoIP client and I want to start/stop on WM_KEYDOWN and WM_KEYUP messages for a certain input, say K. When the main window has focus, this is np, but how do I enable it outside of the window? For example, if the window is not in focus and I'm just looking at the desktop or am in a videogame. How does one perform something like this? I am not sure where to begin.
Also -- I guess you somehow has to poll every input even outside the program, is that expensive?
win32 c++ btw
You need to install keyboard hooks: http://msdn.microsoft.com/en-us/library/ms644990(v=VS.85).aspx
This can be very troubling though for every running application if something steals its keyboard messages.
I don't think you want this - if I'm typing a document into Word and I hit K, I'm going to be very angry when your application pops up instead of a "k" appearing in my document.
Windows allows you to assign shortcut keys to an icon on the desktop, but it limits them to the function keys or to combinations containing both Alt and Ctrl. Right-click on a desktop icon and go to Properties, and look for the field marked "Shortcut key".