Made the source tree a little nicer, added some info for Fedora users.
[umd.git] / tests / util.h
blob9a6e691908c21bdc6e2ca63da96c57015bc926fc
1 #include <SDL/SDL.h>
3 #if defined(_WIN32) || defined(__WIN32__)
4 #include <windows.h>
6 inline void TestWait(int seconds)
8 Sleep(1000*seconds);
11 #else
12 #include <unistd.h>
14 inline void TestWait(int seconds)
16 sleep(seconds);
19 #endif
22 inline int VideoInit()
24 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
25 fprintf(stderr, "Could not initiliaze video: %s\n", SDL_GetError());
26 return 10;
29 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
30 if (!vi) {
31 fprintf(stderr, "Could not get video info: %s", SDL_GetError());
32 return 11;
35 if (!SDL_SetVideoMode(vi->current_w, vi->current_h, 0, SDL_FULLSCREEN)) {
36 fprintf(stderr, "Could not set a fullscreen video mode: %s", SDL_GetError());
37 return 12;
40 TestWait(2);
42 return 0;
45 inline int CollectInput(int *x, int *y, int *button)
47 TestWait(1);
49 SDL_Event e;
50 while (SDL_PollEvent(&e)) {
51 switch(e.type) {
52 case SDL_MOUSEMOTION:
53 *x = e.motion.x;
54 *y = e.motion.y;
55 break;
56 case SDL_MOUSEBUTTONDOWN:
57 *button = 1;
58 break;
62 return 0;
65 inline int VideoQuit()
67 SDL_Quit();