O'Reilly logo

SFML Game Development by Henrik Vogelius Hansson, Artur Moreira, Jan Haller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting the input state in real time

Now, we have gone through many varieties of events. A problem with events is that they report once when the state changes, but you cannot continuously ask them how the state of the input devices look right now.

You can solve this by book keeping yourself, which we have done in the examples preceding this chapter. But SFML, in an effort to make input management easier, has implemented classes that let you access these states in real time whenever you want from wherever you want. We will use the notion of real-time input to denote this alternative method of handling user input.

The three classes sf::Joystick, sf::Keyboard, and sf::Mouse can provide almost the same information that the event-based counterparts do, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required