Dragonfly Q&A

sf::Keyboard::Key to df::Keyboard::Key

0 like 0 dislike
I'm not sure if there's a better way to do this or not, but in the getInput function for InputManager do we need to create a switch statement for converting every sf::Keyboard::Key from sf::Event to df::Keyboard::Key for the KeyboardEvent key?  The enumeration for the sf Key and the df Key are not equivalent.  I'd rather know if a switch case conversion is necessary before writing every case for every key
Dragonfly version 4.0
asked Sep 19, 2015 in Engine Development by jpnelson

1 Answer

0 like 0 dislike

Yes, a switch statement is an efficient way to do this.  Basically, for each sf::Keyboard key, you have a corresponding df::Keyboard key. 

Remember, the reason for doing this is to avoid having the game code, which will access the df::Keyboard value, know anything about or be tied to the sf::Keyboard value.  As for the time it takes to right this, you can make an "empty" case, cut once, and paste it in for each key.  Then go through and fill in the keycodes.  Doesn't take too long. ;-)

answered Sep 19, 2015 by claypool
More information about Dragonfly can be found on the Dragonfly Home Page.