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

Commit 629a8b12 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge changes Iedf67063,Ia5f9bcac,I0d319c65

* changes:
  TouchButtonAccumulator: Recognize mapped stylus buttons
  Extract HID usage accumulation logic from KeyboardInputMapper
  TouchButtonAccumulator: Miscelaneous cleanup
parents 935fb2d6 4f05b5fb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ filegroup {
        "mapper/VibratorInputMapper.cpp",
        "mapper/accumulator/CursorButtonAccumulator.cpp",
        "mapper/accumulator/CursorScrollAccumulator.cpp",
        "mapper/accumulator/HidUsageAccumulator.cpp",
        "mapper/accumulator/SingleTouchMotionAccumulator.cpp",
        "mapper/accumulator/TouchButtonAccumulator.cpp",
    ],
+5 −2
Original line number Diff line number Diff line
@@ -378,8 +378,11 @@ public:
        mEventHub->getAbsoluteAxisInfo(mId, code, &info);
        return info.valid;
    }
    inline bool isKeyPressed(int32_t code) const {
        return mEventHub->getScanCodeState(mId, code) == AKEY_STATE_DOWN;
    inline bool isKeyPressed(int32_t scanCode) const {
        return mEventHub->getScanCodeState(mId, scanCode) == AKEY_STATE_DOWN;
    }
    inline bool isKeyCodePressed(int32_t keyCode) const {
        return mEventHub->getKeyCodeState(mId, keyCode) == AKEY_STATE_DOWN;
    }
    inline int32_t getAbsoluteAxisValue(int32_t code) const {
        int32_t value;
+3 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
namespace android {

ExternalStylusInputMapper::ExternalStylusInputMapper(InputDeviceContext& deviceContext)
      : InputMapper(deviceContext) {}
      : InputMapper(deviceContext), mTouchButtonAccumulator(deviceContext) {}

uint32_t ExternalStylusInputMapper::getSources() const {
    return AINPUT_SOURCE_STYLUS;
@@ -48,13 +48,13 @@ std::list<NotifyArgs> ExternalStylusInputMapper::configure(nsecs_t when,
                                                           const InputReaderConfiguration* config,
                                                           uint32_t changes) {
    getAbsoluteAxisInfo(ABS_PRESSURE, &mRawPressureAxis);
    mTouchButtonAccumulator.configure(getDeviceContext());
    mTouchButtonAccumulator.configure();
    return {};
}

std::list<NotifyArgs> ExternalStylusInputMapper::reset(nsecs_t when) {
    mSingleTouchMotionAccumulator.reset(getDeviceContext());
    mTouchButtonAccumulator.reset(getDeviceContext());
    mTouchButtonAccumulator.reset();
    return InputMapper::reset(when);
}

+3 −15
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ void KeyboardInputMapper::dumpParameters(std::string& dump) const {

std::list<NotifyArgs> KeyboardInputMapper::reset(nsecs_t when) {
    std::list<NotifyArgs> out = cancelAllDownKeys(when);
    mCurrentHidUsage = 0;
    mHidUsageAccumulator.reset();

    resetLedState();

@@ -190,29 +190,17 @@ std::list<NotifyArgs> KeyboardInputMapper::reset(nsecs_t when) {

std::list<NotifyArgs> KeyboardInputMapper::process(const RawEvent* rawEvent) {
    std::list<NotifyArgs> out;
    mHidUsageAccumulator.process(*rawEvent);
    switch (rawEvent->type) {
        case EV_KEY: {
            int32_t scanCode = rawEvent->code;
            int32_t usageCode = mCurrentHidUsage;
            mCurrentHidUsage = 0;

            if (isSupportedScanCode(scanCode)) {
                out += processKey(rawEvent->when, rawEvent->readTime, rawEvent->value != 0,
                                  scanCode, usageCode);
                                  scanCode, mHidUsageAccumulator.consumeCurrentHidUsage());
            }
            break;
        }
        case EV_MSC: {
            if (rawEvent->code == MSC_SCAN) {
                mCurrentHidUsage = rawEvent->value;
            }
            break;
        }
        case EV_SYN: {
            if (rawEvent->code == SYN_REPORT) {
                mCurrentHidUsage = 0;
            }
        }
    }
    return out;
}
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#pragma once

#include "HidUsageAccumulator.h"
#include "InputMapper.h"

namespace android {
@@ -61,7 +62,7 @@ private:
    std::vector<KeyDown> mKeyDowns{}; // keys that are down
    int32_t mMetaState{};

    int32_t mCurrentHidUsage{}; // most recent HID usage seen this packet, or 0 if none
    HidUsageAccumulator mHidUsageAccumulator;

    struct LedState {
        bool avail{}; // led is available
Loading