I want to calibrate a touchscreen named "eGalax Inc. USB TouchController" on my Raspberry Pi. I think X and Y axes of the touchscreen are inverted. I used xinput_calibrator for this purpose. When I followed the xinput_calibrator instructions, it printed the following output:

Calibrating standard Xorg driver "eGalax Inc. USB TouchController"
    current calibration values: min_x=0, max_x=65535 and min_y=0, max_y=65535
    If these values are estimated wrong, either supply it manually with the --precalib option, or run the 'get_precalib.sh' script to automatically get it (through HAL).
    --> Making the calibration permanent <--
  copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)
Section "InputClass"
    Identifier  "calibration"
    MatchProduct    "eGalax Inc. USB TouchController"
    Option  "MinX"  "20697"
    Option  "MaxX"  "20595"
    Option  "MinY"  "53036"
    Option  "MaxY"  "53090"
    Option  "SwapXY"    "1" # unless it was already set to 1
    Option  "InvertX"   "0"  # unless it was already set
    Option  "InvertY"   "0"  # unless it was already set

And it made no changes in the touchscreen behavior (It is not calibrated yet).

After that, I created the '/etc/X11/xorg.conf.d' directory and copied the snippet above (Section ... EndSection) into the '99-calibration.conf' in that directory as stated above, and finally rebooted the Raspberry Pi. But it didn't make any changes. What's going wrong?

3 Answers 3


Options defined in "InputClass" sections of Xorg configuration can be seen (and tested!) at runtime using xinput command. If your config file is valid, you should see something like this:

$ xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ eGalax Inc. USB TouchController           id=4    [slave  pointer  (2)]

$ xinput list-props 4
    MinX (280): 20697
    MaxX (281): 20595
    MinY (282): 53036
    MaxY (283): 53090

$ xinput set-prop 4 'MinX' 0

Once you get the touchscreen working, note which properties you had to set and make sure the config file contains the exact section names, parameter names and values. If the config file still doesn't work, check the Xorg log file for errors. Could be a permission problem or a typo for instance.


You can see whether the changes are being seen by X11 by searching for "eGalax Inc. USB TouchController" (the name of the device, as per your file) in /var/log/Xorg.0.log .

I encountered a similar issue where SwapXY wasn't getting respected, and I couldn't determine why using the log file. Using the TransformationMatrix option instead of SwapXY worked for me. Here's the line to rotate the screen 90 degrees:

Option  "TransformationMatrix" "0 -1 1 1 0 0 0 0 1" 

(This is the option advocated by https://www.instructables.com/id/Rotate-Raspberry-Pi-Display-and-Touchscreen/)


I bought an IrFrame from China that was slightly bigger and broader than the screen I had behind the glass. I was Googling and playing around quite a bit before I finally managed to adjust the IrFrame so that the point touched matched the cursor position on the screen. Thanks to the above text I managed.

Initially, I had tried quite a bit with the tool "xinput_calibrator" which made config files that had no effect. I think it made settings on variables that were incompatible with my device. The commmand "xinput list-props" below tells you what variables you can play with and they were not named like the settings file that xinput_calibrator made, so I just abandoned it.

Here is how I did it:

  1. Command "xinput list" to see what devices I had.
  • I had 2 devices "IrScreen ca" and "IrScreen ca Mouse". Intuitively I tried adjusting the mouse-one but had no effect. Finally, when adjusting the first device "IrScreen ca" I saw the effects on the screen. (So do not let the device name fool you, if you have multiple)
  1. Command "xinput list-props ". This command tells you what variables you can play with. My devide did not have so many, but I understood that the variable "Coordinate Transformation Matrix" was the one I had to modify. This variable takes 9 floating point numbers (actually a 3x3 matrix).

  2. I had to experiment quite a bit with this matrix but this is what I found when the screen is more narrow than the IR frame or not as high. You basically have to play with only 4 of the numbers in the matrix. Initially, the numbers are typically:

    1.0 0 0 0 1.0 0 0 0 1.0

Let me name the ONLY 4 numbers you should touch as below (do NOT modify the other numbers as you will then start to rotate the screen!):

x-width-factor 0 x-displacement
0 y-height-factor y-displacement
0 0 1.0

So, if your frame is wider than your screen, then x-width-factor must be larger than 1.0. In my case, I ended up with 1.13 here. If your frame is higher than your screen, then y-height-factor must be larger than 1.0. In my case they were the same, so I left it at 1.0. Then, my screen was in the middle of the screen on the x-axis (black zones on both sides). To adjust for this, I had to set x-displacement to -0.13 (moved it to the left). A positive number would have moved it to the right. Therefore, I ended up with this matrix:

1.13 0 -0.13
0 1.0 0
0 0 1.0

So you have to test this out, but you should only modify these four numbers!

  1. Finally, I put this matrix into the device variable with the command:

     xinput set-prop 12 'Coordinate Transformation Matrix' 1.13 0 -0.13 0 1.0 0 0 0 1.0

and VOILA, it worked!! (12 was the id for my device. It may be a different number for you in the list!)

  1. Then I had to make sure this command was executed every time Raspberry Pi started the Xwindows graphical user interface. I tried many things, but the fix for me was to create a file named .xsessionrc under the pi user home directory where this command was entered. Then all you have to do is to reboot. :)

Hope this helps others too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.