@@ -19,14 +19,6 @@ class RenderSystem;
1919class Window ;
2020using WindowPtr = std::unique_ptr<Window>;
2121
22- using KeyboardCallbacks = std::vector<std::tuple<int , std::function<void (float )>, Input::ActionTrigger, std::function<void ()>>>;
23- using MouseButtonCallbacks = std::vector<std::tuple<int , std::function<void (float )>, Input::ActionTrigger, std::function<void ()>>>;
24- using MouseScrollCallback = std::function<void (double , double )>;
25- using MouseMoveCallback = std::tuple<double , double , std::function<void (double , double )>>;
26- using InputActions = std::unordered_map<int , std::pair<std::function<void (float )>, Input::ActionTrigger>>;
27- using InputCallbacks = std::tuple<KeyboardCallbacks, MouseButtonCallbacks, MouseScrollCallback, MouseMoveCallback, InputActions>;
28- using CloseCallback = std::function<void ()>;
29-
3022enum class WindowSetting : unsigned int {
3123 FOCUSED = 1 , // /< Forces the window to take the focus.
3224 RESIZABLE = 2 , // /< Makes the window able to be resized, either by dragging the edges & corners or by maximizing it.
@@ -92,7 +84,7 @@ class Window {
9284 // / \param width New window width.
9385 // / \param height New window height.
9486 // / \note The width & height are to be considered just hints; the window manager remains responsible for the actual dimensions, which may be lower.
95- // / This can notably happen when the requested window size exceeds what the screens can display. The actual window's size can be queried afterward.
87+ // / This can notably happen when the requested window size exceeds what the screens can display. The actual size can be queried afterward.
9688 // / \see getWidth(), getHeight()
9789 void resize (unsigned int width, unsigned int height);
9890 // / Sets the window in a fullscreen mode, taking the whole main monitor's screen.
@@ -155,7 +147,7 @@ class Window {
155147 // / Sets the action to be executed on window close.
156148 // / \param func Action to be executed when the window is closed.
157149 void setCloseCallback (std::function<void ()> func);
158- // / Associates all of the callbacks, making them active.
150+ // / Associates all the callbacks, making them active.
159151 void updateCallbacks () const ;
160152#if !defined(RAZ_NO_OVERLAY)
161153 // / Changes the overlay's enabled state.
@@ -178,6 +170,31 @@ class Window {
178170 ~Window () { close (); }
179171
180172private:
173+ struct KeyboardCallback {
174+ Keyboard::Key key;
175+ std::function<void (float )> actionPress;
176+ Input::ActionTrigger frequency;
177+ std::function<void ()> actionRelease;
178+ };
179+
180+ struct MouseButtonCallback {
181+ Mouse::Button button;
182+ std::function<void (float )> actionPress;
183+ Input::ActionTrigger frequency;
184+ std::function<void ()> actionRelease;
185+ };
186+
187+ struct MouseMoveCallback {
188+ double xPrevPos {};
189+ double yPrevPos {};
190+ std::function<void (double , double )> action;
191+ };
192+
193+ struct InputAction {
194+ std::function<void (float )> action;
195+ Input::ActionTrigger frequency;
196+ };
197+
181198 // / Processes actions corresponding to keyboard & mouse inputs.
182199 // / \param deltaTime Amount of time elapsed since the last frame.
183200 void processInputs (float deltaTime);
@@ -196,8 +213,12 @@ class Window {
196213 int m_posX {};
197214 int m_posY {};
198215
199- InputCallbacks m_callbacks {};
200- CloseCallback m_closeCallback {};
216+ std::vector<KeyboardCallback> m_keyboardCallbacks;
217+ std::vector<MouseButtonCallback> m_mouseButtonCallbacks;
218+ std::function<void (double , double )> m_mouseScrollCallback;
219+ MouseMoveCallback m_mouseMoveCallback;
220+ std::unordered_map<int , InputAction> m_inputActions;
221+ std::function<void ()> m_closeCallback;
201222
202223#if !defined(RAZ_NO_OVERLAY)
203224 Overlay m_overlay {};
0 commit comments