Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable touch screen calibration / rotation #17

Closed
kedder opened this issue Mar 9, 2020 · 42 comments · Fixed by #73, #86 or #102
Closed

Enable touch screen calibration / rotation #17

kedder opened this issue Mar 9, 2020 · 42 comments · Fixed by #73, #86 or #102
Assignees
Labels
bug Something isn't working
Milestone

Comments

@kedder
Copy link
Member

kedder commented Mar 9, 2020

According to @mihu-ov, touch screen calibration and rotation doesn't work in 20067.

touch works, but calibration / rotation matrix not activated?

@kedder
Copy link
Member Author

kedder commented Mar 11, 2020

The caltool that is intended to calibrate touchscreen seems to be broken. It segfaults when started with any -r parameter (intended for rotation).

It doesn't run on laptop either: requires root to run and completely hangs, doesn't react to Ctrl-C and requires laptop reboot.

Fixing this requires access to hardware (which I don't posses, unfortunately). @linuxianer99, can you look into this?

@linuxianer99
Copy link
Member

@kedder : Yes, i can do so. But nit before the weekend ...

@linuxianer99 linuxianer99 added the bug Something isn't working label Mar 23, 2020
@SashLi
Copy link

SashLi commented May 3, 2020

Is there any new information to this issue ?

@linuxianer99
Copy link
Member

@kedder : the caltool used before is very fragile.
Maybe we can use tslib https://github.com/libts/tslib/blob/master/README.md#setup-and-configure-tslib instead ?
There is a possibility to emulate a "calibrated touch" via uinput in linux kernel.
Do you know if it is possible to set the input device XCSoar is using ?

@kedder
Copy link
Member Author

kedder commented May 13, 2020

@linuxianer99, I've never dealt with touchscreens before, so it is hard to say. I'm not even sure what mechanisms/apis are involved in reading the touchscreen input. I can see tslib is included in meta-oe, so it should be easy to build it. But again, since I don't have the touchscreen hardware, I can't test it.

@linuxianer99
Copy link
Member

I compiled tslib yesterday evening.
Installation worked fine but i need uinput kernel module. So i have to compile a new kernel for testing.

The only thing is, don't know if i can tell XCSoar to use the /dev/uinput instead of /dev/input/eventx ... We will see ;-)

@marulidu
Copy link

Just completed installation of new touchscreen unit and come across this issue since screen is installed at portrait, 270 orientation. Cursor stays at upper edge despite of touch area. Extremely disappointing. Touch feature became totally useless. I could be more then happy to contribute to software testing.

@linuxianer99
Copy link
Member

@kedder : Think i have a solution for the touch:

Using tslib with tslib_uinput:
tslib_uinput make a virtual event device with calibration and rotation information.

Things to do:

  • disable real touch device for libinput using udev ENV.
    ACTION=="add|change", KERNEL=="event[0-9]*", ENV{ID_PATH_TAG}=="platform-1c25000_rtp", ENV{LIBINPUT_IGNORE_DEVICE}="1"

  • set Env variable TSLIB_TSDEVICE=/dev/input/event5 to tell tslib which device to use.

  • start tslib_uinput: This uses event5 and emulates event7 with all overlay features tslib can do (calibration, rotation, sensitivity, ...)

Do you think this is a useable approach ?

@kedder
Copy link
Member Author

kedder commented May 22, 2020

@linuxianer99, This won't require any change to XCSoar to support touch events via tslib, right? if it works, it looks great!

@linuxianer99
Copy link
Member

@kedder : Yes, no changes to XCSoar.
Just udev things ... and a bit of configuration ...

@linuxianer99 linuxianer99 added this to the Next release milestone May 27, 2020
@linuxianer99 linuxianer99 linked a pull request May 27, 2020 that will close this issue
@Blaubart
Copy link
Contributor

I compiled the new image last night, but touch screen dosen't work. I can't calibrate touch screen. If I start the calibration tool I get the message touch screen is calibrated. If I start XCSoar I have no reaction about the touch screen.

@marulidu
Copy link

Same with mine. Actually touch moves cursor along upper edge only

@linuxianer99
Copy link
Member

@Blaubart
@marulidu
Which type of image did you build ? openvario-testing ?
Which type of hardware do you have ?

@linuxianer99 linuxianer99 reopened this May 28, 2020
@Blaubart
Copy link
Contributor

I have a OV with Pixel Qi 7.0 and tried openvario-testing

@linuxianer99
Copy link
Member

Can you please do the following:

  • on the Openvario linux change to /dev/input/by-path
  • Do a ls -alh and post this output here

@Blaubart
Copy link
Contributor

20-05-29 11-24-49 6505

@linuxianer99
Copy link
Member

@Blaubart Do you have the possibility to change files config files in the linux system ?
Or do you need a full image for testing a fix ?

@Blaubart
Copy link
Contributor

I can change files, no problem

@linuxianer99
Copy link
Member

linuxianer99 commented May 29, 2020

Try to change the following:

in /home/root/.profile
from
export TSLIB_TSDEVICE=/dev/input/event5
to
export TSLIB_TSDEVICE=/dev/input/by-path/platform-1c25000.rtp-event

and
in /etc/ts.env
from
TSLIB_TSDEVICE=/dev/input/event5
to
TSLIB_TSDEVICE=/dev/input/by-path/platform-1c25000.rtp-event

Needs a reboot to take effect !

@Blaubart
Copy link
Contributor

Now I can calibrate the touch screen, but it dosen't react to my finger when XCSoar is running

@linuxianer99
Copy link
Member

Did you do a reboot after the calibration ?
The thing is that there is a systemd service (ts_uinput) which needs to be restarted to apply the calibration. So the easiest way is to reboot.

@Blaubart
Copy link
Contributor

Blaubart commented May 30, 2020

Yes I did.

I don't know why, but now the arrow moves if I move my finger at touch screen. But at X-axis arrow moves just half way. At Y-axis arrow reaches the end of display but my finger moves just have way. The lines at screen stay visible and map dosen't move, zoom or something else.

@kedder
Copy link
Member Author

kedder commented Jun 8, 2020

Thanks to Stephan Langer, who generously donated me the hardware for development, I have a 7" device with the touchscreen (and sensors too) and can play with it now!

I've checked out the image with the tslib support and found couple of issues:

  1. The touchscreen is not always registering as /dev/input/event5 - the number actually depends on how many other input devices (keyboards, mice, etc) are connected. If it is not on event5, ts_uinput will not start at all (therefore tochschreen won't work). We can use /dev/input/by-path/platform-1c25000.rtp-event instead, as @linuxianer99 suggested.

  2. The touchscreen appears to work only for the first time XCSoar is started - if you exit and start the XCSoar again, touchscreen doesn't work until you restart ts_uinput service. Also, when it works, it does in somewhat weird way - the touch screen appears to be always "pushed", I can draw red lines on XCSoar map, and it will not process the gesture even when I'm not touching the screen anymore. Taps (clicks) are not registered - I can't select anything or bring up menu - just draw with the red line.
    The ts_uinput, if run with -v switch would log the pressed coordinate even when XCSoar would not react to touchscreen.

  3. The TSLIB_TSDEVICE env variable doesn't seem to have any effect on XCSoar, so there's no point to put it to .profile (unless I'm missing something)

I'll play with it a little bit more, maybe I'll be able to come up with something working.

@kedder
Copy link
Member Author

kedder commented Jun 9, 2020

I think I made tslib work, including screen rotation, but it is a bit hacky (using LIBINPUT_CALIBRATION_MATRIX to force the rotation), so I'm not too happy with it just yet.

Without LIBINPUT_CALIBRATION_MATRIX hack I've observed the same behaviour on rotated screen as @Blaubart, and this seems like a bug (or just missing feature) in tslib version we use right now (1.16). It seems like 1.18 has some better support for screen rotation and I'll try to upgrade and see if it improves things.

@kedder
Copy link
Member Author

kedder commented Jun 12, 2020

Ok, I think I figured it out. @Blaubart, can you try this new image: 20164-openvario-7-CH070?

The touchscreen should work in all 4 directions after calibration. First, pick your screen orientation, then reboot, then calibrate the touch screen, then start xcsoar.

The image built from my touchscreen branch.

@Blaubart
Copy link
Contributor

Thats sounds good!! Thanks! I use a Pixel Qi 7, so can you send me the image for this display, please?

@kedder
Copy link
Member Author

kedder commented Jun 13, 2020

@Blaubart here you go: 20165-openvario-7-PQ070.

@Blaubart
Copy link
Contributor

Hi Kedder,

it almost works ;-)
Touchscreen works really good, but calibration is not saved. If I restart OpenVario I have to calibrate again because touchscreen dosen't respond to the my finger. After calibrate again touchscreen works until I powered off the device.

Regards and thanks a lot!
Blaubart

kedder added a commit to kedder/meta-openvario that referenced this issue Jun 15, 2020
Supports calibration in all 4 directions. Screen rotation is
implemented using LIBINPUT_CALIBRATION_MATRIX property instead of
tslib because tslib rotation is buggy

see Openvario#17 (comment)
kedder added a commit to kedder/meta-openvario that referenced this issue Jun 15, 2020
Supports calibration in all 4 directions. Screen rotation is
implemented using LIBINPUT_CALIBRATION_MATRIX property instead of
tslib because tslib rotation is buggy

see Openvario#17 (comment)
@kedder
Copy link
Member Author

kedder commented Jun 15, 2020

@Blaubart yeah, apparently I didn't test it well enough. Please try the new image: 20167-openvario-7-PQ070, it should have the problem fixed.

@Blaubart
Copy link
Contributor

Thanks a lot!!!! It works perfectly!

@Blaubart
Copy link
Contributor

How can I see, that it is merged to warrior?

@kedder
Copy link
Member Author

kedder commented Jun 15, 2020

I'll make a pull request, as soon as it merges, this issue will close, you'll get a notification (probably).

kedder added a commit to kedder/meta-openvario that referenced this issue Jun 15, 2020
Supports calibration in all 4 directions. Screen rotation is
implemented using LIBINPUT_CALIBRATION_MATRIX property instead of
tslib because tslib rotation is buggy

see Openvario#17 (comment)
@Blaubart
Copy link
Contributor

I compiled stable and testing version at the same day with the same sources. Touchscreen calibration with testing-image works, with stable not. It dosen't make sense, right??

@kedder
Copy link
Member Author

kedder commented Jul 24, 2020

@Blaubart, no, it does not. Does the officially released stable version have the same issue?

@Blaubart
Copy link
Contributor

I will test next days.
Thanks for helping!!

@Blaubart
Copy link
Contributor

It is the same with officially released stable version for PixelQi 7.0

@linuxianer99
Copy link
Member

Checked content of image a few minutes ago.
So the PR is in the official release image. Checked the udev rules file.

Just to be sure:
The official testing image works
The official stable not ?

@linuxianer99 linuxianer99 reopened this Jul 26, 2020
@Blaubart
Copy link
Contributor

I tried self compiled testing image (works), self compiled stable image (dosen't work) and officially released stable image (dosen't work)

@kedder
Copy link
Member Author

kedder commented Jul 27, 2020

I'll check as soon as I get to my testing device, hopefully this evening.

@kedder
Copy link
Member Author

kedder commented Jul 27, 2020

Ok, I can confirm the problem. It seems like XCSoar-6.8 is interpreting the touch input somehow differently from 7. It should be fixable, but I can't do it till the next week.

@kedder
Copy link
Member Author

kedder commented Aug 5, 2020

@Blaubart, I figured it out. Touchscreen on xcsoar-6.8.x will work after #102 is merged.

@Blaubart
Copy link
Contributor

Blaubart commented Aug 5, 2020

great! Thanks for your help!!

@kedder kedder changed the title Touch screen calibration / rotation Enable touch screen calibration / rotation Aug 5, 2020
@kedder kedder self-assigned this Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants