/[usata]/usata2/src/sdl/input.cpp
ViewVC logotype

Diff of /usata2/src/sdl/input.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by skunix, Fri Feb 25 19:50:48 2005 UTC revision 1.4 by skunix, Wed Mar 2 00:27:11 2005 UTC
# Line 13  Line 13 
13  // $Id$  // $Id$
14    
15  #include <queue>  #include <queue>
16    #include <vector>
17    #include <SDL.h>
18    
19  #include "../input-system.hpp"  #include "../input-system.hpp"
 #include <SDL.h>  
 #include <vector>  
20  #include "../log.hpp"  #include "../log.hpp"
21    
22    
23  namespace usata { namespace input{  namespace usata {
24    namespace input {
25  namespace {  namespace {
26    
 //using namespace input;  
27  struct SDL2Usata  struct SDL2Usata
28  {  {
29          SDLKey s;          SDLKey s;
# Line 41  SDL2Usata key_conversion[]= Line 41  SDL2Usata key_conversion[]=
41    
42  size_t key_conversion_len = sizeof(key_conversion)/sizeof(SDL2Usata);  size_t key_conversion_len = sizeof(key_conversion)/sizeof(SDL2Usata);
43    
44  int key_convert(SDLKey sk)  int key_convert(SDLKey sk) throw()
45  {  {
46          SDL2Usata *conv3rt = &key_conversion[0];          SDL2Usata *conv3rt = &key_conversion[0];
47          int retval(Key::UNKNOWN);          int retval(Key::UNKNOWN);
# Line 63  class SDLDriver : public input::Driver Line 63  class SDLDriver : public input::Driver
63          std::queue<input::Event*> mEventQueue;          std::queue<input::Event*> mEventQueue;
64          public:          public:
65                  SDLDriver();                  SDLDriver();
66                  virtual ~SDLDriver();                  virtual ~SDLDriver()throw();
67                  virtual Event* next();                  virtual Event* next();
68                  Event* process(SDL_Event&);                  static Event* process(SDL_Event&) throw();
69                    static Event* key_process(SDL_Event&ev)throw();
70    
71                  virtual void update();                  virtual void update();
72  };  };
73    
74  SDLDriver::SDLDriver()  SDLDriver::SDLDriver()
75  : input::Driver("SDL")  : input::Driver("SDL")
76  {  {
77            log::BufferedStream ls(log::Level::INFO);
78            ls << "SDL input Driver initialized" << log::commit;
79            
80  }  }
81    
82  SDLDriver::~SDLDriver()  SDLDriver::~SDLDriver() throw()
83  {  {
84  }  }
85    
# Line 91  SDLDriver::next() Line 95  SDLDriver::next()
95  }  }
96    
97  Event*  Event*
98  SDLDriver::process(SDL_Event&ev)  SDLDriver::key_process(SDL_Event&ev) throw()
99    {
100            Event*retval;
101            bool state=false;
102            if (ev.type == SDL_KEYDOWN)
103                    state=true;
104    
105            int key = key_convert(ev.key.keysym.sym);              
106    
107            retval = new KeyEvent(key, state);
108    
109            return retval;
110    };
111    
112    
113    Event*
114    SDLDriver::process(SDL_Event&ev) throw()
115  {  {
116                    
117          switch (ev.type)          switch (ev.type)
118          {          {
119                  case SDL_KEYDOWN:                  case SDL_KEYDOWN:
120                  case SDL_KEYUP:                  case SDL_KEYUP:
121  //                      return key_process();                          return key_process(ev);
122                          break;  
123                  case SDL_QUIT:                  case SDL_QUIT:
124                          return new SystemEvent(SystemEvent::QUIT);                                return new SystemEvent(SystemEvent::QUIT);      
                         break;  
125    
126          };          };
127          return 0;          return 0;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26