SFML community forums

General => Feature requests => Topic started by: Ant on October 23, 2015, 07:10:32 am

Title: Friendly string mapping to Keyboard::Key
Post by: Ant on October 23, 2015, 07:10:32 am
This is a minor request, and is not urgent at all.

I think it'll be beneficial to have a vector of strings or char* that corresponds to the Keyboard::Key enumerator.  I don't plan to use this for comparison but rather for presentation.

Having this will allow me to log more meaningful debugging messages (rather than logging indices), and this could also be used to present to the user when binding controls.
Title: Re: Friendly string mapping to Keyboard::Key
Post by: AlexAUT on October 23, 2015, 08:21:20 am
Have a look at the TextEntered event in the tutorials. They will give you a unicode character on keypress. Maybe not suitable for keymapping but definitely for presentation.


AlexAUT
Title: Re: Friendly string mapping to Keyboard::Key
Post by: Nexus on October 23, 2015, 08:50:12 am
My library Thor provides this functionality:
http://www.bromeon.ch/libraries/thor/v2.0/doc/_input_names_8hpp.html
Title: Re: Friendly string mapping to Keyboard::Key
Post by: Tank on October 23, 2015, 09:10:44 am
Mh, this might be something for SFML.
Title: Re: Friendly string mapping to Keyboard::Key
Post by: Cmdu76 on October 29, 2015, 07:53:15 pm
Yeah it would be nice !

Maybe by using something like that : https://github.com/therocode/smartenum
Title: Re: Friendly string mapping to Keyboard::Key
Post by: Haze on October 28, 2019, 12:29:16 pm
Hi,

I second this request. This will be very useful for any project featuring custom keyboard mapping.

Should this be added to the github issue tracker?
Title: Re: Friendly string mapping to Keyboard::Key
Post by: Tigre Pablito on January 22, 2020, 07:29:16 pm
Hi, Ladies and Guys

What about the ToString() function from the Keyboard.Key class or enum?

I use SFML.Net, and as I have all the Keys, so there is the ToString() function which gives them as a string. Actually I made a Keyboard Input Selector in one of my games and I see, while selecting, all the availavle Keys as strings in each selector box.

Maybe this is not possible in C plus plus? (Sorry I don't know)

On these days, that there are some people that say "I'm moving away from SFML because .... (it doesn't support "the Universe") .....", and also I remember not so long time ago there was a guy (phanoo, if I remember correctly) who prompted everyone "to switch to SDL because SFML didn't have Clippboard support", I would say to all of you, MODESTLY, ... -"Please, move away from SFML, but to SFML.Net!!! You will avoid more than one issue. Switch to SFML.Net!"

Title: Re: Friendly string mapping to Keyboard::Key
Post by: Rosme on January 23, 2020, 04:03:06 pm
Unlike C#, C++ classes don't inherit from an root object class, that contains the ToString function. We are to this day still stuck in doing our own mapping. Thor does provided a mapping, and it's really not that hard to do.

As for prompting people to move to whatever thing, let just people use whatever they want :)
Title: Re: Friendly string mapping to Keyboard::Key
Post by: Tigre Pablito on January 27, 2020, 04:03:09 am
Hi Rosme

Please, read my post again. Did not you understand my irony/joke?

Have not you read when that character, "phanoo" (if I remember correctly), prompted everyone to switch to SDL because SFML did not support Clippboard? Remember that? And now there is also people who say "I'm moving away from SFML because "it does not support 'The Universe' "", this is more current, do you remember?

Well, I based my irony/joke on those circumstances. Actually, I did not think that I would have to explain this, ... but well, everyone can be wrong sometimes!

I know very well that neither SFML nor anyone need my defense, but, please, Ladies and guys, forgive my little joke, please! It just comes from my soul to say, in a way or another, how useful and nice is SFML(.Net) for me.

And yes, obviously you are right, everyone is free to use whatever she/he wants. I was just kidding!

Kind regards,
Pablo
Title: Re: Friendly string mapping to Keyboard::Key
Post by: Rosme on January 27, 2020, 03:04:29 pm
No I did not. Jokes/irony does not translate well in text. But it's fine :)

However, the original answer remain. C++ does not have a ToString that can be overriden.
Title: Re: Friendly string mapping to Keyboard::Key
Post by: Jonny on January 30, 2020, 01:13:39 pm
This is actually something that will be provided by `getDescription` as part of the scancode API

You can take part in the discussion and test it here: https://github.com/SFML/SFML/pull/1235