WEB开发网
开发学院手机开发Android 开发 android键盘映射 阅读

android键盘映射

 2010-07-15 21:14:00 来源:WEB开发网   
核心提示:public void run() {// 在循环中调用:readEvent(ev);...send = preprocessEvent(di, ev);//实际调用的是 KeyQ 类的 preprocessEvent 函数...int keycode = rotateKeyCodeLocked(ev.keycode)

public void run() {

// 在循环中调用:

readEvent(ev);

...

send = preprocessEvent(di, ev);

//实际调用的是 KeyQ 类的 preprocessEvent 函数

...

int keycode = rotateKeyCodeLocked(ev.keycode);

int[] map = mKeyRotationMap;

for (int i=0; i

if (map == keyCode)

return map[i+1];

} //

addLocked(di, curTime, ev.flags,RawInputEvent.CLASS_KEYBOARD,

newKeyEvent(di, di.mDownTime, curTime, down,keycode, 0, scancode,...));

QueuedEvent ev = obtainLocked(device, when, flags, classType, event);

}

};

readEvent() 实际上调用的是 com_android_server_KeyInputQueue.cpp (frameworksaseservicesjni)中的

static jboolean android_server_KeyInputQueue_readEvent(JNIEnv* env, jobject clazz,jobject event) 来读取事件,

bool res = hub->getEvent(&deviceId, &type, &scancode, &keycode,&flags, &value, &when)调用的是EventHub.cpp (frameworksaselibsui)中的:

bool EventHub::getEvent (int32_t* outDeviceId, int32_t* outType,

int32_t* outScancode, int32_t* outKeycode, uint32_t *outFlags,

int32_t* outValue, nsecs_t* outWhen)

在函数中调用了读设备操作:res = read(mFDs.fd, &iev, sizeof(iev));

在构造函数 WindowManagerService()调用 new KeyQ() 以后接着调用了:

mInputThread = new InputDispatcherThread();

...

mInputThread.start();

来启动一个线程 InputDispatcherThread

run()

process();

QueuedEvent ev = mQueue.getEvent(...)

因为WindowManagerService类中: final KeyQ mQueue;

所以实际上 InputDispatcherThread 线程实际上从 KeyQ 的事件队列中读取按键事件,在process() 方法中进行处理事件。

switch (ev.classType)

case RawInputEvent.CLASS_KEYBOARD:

...

上一页  1 2 3 4 5 6  下一页

Tags:android 键盘 映射

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