merge / xf86-input-tslib

X.org tslib input driver
MIT License
7 stars 2 forks source link

Compatibility issue with X and ar1021_i2c #6

Closed zwvk closed 6 years ago

zwvk commented 6 years ago

I have been working with Buildroot, developing for beaglebone black. I have a 4Dsystems gen4 4.3" resistive touch screen cape attached.

I started with this tutorial: http://www.jumpnowtek.com/beaglebone/BeagleBone-Systems-with-Buildroot.html, however I had to modify my device tree to support the gen4 touch screen. I have enabled X.org and am using tslib to filter the touch events into the uinput device which is setup as an input device in my 80-tslib.conf file, here is my modified file:

#
# Catch-all tslib loader for udev-based systems
#
# We match on all touchscreen devices. If you have multiple, please specify.

Section "InputClass"
        Identifier "tslib touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "tslib"
EndSection

Section "InputDevice"
        Identifier "tslib"
        Driver "tslib"
        Option "ScreenNumber"   "0"
        Option "Width"      "480"
        Option "Height"     "272"
        Option "Rotate"     "NONE"
        Option "TslibDevice"    "/dev/uinput"
        Option "CorePointer"
EndSection

The Option "Width" and "Height" parameter in 80-tslib.conf don't seem to have any effect.

I have finally gotten my device calibrated and working correctly, but I had to make these modifications to the tslib.c file:

--- a/src/tslib.c       (Original)
+++ b/src/tslib.c       (Bug Fix)
@@ -284,19 +284,19 @@
                        InitValuatorAxisStruct(device, 0,
                                               XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X),
                                               0,               /* min val */
-                                              priv->width - 1, /* max val */
-                                              priv->width,     /* resolution */
+                                              480 -1,//priv->width - 1,        /* max val */
+                                              1024,//priv->width,      /* resolution */
                                               0,               /* min_res */
-                                              priv->width,     /* max_res */
+                                              1024,//priv->width,      /* max_res */
                                               Absolute);

                        InitValuatorAxisStruct(device, 1,
                                               XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y),
                                               0,               /* min val */
-                                              priv->height - 1,/* max val */
-                                              priv->height,    /* resolution */
+                                              272 -1,//priv->height - 1,/* max val */
+                                              1024,//priv->height,     /* resolution */
                                               0,               /* min_res */
-                                              priv->height,    /* max_res */
+                                              1024,//priv->height,     /* max_res */
                                               Absolute);

                        InitValuatorAxisStruct(device, 2,
@@ -311,19 +311,19 @@
                        InitValuatorAxisStruct(device, 0,
                                               XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_X),
                                               0,               /* min val */
-                                              priv->width - 1, /* max val */
-                                              priv->width,     /* resolution */
+                                              480 -1,//priv->width - 1,        /* max val */
+                                              1024,//priv->width,      /* resolution */
                                               0,               /* min_res */
-                                              priv->width,     /* max_res */
+                                              1024,//priv->width,      /* max_res */
                                               Absolute);

                        InitValuatorAxisStruct(device, 1,
                                               XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_Y),
                                               0,               /* min val */
-                                              priv->height - 1,/* max val */
-                                              priv->height,    /* resolution */
+                                              272 -1,//priv->height - 1,/* max val */
+                                              1024,//priv->height,     /* resolution */
                                               0,               /* min_res */
-                                              priv->height,    /* max_res */
+                                              1024,//priv->height,     /* max_res */
                                               Absolute);

                        InitValuatorAxisStruct(device, 2,

I don't know why this was necessary, only that it fixes the upside down uncalibrated touch screen. These values were determined first by trial and error, until i realized that the width and height values should be the resolution of the device, which I collected with the ts_calibrate command.

# ts_calibrate
xres = 480, yres = 272

1024 for the resolution was chosen based upon the values that used to be there as I found in this link: https://boundarydevices.com/debian-in-more-depth-adding-touch-support/

Anyhow, I am satisfied with the setup I currently have, but I thought I should post these results in case someone else has the same issue/ wants to track down a better solution.

merge commented 6 years ago

Thanks alot for your feedback! I know there are other issues with the 1.x.x versions here and I'll look at them asap (which doesnt mean anything though)

As for your setup though: If you use the ts_uinput daemon program from tslib, you don't need xf86-input-tslib at all! The X11 evdev driver handles it directly. Just put a "Device" option in, or create a udev rule that detects the ts_uinput virtual device.

Am 9. Jänner 2018 17:29:30 MEZ schrieb zwvk notifications@github.com:

I have been working with Buildroot, developing for beaglebone black. I have a 4Dsystems gen4 4.3" resistive touch screen cape attached.

I started with this tutorial: http://www.jumpnowtek.com/beaglebone/BeagleBone-Systems-with-Buildroot.html, however I had to modify my device tree to support the gen4 touch screen. I have enabled X.org and am using tslib to filter the touch events into the uinput device which is setup as an input device in my 80-tslib.conf file, here is my modified file:

#
# Catch-all tslib loader for udev-based systems
#
# We match on all touchscreen devices. If you have multiple, please
specify.

Section "InputClass"
       Identifier "tslib touchscreen catchall"
       MatchIsTouchscreen "on"
       MatchDevicePath "/dev/input/event*"
       Driver "tslib"
EndSection

Section "InputDevice"
       Identifier "tslib"
       Driver "tslib"
       Option "ScreenNumber"   "0"
       Option "Width"      "480"
       Option "Height"     "272"
       Option "Rotate"     "NONE"
       Option "TslibDevice"    "/dev/uinput"
       Option "CorePointer"
EndSection

The Option "Width" and "Height" parameter in 80-tslib.conf don't seem to have any effect.

I have finally gotten my device calibrated and working correctly, but I had to make these modifications to the tslib.c file:

--- a/src/tslib.c       (Original)
+++ b/src/tslib.c       (Bug Fix)
@@ -284,19 +284,19 @@
                       InitValuatorAxisStruct(device, 0,
                            XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X),
                                        0,               /* min val */
-                                              priv->width - 1, /* max
val */
-                                              priv->width,     /*
resolution */
+                                              480 -1,//priv->width -
1,        /* max val */
+                                              1024,//priv->width,     
/* resolution */
                                        0,               /* min_res */
-                                              priv->width,     /*
max_res */
+                                              1024,//priv->width,     
/* max_res */
                                              Absolute);

                       InitValuatorAxisStruct(device, 1,
                            XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y),
                                        0,               /* min val */
-                                              priv->height - 1,/* max
val */
-                                              priv->height,    /*
resolution */
+                                              272 -1,//priv->height -
1,/* max val */
+                                              1024,//priv->height,    
/* resolution */
                                        0,               /* min_res */
-                                              priv->height,    /*
max_res */
+                                              1024,//priv->height,    
/* max_res */
                                              Absolute);

                       InitValuatorAxisStruct(device, 2,
@@ -311,19 +311,19 @@
                       InitValuatorAxisStruct(device, 0,
                XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_X),
                                        0,               /* min val */
-                                              priv->width - 1, /* max
val */
-                                              priv->width,     /*
resolution */
+                                              480 -1,//priv->width -
1,        /* max val */
+                                              1024,//priv->width,     
/* resolution */
                                        0,               /* min_res */
-                                              priv->width,     /*
max_res */
+                                              1024,//priv->width,     
/* max_res */
                                              Absolute);

                       InitValuatorAxisStruct(device, 1,
                XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_Y),
                                        0,               /* min val */
-                                              priv->height - 1,/* max
val */
-                                              priv->height,    /*
resolution */
+                                              272 -1,//priv->height -
1,/* max val */
+                                              1024,//priv->height,    
/* resolution */
                                        0,               /* min_res */
-                                              priv->height,    /*
max_res */
+                                              1024,//priv->height,    
/* max_res */
                                              Absolute);

                       InitValuatorAxisStruct(device, 2,

I don't know why this was necessary, only that it fixes the upside down uncalibrated touch screen. These values were determined first by trial and error, until i realized that the width and height values should be the resolution of the device, which I collected with the ts_calibrate command.

# ts_calibrate
xres = 480, yres = 272

1024 for the resolution was chosen based upon the values that used to be there as I found in this link: https://boundarydevices.com/debian-in-more-depth-adding-touch-support/

Anyhow, I am satisfied with the setup I currently have, but I thought I should post these results in case someone else has the same issue/ wants to track down a better solution.

-- Martin Kepplinger http://martinkepplinger.com sent from mobile

zwvk commented 6 years ago

I've tried using the ts_uinput, but it caused the touch events to jump around all over the place. I think it may be that X is listening to two "different" input devices, where one is the ts_uinput, and the other is the original touch device which has the y axis inverted. Whether or not this is the case there are no problems when I use the modified xf86-input-tslib driver.

merge commented 6 years ago

I think your 80-tslib.conf's InputDevice section doesn't make sense. /dev/uinput is no input device. You can probably remove the section and also kill the ts_uinput program, if running.

...I might be wrong, but that's my first sight impression :)

Am 9. Jänner 2018 20:52:26 MEZ schrieb zwvk notifications@github.com:

I've tried using the ts_uinput, but it caused the touch events to jump around all over the place. I think it may be that X is listening to two "different" input devices, where one is the ts_uinput, and the other is the original touch device which has the y axis inverted. Whether or not this is the case there are no problems when I use the modified xf86-input-tslib driver.

-- Martin Kepplinger http://martinkepplinger.com sent from mobile

zwvk commented 6 years ago

You were right, my 80-tslib.conf file does not make sense. I've reduced it to the following:

#
# Catch-all tslib loader for udev-based systems
#
# We match on all touchscreen devices. If you have multiple, please specify.

Section "InputClass"
        Identifier "tslib touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "tslib"
EndSection

Section "InputDevice"
        Identifier "tslib"
        Driver "tslib"
        Option "CorePointer"
EndSection

This is working fine.

However I've noticed some interesting behavior when I switch to ts_uinput instead of using xf86-input-tslib like you suggested. (This wasn't working for me before because of the junk in 80-tslib.conf)

If I add this line to under Input device 80-tslib.conf:

        Option "Device" "/dev/input/event1"

and then run ts_uinput in the background ts_uinput -v & then when I startx the touchscreen behaves in the same way it used to with xf86-input-tslib before I changed it. The cursor only moves around in a tiny corner on the bottom left of the screen (scaling issue), and it is inverted in the y axis.

This makes me think the problem probably isn't with xf86-input-tslib since the same problem exists with the X11 evdev driver. But somehow hardcoding values into xf86-input-tslib still fixes the problem. Here is my dt which is a possible culprit, bbb-gen4-4dcape43t.zip this is a modification from the one from jumpnowtek

Again, I'm actually satisfied with the way I have things.

Zach