Loading services/inputflinger/include/InputReaderBase.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -437,7 +437,8 @@ public: /* Gets the keyboard layout for a particular input device. */ /* Gets the keyboard layout for a particular input device. */ virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay( virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay( const InputDeviceIdentifier& identifier) = 0; const InputDeviceIdentifier& identifier, const std::optional<KeyboardLayoutInfo> keyboardLayoutInfo) = 0; /* Gets a user-supplied alias for a particular input device, or an empty string if none. */ /* Gets a user-supplied alias for a particular input device, or an empty string if none. */ virtual std::string getDeviceAlias(const InputDeviceIdentifier& identifier) = 0; virtual std::string getDeviceAlias(const InputDeviceIdentifier& identifier) = 0; Loading services/inputflinger/reader/InputDevice.cpp +0 −17 Original line number Original line Diff line number Diff line Loading @@ -225,23 +225,6 @@ std::list<NotifyArgs> InputDevice::configure(nsecs_t when, mIsWaking = mConfiguration.getBool("device.wake").value_or(false); mIsWaking = mConfiguration.getBool("device.wake").value_or(false); } } if (!changes.any() || changes.test(Change::KEYBOARD_LAYOUTS)) { if (!mClasses.test(InputDeviceClass::VIRTUAL)) { std::shared_ptr<KeyCharacterMap> keyboardLayout = mContext->getPolicy()->getKeyboardLayoutOverlay(mIdentifier); bool shouldBumpGeneration = false; for_each_subdevice( [&keyboardLayout, &shouldBumpGeneration](InputDeviceContext& context) { if (context.setKeyboardLayoutOverlay(keyboardLayout)) { shouldBumpGeneration = true; } }); if (shouldBumpGeneration) { bumpGeneration(); } } } if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) { if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) { if (!(mClasses.test(InputDeviceClass::VIRTUAL))) { if (!(mClasses.test(InputDeviceClass::VIRTUAL))) { std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier); std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier); Loading services/inputflinger/reader/mapper/KeyboardInputMapper.cpp +32 −8 Original line number Original line Diff line number Diff line Loading @@ -86,20 +86,26 @@ int32_t KeyboardInputMapper::getDisplayId() { return ADISPLAY_ID_NONE; return ADISPLAY_ID_NONE; } } std::optional<KeyboardLayoutInfo> KeyboardInputMapper::getKeyboardLayoutInfo() const { if (mKeyboardLayoutInfo) { return mKeyboardLayoutInfo; } std::optional<RawLayoutInfo> layoutInfo = getDeviceContext().getRawLayoutInfo(); if (!layoutInfo) { return std::nullopt; } return KeyboardLayoutInfo(layoutInfo->languageTag, layoutInfo->layoutType); } void KeyboardInputMapper::populateDeviceInfo(InputDeviceInfo& info) { void KeyboardInputMapper::populateDeviceInfo(InputDeviceInfo& info) { InputMapper::populateDeviceInfo(info); InputMapper::populateDeviceInfo(info); info.setKeyboardType(mKeyboardType); info.setKeyboardType(mKeyboardType); info.setKeyCharacterMap(getDeviceContext().getKeyCharacterMap()); info.setKeyCharacterMap(getDeviceContext().getKeyCharacterMap()); if (mKeyboardLayoutInfo) { std::optional keyboardLayoutInfo = getKeyboardLayoutInfo(); info.setKeyboardLayoutInfo(*mKeyboardLayoutInfo); if (keyboardLayoutInfo) { } else { info.setKeyboardLayoutInfo(*keyboardLayoutInfo); std::optional<RawLayoutInfo> layoutInfo = getDeviceContext().getRawLayoutInfo(); if (layoutInfo) { info.setKeyboardLayoutInfo( KeyboardLayoutInfo(layoutInfo->languageTag, layoutInfo->layoutType)); } } } } } Loading Loading @@ -152,13 +158,31 @@ std::list<NotifyArgs> KeyboardInputMapper::reconfigure(nsecs_t when, getValueByKey(config.keyboardLayoutAssociations, getDeviceContext().getLocation()); getValueByKey(config.keyboardLayoutAssociations, getDeviceContext().getLocation()); if (mKeyboardLayoutInfo != newKeyboardLayoutInfo) { if (mKeyboardLayoutInfo != newKeyboardLayoutInfo) { mKeyboardLayoutInfo = newKeyboardLayoutInfo; mKeyboardLayoutInfo = newKeyboardLayoutInfo; // Also update keyboard layout overlay as soon as we find the new layout info updateKeyboardLayoutOverlay(); bumpGeneration(); bumpGeneration(); } } } } if (!changes.any() || changes.test(InputReaderConfiguration::Change::KEYBOARD_LAYOUTS)) { if (!getDeviceContext().getDeviceClasses().test(InputDeviceClass::VIRTUAL) && updateKeyboardLayoutOverlay()) { bumpGeneration(); } } return out; return out; } } bool KeyboardInputMapper::updateKeyboardLayoutOverlay() { std::shared_ptr<KeyCharacterMap> keyboardLayout = getDeviceContext() .getContext() ->getPolicy() ->getKeyboardLayoutOverlay(getDeviceContext().getDeviceIdentifier(), getKeyboardLayoutInfo()); return getDeviceContext().setKeyboardLayoutOverlay(keyboardLayout); } void KeyboardInputMapper::configureParameters() { void KeyboardInputMapper::configureParameters() { const PropertyMap& config = getDeviceContext().getConfiguration(); const PropertyMap& config = getDeviceContext().getConfiguration(); mParameters.orientationAware = config.getBool("keyboard.orientationAware").value_or(false); mParameters.orientationAware = config.getBool("keyboard.orientationAware").value_or(false); Loading services/inputflinger/reader/mapper/KeyboardInputMapper.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -99,6 +99,8 @@ private: bool updateMetaStateIfNeeded(int32_t keyCode, bool down); bool updateMetaStateIfNeeded(int32_t keyCode, bool down); std::optional<size_t> findKeyDownIndex(int32_t scanCode); std::optional<size_t> findKeyDownIndex(int32_t scanCode); std::optional<KeyboardLayoutInfo> getKeyboardLayoutInfo() const; bool updateKeyboardLayoutOverlay(); void resetLedState(); void resetLedState(); void initializeLedState(LedState& ledState, int32_t led); void initializeLedState(LedState& ledState, int32_t led); Loading services/inputflinger/tests/FakeInputReaderPolicy.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -227,7 +227,7 @@ void FakeInputReaderPolicy::notifyInputDevicesChanged( } } std::shared_ptr<KeyCharacterMap> FakeInputReaderPolicy::getKeyboardLayoutOverlay( std::shared_ptr<KeyCharacterMap> FakeInputReaderPolicy::getKeyboardLayoutOverlay( const InputDeviceIdentifier&) { const InputDeviceIdentifier&, const std::optional<KeyboardLayoutInfo>) { return nullptr; return nullptr; } } Loading Loading
services/inputflinger/include/InputReaderBase.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -437,7 +437,8 @@ public: /* Gets the keyboard layout for a particular input device. */ /* Gets the keyboard layout for a particular input device. */ virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay( virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay( const InputDeviceIdentifier& identifier) = 0; const InputDeviceIdentifier& identifier, const std::optional<KeyboardLayoutInfo> keyboardLayoutInfo) = 0; /* Gets a user-supplied alias for a particular input device, or an empty string if none. */ /* Gets a user-supplied alias for a particular input device, or an empty string if none. */ virtual std::string getDeviceAlias(const InputDeviceIdentifier& identifier) = 0; virtual std::string getDeviceAlias(const InputDeviceIdentifier& identifier) = 0; Loading
services/inputflinger/reader/InputDevice.cpp +0 −17 Original line number Original line Diff line number Diff line Loading @@ -225,23 +225,6 @@ std::list<NotifyArgs> InputDevice::configure(nsecs_t when, mIsWaking = mConfiguration.getBool("device.wake").value_or(false); mIsWaking = mConfiguration.getBool("device.wake").value_or(false); } } if (!changes.any() || changes.test(Change::KEYBOARD_LAYOUTS)) { if (!mClasses.test(InputDeviceClass::VIRTUAL)) { std::shared_ptr<KeyCharacterMap> keyboardLayout = mContext->getPolicy()->getKeyboardLayoutOverlay(mIdentifier); bool shouldBumpGeneration = false; for_each_subdevice( [&keyboardLayout, &shouldBumpGeneration](InputDeviceContext& context) { if (context.setKeyboardLayoutOverlay(keyboardLayout)) { shouldBumpGeneration = true; } }); if (shouldBumpGeneration) { bumpGeneration(); } } } if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) { if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) { if (!(mClasses.test(InputDeviceClass::VIRTUAL))) { if (!(mClasses.test(InputDeviceClass::VIRTUAL))) { std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier); std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier); Loading
services/inputflinger/reader/mapper/KeyboardInputMapper.cpp +32 −8 Original line number Original line Diff line number Diff line Loading @@ -86,20 +86,26 @@ int32_t KeyboardInputMapper::getDisplayId() { return ADISPLAY_ID_NONE; return ADISPLAY_ID_NONE; } } std::optional<KeyboardLayoutInfo> KeyboardInputMapper::getKeyboardLayoutInfo() const { if (mKeyboardLayoutInfo) { return mKeyboardLayoutInfo; } std::optional<RawLayoutInfo> layoutInfo = getDeviceContext().getRawLayoutInfo(); if (!layoutInfo) { return std::nullopt; } return KeyboardLayoutInfo(layoutInfo->languageTag, layoutInfo->layoutType); } void KeyboardInputMapper::populateDeviceInfo(InputDeviceInfo& info) { void KeyboardInputMapper::populateDeviceInfo(InputDeviceInfo& info) { InputMapper::populateDeviceInfo(info); InputMapper::populateDeviceInfo(info); info.setKeyboardType(mKeyboardType); info.setKeyboardType(mKeyboardType); info.setKeyCharacterMap(getDeviceContext().getKeyCharacterMap()); info.setKeyCharacterMap(getDeviceContext().getKeyCharacterMap()); if (mKeyboardLayoutInfo) { std::optional keyboardLayoutInfo = getKeyboardLayoutInfo(); info.setKeyboardLayoutInfo(*mKeyboardLayoutInfo); if (keyboardLayoutInfo) { } else { info.setKeyboardLayoutInfo(*keyboardLayoutInfo); std::optional<RawLayoutInfo> layoutInfo = getDeviceContext().getRawLayoutInfo(); if (layoutInfo) { info.setKeyboardLayoutInfo( KeyboardLayoutInfo(layoutInfo->languageTag, layoutInfo->layoutType)); } } } } } Loading Loading @@ -152,13 +158,31 @@ std::list<NotifyArgs> KeyboardInputMapper::reconfigure(nsecs_t when, getValueByKey(config.keyboardLayoutAssociations, getDeviceContext().getLocation()); getValueByKey(config.keyboardLayoutAssociations, getDeviceContext().getLocation()); if (mKeyboardLayoutInfo != newKeyboardLayoutInfo) { if (mKeyboardLayoutInfo != newKeyboardLayoutInfo) { mKeyboardLayoutInfo = newKeyboardLayoutInfo; mKeyboardLayoutInfo = newKeyboardLayoutInfo; // Also update keyboard layout overlay as soon as we find the new layout info updateKeyboardLayoutOverlay(); bumpGeneration(); bumpGeneration(); } } } } if (!changes.any() || changes.test(InputReaderConfiguration::Change::KEYBOARD_LAYOUTS)) { if (!getDeviceContext().getDeviceClasses().test(InputDeviceClass::VIRTUAL) && updateKeyboardLayoutOverlay()) { bumpGeneration(); } } return out; return out; } } bool KeyboardInputMapper::updateKeyboardLayoutOverlay() { std::shared_ptr<KeyCharacterMap> keyboardLayout = getDeviceContext() .getContext() ->getPolicy() ->getKeyboardLayoutOverlay(getDeviceContext().getDeviceIdentifier(), getKeyboardLayoutInfo()); return getDeviceContext().setKeyboardLayoutOverlay(keyboardLayout); } void KeyboardInputMapper::configureParameters() { void KeyboardInputMapper::configureParameters() { const PropertyMap& config = getDeviceContext().getConfiguration(); const PropertyMap& config = getDeviceContext().getConfiguration(); mParameters.orientationAware = config.getBool("keyboard.orientationAware").value_or(false); mParameters.orientationAware = config.getBool("keyboard.orientationAware").value_or(false); Loading
services/inputflinger/reader/mapper/KeyboardInputMapper.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -99,6 +99,8 @@ private: bool updateMetaStateIfNeeded(int32_t keyCode, bool down); bool updateMetaStateIfNeeded(int32_t keyCode, bool down); std::optional<size_t> findKeyDownIndex(int32_t scanCode); std::optional<size_t> findKeyDownIndex(int32_t scanCode); std::optional<KeyboardLayoutInfo> getKeyboardLayoutInfo() const; bool updateKeyboardLayoutOverlay(); void resetLedState(); void resetLedState(); void initializeLedState(LedState& ledState, int32_t led); void initializeLedState(LedState& ledState, int32_t led); Loading
services/inputflinger/tests/FakeInputReaderPolicy.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -227,7 +227,7 @@ void FakeInputReaderPolicy::notifyInputDevicesChanged( } } std::shared_ptr<KeyCharacterMap> FakeInputReaderPolicy::getKeyboardLayoutOverlay( std::shared_ptr<KeyCharacterMap> FakeInputReaderPolicy::getKeyboardLayoutOverlay( const InputDeviceIdentifier&) { const InputDeviceIdentifier&, const std::optional<KeyboardLayoutInfo>) { return nullptr; return nullptr; } } Loading