1. 注册
hi->input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
hi->input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
switch (usage->hid) {
case HID_GD_X:
#ifdef SINGLE_TOUCH
hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_X);
input_set_abs_params(hi->input, ABS_X, 0, MAX_X, 0, 0);
#else
hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_MT_POSITION_X);
input_set_abs_params(hi->input, ABS_X, field->logical_minimum, field->logical_maximum, 0, 0);
#endif
return 1;
case HID_GD_Y:
#ifdef SINGLE_TOUCH
hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_Y);
input_set_abs_params(hi->input, ABS_Y, 0, MAX_Y, 0, 0);
#else
hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_MT_POSITION_Y);
input_set_abs_params(hi->input, ABS_Y,field->logical_minimum, field->logical_maximum, 0, 0);
#endif
return 1;
case HID_DG_TIPPRESSURE:
printk(".............ABS_PRESSURE..........\n");
hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_PRESSURE); //++by sbs
input_set_abs_params(hi->input, ABS_PRESSURE, 0, 255, 0, 0);
return 1;
}
2. 上报点
if(nd->pt[i].pressure)
{
#ifdef SINGLE_TOUCH
input_report_abs(input, ABS_X, nd->pt[i].x);
input_report_abs(input, ABS_Y, nd->pt[i].y);
input_report_abs(input, ABS_PRESSURE, nd->pt[i].pressure);
input_sync(input);
all_touch_up = false;
#else
input_report_abs(input, ABS_MT_PRESSURE, nd->pt[i].pressure);
input_report_abs(input, ABS_MT_POSITION_X, nd->pt[i].x);
input_report_abs(input, ABS_MT_POSITION_Y, nd->pt[i].y);
input_report_abs(input, ABS_MT_TRACKING_ID, nd->pt[i].id);
input_mt_sync(input);
all_touch_up = false;
#endif
}
if(i == (nd->total - 1) && all_touch_up == true)
{
#ifdef SINGLE_TOUCH
input_report_abs(input, ABS_PRESSURE, 0);
input_sync(input);
#else
input_mt_sync(input);
#endif