如果usb觸摸點(diǎn)是水平反向或者對(duì)角反向飒泻,可以修改frameworks/base/services/input/InputReader.cpp中的代碼。
?void MultiTouchInputMapper::syncTouch(nsecs_t when, bool* outHavePointerIds) {
? ? ? ? outPointer.distance = inSlot->getDistance();
? ? ? ? outPointer.tiltX = 0;
? ? ? ? outPointer.tiltY = 0;
+
+ //int32_t temp;
+? ? ? ? //temp = outPointer.x;
+? ? ? ? //outPointer.x = outPointer.y;
+? ? ? ? outPointer.x = (3657 - outPointer.x);
+? ? ? ? outPointer.y = (2065 - outPointer.y);
+? ? ? ? //ALOGD("outPointer.x = %d,outPointer.y = %d",outPointer.x,outPointer.y);
? ? ? ? outPointer.toolType = inSlot->getToolType();
? ? ? ? if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
以上代碼可以通過(guò)getDeviceName().string()比較驅(qū)動(dòng)名來(lái)針對(duì)不同型號(hào)的tp進(jìn)行判斷修改噪窘,這樣就不會(huì)影響其他tp了笋庄。
如果tp是橫屏,但是顯示屏是豎屏的修改usb tp驅(qū)動(dòng)kernel/drivers/hid/hid-multitouch.c
具體修改如下:
@@ -136,6 +136,7 @@ static void mt_post_parse(struct mt_device *td);
/* vendor specific classes */
#define MT_CLS_3M 0x0101
+#define MT_ILITEK 0x222a
#define MT_CLS_CYPRESS 0x0102
#define MT_CLS_EGALAX 0x0103
#define MT_CLS_EGALAX_SERIAL 0x0104
@@ -150,7 +151,9 @@ static void mt_post_parse(struct mt_device *td);
#define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p)
#define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p)
-
+//rotation modify
+static int X_max=0;
+static int Y_max=0;
/*
? * these device-dependent functions determine what slot corresponds
? * to a valid contact that was just read.
@@ -460,7 +463,11 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
case HID_UP_GENDESK:
switch (usage->hid) {
- case HID_GD_X:
+ //rotation modify
+ //case HID_GD_X:
+ case HID_GD_Y:
+ X_max = field->logical_maximum;
+ // printk("lwx-mt_touch_input_mapping HID_GD_Y cls->sn_move=%d,max=%d,X_max=%d\n",cls->sn_move,*max,X_max);
if (prev_usage && (prev_usage->hid == usage->hid)) {
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_TOOL_X);
@@ -475,7 +482,11 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
mt_store_field(usage, td, hi);
return 1;
- case HID_GD_Y:
+ //rotation modify
+ //case HID_GD_Y:
+ case HID_GD_X:
+ Y_max = field->logical_maximum;
+ // printk("lwx-mt_touch_input_mapping HID_GD_X cls->sn_move=%d,max=%d,Y_max=%d\n",cls->sn_move,*max,Y_max);
if (prev_usage && (prev_usage->hid == usage->hid)) {
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_TOOL_Y);
@@ -520,20 +531,35 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
case HID_DG_WIDTH:
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_TOUCH_MAJOR);
+ #if 1// //rotation modify
if (!(cls->quirks & MT_QUIRK_NO_AREA))
set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
- cls->sn_width);
+ cls->sn_width);
+ #else
+ if (!(cls->quirks & MT_QUIRK_NO_AREA))
+ set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
+ cls->sn_height);
+ #endif
mt_store_field(usage, td, hi);
return 1;
case HID_DG_HEIGHT:
hid_map_usage(hi, usage, bit, max,
EV_ABS, ABS_MT_TOUCH_MINOR);
+ #if 1// //rotation modify
if (!(cls->quirks & MT_QUIRK_NO_AREA)) {
set_abs(hi->input, ABS_MT_TOUCH_MINOR, field,
cls->sn_height);
input_set_abs_params(hi->input,
ABS_MT_ORIENTATION, 0, 1, 0, 0);
}
+ #else
+ if (!(cls->quirks & MT_QUIRK_NO_AREA)) {
+ set_abs(hi->input, ABS_MT_TOUCH_MINOR, field,
+ cls->sn_width);
+ input_set_abs_params(hi->input,
+ ABS_MT_ORIENTATION, 0, 0, 0, 0);
+ }
+ #endif
mt_store_field(usage, td, hi);
return 1;
case HID_DG_TIPPRESSURE:
@@ -640,9 +666,15 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
/* divided by two to match visual scale of touch */
int major = max(s->w, s->h) >> 1;
int minor = min(s->w, s->h) >> 1;
-
+ #if 0// //rotation modify
input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
- input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
+ input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
+ #else
+ //input_event(input, EV_ABS, ABS_MT_POSITION_X, s->y);
+ input_event(input, EV_ABS, ABS_MT_POSITION_X, X_max-s->y);
+ input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->x);
+ //input_event(input, EV_ABS, ABS_MT_POSITION_Y, Y_max-s->x);
+ #endif
input_event(input, EV_ABS, ABS_MT_TOOL_X, s->cx);
input_event(input, EV_ABS, ABS_MT_TOOL_Y, s->cy);
input_event(input, EV_ABS, ABS_MT_DISTANCE,
以上+號(hào)后面的是修改的代碼倔监,-號(hào)后面是去掉的代碼直砂。
如果tp水平或者對(duì)角反向了可以將下面的注釋的代碼打開(kāi),把使用的代碼注釋掉
+ //input_event(input, EV_ABS, ABS_MT_POSITION_X, s->y);
+ input_event(input, EV_ABS, ABS_MT_POSITION_X, X_max-s->y);
+ input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->x);
+ //input_event(input, EV_ABS, ABS_MT_POSITION_Y, Y_max-s->x);