Dragonfly Q&A

Iterating through key press events for each key.

0 like 0 dislike
So I'm reading on how to implement the InputManager on 4.9.2 and for getInput() and I see that we have to check key press events for each key & button presses for each button. I don't want to write 100+ conditional statements so would it be safe to iterate through the enums in a loop and check them that way?
asked Sep 13, 2016 in Engine Development by kezhang

1 Answer

0 like 0 dislike
Possibly.  You do need to map each SFML enum to a DF enum.  If they were numbered the same (e.g., #1 in SFML was, say, an "A" and #1 in DF was an "A") this might work.  But it would be brittle - if the SFML enums changed, the DF ones would need to change.

<p>Fortunately, 100 conditionals (actually, use a switch) is pretty easy.  Cut and paste and type in 100 letters.  Compared to the time you spend coding and debugging, this is small potatoes.
answered Sep 13, 2016 by claypool
More information about Dragonfly can be found on the Dragonfly Home Page.