1 // Description: 2 // Converts SDL events to stream 3 // 4 // Copyright (C) 2003 Frank Becker 5 // 6 // This program is free software; you can redistribute it and/or modify it under 7 // the terms of the GNU General Public License as published by the Free Software 8 // Foundation; either version 2 of the License, or (at your option) any later 9 // version. 10 // 11 // This program is distributed in the hope that it will be useful, but WITHOUT 12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details 14 // 15 #ifndef _EventWatcher_hpp_ 16 #define _EventWatcher_hpp_ 17 18 #include "SDL.h" 19 20 #include <iostream> 21 using namespace std; 22 23 #include "GameState.hpp" 24 25 class EventWatcher 26 { 27 public: EventWatcher(ostream & os)28 EventWatcher( ostream &os): 29 _outStream(os) 30 { 31 } 32 notify(SDL_Event & event)33 void notify( SDL_Event &event) 34 { 35 switch( event.type) 36 { 37 case SDL_KEYDOWN: 38 case SDL_KEYUP: 39 _outStream << GameState::gameTick << " "; 40 _outStream << (unsigned int)event.type << " "; 41 _outStream << (unsigned int)event.key.keysym.sym << "\n"; 42 break; 43 } 44 } 45 46 private: 47 ostream &_outStream; 48 }; 49 50 #endif 51