WEB开发网      婵犵數濞€濞佳囧磹婵犳艾鐤炬い鎰堕檮閸嬬喐銇勯弽銊с€掗梻鍕閺岋箑螣娓氼垱笑闂佽姘﹂褔婀佸┑鐘诧工妤犲憡绂嶉崜褏纾奸弶鍫涘妼缁楁岸鏌熷畡鐗堝殗闁诡喒鏅犲畷褰掝敃閵堝棙顔忔繝鐢靛仦閸ㄥ爼骞愰幘顔肩;闁规崘绉ぐ鎺撳亹闁绘垶锕╁Λ鍕⒑閹肩偛濡奸悗娑掓櫇缁顓兼径妯绘櫇闂佹寧绻傞弻濠囨晝閸屾稓鍘甸柣搴㈢⊕閿氶柣蹇ョ稻缁绘繃绻濋崘銊т紝闂佽鍨伴崯鏉戠暦閻旂⒈鏁傞柛鈾€鏅欑槐妯衡攽閻愬樊鍤熷┑顔藉劤铻為柛鏇ㄥ墯閸欏繘鏌嶉崫鍕櫣缂佲偓婢跺绠鹃柟瀛樼箘閿涘秵顨ラ悙顏勭伈闁诡喖缍婂畷鎯邦槻婵℃彃顭烽弻娑㈠Ω閵夈儺鍔夌紓浣稿€哥粔褰掑极閹剧粯鏅搁柨鐕傛嫹 ---闂傚倷鐒︾€笛兠洪埡鍛闁跨噦鎷�
开发学院手机开发Android 开发 Android 输入事件流程 阅读

Android 输入事件流程

 2010-05-24 21:08:00 来源:WEB开发网 闂傚倷绶氬ḿ褍螞閹绢喖绠柨鐕傛嫹闂傚倷绀侀幉锟犲垂閻㈠灚宕查柟鎵閸庡秵銇勯幒鎴濃偓鐢稿磻閹炬枼妲堟繛鍡楃С濞岊亞绱撻崒姘扁枌闁瑰嚖鎷�婵犵數濮幏鍐川椤撴繄鎹曢梻渚€娼уú銈吤洪妸鈺佺劦妞ゆ帊鑳堕埊鏇㈡煏閸モ晛浠х紒杈╁仱閺佹捇鏁撻敓锟�闂傚倷绶氬ḿ褍螞閹绢喖绠柨鐕傛嫹  闂傚倷鑳舵灙缂佺粯顨呴埢宥夊即閵忕姵鐎梺缁樺姇閻忔氨鈧凹鍓熷娲垂椤曞懎鍓伴梺閫炲苯澧紒澶婄秺瀵濡歌閸嬫捇妫冨☉娆忔殘闂佷紮缍€娴滎剟鍩€椤掑倹鏆柛瀣躬瀹曚即寮借閺嗭箓鏌ㄩ悤鍌涘
核心提示:if (pollres <= 0) {if (errno != EINTR) {LOGW("select failed (errno=%d)", errno);usleep(100000);}continue;}for(i = 1; i < mFDCount; i++) {if(mFDs

if (pollres <= 0) {

if (errno != EINTR) {

LOGW("select failed (errno=%d) ", errno);

usleep(100000);

}

continue;

}

for(i = 1; i < mFDCount; i++) {

if(mFDs[i].revents) {

LOGV("revents for %d = 0x%08x", i, mFDs[i].revents);

if(mFDs[i].revents & POLLIN) {

res = read(mFDs[i].fd, &iev, sizeof(iev));

if (res == sizeof(iev)) {

LOGV("%s got: t0=%d, t1=%d, type=%d, code=%d, v=%d",

mDevices[i]->path.string(),

(int) iev.time.tv_sec, (int) iev.time.tv_usec,

iev.type, iev.code, iev.value);

*outDeviceId = mDevices[i]->id;

if (*outDeviceId == mFirstKeyboardId) *outDeviceId = 0;

*outType = iev.type;

*outScancode = iev.code;

if (iev.type == EV_KEY) {

err = mDevices[i]->layoutMap->map(iev.code, outKeycode, outFlags);

LOGV("iev.code=%d outKeycode=%d outFlags=0x%08x err=%d ",

iev.code, *outKeycode, *outFlags, err);

if (err != 0) {

*outKeycode = 0;

*outFlags = 0;

}

} else {

*outKeycode = iev.code;

}

*outValue = iev.value;

*outWhen = s2ns(iev.time.tv_sec) + us2ns(iev.time.tv_usec);

return true;

} else {

if (res<0) {

LOGW("could not get event (errno=%d)", errno);

} else {

LOGE("could not get event (wrong size: %d)", res);

}

continue;

}

}

}

}

...

}

对于按键事件,调用mDevices->layoutMap->map 进行映射。映射实际是由 KeyLayoutMap::map完成的,KeyLayoutMap类里读取配置文件qwerty.kl,由配置文件 qwerty.kl 决定键值的映射关系。你可以通过修改./development/emulator/keymaps/qwerty.kl来改变键值的映射关系。

上一页  1 2 3 4  下一页

Tags:Android 输入 事件

编辑录入:coldstar [复制链接] [打 印]
赞助商链接