]> git.localhorst.tv Git - blobs.git/blob - tst/event.hpp
test basic interaction
[blobs.git] / tst / event.hpp
1 #ifndef BLOBS_TEST_EVENT_HPP_
2 #define BLOBS_TEST_EVENT_HPP_
3
4 #include <SDL.h>
5
6
7 namespace blobs {
8 namespace test {
9
10 inline void FakeKeyDown(int sym) {
11         SDL_Event e;
12         e.type = SDL_KEYDOWN;
13         e.key.keysym.sym = sym;
14         SDL_PushEvent(&e);
15 }
16
17 inline void FakeKeyUp(int sym) {
18         SDL_Event e;
19         e.type = SDL_KEYUP;
20         e.key.keysym.sym = sym;
21         SDL_PushEvent(&e);
22 }
23
24 inline void FakeKeyPress(int sym) {
25         FakeKeyDown(sym);
26         FakeKeyUp(sym);
27 }
28
29 inline void FakeMouseDown(int button = SDL_BUTTON_LEFT, int x = 0, int y = 0) {
30         SDL_Event e;
31         e.type = SDL_MOUSEBUTTONDOWN;
32         e.button.button = button;
33         e.button.x = x;
34         e.button.y = y;
35         SDL_PushEvent(&e);
36 }
37
38 inline void FakeMouseUp(int button = SDL_BUTTON_LEFT, int x = 0, int y = 0) {
39         SDL_Event e;
40         e.type = SDL_MOUSEBUTTONUP;
41         e.button.button = button;
42         e.button.x = x;
43         e.button.y = y;
44         SDL_PushEvent(&e);
45 }
46
47 inline void FakeMouseClick(int button = SDL_BUTTON_LEFT, int x = 0, int y = 0) {
48         FakeMouseDown(button, x, y);
49         FakeMouseUp(button, x, y);
50 }
51
52 inline void FakeMouseMotion(int xrel = 0, int yrel = 0) {
53         SDL_Event e;
54         e.type = SDL_MOUSEMOTION;
55         e.motion.xrel = xrel;
56         e.motion.yrel = yrel;
57         SDL_PushEvent(&e);
58 }
59
60 inline void FakeMouseWheel(int y = 0, int x = 0) {
61         SDL_Event e;
62         e.type = SDL_MOUSEWHEEL;
63         e.wheel.x = x;
64         e.wheel.y = y;
65         SDL_PushEvent(&e);
66 }
67
68 inline void FakeQuit() {
69         SDL_Event e;
70         e.type = SDL_QUIT;
71         SDL_PushEvent(&e);
72 }
73
74 }
75 }
76
77 #endif