《Android系统学习》第一章:Input子系统驱动部分

来源:互联网 发布:网络电视的遥控器失灵 编辑:程序博客网 时间:2024/05/24 03:44
一、Input设备(鼠标、键盘、触摸板)的Linux Driver

input core提供的接口:

motion_touchpad = input_allocate_device();    //创建input设备set_bit(ABS_MT_TOUCH_MAJOR, motion_touchpad->keybit);set_bit(ABS_MT_POSITION_X, motion_touchpad->keybit);set_bit(ABS_MT_POSITION_Y, motion_touchpad->keybit);set_bit(ABS_X, motion_touchpad->keybit);set_bit(ABS_Y, motion_touchpad->keybit);    //input设备功能声明;如支持的事件类型(EV_KEY、EV_REL、EV_ABS),支持的按键类型(BTN_LEFT等)input_set_abs_params(motion_touchpad, ABS_MT_POSITION_X,        0, /*max_y*/max_x, 0, 0);input_set_abs_params(motion_touchpad, ABS_MT_POSITION_Y,        0, /*max_x*/max_y, 0, 0);input_set_abs_params(motion_touchpad, ABS_MT_TOUCH_MAJOR,            0, 50, 0, 0);input_set_abs_params(motion_touchpad, ABS_PRESSURE, 0,            50, 0, 0);input_set_abs_params(motion_touchpad, ABS_TOOL_WIDTH, 0,            50, 0, 0);input_set_abs_params(motion_touchpad, ABS_MT_WIDTH_MAJOR, 0,            50, 0, 0);               //input支持事件的具体配置input_report_abs(motion_touchpad, ABS_X, fingers_xy[0]);  //上报绝对坐标input_report_key(motion_touchpad, BTN_2 , f2z > 0);    //上报按键input_report_rel(motion_mouse, cmd.event.code, cmd.event.value);   //上报相对坐标


原创粉丝点击