/[usata]/usata2/src/input-system.cpp
ViewVC logotype

Diff of /usata2/src/input-system.cpp

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

revision 1.2 by skunix, Tue Jan 25 08:28:27 2005 UTC revision 1.3 by skunix, Tue Jan 25 19:26:33 2005 UTC
# Line 17  Line 17 
17  #include <boost/shared_ptr.hpp>  #include <boost/shared_ptr.hpp>
18  #include <boost/bind.hpp>  #include <boost/bind.hpp>
19  #include "input-system.hpp"  #include "input-system.hpp"
20    #include "log.hpp"
21    
22  namespace usata  namespace usata
23  {  {
# Line 25  namespace input Line 26  namespace input
26    
27  typedef boost::shared_ptr<Driver> Driver_sp;  typedef boost::shared_ptr<Driver> Driver_sp;
28    
   
29  Event::Event(int type_)  Event::Event(int type_)
30  : mType (type_)  : mType (type_)
31  {  {
32    
33  }  }
34    KeyEvent::KeyEvent(unsigned Key, bool state)
35    :       Event(Type::KEY),
36            mKey(Key),
37            mState(state)
38    {
39            return;
40    }
41    
42    
43  Driver::Driver(const std::string& name)  Driver::Driver(const std::string& name)
44  :       mName(name)  :       mName(name)
45  {  {
# Line 52  Manager::trim() Line 61  Manager::trim()
61    
62          mDrivers.swap(mDrivers);          mDrivers.swap(mDrivers);
63  }  }
64    int
65    Manager::push_handler(const EventHandler& evh)
66    {
67            int stack_size = mEvhStack.size();
68            mEvhStack.push_back(evh);
69            return stack_size;
70    }
71    
72    int
73    Manager::pop_handler()
74    {
75            mEvhStack.pop_back();
76            return mEvhStack.size();
77    }
78    
79  void  void
80  Manager::process()  Manager::process()
# Line 70  Manager::process() Line 93  Manager::process()
93                          ne = (*it)->next();                          ne = (*it)->next();
94                          if (ne == 0)                          if (ne == 0)
95                                  break;                                  break;
96                            switch (ne->type())
                         if (ne->type() == input::Type::SYSTEM)  
97                          {                          {
98                                  SystemEvent *se = dynamic_cast<SystemEvent*>(ne);                                  case input::Type::SYSTEM:
99                                  if (se)                                  {
100                                            SystemEvent *se = dynamic_cast<SystemEvent*>(ne);
101                                            if (se)
102                                            {
103                                                    if (se->se_type()==SystemEvent::QUIT)
104                                                            quit_signal();
105                                            }
106                                            break;
107                                    }
108                                    case input::Type::KEY:
109                                  {                                  {
110                                          if (se->se_type()==SystemEvent::QUIT)                                          log::BufferedStream logs;
111                                                  quit_signal();                                          if (!mEvhStack.empty())
112                                            {
113                                                    mEvhStack.back()(ne);
114                                            }
115                                    
116                                  }                                  }
117                          }                          }
118    
# Line 87  Manager::process() Line 122  Manager::process()
122    
123                  ++it;                  ++it;
124          }          }
           
   
           
125          return;          return;
126  }  }
127  void  void

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

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