2 * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3 * Alexander Warg <warg@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
6 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
10 #include <l4/mag/server/input_driver>
11 #include <l4/mag/server/input_source>
13 #include <l4/sys/capability>
14 #include <l4/re/console>
15 #include <l4/re/util/event>
17 namespace Mag_server {
19 class Input_source_event : public Input_source
22 L4::Cap<L4Re::Event> _ev_cap;
23 L4Re::Util::Event _event;
25 void core(Core_api *c) { _core = c; }
29 while (L4Re::Event_buffer::Event *e = _event.buffer().next())
36 int get_stream_info(l4_umword_t stream_id, L4Re::Event_stream_info *info)
37 { return _ev_cap->get_stream_info_for_id(stream_id, info); }
39 int get_axis_info(l4_umword_t stream_id, unsigned naxes, unsigned *axes,
40 L4Re::Event_absinfo *info)
41 { return _ev_cap->get_axis_info(stream_id, naxes, axes, info); }
44 class Input_driver_event : public Input_driver
47 Input_source_event _source_be, _source_ev;
50 Input_driver_event() : Input_driver("L4Re::Event") {}
52 void start(Core_api *core)
54 L4::Cap<L4Re::Event> c =
55 L4::cap_dynamic_cast<L4Re::Event>(core->backend_fb());
57 _source_be.core(core);
58 _source_ev.core(core);
60 if (c && !_source_be._event.init(c, L4Re::Util::Event::Mode_polling))
62 _source_be._ev_cap = c;
63 core->add_input_source(&_source_be);
66 c = L4Re::Env::env()->get_cap<L4Re::Event>("ev");
67 if (c && !_source_ev._event.init(c, L4Re::Util::Event::Mode_polling))
69 _source_ev._ev_cap = c;
70 core->add_input_source(&_source_ev);
75 static Input_driver_event _evinput;