Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jun 2021 04:14:24 +0300
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        Mark Kane <mark@kane.mn>
Cc:        usb@freebsd.org, hps@selasky.org
Subject:   Re: eGalax USB touchscreen issues
Message-ID:  <c9e68dbb-5382-976d-7302-d816d8636153@FreeBSD.org>
In-Reply-To: <36983ce5-8358-5a04-2377-46067d3c3c79@FreeBSD.org>
References:  <324d49ca-1c0e-659d-194d-ece4d5f7f5e2@FreeBSD.org> <0ae3fec48e2c351d2c006f4ba4932cd7@kane.mn> <166dd4d4-24cd-c24b-d75e-9a34fa734358@FreeBSD.org> <eccaff2a99153fb44ffa8df3c93d7eb6@kane.mn> <36983ce5-8358-5a04-2377-46067d3c3c79@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------099283402CF1FE16451AD87F
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

On 02.06.2021 14:26, Vladimir Kondratyev wrote:
> On 02.06.2021 00:52, Mark Kane wrote:
>> On 2021-05-31 16:29, Vladimir Kondratyev wrote:
>>> Could you run usbhid-dump one more time?
>>> Following part of dump is broken and does not match Xorg log:
>>>
>>> 000:003:000:DESCRIPTOR         1621478496.823720
>>>   8D 0F 00 09 42 09 32 15 00 25 01 95 02 75 01 81
>>>   02 95 06 75 01 81 03 05 01 09 30 75 10 95 01 A4
>>>   55 00 65 00 36 00 00 46 00 00 16 1E 00 26 C8 0F
>>>   81 02 09 31 16 3C 00 26
>>>
>>> Does evemu-record (devel/evemu) hear any events from eGlax?
>>
>> Sure thing, output for both is below. evemu-record hears events from
>> event8, none from event7.
> 
> There was a stupid mistake in previous patch. Could you test new one
> (attached) ?
> 
>> # usbhid-dump
>> 000:003:001:DESCRIPTOR         1622583731.526623
>> 05 0C 09 01 A1 01 85 01 19 00 2A 3C 02 15 00 26
>> 3C 02 95 01 75 10 81 00 C0 05 01 09 80 A1 01 85
>> 02 19 81 29 83 25 01 75 01 95 03 81 02 95 05 81
>> 01 C0
>>
>> 000:003:000:DESCRIPTOR         1622583731.529418
>> 05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
>> 95 08 75 01 81 02 95 08 75 01 81 01 05 08 19 01
>> 29 03 95 03 75 01 91 02 95 01 75 05 91 01 05 07
>> 19 00 2A FF 00 15 00 26 FF 00 95 06 75 08 81 00
>> C0
>>
>> 000:004:000:DESCRIPTOR         1622583731.530328
>> 05 01 09 01 A1 01 85 01 09 01 A1 00 05 09 19 01
>> 29 02 15 00 25 01 95 02 75 01 81 02 95 01 75 06
>> 81 01 05 01 09 30 09 31 16 00 00 26 FF 0F 36 00
>> 00 46 FF 0F 66 00 00 75 10 95 02 81 02 C0 C0 05
> 
> For now, report descriptor is not broken but it still does not match my
> expectations. Could you post output of
> 
> install sysutils/hid-tools
> sudo kldload hidraw.ko
> sudo hid-decode /dev/hidraw#
> 
> Where # is number corresponding your touchscreen
> 

One more patch :-) with relaxed as compared to MS specs requirements to
usages presence.

-- 
WBR
Vladimir Kondratyev

--------------099283402CF1FE16451AD87F
Content-Type: text/x-patch; charset=UTF-8;
 name="hpen.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="hpen.patch"

diff --git a/sys/dev/hid/hms.c b/sys/dev/hid/hms.c
index 94267b3fcd5..0f60eec86a4 100644
--- a/sys/dev/hid/hms.c
+++ b/sys/dev/hid/hms.c
@@ -109,6 +109,7 @@ static const struct hidmap_item hms_map_wheel_rev[] = {
 
 /* A match on these entries will load hms */
 static const struct hid_device_id hms_devs[] = {
+	{ HID_TLC(HUP_GENERIC_DESKTOP, HUG_POINTER) },
 	{ HID_TLC(HUP_GENERIC_DESKTOP, HUG_MOUSE) },
 };
 
diff --git a/sys/dev/hid/hpen.c b/sys/dev/hid/hpen.c
index 1d505e14089..969dc998b2e 100644
--- a/sys/dev/hid/hpen.c
+++ b/sys/dev/hid/hpen.c
@@ -72,7 +72,7 @@ static hidmap_cb_t	hpen_final_pen_cb;
 	HIDMAP_ABS_CB(HUP_DIGITIZERS, HUD_##usage, &cb)
 
 /* Generic map digitizer page map according to hut1_12v2.pdf */
-static const struct hidmap_item hpen_map_digi[] = {
+static const struct hidmap_item hpen_map[] = {
     { HPEN_MAP_ABS_GD(X,		ABS_X),		  .required = true },
     { HPEN_MAP_ABS_GD(Y,		ABS_Y),		  .required = true },
     { HPEN_MAP_ABS(   TIP_PRESSURE,	ABS_PRESSURE) },
@@ -88,28 +88,21 @@ static const struct hidmap_item hpen_map_digi[] = {
     { HPEN_MAP_BUT(   ERASER,		BTN_TOUCH) },
     { HPEN_MAP_BUT(   TABLET_PICK,	BTN_STYLUS2) },
     { HPEN_MAP_BUT(   SEC_BARREL_SWITCH,BTN_STYLUS2) },
-    { HIDMAP_FINAL_CB(			&hpen_final_digi_cb) },
 };
 
-/* Microsoft-standardized pen support */
 static const struct hidmap_item hpen_map_pen[] = {
-    { HPEN_MAP_ABS_GD(X,		ABS_X),		  .required = true },
-    { HPEN_MAP_ABS_GD(Y,		ABS_Y),		  .required = true },
-    { HPEN_MAP_ABS(   TIP_PRESSURE,	ABS_PRESSURE),	  .required = true },
-    { HPEN_MAP_ABS(   X_TILT,		ABS_TILT_X) },
-    { HPEN_MAP_ABS(   Y_TILT,		ABS_TILT_Y) },
-    { HPEN_MAP_ABS_CB(BATTERY_STRENGTH,	hpen_battery_strenght_cb) },
-    { HPEN_MAP_BUT(   TIP_SWITCH,	BTN_TOUCH),	  .required = true },
-    { HPEN_MAP_BUT(   IN_RANGE,		BTN_TOOL_PEN),	  .required = true },
-    { HPEN_MAP_BUT(   BARREL_SWITCH,	BTN_STYLUS) },
-    { HPEN_MAP_BUT(   INVERT,		BTN_TOOL_RUBBER), .required = true },
-    { HPEN_MAP_BUT(   ERASER,		BTN_TOUCH),	  .required = true },
     { HIDMAP_FINAL_CB(			&hpen_final_pen_cb) },
 };
 
+static const struct hidmap_item hpen_map_digi[] = {
+    { HIDMAP_FINAL_CB(			&hpen_final_digi_cb) },
+};
+
 static const struct hid_device_id hpen_devs[] = {
 	{ HID_TLC(HUP_DIGITIZERS, HUD_DIGITIZER) },
 	{ HID_TLC(HUP_DIGITIZERS, HUD_PEN) },
+	{ HID_TLC(HUP_DIGITIZERS, HUD_TOUCHSCREEN),
+	  HID_BVP(BUS_USB, USB_VENDOR_EGALAX, USB_PRODUCT_EGALAX_TPANEL) },
 };
 
 static int
@@ -186,7 +179,7 @@ hpen_probe(device_t dev)
 {
 	struct hidmap *hm = device_get_softc(dev);
 	int error;
-	bool is_pen;
+	const char *suffix;
 
 	error = HIDBUS_LOOKUP_DRIVER_INFO(dev, hpen_devs);
 	if (error != 0)
@@ -194,15 +187,31 @@ hpen_probe(device_t dev)
 
 	hidmap_set_dev(hm, dev);
 
+	error = HIDMAP_ADD_MAP(hm, hpen_map, NULL);
+	if (error != 0)
+		return (error);
+
 	/* Check if report descriptor belongs to a HID tablet device */
-	is_pen = hidbus_get_usage(dev) == HID_USAGE2(HUP_DIGITIZERS, HUD_PEN);
-	error = is_pen
-	    ? HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL)
-	    : HIDMAP_ADD_MAP(hm, hpen_map_digi, NULL);
+	switch (HID_GET_USAGE(hidbus_get_usage(dev))) {
+	case HUD_PEN:
+		error = HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL);
+		suffix = "Pen";
+		break;
+	case HUD_TOUCHSCREEN:
+		error = HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL);
+		suffix = "TouchScreen";
+		break;
+	case HUD_DIGITIZER:
+		error = HIDMAP_ADD_MAP(hm, hpen_map_digi, NULL);
+		suffix = "Digitizer";
+		break;
+	default:
+		KASSERT(1 == 0, ("Unknown usage"));
+	}
 	if (error != 0)
 		return (error);
 
-	hidbus_set_desc(dev, is_pen ? "Pen" : "Digitizer");
+	hidbus_set_desc(dev, suffix);
 
 	return (BUS_PROBE_DEFAULT);
 }

--------------099283402CF1FE16451AD87F--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?c9e68dbb-5382-976d-7302-d816d8636153>