FifeGUI 0.3.0
A C++ GUI library designed for games.
backends/sdl3/input.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_BACKENDS_SDL_SDLINPUT_HPP_
6#define INCLUDE_FIFECHAN_BACKENDS_SDL_SDLINPUT_HPP_
7
8// Standard library includes
9#include <queue>
10#include <string>
11
12// Platform config include
13#include "fifechan/platform.hpp"
14
15// Third-party library includes
16#include <SDL3/SDL.h>
17
18// Project headers (subdirs before local)
19#include "fifechan/input.hpp"
20#include "fifechan/keyinput.hpp"
21#include "fifechan/mouseinput.hpp"
22
23namespace fcn
24{
25 class Key;
26}
27
28namespace fcn::sdl3
29{
30
36 class FIFEGUI_EXT_API Input : public fcn::Input
37 {
38 public:
42 Input();
43
50 virtual void pushInput(SDL_Event event);
51
57 void _pollInput() override
58 {
59 }
60
61 // Inherited from Input
62
63 bool isKeyQueueEmpty() override;
64
65 KeyInput dequeueKeyInput() override;
66
67 bool isMouseQueueEmpty() override;
68
69 MouseInput dequeueMouseInput() override;
70
71 bool isTextQueueEmpty() override;
72
73 std::string dequeueTextInput() override;
74
75 protected:
82 static MouseInput::Button convertMouseButton(int button);
83
85 std::queue<KeyInput> mKeyInputQueue;
86
88 std::queue<MouseInput> mMouseInputQueue;
89
91 std::queue<std::string> mTextInputQueue;
92
94 bool mMouseDown{false};
95
97 bool mMouseInWindow{false};
98 };
99} // namespace fcn::sdl3
100
101#endif // INCLUDE_FIFECHAN_BACKENDS_SDL_SDLINPUT_HPP_
Abstract interface for polling user input devices.
Definition input.hpp:37
Internal class representing raw keyboard input data.
Definition keyinput.hpp:32
Internal class representing raw mouse input data.
Button
Mouse button.
std::queue< std::string > mTextInputQueue
Queue of text input strings waiting to be processed.
void _pollInput() override
Polls all input.
bool mMouseDown
True if a mouse button is currently held down.
Input()
Constructor.
Definition input.cpp:21
std::queue< MouseInput > mMouseInputQueue
Queue of mouse inputs waiting to be processed.
virtual void pushInput(SDL_Event event)
Pushes an SDL event.
Definition input.cpp:78
std::queue< KeyInput > mKeyInputQueue
Queue of key inputs waiting to be processed.
bool mMouseInWindow
True if the mouse cursor is currently within the application window.
Used replacement tokens by configure_file():