Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c4f7988 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Allow toggle caps lock even if device doesn't a have caps lock key

For Alphabetic keyboards without CapsLock key, we should allow system
to toggle CapsLock modifier state.

Test: atest CtsInputTestCases
Bug: 368397939
Flag: EXEMPT bugfix
Change-Id: I57cfe94bf5ab7804a9a1579dae769c18684776cb
parent 5a71e885
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -691,16 +691,6 @@ int32_t InputDevice::getMetaState() {
    return result;
}

void InputDevice::updateMetaState(int32_t keyCode) {
    first_in_mappers<bool>([keyCode](InputMapper& mapper) {
        if (sourcesMatchMask(mapper.getSources(), AINPUT_SOURCE_KEYBOARD) &&
            mapper.updateMetaState(keyCode)) {
            return std::make_optional(true);
        }
        return std::optional<bool>();
    });
}

void InputDevice::bumpGeneration() {
    mGeneration = mContext->bumpGeneration();
}
+2 −11
Original line number Diff line number Diff line
@@ -584,18 +584,9 @@ int32_t InputReader::getStateLocked(int32_t deviceId, uint32_t sourceMask, int32

void InputReader::toggleCapsLockState(int32_t deviceId) {
    std::scoped_lock _l(mLock);
    InputDevice* device = findInputDeviceLocked(deviceId);
    if (!device) {
        ALOGW("Ignoring toggleCapsLock for unknown deviceId %" PRId32 ".", deviceId);
        return;
    }

    if (device->isIgnored()) {
        ALOGW("Ignoring toggleCapsLock for ignored deviceId %" PRId32 ".", deviceId);
        return;
    if (mKeyboardClassifier->getKeyboardType(deviceId) == KeyboardType::ALPHABETIC) {
        updateLedMetaStateLocked(mLedMetaState ^ AMETA_CAPS_LOCK_ON);
    }

    device->updateMetaState(AKEYCODE_CAPS_LOCK);
}

bool InputReader::hasKeys(int32_t deviceId, uint32_t sourceMask,
+0 −2
Original line number Diff line number Diff line
@@ -122,8 +122,6 @@ public:
    std::optional<int32_t> getLightPlayerId(int32_t lightId);

    int32_t getMetaState();
    void updateMetaState(int32_t keyCode);

    void setKeyboardType(KeyboardType keyboardType);

    void bumpGeneration();
+0 −4
Original line number Diff line number Diff line
@@ -109,10 +109,6 @@ int32_t InputMapper::getMetaState() {
    return 0;
}

bool InputMapper::updateMetaState(int32_t keyCode) {
    return false;
}

std::list<NotifyArgs> InputMapper::updateExternalStylusState(const StylusState& state) {
    return {};
}
+0 −5
Original line number Diff line number Diff line
@@ -111,11 +111,6 @@ public:
    virtual std::optional<int32_t> getLightPlayerId(int32_t lightId) { return std::nullopt; }

    virtual int32_t getMetaState();
    /**
     * Process the meta key and update the global meta state when changed.
     * Return true if the meta key could be handled by the InputMapper.
     */
    virtual bool updateMetaState(int32_t keyCode);

    [[nodiscard]] virtual std::list<NotifyArgs> updateExternalStylusState(const StylusState& state);

Loading