您的位置:首页 > 其它

Double click 转成power之后的上报

2016-03-17 16:27 246 查看
首先来到了

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();为止都是
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: