blob: 79a9610be8deeb489e0f1f81aaa1bdb446660bd4 [file] [log] [blame]
Tim Kilbourn73475a42015-02-13 10:35:20 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "InputDeviceManager"
18//#define LOG_NDEBUG 0
19
20#include <utils/Log.h>
21
22#include "InputDevice.h"
23#include "InputDeviceManager.h"
24
25namespace android {
26
Tim Kilbournc929d252015-04-29 13:50:17 -070027void InputDeviceManager::onInputEvent(const std::shared_ptr<InputDeviceNode>& node, InputEvent& event,
Tim Kilbourn73475a42015-02-13 10:35:20 -080028 nsecs_t event_time) {
29 if (mDevices[node] == nullptr) {
30 ALOGE("got input event for unknown node %s", node->getPath().c_str());
31 return;
32 }
33 mDevices[node]->processInput(event, event_time);
34}
35
Tim Kilbournc929d252015-04-29 13:50:17 -070036void InputDeviceManager::onDeviceAdded(const std::shared_ptr<InputDeviceNode>& node) {
Tim Kilbourn73475a42015-02-13 10:35:20 -080037 mDevices[node] = std::make_shared<EvdevDevice>(node);
38}
39
Tim Kilbournc929d252015-04-29 13:50:17 -070040void InputDeviceManager::onDeviceRemoved(const std::shared_ptr<InputDeviceNode>& node) {
Tim Kilbourn73475a42015-02-13 10:35:20 -080041 if (mDevices[node] == nullptr) {
42 ALOGE("could not remove unknown node %s", node->getPath().c_str());
43 return;
44 }
45 // TODO: tell the InputDevice and InputDeviceNode that they are being
46 // removed so they can run any cleanup.
47 mDevices.erase(node);
48}
49
50} // namespace android