Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
android_input_receiver.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Robert Carr <robert.carr@canonical.com>
17  */
18 
19 #ifndef MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_H_
20 #define MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_H_
21 
22 #include "mir_toolkit/event.h"
23 
24 #include <utils/StrongPointer.h>
25 #include <androidfw/Input.h>
26 
27 #include <memory>
28 #include <chrono>
29 
30 namespace droidinput = android;
31 
32 namespace android
33 {
34 class InputChannel;
35 class InputConsumer;
36 class Looper;
37 }
38 
39 namespace mir
40 {
41 namespace input
42 {
43 namespace receiver
44 {
45 class XKBMapper;
46 
47 namespace android
48 {
49 
51 class InputReceiver
52 {
53 public:
54  InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel);
55  InputReceiver(int fd);
56 
57  virtual ~InputReceiver();
58  int fd() const;
59 
62  virtual bool next_event(std::chrono::milliseconds const& timeout, MirEvent &ev);
63  virtual bool next_event(MirEvent &ev) { return next_event(std::chrono::milliseconds(-1), ev); }
64 
66  virtual void wake();
67 
68 protected:
69  InputReceiver(const InputReceiver&) = delete;
70  InputReceiver& operator=(const InputReceiver&) = delete;
71 
72 private:
73  droidinput::sp<droidinput::InputChannel> input_channel;
74  std::shared_ptr<droidinput::InputConsumer> input_consumer;
75  droidinput::PreallocatedInputEventFactory event_factory;
76  droidinput::sp<droidinput::Looper> looper;
77 
78  bool fd_added;
79 
80  std::shared_ptr<XKBMapper> xkb_mapper;
81 
82  bool try_next_event(MirEvent &ev);
83 };
84 
85 }
86 }
87 }
88 } // namespace mir
89 
90 #endif // MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_H_

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Oct 15 00:23:28 UTC 2013