2
* Copyright © 2012 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
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 General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Robert Carr <robert.carr@canonical.com>
17
* Daniel d'Andradra <daniel.dandrada@canonical.com>
20
#include "android_input_manager.h"
21
#include "android_input_constants.h"
22
#include "event_filter_dispatcher_policy.h"
23
#include "dummy_input_reader_policy.h"
29
#include <InputReader.h>
30
#include <InputDispatcher.h>
32
namespace mi = mir::input;
33
namespace mia = mi::android;
35
mia::InputManager::InputManager(droidinput::sp<droidinput::EventHubInterface> event_hub,
36
std::initializer_list<std::shared_ptr<mi::EventFilter> const> filters) :
38
filter_chain(std::shared_ptr<mi::EventFilterChain>(new mi::EventFilterChain(filters)))
40
droidinput::sp<droidinput::InputDispatcherPolicyInterface> dispatcher_policy = new mia::EventFilterDispatcherPolicy(filter_chain);
41
droidinput::sp<droidinput::InputReaderPolicyInterface> reader_policy = new mia::DummyInputReaderPolicy();
42
dispatcher = new droidinput::InputDispatcher(dispatcher_policy);
43
reader = new droidinput::InputReader(event_hub, reader_policy, dispatcher);
44
reader_thread = new droidinput::InputReaderThread(reader);
45
dispatcher_thread = new droidinput::InputDispatcherThread(dispatcher);
47
dispatcher->setInputDispatchMode(mia::DispatchEnabled, mia::DispatchUnfrozen);
48
dispatcher->setInputFilterEnabled(true);
51
void mia::InputManager::stop()
53
reader_thread->requestExit();
54
dispatcher_thread->requestExit();
57
void mia::InputManager::start()
59
dispatcher_thread->run("InputDispatcher", droidinput::PRIORITY_URGENT_DISPLAY);
60
reader_thread->run("InputReader", droidinput::PRIORITY_URGENT_DISPLAY);