WEB开发网
开发学院手机开发Android 开发 Android事件处理 阅读

Android事件处理

 2010-05-31 14:39:00 来源:WEB开发网   
核心提示:src="http://janla.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" pluginspage="http://www.macromedia.com/go/getflashplayer">
src="http://janla.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" pluginspage="http://www.macromedia.com/go/getflashplayer">

bool EventHub::openPlatformInput(void)

{

...

mFDCount = 1;

mFDs = (pollfd *)calloc(1, sizeof(mFDs[0]));

mDevices = (device_t **)calloc(1, sizeof(mDevices[0]));

mFDs[0].events = POLLIN;

mDevices[0] = NULL;

res = scan_dir(device_path);

...

return true;

}

bool EventHub::openPlatformInput(void) { ... mFDCount = 1; mFDs = (pollfd *)calloc(1, sizeof(mFDs[0])); mDevices = (device_t **)calloc(1, sizeof(mDevices[0])); mFDs[0].events = POLLIN; mDevices[0] = NULL; res = scan_dir(device_path); ... return true; }

EventHub对外提供了一个函数用于从输入设备文件中读取数据。

C代码 < width="14" height="15" src="http://janla.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" pluginspage="http://www.macromedia.com/go/getflashplayer">

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

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

int32_t* outValue, nsecs_t* outWhen)

{

...

while(1) {

// First, report any devices that had last been added/removed.

if (mClosingDevices != NULL) {

device_t* device = mClosingDevices;

LOGV("Reporting device closed: id=0x%x, name=%s ",

device->id, device->path.string());

mClosingDevices = device->next;

*outDeviceId = device->id;

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

*outType = DEVICE_REMOVED;

delete device;

return true;

}

if (mOpeningDevices != NULL) {

device_t* device = mOpeningDevices;

LOGV("Reporting device opened: id=0x%x, name=%s

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

Tags:Android 事件 处理

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