1 /* 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 "InputDeviceManager.h" 21 22 #include <utils/Log.h> 23 24 #include "InputDevice.h" 25 26 namespace android { 27 28 void InputDeviceManager::onInputEvent(const std::shared_ptr<InputDeviceNode>& node, InputEvent& event, 29 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 37 void InputDeviceManager::onDeviceAdded(const std::shared_ptr<InputDeviceNode>& node) { 38 mDevices[node] = std::make_shared<EvdevDevice>(mHost, node); 39 } 40 41 void InputDeviceManager::onDeviceRemoved(const std::shared_ptr<InputDeviceNode>& node) { 42 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 47 // removed so they can run any cleanup, including unregistering from the 48 // host. 49 mDevices.erase(node); 50 } 51 52 } // namespace android 53