Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Friendly string mapping to Keyboard::Key  (Read 3076 times)

0 Members and 1 Guest are viewing this topic.

Ant

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Friendly string mapping to Keyboard::Key
« 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.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Friendly string mapping to Keyboard::Key
« Reply #1 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

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6224
  • Thor Developer
    • View Profile
    • Bromeon
Re: Friendly string mapping to Keyboard::Key
« Reply #2 on: October 23, 2015, 08:50:12 am »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: first SFML book

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1491
    • View Profile
    • Blog
    • Email
Re: Friendly string mapping to Keyboard::Key
« Reply #3 on: October 23, 2015, 09:10:44 am »
Mh, this might be something for SFML.

Cmdu76

  • Full Member
  • ***
  • Posts: 194
    • View Profile
Re: Friendly string mapping to Keyboard::Key
« Reply #4 on: October 29, 2015, 07:53:15 pm »
Yeah it would be nice !

Maybe by using something like that : https://github.com/therocode/smartenum

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
Re: Friendly string mapping to Keyboard::Key
« Reply #5 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?

Tigre Pablito

  • Full Member
  • ***
  • Posts: 218
    • View Profile
    • Email
Re: Friendly string mapping to Keyboard::Key
« Reply #6 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!"


Rosme

  • Full Member
  • ***
  • Posts: 167
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Friendly string mapping to Keyboard::Key
« Reply #7 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 :)
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

Tigre Pablito

  • Full Member
  • ***
  • Posts: 218
    • View Profile
    • Email
Re: Friendly string mapping to Keyboard::Key
« Reply #8 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
« Last Edit: January 27, 2020, 04:06:57 am by Tigre Pablito »

Rosme

  • Full Member
  • ***
  • Posts: 167
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Friendly string mapping to Keyboard::Key
« Reply #9 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.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

Jonny

  • Full Member
  • ***
  • Posts: 112
    • View Profile
    • Email
Re: Friendly string mapping to Keyboard::Key
« Reply #10 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

 

anything