]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/mag/plugins/input_libinput/input_libinput.cc
update
[l4.git] / l4 / pkg / mag / plugins / input_libinput / input_libinput.cc
1 /*
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)
5  *
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.
9  */
10 #include <l4/mag/server/input_driver>
11 #include <l4/mag/server/input_source>
12
13 #include <l4/input/libinput.h>
14
15 namespace {
16 using Mag_server::Input_driver;
17 using Mag_server::Input_source;
18 using Mag_server::Core_api;
19 using Mag_server::User_state;
20
21 class Input_driver_libinput : public Input_driver, public Input_source
22 {
23 public:
24   Input_driver_libinput() : Input_driver("libinput") {}
25   void start(Core_api *core)
26   {
27     if (l4input_init(0xff, 0) == 0)
28       {
29         _core = core;
30         core->add_input_source(this);
31       }
32   }
33
34   void poll_events()
35   {
36     enum { N=20 };
37     L4Re::Event_buffer::Event _evb[N];
38     while (l4input_ispending())
39       {
40         L4Re::Event_buffer::Event *e = _evb;
41         for (int max = l4input_flush(_evb, N); max; --max, ++e)
42           post_event(e);
43       }
44   }
45
46   int get_stream_info(l4_umword_t stream_id, L4Re::Event_stream_info *info)
47   { return l4evdev_stream_info_for_id(stream_id, info); }
48   int get_axis_info(l4_umword_t stream_id, unsigned naxes, unsigned *axes,
49                     L4Re::Event_absinfo *info)
50   { return l4evdev_absinfo(stream_id, naxes, axes, info); }
51 };
52
53 static Input_driver_libinput _libinput;
54 }