2
* Copyright © 2013 Canonical Ltd.
2
* Copyright © 2013-2014 Canonical Ltd.
4
4
* This program is free software: you can redistribute it and/or modify it
5
5
* under the terms of the GNU General Public License version 3,
14
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
* Authored by: Robert Carr <robert.carr@canonical.com>
17
Andreas Pokorny <andreas.pokorny@canonical.com>
19
20
#include "mir/input/android/default_android_input_configuration.h"
24
25
#include "android_input_targeter.h"
25
26
#include "android_input_target_enumerator.h"
26
27
#include "android_input_manager.h"
28
#include "input_translator.h"
29
#include "input_channel_factory.h"
30
#include "common_input_thread.h"
32
#include "mir/input/event_filter.h"
35
#include <InputDispatcher.h>
27
37
#include "mir/input/event_filter.h"
29
39
#include <EventHub.h>
39
49
namespace ms = mir::scene;
40
50
namespace msh = mir::shell;
44
class CommonInputThread : public mia::InputThread
47
CommonInputThread(std::string const& name, droidinput::sp<droidinput::Thread> const& thread)
52
virtual ~CommonInputThread()
58
thread->run(name.c_str(), droidinput::PRIORITY_URGENT_DISPLAY);
62
thread->requestExit();
70
CommonInputThread(const CommonInputThread&) = delete;
71
CommonInputThread& operator=(const CommonInputThread&) = delete;
73
std::string const name;
74
droidinput::sp<droidinput::Thread> const thread;
78
mia::DefaultInputConfiguration::DefaultInputConfiguration(std::shared_ptr<mi::EventFilter> const& event_filter,
79
std::shared_ptr<mi::InputRegion> const& input_region,
80
std::shared_ptr<mi::CursorListener> const& cursor_listener,
81
std::shared_ptr<mi::InputReport> const& input_report)
82
: DispatcherInputConfiguration(event_filter, input_region, cursor_listener, input_report)
52
mia::DefaultInputConfiguration::DefaultInputConfiguration(
53
std::shared_ptr<mi::InputDispatcher> const& input_dispatcher,
54
std::shared_ptr<mi::InputRegion> const& input_region,
55
std::shared_ptr<CursorListener> const& cursor_listener,
56
std::shared_ptr<mi::InputReport> const& input_report) :
57
input_dispatcher(input_dispatcher),
58
input_region(input_region),
59
cursor_listener(cursor_listener),
60
input_report(input_report)
90
droidinput::sp<droidinput::InputDispatcherInterface> mia::DefaultInputConfiguration::the_dispatcher()
68
std::shared_ptr<mi::InputChannelFactory> mia::DefaultInputConfiguration::the_input_channel_factory()
93
[this]() -> droidinput::sp<droidinput::InputDispatcherInterface>
95
return new droidinput::InputDispatcher(the_dispatcher_policy(), input_report);
70
return std::make_shared<mia::InputChannelFactory>();
99
droidinput::sp<droidinput::EventHubInterface> mia::DefaultInputConfiguration::the_event_hub()
73
std::shared_ptr<droidinput::EventHubInterface> mia::DefaultInputConfiguration::the_event_hub()
104
return new droidinput::EventHub(input_report);
78
return std::make_shared<droidinput::EventHub>(input_report);
108
droidinput::sp<droidinput::InputReaderPolicyInterface> mia::DefaultInputConfiguration::the_reader_policy()
82
std::shared_ptr<droidinput::InputReaderPolicyInterface> mia::DefaultInputConfiguration::the_reader_policy()
110
84
return reader_policy(
113
return new mia::InputReaderPolicy(input_region, cursor_listener);
87
return std::make_shared<mia::InputReaderPolicy>(input_region, cursor_listener);
118
droidinput::sp<droidinput::InputReaderInterface> mia::DefaultInputConfiguration::the_reader()
92
std::shared_ptr<droidinput::InputReaderInterface> mia::DefaultInputConfiguration::the_reader()
123
return new droidinput::InputReader(the_event_hub(), the_reader_policy(), the_dispatcher());
97
return std::make_shared<droidinput::InputReader>(
98
the_event_hub(), the_reader_policy(), the_input_translator());
112
std::shared_ptr<droidinput::InputListenerInterface> mia::DefaultInputConfiguration::the_input_translator()
114
return std::make_shared<mia::InputTranslator>(input_dispatcher);
137
117
std::shared_ptr<mi::InputManager> mia::DefaultInputConfiguration::the_input_manager()
139
119
return input_manager(
120
[this]() -> std::shared_ptr<mi::InputManager>
142
return std::make_shared<mia::InputManager>(the_event_hub(), the_dispatcher(),
143
the_reader_thread(), the_dispatcher_thread());
122
return std::make_shared<mia::InputManager>(
124
the_reader_thread());