Hey there,
I was wondering if there was a way to convert all keyboard/button names from string to their enum.
I read in the tutorial that you can do a straight char representation -> sf::keyboard::key enum for characters/numbers, but what about things such as "Back."
In my situation, I'm reading key bindings from a file, such as this:
<?xml version="1.0" encoding="UTF-8" ?>
<Root>
<Keyboard>
<a action="MoveLeft"></a>
<s action="MoveDown"></s>
<d action="MoveRight"></d>
<w action="MoveUp"></w>
<F12 action="whatevs"></F12>
</Keyboard>
</Root>
I use xml to parse this the way I want it, but everything comes out as a string. I need to do a conversion from, say std::string("f12") -> sf::keyboard::F12. I didn't see anything, and the only constant-time way I can think to solve this is to create an std::map with all the key/values defined within it (the map of course allowing constant time lookup). This would allow me to do something such as return _myMap.at("F12") and have a sf::keyboard::key returned, or something similar.
This would however require a map with every keyboard / mouse "button/click" in it. I don't mind doing this, if there is no other way I have missed.
Thanks!!