October 4, 2012   Posted by: Dr. Ace Jeangle

How to get touchscreen working

Some Linux distros come with these drivers included in kernel, others not. If you can’t use touchscreen after Linux is running in X GUI mode or if you don’t have assigned input device in console mode, then you should do the following:

  1. First of all, check all connections. We had many cases when customers forgot or incorrectly connected touchscreen to miniUSB add-on board.
  2. Connect just touchscreen through USB cable to normal PC running Windows. If touchscreen is detected and you can use it in Windows, then all connections are OK and you can proceed further.
  3. If your Linux kernel does not include drivers for touchscreen, then you should recompile kernel with the following options:
    • for AUO LCD (1024×600 px): “Device Drivers –> HID Devices –> Special HID drivers –> HID Multitouch panels“, option name: CONFIG_HID_MULTITOUCH, available in mainline kernel since version 2.6.38
    • for LG LCD (1280×800 px, black frame): “Device Drivers –> HID Devices –> Special HID drivers –> N-Trig touchscreens“, option name: CONFIG_HID_NTRIG, available in mainline kernel since version 2.6.31
  4. If you run Android, then you can encounter problem with non-correct touchscreen vs screen resolution. This happen because Android supposes default screen resolution for external LCD as 720p or 1080p (touchscreen is connected by USB and is considered as external device), but our LCD is 1024×600 or 1280×800. You can easy check it by simply turning on option “Show touches” in Settings->Developer options of Android. Then you will notice the difference in real position of touch and Android touch position. This can be easy improved by placing one of below files to /system/usr/idc folder of Android rootfs. After that touchscreen size and LCD size will match.
    File for Ntrig touchscreen (1280×800, black frame)
    File for Cando touchscreen (1024×600)

    See below links for additional information on touchscreen devices functionality under Android:
    Touch devices in Android
    Input device configuration files
  5. You can use console command getevent (sources for Linux are here: getevent.zip) to check what touchscreen returns when you touch it. Also, you can get more details about touchscreen and its modes with commands getevent -p and getevent -i.
  6. N-trig touchscreen can be tuned with some parameters:
    • min_width – minimum touch contact width to accept
    • min_height – minimum touch contact height to accept
    • activate_slack – number of touch frames to ignore at the start of touch input
    • deactivate_slack – number of empty frames to ignore before deactivating touch
    • activation_width – width threshold to immediately start processing touch events
    • activation_height – height threshold to immediately start processing touch events

    They can be changed right from console, see here for details: http://baruch.siach.name/blog/posts/linux_kernel_module_parameters/

  7. If you have problems with touchscreen, like “crazy” cursor jumps or “phantom” mouse clicks, then try to follow this guide How to calibrate N-Trig touchscreen
  8. Still no success? Drop e-mail to [email protected] and provide description of problem + photo of your LCD touch connection + output of commands “lsusb” and “dmesg” entered in Linux console.
10 comments posted in: blog   |   How-To