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

Commit 29b936e8 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 7353

* changes:
  Implement virtual button support.
parents f88cdf83 c968c3a9
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -73,6 +73,9 @@ public:
    int getKeycodeState(int key) const;
    int getKeycodeState(int key) const;
    int getKeycodeState(int32_t deviceId, int key) const;
    int getKeycodeState(int32_t deviceId, int key) const;
    
    
    status_t scancodeToKeycode(int32_t deviceId, int scancode,
            int32_t* outKeycode, uint32_t* outFlags) const;
    
    // special type codes when devices are added/removed.
    // special type codes when devices are added/removed.
    enum {
    enum {
        DEVICE_ADDED = 0x10000000,
        DEVICE_ADDED = 0x10000000,
@@ -121,7 +124,7 @@ private:
    mutable Mutex   mLock;
    mutable Mutex   mLock;
    
    
    bool            mHaveFirstKeyboard;
    bool            mHaveFirstKeyboard;
    int32_t         mFirstKeyboardId; // the API is that the build in keyboard is id 0, so map it
    int32_t         mFirstKeyboardId; // the API is that the built-in keyboard is id 0, so map it
    
    
    struct device_ent {
    struct device_ent {
        device_t* device;
        device_t* device;
+29 −0
Original line number Original line Diff line number Diff line
@@ -240,6 +240,35 @@ int EventHub::getKeycodeState(int32_t deviceId, int code) const
    return 0;
    return 0;
}
}


status_t EventHub::scancodeToKeycode(int32_t deviceId, int scancode,
        int32_t* outKeycode, uint32_t* outFlags) const
{
    AutoMutex _l(mLock);
    device_t* device = getDevice(deviceId);
    
    if (device != NULL && device->layoutMap != NULL) {
        status_t err = device->layoutMap->map(scancode, outKeycode, outFlags);
        if (err == NO_ERROR) {
            return NO_ERROR;
        }
    }
    
    if (mHaveFirstKeyboard) {
        device = getDevice(mFirstKeyboardId);
        
        if (device != NULL && device->layoutMap != NULL) {
            status_t err = device->layoutMap->map(scancode, outKeycode, outFlags);
            if (err == NO_ERROR) {
                return NO_ERROR;
            }
        }
    }
    
    *outKeycode = 0;
    *outFlags = 0;
    return NAME_NOT_FOUND;
}

EventHub::device_t* EventHub::getDevice(int32_t deviceId) const
EventHub::device_t* EventHub::getDevice(int32_t deviceId) const
{
{
    if (deviceId == 0) deviceId = mFirstKeyboardId;
    if (deviceId == 0) deviceId = mFirstKeyboardId;