[2.0.4+] - Get "char" From Keyboard Input?

[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!------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

What do you need, key code, scan code, or text from keyboard?------------------------
kiss_sdl - Simple universal GUI widget toolkit for SDL2 https://github.com/actsl/kiss_sdl

actsl wrote:

What do you need, key code, scan code, or text from keyboard?
Hi,

We need the “char” character the user pressed on the keyboard.
Need it for new high score name input.

Thanks!------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

JeZ-l-Lee wrote:

Need it for new high score name input.

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.------------------------
kiss_sdl - Simple universal GUI widget toolkit for SDL2 https://github.com/actsl/kiss_sdl

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 < JessePalserMailingLists at gmail.com> wrote:

actsl wrote:

What do you need, key code, scan code, or text from keyboard?

Hi,

We need the “char” character the user pressed on the keyboard.
Need it for new high score name input.

Thanks!


JeZxLee
JessePalser GMail com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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,
DanielOn 05/11/2016 02:21 AM, Jim Clark wrote:

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 <JessePalserMailingLists at gmail.com <mailto:JessePalserMailingLists at gmail.com>> wrote:

__



actsl wrote:	

What do you need, key code, scan code, or text from keyboard?	

Hi,

We need the "char" character the user pressed on the keyboard.
Need it for new high score name input.

Thanks!


------------------------------------------------------------------------

JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com <http://www.16BitSoft.com>

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I were referring to text input.------------------------
kiss_sdl - Simple universal GUI widget toolkit for SDL2 https://github.com/actsl/kiss_sdl

thank you for the warning!On Tue, May 10, 2016 at 8:35 PM, Daniel Gibson wrote:

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:

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 <JessePalserMailingLists at gmail.com <mailto:JessePalserMailingLists at gmail.com>> wrote:

__



actsl wrote:

What do you need, key code, scan code, or text from keyboard?

Hi,

We need the "char" character the user pressed on the keyboard.
Need it for new high score name input.

Thanks!

JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com <http://www.16BitSoft.com>

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org