A generic touchscreen calibration program for X.Org
修訂 | a811614ae8d237084f32b8259165b55643f48f9d (tree) |
---|---|
時間 | 2010-02-01 01:01:37 |
作者 | Tias Guns <tias@ulys...> |
Commiter | Tias Guns |
rename driver to device as we are dealing with devices in the first place, and the drivers of the device only in the second place
@@ -95,9 +95,9 @@ class WrongCalibratorException : public std::invalid_argument { | ||
95 | 95 | |
96 | 96 | // find a calibratable device (using XInput) |
97 | 97 | // retuns number of devices found, |
98 | -// data of last driver is returned in the function parameters | |
99 | -int find_driver(bool verbose, const char*& drivername, XYinfo& axys); | |
100 | -int find_driver(bool verbose, const char*& drivername, XYinfo& axys) | |
98 | +// data of last device is returned in the function parameters | |
99 | +int find_device(bool verbose, const char*& device_name, XYinfo& device_axys); | |
100 | +int find_device(bool verbose, const char*& device_name, XYinfo& device_axys) | |
101 | 101 | { |
102 | 102 | int found = 0; |
103 | 103 |
@@ -146,11 +146,11 @@ int find_driver(bool verbose, const char*& drivername, XYinfo& axys) | ||
146 | 146 | !(ax[1].min_value == -1 && ax[1].max_value == -1)) { |
147 | 147 | /* a calibratable device (no mouse etc) */ |
148 | 148 | found++; |
149 | - drivername = strdup(list->name); | |
150 | - axys.x_min = ax[0].min_value; | |
151 | - axys.x_max = ax[0].max_value; | |
152 | - axys.y_min = ax[1].min_value; | |
153 | - axys.y_max = ax[1].max_value; | |
149 | + device_name = strdup(list->name); | |
150 | + device_axys.x_min = ax[0].min_value; | |
151 | + device_axys.x_max = ax[0].max_value; | |
152 | + device_axys.y_min = ax[1].min_value; | |
153 | + device_axys.y_max = ax[1].max_value; | |
154 | 154 | } |
155 | 155 | |
156 | 156 | } |
@@ -177,7 +177,7 @@ static void usage(char* cmd) | ||
177 | 177 | fprintf(stderr, "\t-h, --help: print this help message\n"); |
178 | 178 | fprintf(stderr, "\t-v, --verbose: print debug messages during the process\n"); |
179 | 179 | fprintf(stderr, "\t--precalib: manually provide the current calibration setting (eg the values in xorg.conf)\n"); |
180 | - fprintf(stderr, "\t--fake: emulate a fake driver (for testing purposes)\n"); | |
180 | + fprintf(stderr, "\t--fake: emulate a fake device (for testing purposes)\n"); | |
181 | 181 | } |
182 | 182 | |
183 | 183 | Calibrator* main_common(int argc, char** argv); |
@@ -224,51 +224,53 @@ Calibrator* main_common(int argc, char** argv) | ||
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - // find driver(s) | |
228 | - const char* drivername = NULL; | |
229 | - XYinfo axys; | |
227 | + | |
228 | + // Choose the device to calibrate | |
229 | + const char* device_name = NULL; | |
230 | + XYinfo device_axys; | |
230 | 231 | if (fake) { |
231 | 232 | // Fake a calibratable device |
232 | - drivername = "Fake_device"; | |
233 | - axys = XYinfo(0,0,0,0); | |
233 | + device_name = "Fake_device"; | |
234 | + device_axys = XYinfo(0,0,0,0); | |
234 | 235 | |
235 | 236 | if (verbose) { |
236 | - printf("DEBUG: Faking device: %s\n", drivername); | |
237 | + printf("DEBUG: Faking device: %s\n", device_name); | |
237 | 238 | } |
238 | 239 | } else { |
239 | 240 | // Find the right device |
240 | - int nr_found = find_driver(verbose, drivername, axys); | |
241 | + int nr_found = find_device(verbose, device_name, device_axys); | |
241 | 242 | |
242 | 243 | if (nr_found == 0) { |
243 | 244 | fprintf (stderr, "Error: No calibratable devices found.\n"); |
244 | 245 | exit(1); |
245 | 246 | } else if (nr_found > 1) { |
246 | - printf ("Warning: multiple calibratable devices found, calibrating last one (%s)\n", drivername); | |
247 | + printf ("Warning: multiple calibratable devices found, calibrating last one (%s)\n", device_name); | |
247 | 248 | } |
248 | 249 | } |
249 | 250 | |
250 | 251 | // override min/max XY from command line ? |
251 | 252 | if (precalib) { |
252 | 253 | if (pre_axys.x_min != -1) |
253 | - axys.x_min = pre_axys.x_min; | |
254 | + device_axys.x_min = pre_axys.x_min; | |
254 | 255 | if (pre_axys.x_max != -1) |
255 | - axys.x_max = pre_axys.x_max; | |
256 | + device_axys.x_max = pre_axys.x_max; | |
256 | 257 | if (pre_axys.y_min != -1) |
257 | - axys.y_min = pre_axys.y_min; | |
258 | + device_axys.y_min = pre_axys.y_min; | |
258 | 259 | if (pre_axys.y_max != -1) |
259 | - axys.y_max = pre_axys.y_max; | |
260 | + device_axys.y_max = pre_axys.y_max; | |
260 | 261 | |
261 | 262 | if (verbose) { |
262 | 263 | printf("DEBUG: Setting precalibration: %i, %i, %i, %i\n", |
263 | - axys.x_min, axys.x_max, axys.y_min, axys.y_max); | |
264 | + device_axys.x_min, device_axys.x_max, | |
265 | + device_axys.y_min, device_axys.y_max); | |
264 | 266 | } |
265 | 267 | } |
266 | 268 | |
267 | 269 | |
268 | - // Different device/driver, different calibrator usage | |
270 | + // Different device/driver, different ways to apply the calibration values | |
269 | 271 | try { |
270 | - // Usbtouchscreen driver | |
271 | - return new CalibratorUsbtouchscreen(drivername, axys, verbose); | |
272 | + // try Usbtouchscreen driver | |
273 | + return new CalibratorUsbtouchscreen(device_name, device_axys, verbose); | |
272 | 274 | |
273 | 275 | } catch(WrongCalibratorException& x) { |
274 | 276 | if (verbose) |
@@ -277,7 +279,7 @@ Calibrator* main_common(int argc, char** argv) | ||
277 | 279 | |
278 | 280 | try { |
279 | 281 | // next, try Evdev driver |
280 | - return new CalibratorEvdev(drivername, axys, verbose); | |
282 | + return new CalibratorEvdev(device_name, device_axys, verbose); | |
281 | 283 | |
282 | 284 | } catch(WrongCalibratorException& x) { |
283 | 285 | if (verbose) |
@@ -285,5 +287,5 @@ Calibrator* main_common(int argc, char** argv) | ||
285 | 287 | } |
286 | 288 | |
287 | 289 | // lastly, presume a standard Xorg driver (evtouch, mutouch, ...) |
288 | - return new CalibratorXorgPrint(drivername, axys, verbose); | |
290 | + return new CalibratorXorgPrint(device_name, device_axys, verbose); | |
289 | 291 | } |