diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2022-07-09 11:27:17 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2022-07-09 11:27:17 -0400 |
commit | 9562fde36d6d28188210eb6053b9e2f9a9242702 (patch) | |
tree | 2f7bbbf62f2418e999af06cfd67f67b54f3649c8 /src/input.hpp | |
parent | 57a1eb6fdccb9023557d0a470796f423f063948a (diff) |
mouse events; wip ui dialog box
Diffstat (limited to 'src/input.hpp')
-rw-r--r-- | src/input.hpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/input.hpp b/src/input.hpp index fa92c39..c5156b7 100644 --- a/src/input.hpp +++ b/src/input.hpp @@ -33,7 +33,7 @@ struct KeyUpEvent SDL_Keycode sym; Uint16 mod; - KeyUpEvent(const SDL_Keysym& keysym) : + explicit KeyUpEvent(const SDL_Keysym& keysym) : sym(keysym.sym), mod(keysym.mod) {} }; @@ -45,10 +45,28 @@ struct KeyDownEvent { SDL_Keycode sym; Uint16 mod; - KeyDownEvent(const SDL_Keysym& keysym) : + explicit KeyDownEvent(const SDL_Keysym& keysym) : sym(keysym.sym), mod(keysym.mod) {} }; +struct MouseUpEvent { + Uint8 button; + Sint32 x; + Sint32 y; + + explicit MouseUpEvent(const SDL_MouseButtonEvent& mbe) : + button(mbe.button), x(mbe.x), y(mbe.y) {} +}; + +struct MouseDownEvent { + Uint8 button; + Sint32 x; + Sint32 y; + + explicit MouseDownEvent(const SDL_MouseButtonEvent& mbe) : + button(mbe.button), x(mbe.x), y(mbe.y) {} +}; + /** * @class InputSystem * Listens for user input from SDL, and emits input events accordingly. @@ -79,6 +97,12 @@ public: if (auto key = event.key; key.repeat == 0) events.emit<KeyDownEvent>(key.keysym); break; + case SDL_MOUSEBUTTONUP: + events.emit<MouseUpEvent>(event.button); + break; + case SDL_MOUSEBUTTONDOWN: + events.emit<MouseDownEvent>(event.button); + break; default: break; } |