usata-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Usata-commits] Changes to usata2/src/input-system.cpp


From: David Lau
Subject: [Usata-commits] Changes to usata2/src/input-system.cpp
Date: Tue, 25 Jan 2005 14:26:35 -0500

Index: usata2/src/input-system.cpp
diff -u usata2/src/input-system.cpp:1.2 usata2/src/input-system.cpp:1.3
--- usata2/src/input-system.cpp:1.2     Tue Jan 25 08:28:27 2005
+++ usata2/src/input-system.cpp Tue Jan 25 19:26:33 2005
@@ -10,13 +10,14 @@
 // included in the software distribution, or visit
 // http://www.fsf.org/licenses/gpl.html.
 //
-// $Id: input-system.cpp,v 1.2 2005/01/25 08:28:27 skunix Exp $
+// $Id: input-system.cpp,v 1.3 2005/01/25 19:26:33 skunix Exp $
 
 #include <vector>
 #include <algorithm>
 #include <boost/shared_ptr.hpp>
 #include <boost/bind.hpp>
 #include "input-system.hpp"
+#include "log.hpp"
 
 namespace usata
 {
@@ -25,12 +26,20 @@
 
 typedef boost::shared_ptr<Driver> Driver_sp;
 
-
 Event::Event(int type_)
 : mType (type_)
 {
 
 }
+KeyEvent::KeyEvent(unsigned Key, bool state)
+:      Event(Type::KEY),
+       mKey(Key),
+       mState(state)
+{
+       return;
+}
+
+
 Driver::Driver(const std::string& name)
 :      mName(name)
 {
@@ -52,6 +61,20 @@
 
        mDrivers.swap(mDrivers);
 }
+int
+Manager::push_handler(const EventHandler& evh)
+{
+       int stack_size = mEvhStack.size();
+       mEvhStack.push_back(evh);
+       return stack_size;
+}
+
+int
+Manager::pop_handler()
+{
+       mEvhStack.pop_back();
+       return mEvhStack.size();
+}
 
 void
 Manager::process()
@@ -70,14 +93,26 @@
                        ne = (*it)->next();
                        if (ne == 0)
                                break;
-
-                       if (ne->type() == input::Type::SYSTEM)
+                       switch (ne->type())
                        {
-                               SystemEvent *se = 
dynamic_cast<SystemEvent*>(ne);
-                               if (se)
+                               case input::Type::SYSTEM:
+                               {
+                                       SystemEvent *se = 
dynamic_cast<SystemEvent*>(ne);
+                                       if (se)
+                                       {
+                                               if 
(se->se_type()==SystemEvent::QUIT)
+                                                       quit_signal();
+                                       }
+                                       break;
+                               }
+                               case input::Type::KEY:
                                {
-                                       if (se->se_type()==SystemEvent::QUIT)
-                                               quit_signal();
+                                       log::BufferedStream logs;
+                                       if (!mEvhStack.empty())
+                                       {
+                                               mEvhStack.back()(ne);
+                                       }
+                               
                                }
                        }
 
@@ -87,9 +122,6 @@
 
                ++it;
        }
-       
-
-       
        return; 
 }
 void




reply via email to

[Prev in Thread] Current Thread [Next in Thread]