A generic touchscreen calibration program for X.Org
Revision | 8f14ada9fa654467e87cb7f95b871ff09c868449 (tree) |
---|---|
Time | 2010-08-16 06:52:23 |
Author | Tias Guns <tias@ulys...> |
Commiter | Tias Guns |
use detected sysfs name in output when possible
@@ -213,6 +213,11 @@ bool CalibratorEvdev::finish_data(const XYinfo new_axys, int swap_xy) | ||
213 | 213 | XSync(display, False); |
214 | 214 | |
215 | 215 | |
216 | + const char* sysfs_name = get_sysfs_name(); | |
217 | + bool not_sysfs_name = (sysfs_name == NULL); | |
218 | + if (not_sysfs_name) | |
219 | + sysfs_name = "!!Name_Of_TouchScreen!!"; | |
220 | + | |
216 | 221 | // TODO: detect which are applicable at runtime/in the makefile ? |
217 | 222 | printf("\n\n--> How to make the calibration permanent <--\n"); |
218 | 223 | printf("On recent systems you can create an xorg.conf.d snippet, on older systems you have to create a script with the xinput commands:\n\n"); |
@@ -222,12 +227,14 @@ bool CalibratorEvdev::finish_data(const XYinfo new_axys, int swap_xy) | ||
222 | 227 | printf(" copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf'\n"); |
223 | 228 | printf("Section \"InputClass\"\n"); |
224 | 229 | printf(" Identifier \"calibration\"\n"); |
225 | - printf(" MatchProduct \"%s\"\n", device_name); | |
230 | + printf(" MatchProduct \"%s\"\n", sysfs_name); | |
226 | 231 | printf(" Option \"Calibration\" \"%d %d %d %d\"\n", |
227 | 232 | new_axys.x_min, new_axys.x_max, new_axys.y_min, new_axys.y_max); |
228 | 233 | if (swap_xy != 0) |
229 | 234 | printf(" Option \"SwapAxes\" \"%d\"\n", new_swap_xy); |
230 | 235 | printf("EndSection\n"); |
236 | + if (not_sysfs_name) | |
237 | + printf("\nChange '%s' by your device's name, in the snippet above.\n", sysfs_name); | |
231 | 238 | printf("\n"); |
232 | 239 | |
233 | 240 | // create startup script |
@@ -48,6 +48,12 @@ bool CalibratorXorgPrint::finish_data(const XYinfo new_axys, int swap_xy) | ||
48 | 48 | // (unfortunately there is no way to verify this (yet)) |
49 | 49 | int new_swap_xy = swap_xy; |
50 | 50 | |
51 | + | |
52 | + const char* sysfs_name = get_sysfs_name(); | |
53 | + bool not_sysfs_name = (sysfs_name == NULL); | |
54 | + if (not_sysfs_name) | |
55 | + sysfs_name = "!!Name_Of_TouchScreen!!"; | |
56 | + | |
51 | 57 | // TODO: detect which are applicable at runtime/in the makefile ? |
52 | 58 | printf("\n\n--> How to make the calibration permanent <--\n"); |
53 | 59 | printf("On recent systems you can create an xorg.conf.d snippet, on older systems you have to create a HAL policy file:\n\n"); |
@@ -57,7 +63,7 @@ bool CalibratorXorgPrint::finish_data(const XYinfo new_axys, int swap_xy) | ||
57 | 63 | printf(" copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf'\n"); |
58 | 64 | printf("Section \"InputClass\"\n"); |
59 | 65 | printf(" Identifier \"calibration\"\n"); |
60 | - printf(" MatchProduct \"%s\"\n", "%Name_Of_TouchScreen%"); | |
66 | + printf(" MatchProduct \"%s\"\n", sysfs_name); | |
61 | 67 | printf(" Option \"MinX\" \"%d\"\n", new_axys.x_min); |
62 | 68 | printf(" Option \"MaxX\" \"%d\"\n", new_axys.x_max); |
63 | 69 | printf(" Option \"MinY\" \"%d\"\n", new_axys.y_min); |
@@ -70,15 +76,18 @@ bool CalibratorXorgPrint::finish_data(const XYinfo new_axys, int swap_xy) | ||
70 | 76 | // HAL policy output |
71 | 77 | printf("* HAL policy (older systems using HAL)\n"); |
72 | 78 | printf(" copy the policy below into '/etc/hal/fdi/policy/touchscreen.fdi'\n\ |
73 | -<match key=\"info.product\" contains=\"%%Name_Of_TouchScreen%%\">\n\ | |
79 | +<match key=\"info.product\" contains=\"%s\">\n\ | |
74 | 80 | <merge key=\"input.x11_options.minx\" type=\"string\">%d</merge>\n\ |
75 | 81 | <merge key=\"input.x11_options.maxx\" type=\"string\">%d</merge>\n\ |
76 | 82 | <merge key=\"input.x11_options.miny\" type=\"string\">%d</merge>\n\ |
77 | 83 | <merge key=\"input.x11_options.maxy\" type=\"string\">%d</merge>\n" |
78 | - , new_axys.x_min, new_axys.x_max, new_axys.y_min, new_axys.y_max); | |
84 | + , sysfs_name, new_axys.x_min, new_axys.x_max, new_axys.y_min, new_axys.y_max); | |
79 | 85 | if (swap_xy != 0) |
80 | 86 | printf(" <merge key=\"input.x11_options.swapxy\" type=\"string\">%d</merge>\n", new_swap_xy); |
81 | 87 | printf("</match>\n"); |
82 | 88 | |
89 | + if (not_sysfs_name) | |
90 | + printf("\nChange '%s' by your device's name, in the configs above.\n", sysfs_name); | |
91 | + | |
83 | 92 | return true; |
84 | 93 | } |