Keyboard and Mouse Input

We use glfw3 for window and input management with callbacks instead of manual polling. This way, we ensure we are not missing a key event. For more information check out glfw’s input guide. We use a wrapper class for input named Input. Currently, this supports keyboard, mouse, and one gamepad.

Note

We redirect input events to class methods which handle it. Because glfw is a C-style API, it is not possible to use class methods directly as callbacks for keyboard and mouse input data. To fix this, we set the glfw window user pointer to the class instance which contains the input callback methods. Then, we use a lambda to set up the class method as callback. All setups are done in Application::setup_window_and_input_callbacks. For more information about this workaround, check out this Stackoverflow issue.

Note

It’s not possible handle glfw input data in a thread which is separate from the thread which created the corresponding window. For more information, check out this glfw forum post.

Keyboard and Mouse Input

  • Keyboard and mouse input data is managed in the KeyboardMouseInputData class.

Gamepads

  • Gamepad input data is managed in the GamepadInputData class.

Note

We currently support only one gamepad. Refactoring of this is required. See issue 612.

Joysticks

Note

We do not yet support joysticks, but glfw allows us to support them in the future. See issue 612.