分类: LINUX
2009-09-23 11:29:44
转载时请注明出处和作者联系方式
文章出处:http://www.limodev.cn/blog
作者联系方式:李先静
uinput 是linux 2.6用来实现用户空间输入设备的内核接口,用它可以在用户空间实现输入设备,向系统中注入输入事件,而不需要通过GUI去实现。使用时要确保内核编译时 支持uinput模块,可能还要手工创建设备文件/dev/uinput(mknod /dev/uinput c 10 223)。
o 创建user input device
UInput* uinput_create(const char* dev, int xmax, int ymax);
android平台用xmax和ymax对触摸屏做简单的校准,如果不设置为实际的值,事件先会被丢掉。
o 上报mouse按键事件
void uinput_report_lbutton_event(UInput* thiz, int press);
void uinput_report_mbutton_event(UInput* thiz, int press);
void uinput_report_rbutton_event(UInput* thiz, int press);
o 上报mouse移动事件
void uinput_report_move_event(UInput* thiz, int x, int y);
o 上报按键事件
void uinput_report_key_event(UInput* thiz, unsigned short key, int press);
o 上报触摸屏事件
void uinput_report_touch_event(UInput* thiz, int x, int y, int press/*1(down) 0(up) -1(move)*/);
o 销毁设备
void uinput_destroy(UInput* thiz);
有需要的朋友请到这里下载。