1

I've been playing around with this touchscreen which uses eGalax drivers.
OS of the board it's connected to is Ubuntu LTS 16.04.01

For some reason, I can't quite get it calibrated just right, but that's not really the point of this question.

When I run xinput_calibrator for the system to attempt to magically calibrate it for me by hitting all the little dots, it really just generates 4 comma separated data points, which ultimately get plugged into the xinput properties for that device (namely, "Evdev Axis Calibration").

I would like to understand how those 4 numbers are calculated.

I can't find a decent resource online explaining exactly what this program does to come up with those numbers, but this information might be useful in troubleshooting now and in the future.

As a reference, here is one of my calibration sessions:

root@MyDevice:~# xinput_calibrator -v
DEBUG: XInputExtension version is 2.3
DEBUG: Skipping virtual master devices and devices without axis valuators.
DEBUG: Skipping device 'Virtual core XTEST pointer' id=4, does not report Absolute events.
Warning: multiple calibratable devices found, calibrating last one (eGalax Inc. USB TouchController)
        use --device to select another one.
DEBUG: Selected device: eGalax Inc. USB TouchController
DEBUG: Not usbtouchscreen calibrator: Not a usbtouchscreen device
DEBUG: Read axes swap value of 0.
DEBUG: Read InvertX=0, InvertY=0.
Calibrating EVDEV driver for "eGalax Inc. USB TouchController" id=12
        current calibration values (from XInput): min_x=2226, max_x=294 and min_y=402, max_y=2138
DEBUG: Found that 'eGalax Inc. USB TouchController' is a sysfs name.
DEBUG: Adding click 0 (X=0, Y=63)
DEBUG: Adding click 1 (X=696, Y=61)
DEBUG: Adding click 2 (X=0, Y=479)
DEBUG: Adding click 3 (X=685, Y=479)

Doing dynamic recalibration:
        Setting calibration data: 2504, 281, 375, 2386
DEBUG: Successfully applied axis calibration.
        --> Making the calibration permanent <--
DEBUG: Found that 'eGalax Inc. USB TouchController' is a sysfs name.
  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  "Calibration"   "2504 281 375 2386"
        Option  "SwapAxes"      "0"
EndSection

So you can see, the calibrator read my previous calibration data as "min_x=2226, max_x=294 and min_y=402, max_y=2138", and then generated the data points "2504, 281, 375, 2386" based on the calibration session that just happened.

How were the data points "2504, 281, 375, 2386" calculated?

0

This data is read from evdev. And, as this is an open-source project, we can even see the code!

In fact, the line that outputs this data is right here:

printf("\tSetting calibration data: %d, %d, %d, %d\n", new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);

Now, the parent function for this (set_calibration) is called in finish_data. This, in turn is called by finish.

In short, it does some complicated scaling based on the screen size and the captured points, and then returns the parameter values for the valid X/Y range, which is the new defined "corner" of the screen.

Basically, it takes the average of all of your calibration clicks, determines the scaling, parses it into more scaling so that X can understand it, and then rounds it into "pretty" values. If needed, it will optionally reverse/swap the touchscreen calibration data in order to fit the touchscreen's setup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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