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 |
{ |
{ |
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 |
{ |
{ |
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() |
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 |
|
|
122 |
|
|
123 |
++it; |
++it; |
124 |
} |
} |
|
|
|
|
|
|
|
|
|
125 |
return; |
return; |
126 |
} |
} |
127 |
void |
void |