X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=tst%2Fevent.hpp;fp=tst%2Fevent.hpp;h=315d0d46dba2736ce7e3f16d0e1e2c44583dd71e;hp=0000000000000000000000000000000000000000;hb=cf31daa35ac163986158b6f95df06fd7b43f6e79;hpb=34697f07a0bb7b26b3eb2f102d18fb74e5ed7ec4 diff --git a/tst/event.hpp b/tst/event.hpp new file mode 100644 index 0000000..315d0d4 --- /dev/null +++ b/tst/event.hpp @@ -0,0 +1,77 @@ +#ifndef BLOBS_TEST_EVENT_HPP_ +#define BLOBS_TEST_EVENT_HPP_ + +#include + + +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