Double click 转成power之后的上报

首先来到了

void KeyboardInputMapper::process(const RawEvent* rawEvent) {
    switch (rawEvent->type) {
    case EV_KEY: {
        int32_t scanCode = rawEvent->code;
        int32_t usageCode = mCurrentHidUsage;
        mCurrentHidUsage = 0;
ALOGD("matt-KeyboardInputMapper::process-scanCode=%d  ,%d ",scanCode,usageCode);
        if (isKeyboardOrGamepadKey(scanCode)) {      //双击灭屏的时候过不了这一关,所以双击灭屏是更上层做的
            processKey(rawEvent->when, rawEvent->value != 0, scanCode, usageCode);
        }
        break;
    }
}

status_t KeyLayoutMap::mapKey(int32_t scanCode, int32_t usageCode,
        int32_t* outKeyCode, uint32_t* outFlags) const {


   ALOGD("matt-mapKey11: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d, outFlags=0x%08x.",
            scanCode, usageCode, *outKeyCode, *outFlags);
    const Key* key = getKey(scanCode, usageCode);
    if (!key) {
#if DEBUG_MAPPING
        ALOGD("matt-mapKey: scanCode=%d, usageCode=0x%08x ~ Failed.", scanCode, usageCode);
#endif
        *outKeyCode = AKEYCODE_UNKNOWN;
        *outFlags = 0;
        return NAME_NOT_FOUND;
    }
ALOGD("matt-mapKey:  key->keyCode=%d ", key->keyCode);


    *outKeyCode = key->keyCode;
    *outFlags = key->flags;


#if DEBUG_MAPPING
    ALOGD("matt-mapKey: scanCode=%d, usageCode=0x%08x ~ Result keyCode=%d, outFlags=0x%08x.",
            scanCode, usageCode, *outKeyCode, *outFlags);
#endif
    return NO_ERROR;
}


const KeyLayoutMap::Key* KeyLayoutMap::getKey(int32_t scanCode, int32_t usageCode) const {
    if (usageCode) {
        ssize_t index = mKeysByUsageCode.indexOfKey(usageCode);
        if (index >= 0) {
            return &mKeysByUsageCode.valueAt(index);
        }
    }
    if (scanCode) {
        ssize_t index = mKeysByScanCode.indexOfKey(scanCode);   //这里有妖额子
  ALOGD("matt-mapKey: index=%d",index); //最奇怪的就是同样的进来,却是不同的结果
        if (index >= 0) {
            return &mKeysByScanCode.valueAt(index);
        }
    }
    return NULL;
}



双击之后的log:

01-01 10:57:47.389  1687  2444 D InputReader: matt-KeyboardInputMapper::process-scanCode=116  ,0 
01-01 10:57:47.390  1687  2444 D EventHub: matt- EventHub::mapKey
01-01 10:57:47.390  1687  2444 D EventHub: matt- EventHub::mapKey1
01-01 10:57:47.390  1687  2444 D KeyLayoutMap: matt-mapKey11: scanCode=116, usageCode=0x00000000 ~ Result keyCode=0, outFlags=0x00000055.
01-01 10:57:47.390  1687  2444 D KeyLayoutMap: matt-mapKey: index=7
01-01 10:57:47.390  1687  2444 D KeyLayoutMap: matt-mapKey:  key->keyCode=820 
01-01 10:57:47.390  1687  2444 D KeyLayoutMap: matt-mapKey: scanCode=116, usageCode=0x00000000 ~ Result keyCode=820, outFlags=0x00000003.
01-01 10:57:47.390  1687  2444 D EventHub: matt- EventHub::mapKey2
01-01 10:57:47.390  1687  2444 D EventHub: matt- EventHub::mapKey3
01-01 10:57:47.390  1687  2444 D InputReader: matt-processKey keyCode=820 
01-01 10:57:47.390  1687  2444 D InputReader: matt-processKey keyCode2=820 
01-01 10:57:47.390  1687  2444 D InputReader: matt-KeyboardInputMapper::process-scanCode=116  ,0 
01-01 10:57:47.390  1687  2444 D EventHub: matt- EventHub::mapKey
01-01 10:57:47.390  1687  2444 D EventHub: matt- EventHub::mapKey1
01-01 10:57:47.390  1687  2444 D KeyLayoutMap: matt-mapKey11: scanCode=116, usageCode=0x00000000 ~ Result keyCode=0, outFlags=0x00000055.
01-01 10:57:47.390  1687  2444 D KeyLayoutMap: matt-mapKey: index=7
01-01 10:57:47.390  1687  2444 D KeyLayoutMap: matt-mapKey:  key->keyCode=820 
01-01 10:57:47.390  1687  2444 D KeyLayoutMap: matt-mapKey: scanCode=116, usageCode=0x00000000 ~ Result keyCode=820, outFlags=0x00000003.
01-01 10:57:47.390  1687  2444 D EventHub: matt- EventHub::mapKey2
01-01 10:57:47.390  1687  2444 D EventHub: matt- EventHub::mapKey3
01-01 10:57:47.390  1687  2444 D InputReader: matt-processKey keyCode=820 
01-01 10:57:47.390  1687  2444 D InputReader: matt-processKey keyCode4-=820 
01-01 10:57:47.390  1687  2444 D InputReader: matt-processKey keyCode4=820 

按下真正的power key的log:

01-01 10:58:21.011  1687  2444 D InputReader: matt-KeyboardInputMapper::process-scanCode=116  ,0 
01-01 10:58:21.011  1687  2444 D EventHub: matt- EventHub::mapKey
01-01 10:58:21.011  1687  2444 D EventHub: matt- EventHub::mapKey1
01-01 10:58:21.011  1687  2444 D KeyLayoutMap: matt-mapKey11: scanCode=116, usageCode=0x00000000 ~ Result keyCode=0, outFlags=0x00000055.
01-01 10:58:21.011  1687  2444 D KeyLayoutMap: matt-mapKey: index=110
01-01 10:58:21.011  1687  2444 D KeyLayoutMap: matt-mapKey:  key->keyCode=26 
01-01 10:58:21.011  1687  2444 D KeyLayoutMap: matt-mapKey: scanCode=116, usageCode=0x00000000 ~ Result keyCode=26, outFlags=0x00000000.
01-01 10:58:21.011  1687  2444 D EventHub: matt- EventHub::mapKey2
01-01 10:58:21.011  1687  2444 D EventHub: matt- EventHub::mapKey3
01-01 10:58:21.011  1687  2444 D InputReader: matt-processKey keyCode=26 
01-01 10:58:21.011  1687  2444 D InputReader: matt-processKey keyCode2=26 
01-01 10:58:21.128  1687  2444 D InputReader: matt-KeyboardInputMapper::process-scanCode=116  ,0 
01-01 10:58:21.128  1687  2444 D EventHub: matt- EventHub::mapKey
01-01 10:58:21.128  1687  2444 D EventHub: matt- EventHub::mapKey1
01-01 10:58:21.128  1687  2444 D KeyLayoutMap: matt-mapKey11: scanCode=116, usageCode=0x00000000 ~ Result keyCode=0, outFlags=0x00000055.
01-01 10:58:21.128  1687  2444 D KeyLayoutMap: matt-mapKey: index=110
01-01 10:58:21.128  1687  2444 D KeyLayoutMap: matt-mapKey:  key->keyCode=26 
01-01 10:58:21.128  1687  2444 D KeyLayoutMap: matt-mapKey: scanCode=116, usageCode=0x00000000 ~ Result keyCode=26, outFlags=0x00000000.
01-01 10:58:21.128  1687  2444 D EventHub: matt- EventHub::mapKey2
01-01 10:58:21.128  1687  2444 D EventHub: matt- EventHub::mapKey3
01-01 10:58:21.128  1687  2444 D InputReader: matt-processKey keyCode=26 
01-01 10:58:21.128  1687  2444 D InputReader: matt-processKey keyCode4-=26 
01-01 10:58:21.128  1687  2444 D InputReader: matt-processKey keyCode4=26 


哪怕到了inputdispatch里还算不同的keycode,到mLooper->wake();为止都是

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值