• Alexios
  • hacks
  • linux
  • patches

This is a patch adding some extra functionality to the Linux USB touchscreen driver. It adds features useful in developing and testing applications on touch-screens, as well as the ability to reverse the x and/or y axes — not every tablet out there defines its axes the same way.

Installation

Download this patch and then run the usual:

cd /usr/src/linux-kernel
patch </tmp/touchscreen-patch # Or whatever you called it.

Then compile your kernel as usual. If you're updating the module, you don't need to compile your entire kernel (but it's probably a good idea if you're not sure you know what this is):

make modules modules_install SUBDIRS=drivers/input/touchscreen
depmod -a
rmmod usbtouchscreen
modprobe usbtouchscreen

How to Use It

Simply insert the driver as per usual. The touchscreen device is exposed as an event device (/dev/input/event*). Check /sys/class/input for more information on what's what.

There is one module option, swap_xy. It swaps the X and Y axes.

Module options may be set in the sys filesystem by modifying the file nodes in /sys/module/usbtouchscreen.

What's New

The patch adds three new options to this module:

reverse_x
Reverses the X axis. This happens after the swap_xy option has taken effect. Figure out the axes orientation first.
reverse_y
Likewise, reverses the Y axis.
no_mouse
During development of your touchscreen application, you will probably not want it to issue mouse events to X11. Enable this option and the touchscreen driver will report its co-ordinates using the event layer's ABS_HAT0X (0x10) and ABS_HAT0Y (0x11) absolute axes instead of ABS_X (0x0) and ABS_Y (0x1).

All of these may be changed after the modules have been inserted by writing Y or N to the ‘files’ in directory /sys/module/usbtouchscreen.

To enable those at module loading time, say something like this:

modprobe usbtouchscreen swap_xy reverse_x no_mouse

The Patch

I have two versions of the patch tested against Linux 2.6.18 (the original one), and 2.6.25, where some event driver symbols got changed in the kernel. I'm unsure exactly when the change happened. If you have a kernel between 2.6.18 and 2.6.25 (why?), I recommend trying the newer patch first, then the older one if that doesn't work.

[files:patches/.*-usbtouchscreen.patch|USBTouchscreen Patches|Get a patch for the appropriate Linux kernel version.]