1
Window / String representation of a sf::Keyboard::Key
« on: June 19, 2013, 08:12:53 pm »
Is there a solution to computing the string representation of a sf::Keyboard::Key that doesn't involve a massive switch or if-else statement?
Ideally, I would like to avoid something like this:
Ideally, I would like to avoid something like this:
const char *getKeyName(const sf::Keyboard::Key key) {
switch(key) {
case sf::Keyboard::Unknown:
return "Unknown";
case sf::Keyboard::A:
return "A";
case sf::Keyboard::B:
return "B";
case sf::Keyboard::C:
return "C";
// ... All the other keys.
}
switch(key) {
case sf::Keyboard::Unknown:
return "Unknown";
case sf::Keyboard::A:
return "A";
case sf::Keyboard::B:
return "B";
case sf::Keyboard::C:
return "C";
// ... All the other keys.
}