A generic touchscreen calibration program for X.Org
修订版 | ed927a17416f42452f57c030a0c0c9c001bd3329 (tree) |
---|---|
时间 | 2009-11-29 23:21:49 |
作者 | Tias <tias@kata...> |
Commiter | Tias |
Add example FDI policy file for generic touchscreen, next to example
xorg.conf values
@@ -1,6 +1,4 @@ | ||
1 | 1 | /* |
2 | - * Copyright © 2008 Soren Hauberg | |
3 | - * | |
4 | 2 | * Permission to use, copy, modify, distribute, and sell this software |
5 | 3 | * and its documentation for any purpose is hereby granted without |
6 | 4 | * fee, provided that the above copyright notice appear in all copies |
@@ -282,7 +280,7 @@ public: | ||
282 | 280 | CalibratorXorgPrint::CalibratorXorgPrint (const char* drivername0, int min_x, int max_x, int min_y, int max_y) |
283 | 281 | : Calibrator (drivername0, min_x, max_x, min_y, max_y) |
284 | 282 | { |
285 | - printf ("Calibrating unknown driver \"%s\" (currently having min_x=%d, max_x=%d and min_y=%d, max_y=%d)\n", | |
283 | + printf ("Calibrating Xorg driver \"%s\" (currently having min_x=%d, max_x=%d and min_y=%d, max_y=%d)\n", | |
286 | 284 | drivername, oldcalib_min_x, oldcalib_max_x, oldcalib_min_y, oldcalib_max_y); |
287 | 285 | printf("\tIf the current calibration data is estimated wrong then either supply it manually with --precalib <minx> <maxx> <miny> <maxy> or run the 'get_precalib.sh' script to automatically get it from your current Xorg configuration (through hal).\n"); |
288 | 286 | } |
@@ -293,7 +291,16 @@ void CalibratorXorgPrint::finish_data ( | ||
293 | 291 | /* We ignore flip_x and flip_y, |
294 | 292 | * the min/max values will already be flipped and drivers can handle this */ |
295 | 293 | |
296 | - printf ("Suggested new values for xorg.conf:\n"); | |
294 | + // FDI policy file | |
295 | + printf("\nNew method for making the calibration permanent: create an FDI policy file like /etc/hal/fdi/policy/touchscreen.fdi with:\n\ | |
296 | +<match key=\"info.product\" contains=\"%%Name_Of_TouchScreen%%\">\n\ | |
297 | + <merge key=\"input.x11_options.minx\" type=\"string\">%d</merge>\n\ | |
298 | + <merge key=\"input.x11_options.miny\" type=\"string\">%d</merge>\n\ | |
299 | + <merge key=\"input.x11_options.maxx\" type=\"string\">%d</merge>\n\ | |
300 | + <merge key=\"input.x11_options.maxy\" type=\"string\">%d</merge>\n\ | |
301 | +</match>\n", min_x, max_x, min_y, max_y); | |
302 | + | |
303 | + printf ("\nOld method, edit /etc/X11/xorg.conf and add in the 'Section \"Device\"' of your touchscreen device:\n"); | |
297 | 304 | printf ("\tOption\t\"MinX\"\t\t\"%d\"\t# was \"%d\"\n", |
298 | 305 | min_x, oldcalib_min_x); |
299 | 306 | printf ("\tOption\t\"MaxX\"\t\t\"%d\"\t# was \"%d\"\n", |
@@ -302,7 +309,8 @@ void CalibratorXorgPrint::finish_data ( | ||
302 | 309 | min_y, oldcalib_min_y); |
303 | 310 | printf ("\tOption\t\"MaxY\"\t\t\"%d\"\t# was \"%d\"\n", |
304 | 311 | max_y, oldcalib_max_y); |
305 | - printf ("\tOption\t\"SwapXY\"\t\"%d\"\n", swap_xy); | |
312 | + if (swap_xy != 0) | |
313 | + printf ("\tOption\t\"SwapXY\"\t\"%d\"\n", swap_xy); | |
306 | 314 | } |
307 | 315 | |
308 | 316 |
@@ -404,9 +412,16 @@ CalibratorEvdev::~CalibratorEvdev () { | ||
404 | 412 | void CalibratorEvdev::finish_data ( |
405 | 413 | int min_x, int max_x, int min_y, int max_y, int swap_xy, int flip_x, int flip_y) |
406 | 414 | { |
415 | + printf("\nTo make the changes permanent, create add a startup script to your window manager with the following command(s):\n"); | |
416 | + if (swap_xy) | |
417 | + printf(" xinput set-int-prop \"%s\" \"Evdev Axes Swap\" 8 %d\n", drivername, swap_xy); | |
418 | + printf(" xinput set-int-prop \"%s\" \"Evdev Axis Calibration\" 32 %d %d %d %d\n", drivername, min_x, max_x, min_y, max_y); | |
419 | + | |
420 | + | |
421 | + printf("\nDoing dynamic recalibration:\n"); | |
407 | 422 | // Evdev Axes Swap |
408 | 423 | if (swap_xy) { |
409 | - printf("Swapping X and Y axis...\n"); | |
424 | + printf("\tSwapping X and Y axis...\n"); | |
410 | 425 | // xinput set-int-prop 4 224 8 0 |
411 | 426 | char str_prop[50]; |
412 | 427 | sprintf(str_prop, "Evdev Axes Swap"); |
@@ -425,8 +440,8 @@ void CalibratorEvdev::finish_data ( | ||
425 | 440 | /* Ignored, X server can handle it by flipping min/max values. */ |
426 | 441 | |
427 | 442 | // Evdev Axis Calibration |
428 | - // xinput set-int-prop 4 223 5 500 8 300 | |
429 | - printf("Setting new calibration data: %d, %d, %d, %d\n", min_x, max_x, min_y, max_y); | |
443 | + // xinput set-int-prop 4 223 32 5 500 8 300 | |
444 | + printf("\tSetting new calibration data: %d, %d, %d, %d\n", min_x, max_x, min_y, max_y); | |
430 | 445 | char str_prop[50]; |
431 | 446 | sprintf(str_prop, "Evdev Axis Calibration"); |
432 | 447 | char str_min_x[20]; |
@@ -1134,7 +1149,7 @@ int main(int argc, char** argv) | ||
1134 | 1149 | } |
1135 | 1150 | } |
1136 | 1151 | } |
1137 | - | |
1152 | + | |
1138 | 1153 | Gtk::Main kit(argc, argv); |
1139 | 1154 | |
1140 | 1155 | Gtk::Window win; |