also output multiple times when you press a key?
unfortunately yes. just tapped 'a' and the console is full of output (23 messages to be exact)
It's not at all obvious as you didn't show it.
sorry, didn't mean it like that. I meant that if it wasn't in a loop, the app would freeze right after a startup, not produce an excessive amount of input.
Are you polling the events in a different thread?
No, everything runs in one main thread. It is organized more/less in the following way
int main()
{
Program program; //this object contains the sf::Event mEvent and sf::RenderWindow* mWindow object, which is then shared with all other subsystems
program.run();
}
program.run()
{
while (mRunning)
{
mWindow->pollEvent(mEvent);
if (mEvent.type == sf::Event::Closed)
mRunning = false;
mLoadedSoftware->fillPages();
mLoadedSoftware->updatePages();
mLoadedSoftware->drawPages();
}
}
and then in Software object, to which the pointer to mEvent is passed, we have updatePages()
void Software::updatePages()
{
mActiveState->updatePages();
}
which for each state calls it's own input handling. Maybe also worth noting is that all the input, regardless of the state, behaves in the same way: i.e. one mouse click generates tens of click events. But all of this was easy to work around with bool triggers. For typing it's no good as using the bool trigger 'pressed/unpressed' makes the program miss half of the letters typed
edit: also, right after creating a new sf::RenderWindow object i put
mWindow->setKeyRepeatEnabled(false);
but it doesn't change a thing in the program's behavior