Possible to get physical keyboard layout for a on-screen keyboard? - c++

I'm currently working on a on-screen keyboard for a touchscreen app.
I wonder if anyone have experience on how the keyplacement shall look? (Unicode, on other languages like Japanese, Korean, Norwegian, Swedish etc) Finished layouts etc...
I found this info regarding layout/scancodes: http://www.quadibloc.com/comp/scan.htm
If I build a 101/102/106-keyboards after this layout, with scancode 3 range, will it look "correct" physically for most people? Even when someone earlier stated that it is 150 keyboard layouts out there gasp, so I guess it wouldn't please all.
Microsoft have their own layout lists here: http://msdn.microsoft.com/nb-no/bb964651
The U+xxxx is virtualcodes, are there any tables like U+0031 (number 1) is the [x,y] -> [1, 0] position in a keyboard?
Thanks for any suggestion/help!

I'm from Israel, and I can help you with Hebrew lay-out if you need it. But that Microsoft site you posted looks pretty much enough

Do consult with locals on how the keyboard actually works. I've seen some where the thing printed on the right-hand side works with the right alt or with some other odd key. If you get that wrong the user is going to be very confused still.

Related

Why Visual Studio (2017; 15.7.5) don't let me change c++ keywords color

I can change the colour to a truckload of items in editor font & colors tool, except for the very pillar of (c++) keywords (looks like to apply to all of the flow-control keywords):
return; if/else; break; switch/case; while/do; for;
No matter the editor theme, there is no such selection (flow control keyword) in the tools dialogue so in dark theme, they are always displayed in freaking ugly red colour (on dark theme!).
In the dialogue, there are "keyword"; "user keyword" selection. But the shown colour is not Red.
google: I've tried to formulate in every query forms that my English skills can do, nothing is to be found about those specific keywords and colour (topics).
Anybody is experiencing the same issue?
Bugs with locale language on Windows 10 (Visual Studio 2017 15.7.?)?
(Windows 10 locale is French. Changing it to English is not an option)
Thanks.
P.S.: Btw, in my humble opinion, that tools dialogue must be redone! It is a huge mess! Mixing everythings in the "font and colors section" is scary, overwhelming.
Here. I found the culprit: This extension: "Viasfora" bypasses the colouring of flow control keywords. I will report it to whoever it is. Sad. I like so much this Rainbow Brackets extension.
Sorry for disturbing. Therefore, I think this issue might be useful to others in the same situation.

How to move the console cursor from right to left as input is given in C++

In c++, by default input is taken as left align. I am looking to write a function or code to take the input string as right align. Means, my input cursor will be at the right side of the prompt/textbox. can anyone help me in this regard?
Here is the screenshot of my requirement:
Edited:
I have actually 2 problem... Is there any way to take input(cin) right aligned (above picture)?
if not then can you provide me with the code to make right align input textbox in visual c++ ?
Your question is too vague and broad to give an actual concise answer. However from what I'm gathering from your question as well as the comments listed below it, it appears that you are working with Windows and are tasked with writing a win32 console application where you have to manipulate the console to accept input that is right aligned.
What I can do for you here is point you in a direction that may give you the answers you are looking for. You can find the documentations for the Windows Console API here: https://learn.microsoft.com/en-us/windows/console/ There is quite a bit of information about everything you need to know on how to acquire a handle to the console, to getting the console buffer, info structures etc. How to manipulate the buffer size, the cursor position, changing font type, size & color(foreground, background and highlighted text). Other than that I will have to agree with the rest of the community that your initial question was too vague and broad and that it has the impression of a X/Y problem.

Use of TABs in DirectWrite

I am just working my way through DirectWrite in C++ which appears to be solving my demands for having equal layouts in different render targets (screen and printer).
I have closely inspected the HelloWorld sample (http://msdn.microsoft.com/en-us/library/windows/desktop/dd368048%28v=vs.85%29.aspx) and already learned a lot from that.
The HelloWorld example was even topped (my opinion) by an article from Charles Petzold which was throwing much more light on advanced features of DirectWrite: "Character Formatting Extensions with DirectWrite" (http://www.charlespetzold.com/blog/2014/01/Character-Formatting-Extensions-with-DirectWrite.html).
But there is still one subject missing in all the documentation and examples I found so far: The documentation about use of TABstops in DirectWrite. All I found so far is a (very) short documentation about setting of "incremental tabs" which does not even mention how the text in each individual tab can be aligned.
Does anybody know about a more in-depth description about TABs in DirectWrite?
Thanks in advance.
Sounds like you're thinking Word degree of complexity tab stops with individual widths and alignment for each tab - IDWriteTextLayout supports uniform tab spacing where each tab is a multiple of a distance set by SetIncrementalTabStop. If you need to lay out several unique layouts with distinct distances and alignments, you'll need to create one IDWriteTextLayout per column. Tabs are convenient, but they aren't best for tables.

How to assign keys on physical position at the keyboard on Windows?

There are at least 3 different keyboard layouts who are using the program i make, and i dont care which key they press, the more important thing is where the keys are pressed.
I cant just ask the user to press 100 different keys/combinations, that would take too much time and be very confusing to the user.
Is there some library or something that can do this for me?
This answer says that you can use the keyboard "Scan Code" which should be the same on all keyboards. So it appears that there is in fact a way to determine the key location.
Even without using the scan code, you could implement a mapping table for all the keyboard layouts you support. So if the keyboard layout is US English, the key would map to command A, but on layout German German, it would map to command B, and some other command would map to command A. It may not work for all keyboards, but if it works for all of your users that's what matters. I can see why you were looking for an existing library to do this as it would be a significant amount of work.
This cannot be done. Keyboards do not come with their layout in an electronic form, that could be looked up by the OS. They just send the code for the key pressed, not where the key resides. I'm working on several keyboards daily, which are all classified as having German layout, but with some of the keys being in different places.
The only way to find out at what physical position a specific key is on a specific keyboard is to look at what's printed on the key.

Keyboard input in games (for GLUT)

Almost every game use keyboard as input. I have been searching for 2 days on this topic and found quite much about it. Keyboards have many disadvantages, but main problems I found are different layouts and second that if you are pressing 3 keys at time, it can lead to corruption (row-column error). If you don't know what I'm talking about, keyboard is made as grid and it checks which row and column has connected. But if you press E,D (row 1,2 column 3)
and R (row 1, column 4), keyboard can show even F because it find it pressed(row 2, column 4 both pressed).
So I think we can't do anything about that second, but if anyone got idea how to solve it better then use keys that don't form L, I'd be glad :)
But my main problem are different keyboard layouts which is real pain. I'm slovak so Slovak layout of numbers look like this:
+ľščťžýáíé and with shift 1234567890, we also got QWERTZ but you can use QWERTY.
You all know how the English look like but just for sure:
1234567890 and shift !##$%^&*()
Most of time I'm using english one because I got used to it when programming. Anyway there are different people using different layouts. When you are making game that depend on which key is pressed, for example good old WASD pattern, you can't use that on french one which is AZERTY layout. It would be strange. Same as using numbers for choosing gun in action game. As you can see slovak would have to press shift to get it work.
I'm also using OpeGL. There is problem when you are mapping which keys are pressed. For example widely used solution to make map of 256 bools for each charakter, is suffering from SHIFT. You press a, SHIFT and release a you got: a down, A up. So I thought about binding some keys together, as A and a, 1 and !, but then I realized I'll just change layout and everything is wrong.
So what is solution for that? I think there is someone out there that is in game industry or made some game and had to solve this. Only solution that comes on my mind is to force english layout for UI (and choosen layout for chat).
After next searching I found what I need but I need cross-platform one:
virtual key codes
And next search revealed SDL key
Result: Don't ever start with GLUT if you go making games, use SFML or SDL
Thanks to everyone for helping me, there were more problems in this so idea of key binding/mapping, SDL and so on, each helped me alot.
If you're getting a "character" every time user presses something, then your keyboard routines aren't suitable for game input - only for text entry.
You need to use input routines that completely ignore keyboard layout switching and operate on some kind of raw keycodes (so when user presses shift+a, you'll know that shift is pressed and that "a" key is pressed, but you won't get "A" character). Also, routines should allow you to query if a key is pressed or not.
For windows that is DirectInput or XInput. For cross-platform this is libsdl and SDL_GetKeyState. And you'll need to provide keymapping options for the user. Glut probably isn't suitable for your task.
The common approach seems to be to ignore the problem. Worse-is-better in its early stage.
Unfortunately I'm using svorak keyboard layout so it really doesn't just work for me.
I've been approaching this same problem by binding into multiple keys on the keyboard. So that player jumps from both x and j -keys. It doesn't do so well in something that isn't shoot-jump -kind of game.
Nice stuff would be if you could just find row/col or some driver-near interface to your keyboard.
Some auto-keyboard configuration software would be neat though I've not yet seen anything like that. Maybe we should write one?
First up, separate keypresses from text entry. You shouldn't care what letter or number comes up when you press a key with shift as well - the operating system should handle that and generate an event you can use in the rare times you need the text. Usually, you should just look for the key press and any shift presses and act on those.
Second, load the bindings from keys to commands from a data file, rather than hardcoding it. Distribute default bindings for QWERTY and whatever default layout you have. If the data format is quite straightforward then people won't mind customising it to fit their keyboard and preferences. You can also add an in-game keybinding editor later.
This isn't really about OpenGL since by default that doesn't care about keypresses. Perhaps you are using an addon library or extension that handles keys for you - ensure that whatever you're using can give you individual key values and the state of shift/alt/ctrl independently, and that it also provides text input via an independent system.
Allow your users to define the keys to use for each action ...
or use the arrow keys .. that should be pretty universal :)
Turn the keyboard input into metadata, so you could allow users to configure at their will but also provide different keyboard shortcuts depending on the keyboard layout used in a config file .