A generic touchscreen calibration program for X.Org
Revision | b2db8b03022470e9e71cef206cac72b18501a7ef (tree) |
---|---|
Time | 2010-01-09 18:59:13 |
Author | Tias Guns <tias@ulys...> |
Commiter | Tias Guns |
minor fixes
- avoid string dereference of drivername
- document --fake and make behaviour consistent
@@ -89,7 +89,7 @@ struct XYinfo { | ||
89 | 89 | // find a calibratable device (using Xinput) |
90 | 90 | // retuns number of devices found, |
91 | 91 | // data of last driver is returned in the function parameters |
92 | -int find_driver(const char* drivername, XYinfo& axys) | |
92 | +int find_driver(const char*& drivername, XYinfo& axys) | |
93 | 93 | { |
94 | 94 | int found = 0; |
95 | 95 |
@@ -153,8 +153,9 @@ int find_driver(const char* drivername, XYinfo& axys) | ||
153 | 153 | |
154 | 154 | static void usage(char* cmd) |
155 | 155 | { |
156 | - fprintf(stderr, "Usage: %s [-h|--help] [--precalib <minx> <maxx> <miny> <maxy>]\n", cmd); | |
156 | + fprintf(stderr, "Usage: %s [-h|--help] [--precalib <minx> <maxx> <miny> <maxy>] [--fake]\n", cmd); | |
157 | 157 | fprintf(stderr, "\t--precalib: manually provide the current calibration setting (eg the values in xorg.conf)\n"); |
158 | + fprintf(stderr, "\t--fake: emulate a fake driver (for testing purposes)\n"); | |
158 | 159 | } |
159 | 160 | |
160 | 161 | Calibrator* main_common(int argc, char** argv) |
@@ -196,20 +197,20 @@ Calibrator* main_common(int argc, char** argv) | ||
196 | 197 | // find driver(s) |
197 | 198 | const char* drivername = NULL; |
198 | 199 | XYinfo axys; |
199 | - int nr_found = find_driver(drivername, axys); | |
200 | - if (nr_found == 0) { | |
201 | - if (fake) { | |
202 | - // Fake a calibratable device | |
203 | - drivername = "Fake_device"; | |
204 | - axys = XYinfo(0,0,0,0); | |
205 | - } else { | |
200 | + if (fake) { | |
201 | + // Fake a calibratable device | |
202 | + drivername = "Fake_device"; | |
203 | + axys = XYinfo(0,0,0,0); | |
204 | + } else { | |
205 | + // Find the right device | |
206 | + int nr_found = find_driver(drivername, axys); | |
207 | + if (nr_found == 0) { | |
206 | 208 | fprintf (stderr, "Error: No calibratable devices found.\n"); |
207 | 209 | exit(1); |
210 | + } else if (nr_found > 1) { | |
211 | + printf ("Warning: multiple calibratable devices found, calibrating last one (%s)\n", drivername); | |
208 | 212 | } |
209 | 213 | } |
210 | - if (nr_found > 1) { | |
211 | - printf ("Warning: multiple calibratable devices found, calibrating last one (%s)\n", drivername); | |
212 | - } | |
213 | 214 | |
214 | 215 | // override min/max XY from command line ? |
215 | 216 | if (precalib) { |