[2.0.4+] - Get "char" From Keyboard Input? |
JeZ-l-Lee
|
[2.0.4+] - Get "char" From Keyboard Input?
Hi, After a long stint with HTML5 and then GameMaker:Studio, our development team has come back to cross-platform C++ with SDL2. We are in the process of improving our current SDL2 2-D game engine but need some help: How can we get the "char" pressed on the keyboard? We looked here but did not see anything to use: https://wiki.libsdl.org/CategoryKeyboard Thank you in advance! |
|||||||||||
|
actsl
|
What do you need, key code, scan code, or text from keyboard?
|
|||||||||||
|
actsl
|
Name input, i see, this is a text from keyboard. You cannot get char from the keyboard. All keyboard input is UTF-8 (8-bit Unicode). If event->type is SDL_TEXTINPUT , then event->text.text contains the string that is the UTF-8 code of the character that corresponds to the pressed key, 1 to 4 chars. If you only use ACII, then the length of that string is always 1 char. It is important to call SDL_StartTextInput() before starting text input. You may see from the code of my widget toolkit below, how it is done. Also the processing that you likely need, if some characters are not ASCII. |
|||||||||||||
|
[2.0.4+] - Get "char" From Keyboard Input? |
Jim Clark
Guest
|
Hello,
are you referring to something like this? https://wiki.libsdl.org/SDLKeycodeLookup each keycode has a specific hex value that is a char if im not mistaken. On Tue, May 10, 2016 at 7:58 PM, JeZ-l-Lee wrote:
|
|||||||||||||
|
[2.0.4+] - Get "char" From Keyboard Input? |
Daniel Gibson
Guest
|
Keycodes don't work well as chars, especially for non-ascii chars (one
thing is that IIRC they're not unicode chars, the other is that one might use dead keys and input "`e" for "é" and here keycodes won't give you at all what you want. Just use SDL_TEXTINPUT events, that's what they're for. Cheers, Daniel On 05/11/2016 02:21 AM, Jim Clark wrote:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
actsl
|
I were referring to text input.
|
|||||||||||
|
[2.0.4+] - Get "char" From Keyboard Input? |
Jim Clark
Guest
|
thank you for the warning!Â
On Tue, May 10, 2016 at 8:35 PM, Daniel Gibson wrote:
|
|||||||||||||||
|