Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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 class InputReceiverReport;
47 
48 namespace android
49 {
50 
52 class InputReceiver
53 {
54 public:
55  InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel,
56  std::shared_ptr<InputReceiverReport> const& report);
57  InputReceiver(int fd,
58  std::shared_ptr<InputReceiverReport> const& report);
59 
60  virtual ~InputReceiver();
61  int fd() const;
62 
65  virtual bool next_event(std::chrono::milliseconds const& timeout, MirEvent &ev);
66  virtual bool next_event(MirEvent &ev) { return next_event(std::chrono::milliseconds(-1), ev); }
67 
69  virtual void wake();
70 
71 protected:
72  InputReceiver(const InputReceiver&) = delete;
73  InputReceiver& operator=(const InputReceiver&) = delete;
74 
75 private:
76  droidinput::sp<droidinput::InputChannel> input_channel;
77  std::shared_ptr<InputReceiverReport> const report;
78 
79  std::shared_ptr<droidinput::InputConsumer> input_consumer;
80  droidinput::PreallocatedInputEventFactory event_factory;
81  droidinput::sp<droidinput::Looper> looper;
82 
83  bool fd_added;
84 
85  std::shared_ptr<XKBMapper> xkb_mapper;
86 
87  bool try_next_event(MirEvent &ev);
88 };
89 
90 }
91 }
92 }
93 } // namespace mir
94 
95 #endif // MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_H_
input_rectangles report(report)
Definition: event.h:207

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014