From 0485661fd05af686acf886cb2c96dd4a5e38bb4d Mon Sep 17 00:00:00 2001 From: vimene Date: Fri, 3 Jan 2025 08:19:05 +0100 Subject: improved keyboard and mouse controls --- src/ctrl/mouse.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/ctrl/mouse.h') diff --git a/src/ctrl/mouse.h b/src/ctrl/mouse.h index 8b66cee..521b0a4 100644 --- a/src/ctrl/mouse.h +++ b/src/ctrl/mouse.h @@ -3,16 +3,19 @@ #include "math/vector.h" -using engine::math::Vector2; - namespace engine::controllers { +template class Mouse { public: - bool moved; - Vector2 rel_motion; + constexpr Mouse(MouseMotionCallback mouse_motion_cb) : mouse_motion_cb{mouse_motion_cb} {} + + void mouse_motion_event(Vector2 rel) const & { + mouse_motion_cb(rel); + } - constexpr Mouse() : moved{false}, rel_motion{0.f, 0.f} {} + private: + MouseMotionCallback mouse_motion_cb; }; } -- cgit v1.2.3