Enter the keyboard in the game (for GLUT)

Almost every game uses a keyboard as an input. I searched 2 days on this topic and found a lot about it. Keyboards have many shortcomings, but the main problems that I found are different layouts, and secondly, if you press 3 keys in time, this can lead to damage (row column error). If you don’t know what I'm talking about, the keyboard is gridded and checks which row and column are connected. But if you press E, D (row 1,2 of column 3) and R (row 1, column 4), the keyboard can even display F because it finds it pressed (row 2, column 4 are pressed).

So, I think that we can’t do anything with this second, but if anyone has an idea how best to solve it, use keys that do not form L, I would be glad :)

But my main problem is the different keyboard layouts, which are a real pain. I’m a Slovak, so the Slovak layout of numbers looks like this: + ľščťžýáíé and with a change of 1234567890, we also got QWERTZ, but you can use QWERTY. You all know what the English look like, but for sure: 1234567890 and shift! @ # $% ^ & * ()

In most cases, I use English because I'm used to it when programming. In any case, different people use different layouts. When you make a game that depends on which key is pressed, for example, the good old WASD template, you cannot use it in French, which is an AZERTY layout. It would be strange. Same as using numbers to select weapons in action. As you can see, the word will need to press shift to make it work.

I also use OpeGL. There is a problem when you indicate which keys are pressed. For example, a widely used solution for creating a map of 256 points for each character suffers from SHIFT. You press a, SHIFT and release you: down, A up. So I thought about binding some keys together, like A and a, 1 and !, But then I realized that we just change the layout, and that's not it.

So what is this solution for? I think that there is someone who is in the gaming industry or has made some kind of game and should have solved it. The only solution that comes to my mind is to force the English layout for the user interface (and choose the layout for the chat).

After the next search, I found what I need, but I need cross-platform: virtual key codes

And the next search showed the SDL key

: GLUT, , SFML SDL

, , / , SDL .., .

+3
5

"" , -, - .

, - (, shift + a, , "a", "A" ). , , .

, DirectInput XInput. - libsdl SDL_GetKeyState. . , .

+2

, , . - .

, svorak, .

, . , x j. -, -.

, / , .

, . , ?

+1

, . , , , - , , . .

-, , hardcoding. QWERTY . , . .

OpenGL, . , , - , , , shift/alt/ctrl , .

+1

...

.. :)

0

Turn keyboard input into metadata so that you can allow users to customize them as they wish, but also provide different keyboard shortcuts depending on the keyboard layout used in the configuration file.

0
source

Source: https://habr.com/ru/post/1755977/


All Articles