added struct subsys so that we know each
[winnie] / src / sdl / event.cc
1 /*
2 winnie - an experimental window system
3
4 Copyright (C) 2013 Eleni Maria Stea
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 Author: Eleni Maria Stea <elene.mst@gmail.com>
20 */
21
22 #ifdef WINNIE_SDL
23 #include <stdlib.h>
24 #include <SDL/SDL.h>
25
26 #include "event.h"
27 #include "keyboard.h"
28 #include "mouse.h"
29 #include "wm.h"
30
31 SDL_Event sdl_event;
32 void process_events()
33 {
34         wm->process_windows();
35         if(!SDL_WaitEvent(&sdl_event)) {
36                 return;
37         }
38
39         switch(sdl_event.type) {
40         case SDL_KEYDOWN:
41         case SDL_KEYUP:
42                 process_keyboard_event();
43                 break;
44         case SDL_MOUSEMOTION:
45         case SDL_MOUSEBUTTONDOWN:
46         case SDL_MOUSEBUTTONUP:
47                 process_mouse_event();
48                 break;
49         case SDL_QUIT:
50                 exit(0);
51         default:
52                 break;
53         }
54 }
55
56 #endif // WINNIE_SDL