~alan-griffiths/mir/knee-jerk-mir_surface_state_automatic

« back to all changes in this revision

Viewing changes to src/input/android/android_input_manager.cpp

  • Committer: Kevin DuBois
  • Date: 2012-11-13 01:36:29 UTC
  • mfrom: (245 trunk)
  • mto: This revision was merged to the branch mainline in revision 246.
  • Revision ID: kevin.dubois@canonical.com-20121113013629-q4496w4mp5e33auk
merge in base branch. move the demo clients to a new directory, examples/

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012 Canonical Ltd.
 
3
 *
 
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.
 
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 General Public License for more details.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Robert Carr <robert.carr@canonical.com>
 
17
 *              Daniel d'Andradra <daniel.dandrada@canonical.com>
 
18
 */
 
19
 
 
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"
 
24
 
 
25
#include <memory>
 
26
#include <vector>
 
27
 
 
28
#include <EventHub.h>
 
29
#include <InputReader.h>
 
30
#include <InputDispatcher.h>
 
31
 
 
32
namespace mi = mir::input;
 
33
namespace mia = mi::android;
 
34
 
 
35
mia::InputManager::InputManager(droidinput::sp<droidinput::EventHubInterface> event_hub,
 
36
                                std::initializer_list<std::shared_ptr<mi::EventFilter> const> filters) :
 
37
  event_hub(event_hub),
 
38
  filter_chain(std::shared_ptr<mi::EventFilterChain>(new mi::EventFilterChain(filters)))
 
39
{
 
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);
 
46
    
 
47
    dispatcher->setInputDispatchMode(mia::DispatchEnabled, mia::DispatchUnfrozen);
 
48
    dispatcher->setInputFilterEnabled(true);
 
49
}
 
50
 
 
51
void mia::InputManager::stop()
 
52
{
 
53
    reader_thread->requestExit();
 
54
    dispatcher_thread->requestExit();
 
55
}
 
56
 
 
57
void mia::InputManager::start()
 
58
{
 
59
    dispatcher_thread->run("InputDispatcher", droidinput::PRIORITY_URGENT_DISPLAY);
 
60
    reader_thread->run("InputReader", droidinput::PRIORITY_URGENT_DISPLAY);
 
61
}
 
62