blob: d50c1aecfdbf36c695b765bfc1de00e8c41391c6 [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
Tim Kilbourndbc8c162015-05-19 15:04:30 -070020#include "InputDeviceManager.h"
21
Tim Kilbourn73475a42015-02-13 10:35:20 -080022#include <utils/Log.h>
23
24#include "InputDevice.h"
Tim Kilbourn73475a42015-02-13 10:35:20 -080025
26namespace android {
27
Tim Kilbournc929d252015-04-29 13:50:17 -070028void InputDeviceManager::onInputEvent(const std::shared_ptr<InputDeviceNode>& node, InputEvent& event,
Tim Kilbourn73475a42015-02-13 10:35:20 -080029 nsecs_t event_time) {
30 if (mDevices[node] == nullptr) {
31 ALOGE("got input event for unknown node %s", node->getPath().c_str());
32 return;
33 }
34 mDevices[node]->processInput(event, event_time);
35}
36
Tim Kilbournc929d252015-04-29 13:50:17 -070037void InputDeviceManager::onDeviceAdded(const std::shared_ptr<InputDeviceNode>& node) {
Tim Kilbourn3186e7b2015-04-16 15:32:08 -070038 mDevices[node] = std::make_shared<EvdevDevice>(mHost, node);
Tim Kilbourn73475a42015-02-13 10:35:20 -080039}
40
Tim Kilbournc929d252015-04-29 13:50:17 -070041void InputDeviceManager::onDeviceRemoved(const std::shared_ptr<InputDeviceNode>& node) {
Tim Kilbourn73475a42015-02-13 10:35:20 -080042 if (mDevices[node] == nullptr) {
43 ALOGE("could not remove unknown node %s", node->getPath().c_str());
44 return;
45 }
46 // TODO: tell the InputDevice and InputDeviceNode that they are being
Tim Kilbourn4f3145d2015-05-04 17:26:30 -070047 // removed so they can run any cleanup, including unregistering from the
48 // host.
Tim Kilbourn73475a42015-02-13 10:35:20 -080049 mDevices.erase(node);
50}
51
52} // namespace android