]> git.localhorst.tv Git - blobs.git/blobdiff - tst/event.hpp
test basic interaction
[blobs.git] / tst / event.hpp
diff --git a/tst/event.hpp b/tst/event.hpp
new file mode 100644 (file)
index 0000000..315d0d4
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef BLOBS_TEST_EVENT_HPP_
+#define BLOBS_TEST_EVENT_HPP_
+
+#include <SDL.h>
+
+
+namespace blobs {
+namespace test {
+
+inline void FakeKeyDown(int sym) {
+       SDL_Event e;
+       e.type = SDL_KEYDOWN;
+       e.key.keysym.sym = sym;
+       SDL_PushEvent(&e);
+}
+
+inline void FakeKeyUp(int sym) {
+       SDL_Event e;
+       e.type = SDL_KEYUP;
+       e.key.keysym.sym = sym;
+       SDL_PushEvent(&e);
+}
+
+inline void FakeKeyPress(int sym) {
+       FakeKeyDown(sym);
+       FakeKeyUp(sym);
+}
+
+inline void FakeMouseDown(int button = SDL_BUTTON_LEFT, int x = 0, int y = 0) {
+       SDL_Event e;
+       e.type = SDL_MOUSEBUTTONDOWN;
+       e.button.button = button;
+       e.button.x = x;
+       e.button.y = y;
+       SDL_PushEvent(&e);
+}
+
+inline void FakeMouseUp(int button = SDL_BUTTON_LEFT, int x = 0, int y = 0) {
+       SDL_Event e;
+       e.type = SDL_MOUSEBUTTONUP;
+       e.button.button = button;
+       e.button.x = x;
+       e.button.y = y;
+       SDL_PushEvent(&e);
+}
+
+inline void FakeMouseClick(int button = SDL_BUTTON_LEFT, int x = 0, int y = 0) {
+       FakeMouseDown(button, x, y);
+       FakeMouseUp(button, x, y);
+}
+
+inline void FakeMouseMotion(int xrel = 0, int yrel = 0) {
+       SDL_Event e;
+       e.type = SDL_MOUSEMOTION;
+       e.motion.xrel = xrel;
+       e.motion.yrel = yrel;
+       SDL_PushEvent(&e);
+}
+
+inline void FakeMouseWheel(int y = 0, int x = 0) {
+       SDL_Event e;
+       e.type = SDL_MOUSEWHEEL;
+       e.wheel.x = x;
+       e.wheel.y = y;
+       SDL_PushEvent(&e);
+}
+
+inline void FakeQuit() {
+       SDL_Event e;
+       e.type = SDL_QUIT;
+       SDL_PushEvent(&e);
+}
+
+}
+}
+
+#endif