Ubuntu Wiki
Touchscreen
This page is a documentation of my dealings with various touchscreen devices I’ve encountered. In my experience, most modern devices work out of the box with both 10.04 LTS or 12.04 LTS, but lack the proper calibration or configuration. Some older devices, especially those embedded in laptops such as GD Itronix line of rugged computers, use serial interfaces which lack the configuration to work in Linux. The methods documented here should work with other distros as well.
Global Dynamics Itronix GoBook XR-1
This is a rugged laptop I picked up from ebay for a good price, which the seller wiped with Ubuntu 10.04 due to the expense of Microsoft’s Windows relicensing fee. The device has an integrated serial touchscreen, and the manufacturer is notorious for hiding any and all documentation on legacy devices such as this one. With a little trial and error however, it’s relatively simple to configure this and similar devices. This method should work for most GD products, including the newer GD8000 which replaced this device. Skip to the section for configuring serial devices for these machines.
Checking for touchscreen connectivity
When encountering a new device, the first order of business is to determine how the touchscreen is connected to your computer. If the touchscreen produces no events out of the box, check to see if it’s an USB device or not:
USB connection
Check the output for any reference to a touchscreen. If your touchscreen has an USB interface, and it isn’t working, then you may need to blacklist the usbtouchscreen driver for it to work:
If your touchscreen begins to produce events, then you can permanently blacklist the usbtouchscreen driver:
Some touchscreens might already have good or perfect calibrations, otherwise you’ll need to continue to the calibration section.
Serial connection
If there is no reference to a touchscreen device in your lsusb output, the connection is most likely through one of your serial ports. The actual IRQ mapping varies between manufacturers. In the case of Itronix devices, the default is /dev/ttyS3. A simple way to check for connections is to check each one for events:
Touch anywhere on your screen to check for any character output. If nothing happens, quit screen by pressing Ctrl+A and then the ‘\’ key to quit. Continue with /dev/ttyS1, etc. until you get a response. Once you’ve determined the device, we can try a few different drivers. In the case of Itronix (and most other devices using the Touchkit driver), the correct driver is touchit213.
Will work for most touchkit screens. The calibration or one or more axes may be swapped, but if the calibration is approximate then it’s probably the correct driver. Press Ctrl+C to try a new mode. inputattach supports any of the following modes, which includes external touchscreens which may attach through a physical serial port:
If your device is built into a laptop, you’ll have the best luck with the mtouch, touchright, touchwin, or touchit213 drivers. Likewise, non-Elo external touchscreens will most likely use touchit213. If your device is a tablet with stylus-only input, fujitsu is a popular maker of embedded tablet devices.
To attach the touchscreen at startup, edit your /etc/rc.local to look like the following:
Replace -t213 with your appropriate driver and /dev/ttyS3 with the correct device.
Again, don’t worry if the calibration isn’t perfect, or if an axis is inverted or reversed — this will be addressed in the calibration section.
Calibration
Thanks to the wonderful work of the freedesktop.org developers, calibration is no longer a black art in Linux. The calibration utility is included in Ubuntu 12.04 and later:
And for 10.04, there’s a ppa available:
Packages and source files are available for other distros here.
The use is pretty straight forward. I had issues getting it to work properly with HAL, however this will work regardless:
Follow the instructions pressing each target, and the calibration output will be printed to the terminal. The calibration will be set immediately, but will not survive reboots. If you’re using GDM, you can put the calibration command in your /etc/gdm/Init/Default. I placed calibration values for my XR-1 in both GDM and as a gnome startup script, since it uses automatic login:
Inverted/reversed axes
If your axes are swapped or reversed with the calibration output from xinput_calibrator (after a reboot or X restart), you may need to invert them explicitly, as I did with the XR-1.
The 0 and 1 in the above command enables axis inversion for the x or y axis (0=normal, 1=invert).
If your x and y axis are swapped, use the «Evdev Axis Swap» 1 verb:
When you’re satisfied with the result, you may need to perform calibration again with xinput-calibrator.
Troubleshooting
Different modes and drivers accept different xinput options. To get your touchscreen’s device name, use xinput list. Individual driver options can be obtained by using xinput list-props , where is either the device name as a string or the
eGalax Touchscreens in 14.04LTS
After fighting with USB eGalaxy Touchscreens for a week or so the solution turned out to be quite simple. I’ve documented everything with photos here on Google Drive
Files
You can get the files here on the website of EETI eGalax
Unzip the file
Just unzip the file in the current directory
Here is a quick rundown of the steps
Ensure the Kernel Modules start on boot
Modify the file /etc/modules to add the modules usbtouchscreen and usbhid. These must come after lp and before rtc.
/etc/modules
Load the Kernel Modules (only the 1st time)
Then load the modules by hand the 1st time (or reboot)
sudo modprobe usbtouchscreen usbhid
Move the Daemon and Calibration Files
Move al the files in the folder /home/user/Downloads/eGalax/eGTouch_v2.5.4330.L-x/eGTouch64/eGTouch64withX to /usr/local/bin/ *Note the following command is one line
sudo rsync -avz /home/$USER/Downloads/eGalax/eGTouch_v2.5.4330.L-x/eGTouch64/eGTouch64withX /usr/local/bin/
Place Upstart Job
place the following Upstart job in /etc/init
/etc/init/egalaxtouch.conf
Start the Touchscreen Daemon
Start the touchscreen daemon with the following command
sudo service egalaxtouch start
Calibration
Calibrate the Touchscreen with eGTouchU
sudo /usr/local/bin/eGTouchU
For Dual Screen Configurations:
Follow the onscreen prompts of the config program for dual screen setup choose Left or Right mode!
Then calibrate the screen using the tools tab
Touchscreen (последним исправлял пользователь alan-pater 2015-05-30 10:25:36)
The material on this wiki is available under a free license, see Copyright / License for details.
Install a touchscreen for Linux
How to set up and configure a PSOne LCD with touchscreen input
KDE, GNOME/Nautilus, OpenWindows, WINE, etc. — plenty of GUIs make it easier for users to access the power and elegance of Linux applications. What component can be added to this mix to insinuate Linux even more firmly into the consumer device arena? A touchscreen. With a touchscreen, a Linux device can become a controller for a slew of devices such as a digital video recorder, a TiVo-like personal video recorder, a media center, a smart-house system, or even a control interface to a toaster. The possibilities are boundless.
Touchscreens come in a variety of pre-packaged and separately packaged solutions. They have been around almost as long as CRTs and now show up in LCDs as well. In some cases, the touchscreen is already integrated into the display unit. In others (as discussed in this article), they are separate units that must be matched in size and intended function.
This article gives you an overview of the steps to prepare to install and configure the LCD (the image screen), the modeline (a configuration line that tells the server how to drive the monitor), and the touchscreen (for input). It also gives you some resources to answer other questions that might come up when you start to integrate a touchscreen.
Installing the LCD
The touchscreen is for input only; therefore, you need something behind it to display an image. Besides displaying the user interface, the display is used for calibration, which can be done in these two main ways:
- The easier route is to acquire an LCD screen from any of various vendors and hook it up to a PC system. Just ensure the connections will work with your video card, either directly or with an adapter.
- The more difficult route, and the one described in this article, is to acquire a PSOne LCD for a fairly small price. This will require some soldering and cable splicing, which is not overly difficult if you follow one of the guides available for this modification (see Related topics). Going this route and using a PSOne LCD will require a video card with a CSYNC (composite sync) signal — most ATI and Matrox cards have this. You can build a circuit that generates a CSYNC signal for cards that don’t do this already (see Related topics), but it is generally easier to just purchase a card that already generates it.
What is a touchscreen?
Touchscreens are display overlays that allow a display to be used as an input device, removing the keyboard and/or the mouse as the primary input device for interacting with the display’s content. Touchscreen panels are usually one of the following:
- Pressure-sensitive (resistive)
- Electrically-sensitive (capacitance)
- Acoustically-sensitive (SAW, surface acoustic wave)
- Photo-sensitive (infrared)
Originally used on POS (point of sale), ATM, PDA, and other information device displays, touchscreens are rapidly gaining acceptance as control surfaces for heavy industry, because they adapt to rapidly changing conditions in, for instance, assembly-line conditions. Partly because of this acceptance, SoC (System on a Chip) and display manufacturers have started integrating touchscreen capabilities into their products; previously this requirement was met by after-market manufacturers.
Connecting the power
The LCD needs power to function and backlight the display. Just as with the LCD installation, there is an easy way and a hard way:
- The easy way is to purchase an LCD that can be plugged into a wall outlet or car adapter, depending on your needs. Plugging into a wall outlet is simple, since the PC generally requires wall power also.
- The difficult way (and the way I chose) is to purchase a car power adapter from eBay. It uses 12 volts, which is a voltage also provided inside an ordinary computer case via the power supply. I simply followed the guide «Hooking up a Neon Light,» since they are functionally the same (see Related topics). After making the changes, it will plug directly into a PC power supply. Again, you’ll have to do some cable splicing and soldering, but in the end you avoid having to use an additional wall outlet.
Now for the modeline.
Remind me: What’s a modeline?
A modeline is a configuration line in a configuration file that provides information to the server about a connected computer monitor and how to drive it at a specified display resolution. (Originally it was XF86Config in XFree86.) Now, in many Linux/UNIX® versions, modelines are no longer needed since the server calculates the configuration at startup based on other factors, such as:
- Generic and intuitive settings in the server configuration file
- Monitor capabilities acquired via an EDID query
EDID (Extended Display Identification Data) is a VESA standard data format that contains basic information about a monitor and its capabilities, including vendor information, maximum image size, color characteristics, factory pre-set timings, frequency range limits, and character strings for the monitor name and serial number. The information is stored in the display and is used to communicate with the system through a Display Data Channel (DDC), which rests between the monitor and the PC graphics adapter. The latest version of EDID can be used in CRT displays, LCD displays, and future display types because EDID offers general descriptions of almost all display parameters.
An individual modeline has 10 parameters, beginning with a label for the resolution being specified. The second parameter specifies the rate of the pixel clock in megahertz. Following are two groups of four numbers. The first group specifies the x-resolution (width) and related parameters; the second specifies the y-resolution (height). For options, extra parameters for controlling horizontal and vertical synchronization can be added, and there are also options for interlaced and doublescan modes.
So why bother with modelines? For obsolete, unusual, or insufficiently finely tuned display hardware, manually setting modelines may be the only available solution.
Determining the proper modeline
If you took the easy route for hooking up the LCD, your screen may be recognized automatically when the Linux OS boots; if so, you are ready to set up the touchscreen. If you took the more difficult route, or if your LCD wasn’t automatically recognized, you may need to build a custom modeline. Various modelines may be gathered by querying Google, by checking manufacturers’ specifications, or by trying various included ones in the proper configuration file. If you are installing a PSOne LCD, the easiest way to arrive at a proper modeline is to use a Windows based-PC and the PowerStrip tool (which provides advanced, multi-display, programmable hardware support to a wide range of video cards; see Related topics).
If you know the native resolution for the LCD, you should start with that. For the PSOne LCD, you should start with 640x480i (Arcade). From there, you may need to adjust the scan rate (a setting that the PowerStrip tool allows you to modify) until you get a stable picture.
Table 1 lists appropriate modelines for various video cards for a PSOne LCD — I found these by searching the Internet. I do not have access to all these various cards, so the only one I can vouch for is the ATI 9600XT that I use. If you find these in error or would like to contribute to this list, please send me an e-mail.
Card | NTSC/PAL | Modeline |
---|---|---|
Matrox Mystique | NTSC | «640×480» 12.954 640 680 744 816 480 496 504 528 interlace +hsync +vsync |
Matrox Millenium G200 | NTSC | «640×480» 13.193 640 688 752 832 480 492 500 524 interlace -hsync -vsync |
Matrox Millenium G200 | PAL | «720×576» 14.875 720 736 800 896 576 602 606 668 interlace +hsync +vsync |
ATI 7000 | NTSC | «640×480» 12.175 640 664 720 784 480 486 493 524 interlace +hsync +vsync |
ATI 7000 | PAL | «720×576» 14.950 720 763 859 920 576 580 584 588 interlace +hsync +vsync |
ATI 9600XT | NTSC | «640×480» 13.582 640 704 768 864 480 486 493 524 interlace -hsync -vsync |
ATI 9700 | PAL | «720×576» 14.881 720 781 829 960 576 606 610 646 interlace +hsync +vsync |
EPIA 800 | NTSC | «640×480» 13.678 640 672 736 800 480 486 494 524 interlace composite |
Placement of the modeline
Now that you’ve determined the right modeline, there are two places that this information needs to go. The first place is in the xorg.conf config file, and the second is in the boot parameters. Let’s look at both.
The xorg.conf config file
Listing 1 is an example of an xorg.conf config file. You could easily modify this to a dual-head display setup by adding another Monitor/Screen identifier. Also, notice the ForceMinDotClock option. The ATI 9600XT reports its minimum dot clock as 20M, but it can really go lower. This option allows you to set the dot clock lower in the modeline. The PSOne LCD requires a lower dot clock (in the range or 12M-15M) to drive the display. You may or may not have to include this setting depending on the LCD you are using.
This listing also contains the necessary information for the touchkit. The device and driver were taken from the installation manual for the touchkit I used. It may be different depending on the manufacturer of the touchscreen you decide to use.
Listing 1. An xorg.conf config file
Kernel boot options
The second place to include these options is during boot so that the kernel can correctly display the information. The best place to determine what options to supply is to use Section 18 of the Framebuffer Howto (see Related topics). Using the xorg.conf file in Listing 1 and Section 18 of the Framebuffer Howto, find the following (correct) video boot parameter:
Listing 2. Kernel boot options
You need to add this video option to the appropriate boot config file (menu.lst for GRUB or lilo.conf for LILO). The video option doesn’t really kick in until the rhgb (Red Hat Graphical Boot) starts. vga=0x301 sets up the graphics as 640×480 (see Section 5.3 of the Howto). It doesn’t quite get you what you need for the PSOne screen, but it does make it somewhat more viewable for the text that comes up before rhgb.
Setting up the touchscreen
The first thing is to install the appropriate touchscreen software. For the touchscreen I used, download the software from eGalax (see Related topics). I am using the FC3 distribution, so I downloaded the FC3 image. The only modification I had to make was to point the build process to the x86_64 include files for the X server. I did this by putting -I/usr/X11R6/lib64/Server/include in the makefile for the touchkit_drv.o file. The installation is set up for a 32-bit system, so you would need to do this only if you have a strict 64-bit system.
Listing 3 shows two lines from the xorg.conf config file. The first line tells the X server to send all the core events to the TKPANEL device as well as the mouse (so both can be used simultaneously). The second says that if no mouse is present, continue to bring up the X display. This way, the touchscreen can be used without a mouse connected to the system.
Listing 3. Two important lines in the xorg.conf file
You may need to configure the touchscreen with the touchcfg configuration utility (or whatever utility is appropriate for your touchscreen). Figure 1 is a screenshot of the touchcfg utility.
Figure 1. The touchcfg config utility
From this utility, you can do the calibrations that tell the touchscreen where the edges of your display are. A finer-point calibration (25pt instead of 4pt) will give you better approximation of screen locations. This utility also lets you perform a simple drawing test and set the double-click speed and area. Other touchscreen configuration utilities may have more or fewer features.
When this is complete, you are done. When the machine is rebooted, the touchscreen will now function just like a regular mouse. You can select text and icons by putting your finger on the text. Hold your finger down for a right mouse-click. Figures 2 and 3 show some bootup screens for the LCD.