Dragonfly Q&A

Question on testing the input.

0 like 0 dislike
It is a little unclear to me as to how I should be testing the input outside of the game loop.  Mainly because getInput() returns void, should it be returning the character that was pressed?
asked Sep 21, 2014 in Engine Development by remckenna

2 Answers

0 like 0 dislike

Try doing with the objects and start from there, I think. Even I couldn't get myself to detect mouse inputs, such as button clicks or button pressed. I even registered all mouse events using:



Mouse inputs are here:



You can also get Programmer's Guide to NCurses, a book about NCurses programming. 

answered Sep 21, 2014 by tom_mai78101
0 like 0 dislike

getInput() doesn't return anything.  Instead, if there is input, it sends an input event (e.g., an EventKeyboard) to all Objects (using Manager onEvent()).  So, you could test this functionality in a variety of ways.  One example:

Start up the GraphicsManager (needed since it starts up Curses)

Start up the InputManager

Create an Object (say, a Hero derived from Object)

Sleep or loop for a few seconds, giving you time to press a key

Call InputManager getInput()

If getInput() does it's job, the eventHandler() for the derived object should get a keyboard event with the key.

For automated testing, you can use ungetch() to "push" keystrokes to simulate a player pressing keys and test from there.

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