Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Dec 2020 15:21:44 +0300
From:      Vladimir Kondratyev <vladimir@kondratyev.su>
To:        freebsd-x11@freebsd.org
Subject:   Re: Xorg (latest from ports) and no mouse movement
Message-ID:  <3cb95850-540c-a425-524d-5e3ce3b5a10d@kondratyev.su>
In-Reply-To: <4dafd8bb-14fa-dee9-353f-625f8479af95@kondratyev.su>
References:  <20201205114354.GA3814@c720-r342378> <20201205115850.GA4689@c720-r342378> <56a68baa-fec7-6610-5d24-6159b75927ab@kondratyev.su> <20201205144428.GA7042@c720-r342378> <d01e5270-77b0-5bf1-6af4-7cd75d5029ca@kondratyev.su> <u4tmdt.qkvl4m.2wallm-qmf@ms-10.1blu.de> <5cad48e4-2414-1581-f79d-5b2d4d0b6619@kondratyev.su> <X9IWYJvIfAjdU348@c720-r368166.fritz.box> <1f745bc6-8315-3825-d3c4-8b04cd63a88c@kondratyev.su> <X9nva3MXXq4Crg7g@c720-r368166.fritz.box> <4dafd8bb-14fa-dee9-353f-625f8479af95@kondratyev.su>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------5D5100A6371532A4838E42F3
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit

On 16.12.2020 14:55, Vladimir Kondratyev wrote:

> 
>> #   Event type 1 (EV_KEY)
>> #     Event code 272 (BTN_LEFT)
>> #     Event code 274 (BTN_MIDDLE)
>> #     Event code 325 (BTN_TOOL_FINGER)
>> #     Event code 328 (BTN_TOOL_QUINTTAP)
>> #     Event code 330 (BTN_TOUCH)
>> #     Event code 333 (BTN_TOOL_DOUBLETAP)
>> #     Event code 334 (BTN_TOOL_TRIPLETAP)
>> #     Event code 335 (BTN_TOOL_QUADTAP)
>> #   Event type 3 (EV_ABS)
> 
> It looks like middle button is misdetected

Try attached patch too. It makes cyapa button detection code closer to
what Linux driver does.


> _______________________________________________
> freebsd-x11@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-x11
> To unsubscribe, send any mail to "freebsd-x11-unsubscribe@freebsd.org"
> 


--------------5D5100A6371532A4838E42F3
Content-Type: text/x-patch; charset=UTF-8;
 name="cyapa.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="cyapa.patch"

diff --git a/sys/dev/cyapa/cyapa.c b/sys/dev/cyapa/cyapa.c
index 293d68e9abdc..d2323f2fa9b4 100644
--- a/sys/dev/cyapa/cyapa.c
+++ b/sys/dev/cyapa/cyapa.c
@@ -99,6 +99,8 @@ __FBSDID("$FreeBSD$");
  * below) the other two.
  */
 
+#include "opt_evdev.h"
+
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/conf.h>
@@ -126,6 +128,11 @@ __FBSDID("$FreeBSD$");
 #include <dev/iicbus/iicbus.h>
 #include <dev/cyapa/cyapa.h>
 
+#ifdef EVDEV_SUPPORT
+#include <dev/evdev/input.h>
+#include <dev/evdev/evdev.h>
+#endif
+
 #include "iicbus_if.h"
 #include "bus_if.h"
 #include "device_if.h"
@@ -153,6 +160,9 @@ struct cyapa_softc {
 	struct selinfo selinfo;
 	struct mtx mutex;
 	struct intr_config_hook intr_hook;
+#ifdef EVDEV_SUPPORT
+	struct evdev_dev *evdev;
+#endif
 
 	int	cap_resx;
 	int	cap_resy;
@@ -536,13 +546,13 @@ cyapa_attach(device_t dev)
 	    cap.phy_siz_x_low;
 	sc->cap_phyy = ((cap.phy_siz_xy_high << 8) & 0x0F00) |
 	    cap.phy_siz_y_low;
-	sc->cap_buttons = cap.buttons;
+	sc->cap_buttons = cap.buttons >> 3;
 
 	device_printf(dev, "%5.5s-%6.6s-%2.2s buttons=%c%c%c res=%dx%d\n",
 	    cap.prod_ida, cap.prod_idb, cap.prod_idc,
-	    ((cap.buttons & CYAPA_FNGR_LEFT) ? 'L' : '-'),
-	    ((cap.buttons & CYAPA_FNGR_MIDDLE) ? 'M' : '-'),
-	    ((cap.buttons & CYAPA_FNGR_RIGHT) ? 'R' : '-'),
+	    ((sc->cap_buttons & CYAPA_FNGR_LEFT) ? 'L' : '-'),
+	    ((sc->cap_buttons & CYAPA_FNGR_MIDDLE) ? 'M' : '-'),
+	    ((sc->cap_buttons & CYAPA_FNGR_RIGHT) ? 'R' : '-'),
 	    sc->cap_resx, sc->cap_resy);
 
 	sc->hw.buttons = 5;
@@ -561,8 +571,48 @@ cyapa_attach(device_t dev)
 	sc->intr_hook.ich_func = cyapa_start;
 	sc->intr_hook.ich_arg = sc->dev;
 
+#ifdef EVDEV_SUPPORT
+	sc->evdev = evdev_alloc();
+	evdev_set_name(sc->evdev, device_get_desc(sc->dev));
+	evdev_set_phys(sc->evdev, device_get_nameunit(sc->dev));
+	evdev_set_id(sc->evdev, BUS_I2C, 0, 0, 1);
+	evdev_set_flag(sc->evdev, EVDEV_FLAG_MT_STCOMPAT);
+	evdev_set_flag(sc->evdev, EVDEV_FLAG_MT_AUTOREL);
+
+	evdev_support_event(sc->evdev, EV_SYN);
+	evdev_support_event(sc->evdev, EV_ABS);
+	evdev_support_event(sc->evdev, EV_KEY);
+	evdev_support_prop(sc->evdev, INPUT_PROP_POINTER);
+	if (sc->cap_buttons & CYAPA_FNGR_LEFT)
+		evdev_support_key(sc->evdev, BTN_LEFT);
+	if (sc->cap_buttons & CYAPA_FNGR_RIGHT)
+		evdev_support_key(sc->evdev, BTN_RIGHT);
+	if (sc->cap_buttons & CYAPA_FNGR_MIDDLE)
+		evdev_support_key(sc->evdev, BTN_MIDDLE);
+	if (CYAPA_FNGR_LEFT == (sc->cap_buttons &
+	    (CYAPA_FNGR_LEFT | CYAPA_FNGR_RIGHT | CYAPA_FNGR_MIDDLE)))
+		evdev_support_prop(sc->evdev, INPUT_PROP_BUTTONPAD);
+
+	evdev_support_abs(sc->evdev, ABS_MT_SLOT,
+	    0, 0, CYAPA_MAX_MT - 1, 0, 0, 0);
+	evdev_support_abs(sc->evdev, ABS_MT_TRACKING_ID, 0, -1, 15, 0, 0, 0);
+	evdev_support_abs(sc->evdev, ABS_MT_POSITION_X, 0, 0, sc->cap_resx,
+	    0, 0, sc->cap_phyx != 0 ? sc->cap_resx / sc->cap_phyx : 0);
+	evdev_support_abs(sc->evdev, ABS_MT_POSITION_Y, 0, 0, sc->cap_resy,
+	    0, 0, sc->cap_phyy != 0 ? sc->cap_resy / sc->cap_phyy : 0);
+	evdev_support_abs(sc->evdev, ABS_MT_PRESSURE, 0, 0, 255, 0, 0, 0);
+
+	if (evdev_register(sc->evdev) != 0) {
+		mtx_destroy(&sc->mutex);
+		return (ENOMEM);
+	}
+#endif
+
 	/* Postpone start of the polling thread until sleep is available */
 	if (config_intrhook_establish(&sc->intr_hook) != 0) {
+#ifdef EVDEV_SUPPORT
+		evdev_free(sc->evdev);
+#endif
 		mtx_destroy(&sc->mutex);
 		return (ENOMEM);
 	}
@@ -596,6 +646,10 @@ cyapa_detach(device_t dev)
 	seldrain(&sc->selinfo);
 	knlist_destroy(&sc->selinfo.si_note);
 
+#ifdef EVDEV_SUPPORT
+	evdev_free(sc->evdev);
+#endif
+
 	mtx_destroy(&sc->mutex);
 
 	return (0);
@@ -1321,6 +1375,40 @@ cyapa_raw_input(struct cyapa_softc *sc, struct cyapa_regs *regs, int freq)
 		    nfingers);
 	}
 
+#ifdef EVDEV_SUPPORT
+	if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE) {
+		for (i = 0; i < nfingers; ++i) {
+			int32_t slot = evdev_get_mt_slot_by_tracking_id(
+			    sc->evdev, regs->touch[i].id);
+			if (slot == -1) {
+				if (cyapa_debug)
+					printf("Slot overflow for i=%d\n",
+					    regs->touch[i].id);
+				continue;
+			}
+			evdev_push_abs(sc->evdev, ABS_MT_SLOT, slot);
+			evdev_push_abs(sc->evdev, ABS_MT_TRACKING_ID,
+			    regs->touch[i].id);
+			evdev_push_abs(sc->evdev, ABS_MT_POSITION_X,
+			    CYAPA_TOUCH_X(regs, i));
+			evdev_push_abs(sc->evdev, ABS_MT_POSITION_Y,
+			    CYAPA_TOUCH_Y(regs, i));
+			evdev_push_abs(sc->evdev, ABS_MT_PRESSURE,
+			    CYAPA_TOUCH_P(regs, i));
+		}
+		if (sc->cap_buttons & CYAPA_FNGR_LEFT)
+			evdev_push_key(sc->evdev, BTN_LEFT,
+			    regs->fngr & CYAPA_FNGR_LEFT);
+		if (sc->cap_buttons & CYAPA_FNGR_RIGHT)
+			evdev_push_key(sc->evdev, BTN_RIGHT,
+			    regs->fngr & CYAPA_FNGR_RIGHT);
+		if (sc->cap_buttons & CYAPA_FNGR_MIDDLE)
+			evdev_push_key(sc->evdev, BTN_MIDDLE,
+			    regs->fngr & CYAPA_FNGR_MIDDLE);
+		evdev_sync(sc->evdev);
+	}
+#endif
+
 	seen_thumb = 0;
 	for (i = 0; i < afingers; ) {
 		if (cyapa_debug) {
@@ -1731,4 +1819,7 @@ cyapa_fuzz(int delta, int *fuzzp)
 
 DRIVER_MODULE(cyapa, iicbus, cyapa_driver, cyapa_devclass, NULL, NULL);
 MODULE_DEPEND(cyapa, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER);
+#ifdef EVDEV_SUPPORT
+MODULE_DEPEND(cyapa, evdev, 1, 1, 1);
+#endif
 MODULE_VERSION(cyapa, 1);
diff --git a/sys/modules/i2c/cyapa/Makefile b/sys/modules/i2c/cyapa/Makefile
index 0f5b3aa26561..817c5ba68777 100644
--- a/sys/modules/i2c/cyapa/Makefile
+++ b/sys/modules/i2c/cyapa/Makefile
@@ -2,6 +2,7 @@
 
 .PATH:		${SRCTOP}/sys/dev/cyapa
 KMOD		= cyapa
-SRCS		= cyapa.c device_if.h bus_if.h iicbus_if.h vnode_if.h
+SRCS		= cyapa.c device_if.h bus_if.h iicbus_if.h vnode_if.h \
+		  opt_evdev.h
 
 .include <bsd.kmod.mk>

--------------5D5100A6371532A4838E42F3--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3cb95850-540c-a425-524d-5e3ce3b5a10d>