Lines Matching refs:device

976     Device* device = getDeviceLocked(deviceId);  in getDeviceIdentifier()  local
977 return device != nullptr ? device->identifier : InputDeviceIdentifier(); in getDeviceIdentifier()
982 Device* device = getDeviceLocked(deviceId); in getDeviceClasses() local
983 return device != nullptr ? device->classes : ftl::Flags<InputDeviceClass>(0); in getDeviceClasses()
988 Device* device = getDeviceLocked(deviceId); in getDeviceControllerNumber() local
989 return device != nullptr ? device->controllerNumber : 0; in getDeviceControllerNumber()
994 Device* device = getDeviceLocked(deviceId); in getConfiguration() local
995 if (device == nullptr || device->configuration == nullptr) { in getConfiguration()
998 return *device->configuration; in getConfiguration()
1008 const Device* device = getDeviceLocked(deviceId); in getAbsoluteAxisInfo() local
1009 if (device == nullptr) { in getAbsoluteAxisInfo()
1015 auto it = device->absState.find(axis); in getAbsoluteAxisInfo()
1016 if (it == device->absState.end()) { in getAbsoluteAxisInfo()
1026 Device* device = getDeviceLocked(deviceId); in hasRelativeAxis() local
1027 return device != nullptr ? device->relBitmask.test(axis) : false; in hasRelativeAxis()
1035 Device* device = getDeviceLocked(deviceId); in hasInputProperty() local
1036 return property >= 0 && property <= INPUT_PROP_MAX && device != nullptr in hasInputProperty()
1037 ? device->propBitmask.test(property) in hasInputProperty()
1044 Device* device = getDeviceLocked(deviceId); in hasMscEvent() local
1045 return mscEvent >= 0 && mscEvent <= MSC_MAX && device != nullptr in hasMscEvent()
1046 ? device->mscBitmask.test(mscEvent) in hasMscEvent()
1055 const Device* device = getDeviceLocked(deviceId); in getScanCodeState() local
1056 if (device == nullptr || !device->hasValidFd() || !device->keyBitmask.test(scanCode)) { in getScanCodeState()
1059 return device->keyState.test(scanCode) ? AKEY_STATE_DOWN : AKEY_STATE_UP; in getScanCodeState()
1064 const Device* device = getDeviceLocked(deviceId); in getKeyCodeState() local
1065 if (device == nullptr || !device->hasValidFd() || !device->keyMap.haveKeyLayout()) { in getKeyCodeState()
1069 device->keyMap.keyLayoutMap->findScanCodesForKey(keyCode); in getKeyCodeState()
1074 [&device](const int32_t sc) { in getKeyCodeState()
1075 return sc >= 0 && sc <= KEY_MAX && device->keyState.test(sc); in getKeyCodeState()
1084 Device* device = getDeviceLocked(deviceId); in getKeyCodeForKeyLocation() local
1085 if (device == nullptr || !device->hasValidFd() || device->keyMap.keyCharacterMap == nullptr || in getKeyCodeForKeyLocation()
1086 device->keyMap.keyLayoutMap == nullptr) { in getKeyCodeForKeyLocation()
1090 device->keyMap.keyLayoutMap->findScanCodesForKey(locationKeyCode); in getKeyCodeForKeyLocation()
1103 device->getKeyCharacterMap()->mapKey(scanCodes[0], /*usageCode=*/0, &outKeyCode); in getKeyCodeForKeyLocation()
1118 return device->getKeyCharacterMap()->applyKeyRemapping(outKeyCode); in getKeyCodeForKeyLocation()
1126 const Device* device = getDeviceLocked(deviceId); in getSwitchState() local
1127 if (device == nullptr || !device->hasValidFd() || !device->swBitmask.test(sw)) { in getSwitchState()
1130 return device->swState.test(sw) ? AKEY_STATE_DOWN : AKEY_STATE_UP; in getSwitchState()
1139 const Device* device = getDeviceLocked(deviceId); in getAbsoluteAxisValue() local
1140 if (device == nullptr || !device->hasValidFd()) { in getAbsoluteAxisValue()
1143 const auto it = device->absState.find(axis); in getAbsoluteAxisValue()
1144 if (it == device->absState.end()) { in getAbsoluteAxisValue()
1154 const Device* device = getDeviceLocked(deviceId); in getMtSlotValues() local
1155 if (device == nullptr || !device->hasValidFd() || !device->absBitmask.test(axis)) { in getMtSlotValues()
1161 if (ioctl(device->fd, EVIOCGMTSLOTS(bufferSize), outValues.data()) != OK) { in getMtSlotValues()
1171 Device* device = getDeviceLocked(deviceId); in markSupportedKeyCodes() local
1172 if (device != nullptr && device->keyMap.haveKeyLayout()) { in markSupportedKeyCodes()
1174 if (device->hasKeycodeLocked(keyCodes[codeIndex])) { in markSupportedKeyCodes()
1185 Device* device = getDeviceLocked(deviceId); in addKeyRemapping() local
1186 if (device == nullptr) { in addKeyRemapping()
1189 const std::shared_ptr<KeyCharacterMap> kcm = device->getKeyCharacterMap(); in addKeyRemapping()
1198 Device* device = getDeviceLocked(deviceId); in mapKey() local
1201 if (device != nullptr) { in mapKey()
1203 const std::shared_ptr<KeyCharacterMap> kcm = device->getKeyCharacterMap(); in mapKey()
1212 if (status != NO_ERROR && device->keyMap.haveKeyLayout()) { in mapKey()
1213 if (!device->keyMap.keyLayoutMap->mapKey(scanCode, usageCode, outKeycode, outFlags)) { in mapKey()
1244 Device* device = getDeviceLocked(deviceId); in mapAxis() local
1246 if (device == nullptr || !device->keyMap.haveKeyLayout()) { in mapAxis()
1249 std::optional<AxisInfo> info = device->keyMap.keyLayoutMap->mapAxis(scanCode); in mapAxis()
1260 Device* device = getDeviceLocked(deviceId); in mapSensor() local
1262 if (device != nullptr && device->keyMap.haveKeyLayout()) { in mapSensor()
1263 return device->keyMap.keyLayoutMap->mapSensor(absCode); in mapSensor()
1273 Device* device = getDeviceLocked(deviceId); in getBatteryInfoLocked() local
1274 if (device == nullptr || !device->associatedDevice) { in getBatteryInfoLocked()
1277 return device->associatedDevice->batteryInfos; in getBatteryInfoLocked()
1310 Device* device = getDeviceLocked(deviceId); in getLightInfoLocked() local
1311 if (device == nullptr || !device->associatedDevice) { in getLightInfoLocked()
1314 return device->associatedDevice->lightInfos; in getLightInfoLocked()
1456 Device* device = getDeviceLocked(deviceId); in getRawLayoutInfo() local
1457 if (device == nullptr || !device->associatedDevice) { in getRawLayoutInfo()
1460 return device->associatedDevice->layoutInfo; in getRawLayoutInfo()
1471 Device* device = getDeviceLocked(deviceId); in hasScanCode() local
1472 if (device != nullptr && scanCode >= 0 && scanCode <= KEY_MAX) { in hasScanCode()
1473 return device->keyBitmask.test(scanCode); in hasScanCode()
1480 Device* device = getDeviceLocked(deviceId); in hasKeyCode() local
1481 if (device != nullptr) { in hasKeyCode()
1482 return device->hasKeycodeLocked(keyCode); in hasKeyCode()
1489 Device* device = getDeviceLocked(deviceId); in hasLed() local
1491 if (device != nullptr && device->mapLed(led, &sc) == NO_ERROR) { in hasLed()
1492 return device->ledBitmask.test(sc); in hasLed()
1499 Device* device = getDeviceLocked(deviceId); in setLedState() local
1500 if (device != nullptr && device->hasValidFd()) { in setLedState()
1501 device->setLedStateLocked(led, on); in setLedState()
1510 Device* device = getDeviceLocked(deviceId); in getVirtualKeyDefinitions() local
1511 if (device != nullptr && device->virtualKeyMap) { in getVirtualKeyDefinitions()
1513 device->virtualKeyMap->getVirtualKeys(); in getVirtualKeyDefinitions()
1520 Device* device = getDeviceLocked(deviceId); in getKeyCharacterMap() local
1521 if (device != nullptr) { in getKeyCharacterMap()
1522 return device->getKeyCharacterMap(); in getKeyCharacterMap()
1530 Device* device = getDeviceLocked(deviceId); in setKeyboardLayoutOverlay() local
1531 if (device == nullptr || device->keyMap.keyCharacterMap == nullptr) { in setKeyboardLayoutOverlay()
1535 device->keyMap.keyCharacterMap->clearLayoutOverlay(); in setKeyboardLayoutOverlay()
1538 device->keyMap.keyCharacterMap->combine(*map); in setKeyboardLayoutOverlay()
1646 Device* device = getDeviceLocked(deviceId); in vibrate() local
1647 if (device != nullptr && device->hasValidFd()) { in vibrate()
1651 effect.id = device->ffEffectId; in vibrate()
1657 if (ioctl(device->fd, EVIOCSFF, &effect)) { in vibrate()
1659 device->identifier.name.c_str(), errno); in vibrate()
1662 device->ffEffectId = effect.id; in vibrate()
1668 ev.code = device->ffEffectId; in vibrate()
1670 if (write(device->fd, &ev, sizeof(ev)) != sizeof(ev)) { in vibrate()
1672 device->identifier.name.c_str(), errno); in vibrate()
1675 device->ffEffectPlaying = true; in vibrate()
1681 Device* device = getDeviceLocked(deviceId); in cancelVibrate() local
1682 if (device != nullptr && device->hasValidFd()) { in cancelVibrate()
1683 if (device->ffEffectPlaying) { in cancelVibrate()
1684 device->ffEffectPlaying = false; in cancelVibrate()
1690 ev.code = device->ffEffectId; in cancelVibrate()
1692 if (write(device->fd, &ev, sizeof(ev)) != sizeof(ev)) { in cancelVibrate()
1694 device->identifier.name.c_str(), errno); in cancelVibrate()
1704 Device* device = getDeviceLocked(deviceId); in getVibratorIds() local
1705 if (device != nullptr && device->hasValidFd() && in getVibratorIds()
1706 device->classes.test(InputDeviceClass::VIBRATOR)) { in getVibratorIds()
1717 for (const auto& device : mOpeningDevices) { in hasDeviceWithDescriptorLocked() local
1718 if (descriptor == device->identifier.descriptor) { in hasDeviceWithDescriptorLocked()
1723 for (const auto& [id, device] : mDevices) { in hasDeviceWithDescriptorLocked()
1724 if (descriptor == device->identifier.descriptor) { in hasDeviceWithDescriptorLocked()
1740 for (const auto& [id, device] : mDevices) { in getDeviceByPathLocked()
1741 if (device->path == devicePath) { in getDeviceByPathLocked()
1742 return device.get(); in getDeviceByPathLocked()
1756 for (const auto& [id, device] : mDevices) { in getDeviceByFdLocked()
1757 if (device->fd == fd) { in getDeviceByFdLocked()
1759 return device.get(); in getDeviceByFdLocked()
1761 if (device->videoDevice && device->videoDevice->getFd() == fd) { in getDeviceByFdLocked()
1763 return device.get(); in getDeviceByFdLocked()
1871 std::unique_ptr<Device> device = std::move(*it); in getEvents() local
1872 ALOGV("Reporting device closed: id=%d, name=%s\n", device->id, device->path.c_str()); in getEvents()
1873 const int32_t deviceId = (device->id == mBuiltInKeyboardId) in getEvents()
1875 : device->id; in getEvents()
1895 std::unique_ptr<Device> device = std::move(*mOpeningDevices.rbegin()); in getEvents() local
1897 ALOGV("Reporting device opened: id=%d, name=%s\n", device->id, device->path.c_str()); in getEvents()
1898 const int32_t deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id; in getEvents()
1909 if (tryAddVideoDeviceLocked(*device, videoDevice)) { in getEvents()
1916 auto [dev_it, inserted] = mDevices.insert_or_assign(device->id, std::move(device)); in getEvents()
1918 ALOGW("Device id %d exists, replaced.", device->id); in getEvents()
1966 Device* device = getDeviceByFdLocked(eventItem.data.fd); in getEvents() local
1967 if (device == nullptr) { in getEvents()
1973 if (device->videoDevice && eventItem.data.fd == device->videoDevice->getFd()) { in getEvents()
1975 size_t numFrames = device->videoDevice->readAndQueueFrames(); in getEvents()
1978 device->videoDevice->getName().c_str()); in getEvents()
1983 device->videoDevice->getName().c_str()); in getEvents()
1984 unregisterVideoDeviceFromEpollLocked(*device->videoDevice); in getEvents()
1985 device->videoDevice = nullptr; in getEvents()
1988 device->videoDevice->getName().c_str()); in getEvents()
1996 read(device->fd, readBuffer.data(), in getEvents()
2002 device->fd, readSize, readBuffer.size(), errno); in getEvents()
2004 closeDeviceLocked(*device); in getEvents()
2012 const int32_t deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id; in getEvents()
2017 device->trackInputEvent(iev); in getEvents()
2036 device->identifier.name.c_str()); in getEvents()
2038 closeDeviceLocked(*device); in getEvents()
2041 device->identifier.name.c_str()); in getEvents()
2115 Device* device = getDeviceLocked(deviceId); in getVideoFrames() local
2116 if (device == nullptr || !device->videoDevice) { in getVideoFrames()
2119 return device->videoDevice->consumeFrames(); in getVideoFrames()
2183 status_t EventHub::registerDeviceForEpollLocked(Device& device) { in registerDeviceForEpollLocked() argument
2184 status_t result = registerFdForEpoll(device.fd); in registerDeviceForEpollLocked()
2186 ALOGE("Could not add input device fd to epoll for device %" PRId32, device.id); in registerDeviceForEpollLocked()
2189 if (device.videoDevice) { in registerDeviceForEpollLocked()
2190 registerVideoDeviceForEpollLocked(*device.videoDevice); in registerDeviceForEpollLocked()
2202 status_t EventHub::unregisterDeviceFromEpollLocked(Device& device) { in unregisterDeviceFromEpollLocked() argument
2203 if (device.hasValidFd()) { in unregisterDeviceFromEpollLocked()
2204 status_t result = unregisterFdFromEpoll(device.fd); in unregisterDeviceFromEpollLocked()
2206 ALOGW("Could not remove input device fd from epoll for device %" PRId32, device.id); in unregisterDeviceFromEpollLocked()
2210 if (device.videoDevice) { in unregisterDeviceFromEpollLocked()
2211 unregisterVideoDeviceFromEpollLocked(*device.videoDevice); in unregisterDeviceFromEpollLocked()
2250 for (const auto& [deviceId, device] : mDevices) { in openDeviceLocked()
2251 if (device->path == devicePath) { in openDeviceLocked()
2338 std::unique_ptr<Device> device = in openDeviceLocked() local
2356 device->loadConfigurationLocked(); in openDeviceLocked()
2359 device->readDeviceBitMask(EVIOCGBIT(EV_KEY, 0), device->keyBitmask); in openDeviceLocked()
2360 device->readDeviceBitMask(EVIOCGBIT(EV_ABS, 0), device->absBitmask); in openDeviceLocked()
2361 device->readDeviceBitMask(EVIOCGBIT(EV_REL, 0), device->relBitmask); in openDeviceLocked()
2362 device->readDeviceBitMask(EVIOCGBIT(EV_SW, 0), device->swBitmask); in openDeviceLocked()
2363 device->readDeviceBitMask(EVIOCGBIT(EV_LED, 0), device->ledBitmask); in openDeviceLocked()
2364 device->readDeviceBitMask(EVIOCGBIT(EV_FF, 0), device->ffBitmask); in openDeviceLocked()
2365 device->readDeviceBitMask(EVIOCGBIT(EV_MSC, 0), device->mscBitmask); in openDeviceLocked()
2366 device->readDeviceBitMask(EVIOCGPROP(0), device->propBitmask); in openDeviceLocked()
2371 device->keyBitmask.any(0, BTN_MISC) || device->keyBitmask.any(BTN_WHEEL, KEY_MAX + 1); in openDeviceLocked()
2372 bool haveGamepadButtons = device->keyBitmask.any(BTN_MISC, BTN_MOUSE) || in openDeviceLocked()
2373 device->keyBitmask.any(BTN_JOYSTICK, BTN_DIGI); in openDeviceLocked()
2374 bool haveStylusButtons = device->keyBitmask.test(BTN_STYLUS) || in openDeviceLocked()
2375 device->keyBitmask.test(BTN_STYLUS2) || device->keyBitmask.test(BTN_STYLUS3); in openDeviceLocked()
2377 device->classes |= InputDeviceClass::KEYBOARD; in openDeviceLocked()
2381 if (device->keyBitmask.test(BTN_MOUSE) && device->relBitmask.test(REL_X) && in openDeviceLocked()
2382 device->relBitmask.test(REL_Y)) { in openDeviceLocked()
2383 device->classes |= InputDeviceClass::CURSOR; in openDeviceLocked()
2387 if (device->configuration) { in openDeviceLocked()
2388 std::string deviceType = device->configuration->getString("device.type").value_or(""); in openDeviceLocked()
2390 device->classes |= InputDeviceClass::ROTARY_ENCODER; in openDeviceLocked()
2392 device->classes |= InputDeviceClass::EXTERNAL_STYLUS; in openDeviceLocked()
2398 if (device->absBitmask.test(ABS_MT_POSITION_X) && device->absBitmask.test(ABS_MT_POSITION_Y)) { in openDeviceLocked()
2402 if (device->keyBitmask.test(BTN_TOUCH) || !haveGamepadButtons) { in openDeviceLocked()
2403 device->classes |= (InputDeviceClass::TOUCH | InputDeviceClass::TOUCH_MT); in openDeviceLocked()
2404 if (device->propBitmask.test(INPUT_PROP_POINTER) && in openDeviceLocked()
2405 !device->keyBitmask.any(BTN_TOOL_PEN, BTN_TOOL_FINGER) && !haveStylusButtons) { in openDeviceLocked()
2406 device->classes |= InputDeviceClass::TOUCHPAD; in openDeviceLocked()
2410 } else if (device->keyBitmask.test(BTN_TOUCH) && device->absBitmask.test(ABS_X) && in openDeviceLocked()
2411 device->absBitmask.test(ABS_Y)) { in openDeviceLocked()
2412 device->classes |= InputDeviceClass::TOUCH; in openDeviceLocked()
2414 } else if ((device->absBitmask.test(ABS_PRESSURE) || device->keyBitmask.test(BTN_TOUCH)) && in openDeviceLocked()
2415 !device->absBitmask.test(ABS_X) && !device->absBitmask.test(ABS_Y)) { in openDeviceLocked()
2416 device->classes |= InputDeviceClass::EXTERNAL_STYLUS; in openDeviceLocked()
2423 auto assumedClasses = device->classes | InputDeviceClass::JOYSTICK; in openDeviceLocked()
2425 if (device->absBitmask.test(i) && in openDeviceLocked()
2427 device->classes = assumedClasses; in openDeviceLocked()
2434 if (device->propBitmask.test(INPUT_PROP_ACCELEROMETER)) { in openDeviceLocked()
2435 device->classes |= InputDeviceClass::SENSOR; in openDeviceLocked()
2440 if (device->swBitmask.test(i)) { in openDeviceLocked()
2441 device->classes |= InputDeviceClass::SWITCH; in openDeviceLocked()
2447 if (device->ffBitmask.test(FF_RUMBLE)) { in openDeviceLocked()
2448 device->classes |= InputDeviceClass::VIBRATOR; in openDeviceLocked()
2452 if ((device->classes.test(InputDeviceClass::TOUCH))) { in openDeviceLocked()
2455 bool success = device->loadVirtualKeyMapLocked(); in openDeviceLocked()
2457 device->classes |= InputDeviceClass::KEYBOARD; in openDeviceLocked()
2465 if (device->classes.any(InputDeviceClass::KEYBOARD | InputDeviceClass::JOYSTICK | in openDeviceLocked()
2468 keyMapStatus = device->loadKeyMapLocked(); in openDeviceLocked()
2472 if (device->classes.test(InputDeviceClass::KEYBOARD)) { in openDeviceLocked()
2475 isEligibleBuiltInKeyboard(device->identifier, device->configuration.get(), in openDeviceLocked()
2476 &device->keyMap)) { in openDeviceLocked()
2477 mBuiltInKeyboardId = device->id; in openDeviceLocked()
2481 if (device->hasKeycodeLocked(AKEYCODE_Q)) { in openDeviceLocked()
2482 device->classes |= InputDeviceClass::ALPHAKEY; in openDeviceLocked()
2487 [&](int32_t keycode) { return device->hasKeycodeLocked(keycode); })) { in openDeviceLocked()
2488 device->classes |= InputDeviceClass::DPAD; in openDeviceLocked()
2493 [&](int32_t keycode) { return device->hasKeycodeLocked(keycode); })) { in openDeviceLocked()
2494 device->classes |= InputDeviceClass::GAMEPAD; in openDeviceLocked()
2498 if (!device->classes.any(InputDeviceClass::TOUCH | InputDeviceClass::TOUCH_MT) && in openDeviceLocked()
2499 !device->classes.any(InputDeviceClass::ALPHAKEY) && in openDeviceLocked()
2501 [&](int32_t keycode) { return device->hasKeycodeLocked(keycode); })) { in openDeviceLocked()
2502 device->classes |= InputDeviceClass::EXTERNAL_STYLUS; in openDeviceLocked()
2507 if (device->classes == ftl::Flags<InputDeviceClass>(0)) { in openDeviceLocked()
2509 device->identifier.name.c_str()); in openDeviceLocked()
2514 if (device->associatedDevice && !device->associatedDevice->batteryInfos.empty()) { in openDeviceLocked()
2515 device->classes |= InputDeviceClass::BATTERY; in openDeviceLocked()
2519 if (device->associatedDevice && !device->associatedDevice->lightInfos.empty()) { in openDeviceLocked()
2520 device->classes |= InputDeviceClass::LIGHT; in openDeviceLocked()
2524 if (device->deviceHasMicLocked()) { in openDeviceLocked()
2525 device->classes |= InputDeviceClass::MIC; in openDeviceLocked()
2529 if (device->isExternalDeviceLocked()) { in openDeviceLocked()
2530 device->classes |= InputDeviceClass::EXTERNAL; in openDeviceLocked()
2533 if (device->classes.any(InputDeviceClass::JOYSTICK | InputDeviceClass::DPAD) && in openDeviceLocked()
2534 device->classes.test(InputDeviceClass::GAMEPAD)) { in openDeviceLocked()
2535 device->controllerNumber = getNextControllerNumberLocked(device->identifier.name); in openDeviceLocked()
2536 device->setLedForControllerLocked(); in openDeviceLocked()
2539 if (registerDeviceForEpollLocked(*device) != OK) { in openDeviceLocked()
2543 device->configureFd(); in openDeviceLocked()
2547 deviceId, fd, devicePath.c_str(), device->identifier.name.c_str(), in openDeviceLocked()
2548 device->classes.string().c_str(), device->configurationFile.c_str(), in openDeviceLocked()
2549 device->keyMap.keyLayoutFile.c_str(), device->keyMap.keyCharacterMapFile.c_str(), in openDeviceLocked()
2552 addDeviceLocked(std::move(device)); in openDeviceLocked()
2562 for (const auto& [id, device] : mDevices) { in openVideoDeviceLocked()
2563 if (tryAddVideoDeviceLocked(*device, videoDevice)) { in openVideoDeviceLocked()
2575 bool EventHub::tryAddVideoDeviceLocked(EventHub::Device& device, in tryAddVideoDeviceLocked() argument
2577 if (videoDevice->getName() != device.identifier.name) { in tryAddVideoDeviceLocked()
2580 device.videoDevice = std::move(videoDevice); in tryAddVideoDeviceLocked()
2581 if (device.enabled) { in tryAddVideoDeviceLocked()
2582 registerVideoDeviceForEpollLocked(*device.videoDevice); in tryAddVideoDeviceLocked()
2589 Device* device = getDeviceLocked(deviceId); in isDeviceEnabled() local
2590 if (device == nullptr) { in isDeviceEnabled()
2594 return device->enabled; in isDeviceEnabled()
2599 Device* device = getDeviceLocked(deviceId); in enableDevice() local
2600 if (device == nullptr) { in enableDevice()
2604 if (device->enabled) { in enableDevice()
2608 status_t result = device->enable(); in enableDevice()
2614 device->configureFd(); in enableDevice()
2616 return registerDeviceForEpollLocked(*device); in enableDevice()
2621 Device* device = getDeviceLocked(deviceId); in disableDevice() local
2622 if (device == nullptr) { in disableDevice()
2626 if (!device->enabled) { in disableDevice()
2630 unregisterDeviceFromEpollLocked(*device); in disableDevice()
2631 return device->disable(); in disableDevice()
2643 std::unique_ptr<Device>& device = *it; in sysfsNodeChanged() local
2644 if (device->associatedDevice && in sysfsNodeChanged()
2645 sysfsNodePath.find(device->associatedDevice->sysfsRootPath.string()) != in sysfsNodeChanged()
2647 device->associatedDevice->isChanged()) { in sysfsNodeChanged()
2649 openDeviceLocked(device->path); in sysfsNodeChanged()
2655 for (const auto& [id, device] : mDevices) { in sysfsNodeChanged()
2656 if (device->associatedDevice && in sysfsNodeChanged()
2657 sysfsNodePath.find(device->associatedDevice->sysfsRootPath.string()) != in sysfsNodeChanged()
2659 device->associatedDevice->isChanged()) { in sysfsNodeChanged()
2660 devicesToReopen.push_back(device.get()); in sysfsNodeChanged()
2663 for (const auto& device : devicesToReopen) { in sysfsNodeChanged() local
2664 closeDeviceLocked(*device); in sysfsNodeChanged()
2665 openDeviceLocked(device->path); in sysfsNodeChanged()
2676 std::unique_ptr<Device> device = in createVirtualKeyboardLocked() local
2679 device->classes = InputDeviceClass::KEYBOARD | InputDeviceClass::ALPHAKEY | in createVirtualKeyboardLocked()
2681 device->loadKeyMapLocked(); in createVirtualKeyboardLocked()
2682 addDeviceLocked(std::move(device)); in createVirtualKeyboardLocked()
2685 void EventHub::addDeviceLocked(std::unique_ptr<Device> device) { in addDeviceLocked() argument
2686 reportDeviceAddedForStatisticsLocked(device->identifier, device->classes); in addDeviceLocked()
2687 mOpeningDevices.push_back(std::move(device)); in addDeviceLocked()
2708 Device* device = getDeviceByPathLocked(devicePath); in closeDeviceByPathLocked() local
2709 if (device != nullptr) { in closeDeviceByPathLocked()
2710 closeDeviceLocked(*device); in closeDeviceByPathLocked()
2724 for (const auto& [id, device] : mDevices) { in closeVideoDeviceByPathLocked()
2725 if (device->videoDevice && device->videoDevice->getPath() == devicePath) { in closeVideoDeviceByPathLocked()
2726 unregisterVideoDeviceFromEpollLocked(*device->videoDevice); in closeVideoDeviceByPathLocked()
2727 device->videoDevice = nullptr; in closeVideoDeviceByPathLocked()
2744 void EventHub::closeDeviceLocked(Device& device) { in closeDeviceLocked() argument
2745 ALOGI("Removed device: path=%s name=%s id=%d fd=%d classes=%s", device.path.c_str(), in closeDeviceLocked()
2746 device.identifier.name.c_str(), device.id, device.fd, device.classes.string().c_str()); in closeDeviceLocked()
2748 if (device.id == mBuiltInKeyboardId) { in closeDeviceLocked()
2750 device.path.c_str(), mBuiltInKeyboardId); in closeDeviceLocked()
2754 unregisterDeviceFromEpollLocked(device); in closeDeviceLocked()
2755 if (device.videoDevice) { in closeDeviceLocked()
2757 mUnattachedVideoDevices.push_back(std::move(device.videoDevice)); in closeDeviceLocked()
2760 releaseControllerNumberLocked(device.controllerNumber); in closeDeviceLocked()
2761 device.controllerNumber = 0; in closeDeviceLocked()
2762 device.close(); in closeDeviceLocked()
2763 mClosingDevices.push_back(std::move(mDevices[device.id])); in closeDeviceLocked()
2765 mDevices.erase(device.id); in closeDeviceLocked()
2857 for (const auto& [id, device] : mDevices) { in dump()
2858 if (mBuiltInKeyboardId == device->id) { in dump()
2860 device->id, device->identifier.name.c_str()); in dump()
2862 dump += StringPrintf(INDENT2 "%d: %s\n", device->id, in dump()
2863 device->identifier.name.c_str()); in dump()
2865 dump += StringPrintf(INDENT3 "Classes: %s\n", device->classes.string().c_str()); in dump()
2866 dump += StringPrintf(INDENT3 "Path: %s\n", device->path.c_str()); in dump()
2867 dump += StringPrintf(INDENT3 "Enabled: %s\n", toString(device->enabled)); in dump()
2868 dump += StringPrintf(INDENT3 "Descriptor: %s\n", device->identifier.descriptor.c_str()); in dump()
2869 dump += StringPrintf(INDENT3 "Location: %s\n", device->identifier.location.c_str()); in dump()
2870 dump += StringPrintf(INDENT3 "ControllerNumber: %d\n", device->controllerNumber); in dump()
2871 dump += StringPrintf(INDENT3 "UniqueId: %s\n", device->identifier.uniqueId.c_str()); in dump()
2874 device->identifier.bus, device->identifier.vendor, in dump()
2875 device->identifier.product, device->identifier.version, in dump()
2876 toString(device->identifier.bluetoothAddress).c_str()); in dump()
2878 device->keyMap.keyLayoutFile.c_str()); in dump()
2880 device->keyMap.keyCharacterMapFile.c_str()); in dump()
2881 if (device->associatedDevice && device->associatedDevice->layoutInfo) { in dump()
2883 device->associatedDevice->layoutInfo->languageTag.c_str()); in dump()
2885 device->associatedDevice->layoutInfo->layoutType.c_str()); in dump()
2888 device->configurationFile.c_str()); in dump()
2890 device->videoDevice ? device->videoDevice->dump().c_str() in dump()
2893 device->associatedDevice in dump()
2894 ? device->associatedDevice->sysfsRootPath.c_str() in dump()
2896 if (device->keyBitmask.any(0, KEY_MAX + 1)) { in dump()
2897 const auto pressedKeys = device->keyState.dumpSetIndices(", ", [](int i) { in dump()
2902 if (device->swBitmask.any(0, SW_MAX + 1)) { in dump()
2903 const auto pressedSwitches = device->swState.dumpSetIndices(", ", [](int i) { in dump()
2908 if (!device->absState.empty()) { in dump()
2910 for (const auto& [axis, state] : device->absState) { in dump()