File tree Expand file tree Collapse file tree
services/inputflinger/reader Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -137,6 +137,9 @@ class KeyCharacterMap {
137137 /* Returns keycode after applying Android key code remapping defined in mKeyRemapping */
138138 int32_t applyKeyRemapping (int32_t fromKeyCode) const ;
139139
140+ /* * Returns list of keycodes that remap to provided keycode (@see setKeyRemapping()) */
141+ std::vector<int32_t > findKeyCodesMappedToKeyCode (int32_t toKeyCode) const ;
142+
140143 /* Returns the <keyCode, metaState> pair after applying key behavior defined in the kcm file,
141144 * that tries to find a replacement key code based on current meta state */
142145 std::pair<int32_t /* keyCode*/ , int32_t /* metaState*/ > applyKeyBehavior (int32_t keyCode,
Original file line number Diff line number Diff line change @@ -365,6 +365,17 @@ int32_t KeyCharacterMap::applyKeyRemapping(int32_t fromKeyCode) const {
365365 return toKeyCode;
366366}
367367
368+ std::vector<int32_t > KeyCharacterMap::findKeyCodesMappedToKeyCode (int32_t toKeyCode) const {
369+ std::vector<int32_t > fromKeyCodes;
370+
371+ for (const auto & [from, to] : mKeyRemapping ) {
372+ if (toKeyCode == to) {
373+ fromKeyCodes.push_back (from);
374+ }
375+ }
376+ return fromKeyCodes;
377+ }
378+
368379std::pair<int32_t , int32_t > KeyCharacterMap::applyKeyBehavior (int32_t fromKeyCode,
369380 int32_t fromMetaState) const {
370381 int32_t toKeyCode = fromKeyCode;
Original file line number Diff line number Diff line change @@ -659,6 +659,19 @@ void EventHub::Device::populateAbsoluteAxisStates() {
659659}
660660
661661bool EventHub::Device::hasKeycodeLocked (int keycode) const {
662+ if (hasKeycodeInternalLocked (keycode)) {
663+ return true ;
664+ }
665+
666+ for (auto & fromKey : getKeyCharacterMap ()->findKeyCodesMappedToKeyCode (keycode)) {
667+ if (hasKeycodeInternalLocked (fromKey)) {
668+ return true ;
669+ }
670+ }
671+ return false ;
672+ }
673+
674+ bool EventHub::Device::hasKeycodeInternalLocked (int keycode) const {
662675 if (!keyMap.haveKeyLayout ()) {
663676 return false ;
664677 }
@@ -676,7 +689,6 @@ bool EventHub::Device::hasKeycodeLocked(int keycode) const {
676689 if (usageCodes.size () > 0 && mscBitmask.test (MSC_SCAN)) {
677690 return true ;
678691 }
679-
680692 return false ;
681693}
682694
Original file line number Diff line number Diff line change @@ -680,6 +680,7 @@ class EventHub : public EventHubInterface {
680680 void configureFd ();
681681 void populateAbsoluteAxisStates ();
682682 bool hasKeycodeLocked (int keycode) const ;
683+ bool hasKeycodeInternalLocked (int keycode) const ;
683684 void loadConfigurationLocked ();
684685 bool loadVirtualKeyMapLocked ();
685686 status_t loadKeyMapLocked ();
You can’t perform that action at this time.
0 commit comments