aboutsummaryrefslogtreecommitdiffstats
path: root/src/input.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input.hpp')
-rw-r--r--src/input.hpp28
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;
}