一、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); //上报相对坐标