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, ...

Get SFML Game Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.