Loading services/inputflinger/InputReader.cpp +45 −12 Original line number Original line Diff line number Diff line Loading @@ -697,6 +697,21 @@ int32_t InputReader::getStateLocked(int32_t deviceId, uint32_t sourceMask, int32 return result; return result; } } void InputReader::toggleCapsLockState(int32_t deviceId) { ssize_t deviceIndex = mDevices.indexOfKey(deviceId); if (deviceIndex < 0) { ALOGW("Ignoring toggleCapsLock for unknown deviceId %" PRId32 ".", deviceId); return; } InputDevice* device = mDevices.valueAt(deviceIndex); if (device->isIgnored()) { return; } device->updateMetaState(AKEYCODE_CAPS_LOCK); } bool InputReader::hasKeys(int32_t deviceId, uint32_t sourceMask, bool InputReader::hasKeys(int32_t deviceId, uint32_t sourceMask, size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) { size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) { AutoMutex _l(mLock); AutoMutex _l(mLock); Loading Loading @@ -1172,6 +1187,13 @@ int32_t InputDevice::getMetaState() { return result; return result; } } void InputDevice::updateMetaState(int32_t keyCode) { size_t numMappers = mMappers.size(); for (size_t i = 0; i < numMappers; i++) { mMappers[i]->updateMetaState(keyCode); } } void InputDevice::fadePointer() { void InputDevice::fadePointer() { size_t numMappers = mMappers.size(); size_t numMappers = mMappers.size(); for (size_t i = 0; i < numMappers; i++) { for (size_t i = 0; i < numMappers; i++) { Loading Loading @@ -1880,6 +1902,9 @@ int32_t InputMapper::getMetaState() { return 0; return 0; } } void InputMapper::updateMetaState(int32_t keyCode) { } void InputMapper::updateExternalStylusState(const StylusState& state) { void InputMapper::updateExternalStylusState(const StylusState& state) { } } Loading Loading @@ -2265,18 +2290,12 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode, } } } } int32_t oldMetaState = mMetaState; if (updateMetaStateIfNeeded(keyCode, down)) { int32_t newMetaState = updateMetaState(keyCode, down, oldMetaState); bool metaStateChanged = oldMetaState != newMetaState; if (metaStateChanged) { mMetaState = newMetaState; updateLedState(false); // If global meta state changed send it along with the key. // If global meta state changed send it along with the key. // If it has not changed then we'll use what keymap gave us, // If it has not changed then we'll use what keymap gave us, // since key replacement logic might temporarily reset a few // since key replacement logic might temporarily reset a few // meta bits for given key. // meta bits for given key. keyMetaState = newMetaState; keyMetaState = mMetaState; } } nsecs_t downTime = mDownTime; nsecs_t downTime = mDownTime; Loading @@ -2294,10 +2313,6 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode, policyFlags |= POLICY_FLAG_DISABLE_KEY_REPEAT; policyFlags |= POLICY_FLAG_DISABLE_KEY_REPEAT; } } if (metaStateChanged) { getContext()->updateGlobalMetaState(); } if (down && !isMetaKey(keyCode)) { if (down && !isMetaKey(keyCode)) { getContext()->fadePointer(); getContext()->fadePointer(); } } Loading Loading @@ -2335,6 +2350,24 @@ int32_t KeyboardInputMapper::getMetaState() { return mMetaState; return mMetaState; } } void KeyboardInputMapper::updateMetaState(int32_t keyCode) { updateMetaStateIfNeeded(keyCode, false); } bool KeyboardInputMapper::updateMetaStateIfNeeded(int32_t keyCode, bool down) { int32_t oldMetaState = mMetaState; int32_t newMetaState = android::updateMetaState(keyCode, down, oldMetaState); bool metaStateChanged = oldMetaState != newMetaState; if (metaStateChanged) { mMetaState = newMetaState; updateLedState(false); getContext()->updateGlobalMetaState(); } return metaStateChanged; } void KeyboardInputMapper::resetLedState() { void KeyboardInputMapper::resetLedState() { initializeLedState(mCapsLockLedState, ALED_CAPS_LOCK); initializeLedState(mCapsLockLedState, ALED_CAPS_LOCK); initializeLedState(mNumLockLedState, ALED_NUM_LOCK); initializeLedState(mNumLockLedState, ALED_NUM_LOCK); Loading services/inputflinger/InputReader.h +10 −0 Original line number Original line Diff line number Diff line Loading @@ -359,6 +359,9 @@ public: virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t sw) = 0; int32_t sw) = 0; /* Toggle Caps Lock */ virtual void toggleCapsLockState(int32_t deviceId) = 0; /* Determine whether physical keys exist for the given framework-domain key codes. */ /* Determine whether physical keys exist for the given framework-domain key codes. */ virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) = 0; size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) = 0; Loading Loading @@ -461,6 +464,8 @@ public: virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t sw); int32_t sw); virtual void toggleCapsLockState(int32_t deviceId); virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags); size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags); Loading Loading @@ -616,6 +621,7 @@ public: void cancelTouch(nsecs_t when); void cancelTouch(nsecs_t when); int32_t getMetaState(); int32_t getMetaState(); void updateMetaState(int32_t keyCode); void fadePointer(); void fadePointer(); Loading Loading @@ -1031,6 +1037,7 @@ public: virtual void cancelTouch(nsecs_t when); virtual void cancelTouch(nsecs_t when); virtual int32_t getMetaState(); virtual int32_t getMetaState(); virtual void updateMetaState(int32_t keyCode); virtual void updateExternalStylusState(const StylusState& state); virtual void updateExternalStylusState(const StylusState& state); Loading Loading @@ -1116,6 +1123,7 @@ public: const int32_t* keyCodes, uint8_t* outFlags); const int32_t* keyCodes, uint8_t* outFlags); virtual int32_t getMetaState(); virtual int32_t getMetaState(); virtual void updateMetaState(int32_t keyCode); private: private: struct KeyDown { struct KeyDown { Loading Loading @@ -1156,6 +1164,8 @@ private: void processKey(nsecs_t when, bool down, int32_t scanCode, int32_t usageCode); void processKey(nsecs_t when, bool down, int32_t scanCode, int32_t usageCode); bool updateMetaStateIfNeeded(int32_t keyCode, bool down); ssize_t findKeyDown(int32_t scanCode); ssize_t findKeyDown(int32_t scanCode); void resetLedState(); void resetLedState(); Loading Loading
services/inputflinger/InputReader.cpp +45 −12 Original line number Original line Diff line number Diff line Loading @@ -697,6 +697,21 @@ int32_t InputReader::getStateLocked(int32_t deviceId, uint32_t sourceMask, int32 return result; return result; } } void InputReader::toggleCapsLockState(int32_t deviceId) { ssize_t deviceIndex = mDevices.indexOfKey(deviceId); if (deviceIndex < 0) { ALOGW("Ignoring toggleCapsLock for unknown deviceId %" PRId32 ".", deviceId); return; } InputDevice* device = mDevices.valueAt(deviceIndex); if (device->isIgnored()) { return; } device->updateMetaState(AKEYCODE_CAPS_LOCK); } bool InputReader::hasKeys(int32_t deviceId, uint32_t sourceMask, bool InputReader::hasKeys(int32_t deviceId, uint32_t sourceMask, size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) { size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) { AutoMutex _l(mLock); AutoMutex _l(mLock); Loading Loading @@ -1172,6 +1187,13 @@ int32_t InputDevice::getMetaState() { return result; return result; } } void InputDevice::updateMetaState(int32_t keyCode) { size_t numMappers = mMappers.size(); for (size_t i = 0; i < numMappers; i++) { mMappers[i]->updateMetaState(keyCode); } } void InputDevice::fadePointer() { void InputDevice::fadePointer() { size_t numMappers = mMappers.size(); size_t numMappers = mMappers.size(); for (size_t i = 0; i < numMappers; i++) { for (size_t i = 0; i < numMappers; i++) { Loading Loading @@ -1880,6 +1902,9 @@ int32_t InputMapper::getMetaState() { return 0; return 0; } } void InputMapper::updateMetaState(int32_t keyCode) { } void InputMapper::updateExternalStylusState(const StylusState& state) { void InputMapper::updateExternalStylusState(const StylusState& state) { } } Loading Loading @@ -2265,18 +2290,12 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode, } } } } int32_t oldMetaState = mMetaState; if (updateMetaStateIfNeeded(keyCode, down)) { int32_t newMetaState = updateMetaState(keyCode, down, oldMetaState); bool metaStateChanged = oldMetaState != newMetaState; if (metaStateChanged) { mMetaState = newMetaState; updateLedState(false); // If global meta state changed send it along with the key. // If global meta state changed send it along with the key. // If it has not changed then we'll use what keymap gave us, // If it has not changed then we'll use what keymap gave us, // since key replacement logic might temporarily reset a few // since key replacement logic might temporarily reset a few // meta bits for given key. // meta bits for given key. keyMetaState = newMetaState; keyMetaState = mMetaState; } } nsecs_t downTime = mDownTime; nsecs_t downTime = mDownTime; Loading @@ -2294,10 +2313,6 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t scanCode, policyFlags |= POLICY_FLAG_DISABLE_KEY_REPEAT; policyFlags |= POLICY_FLAG_DISABLE_KEY_REPEAT; } } if (metaStateChanged) { getContext()->updateGlobalMetaState(); } if (down && !isMetaKey(keyCode)) { if (down && !isMetaKey(keyCode)) { getContext()->fadePointer(); getContext()->fadePointer(); } } Loading Loading @@ -2335,6 +2350,24 @@ int32_t KeyboardInputMapper::getMetaState() { return mMetaState; return mMetaState; } } void KeyboardInputMapper::updateMetaState(int32_t keyCode) { updateMetaStateIfNeeded(keyCode, false); } bool KeyboardInputMapper::updateMetaStateIfNeeded(int32_t keyCode, bool down) { int32_t oldMetaState = mMetaState; int32_t newMetaState = android::updateMetaState(keyCode, down, oldMetaState); bool metaStateChanged = oldMetaState != newMetaState; if (metaStateChanged) { mMetaState = newMetaState; updateLedState(false); getContext()->updateGlobalMetaState(); } return metaStateChanged; } void KeyboardInputMapper::resetLedState() { void KeyboardInputMapper::resetLedState() { initializeLedState(mCapsLockLedState, ALED_CAPS_LOCK); initializeLedState(mCapsLockLedState, ALED_CAPS_LOCK); initializeLedState(mNumLockLedState, ALED_NUM_LOCK); initializeLedState(mNumLockLedState, ALED_NUM_LOCK); Loading
services/inputflinger/InputReader.h +10 −0 Original line number Original line Diff line number Diff line Loading @@ -359,6 +359,9 @@ public: virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t sw) = 0; int32_t sw) = 0; /* Toggle Caps Lock */ virtual void toggleCapsLockState(int32_t deviceId) = 0; /* Determine whether physical keys exist for the given framework-domain key codes. */ /* Determine whether physical keys exist for the given framework-domain key codes. */ virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) = 0; size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) = 0; Loading Loading @@ -461,6 +464,8 @@ public: virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t sw); int32_t sw); virtual void toggleCapsLockState(int32_t deviceId); virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags); size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags); Loading Loading @@ -616,6 +621,7 @@ public: void cancelTouch(nsecs_t when); void cancelTouch(nsecs_t when); int32_t getMetaState(); int32_t getMetaState(); void updateMetaState(int32_t keyCode); void fadePointer(); void fadePointer(); Loading Loading @@ -1031,6 +1037,7 @@ public: virtual void cancelTouch(nsecs_t when); virtual void cancelTouch(nsecs_t when); virtual int32_t getMetaState(); virtual int32_t getMetaState(); virtual void updateMetaState(int32_t keyCode); virtual void updateExternalStylusState(const StylusState& state); virtual void updateExternalStylusState(const StylusState& state); Loading Loading @@ -1116,6 +1123,7 @@ public: const int32_t* keyCodes, uint8_t* outFlags); const int32_t* keyCodes, uint8_t* outFlags); virtual int32_t getMetaState(); virtual int32_t getMetaState(); virtual void updateMetaState(int32_t keyCode); private: private: struct KeyDown { struct KeyDown { Loading Loading @@ -1156,6 +1164,8 @@ private: void processKey(nsecs_t when, bool down, int32_t scanCode, int32_t usageCode); void processKey(nsecs_t when, bool down, int32_t scanCode, int32_t usageCode); bool updateMetaStateIfNeeded(int32_t keyCode, bool down); ssize_t findKeyDown(int32_t scanCode); ssize_t findKeyDown(int32_t scanCode); void resetLedState(); void resetLedState(); Loading