A generic touchscreen calibration program for X.Org
Révision | 42dc87f2ad6843a0998485bd2141984baee7f387 (tree) |
---|---|
l'heure | 2010-07-07 05:16:59 |
Auteur | Tias Guns <tias@ulys...> |
Commiter | Tias Guns |
add --misclick <nr of pixels> as runtime option
@@ -220,14 +220,16 @@ int find_device(const char* pre_device, bool verbose, bool list_devices, | ||
220 | 220 | return found; |
221 | 221 | } |
222 | 222 | |
223 | -static void usage(char* cmd) | |
223 | +static void usage(char* cmd, unsigned thr_misclick) | |
224 | 224 | { |
225 | - fprintf(stderr, "Usage: %s [-h|--help] [-v|--verbose] [--list] [--device <device name or id>] [--precalib <minx> <maxx> <miny> <maxy>] [--fake]\n", cmd); | |
225 | + fprintf(stderr, "Usage: %s [-h|--help] [-v|--verbose] [--list] [--device <device name or id>] [--precalib <minx> <maxx> <miny> <maxy>] [--misclick <nr of pixels>] [--fake]\n", cmd); | |
226 | 226 | fprintf(stderr, "\t-h, --help: print this help message\n"); |
227 | 227 | fprintf(stderr, "\t-v, --verbose: print debug messages during the process\n"); |
228 | 228 | fprintf(stderr, "\t--list: list calibratable input devices and quit\n"); |
229 | 229 | fprintf(stderr, "\t--device <device name or id>: select a specific device to calibrate\n"); |
230 | - fprintf(stderr, "\t--precalib: manually provide the current calibration setting (eg the values in xorg.conf)\n"); | |
230 | + fprintf(stderr, "\t--precalib: manually provide the current calibration setting (eg. the values in xorg.conf)\n"); | |
231 | + fprintf(stderr, "\t--misclick: set the misclick threshold (0=off, default: %i pixels)\n", | |
232 | + thr_misclick); | |
231 | 233 | fprintf(stderr, "\t--fake: emulate a fake device (for testing purposes)\n"); |
232 | 234 | } |
233 | 235 |
@@ -250,7 +252,7 @@ Calibrator* main_common(int argc, char** argv) | ||
250 | 252 | if (strcmp("-h", argv[i]) == 0 || |
251 | 253 | strcmp("--help", argv[i]) == 0) { |
252 | 254 | fprintf(stderr, "xinput_calibratior, v%s\n\n", VERSION); |
253 | - usage(argv[0]); | |
255 | + usage(argv[0], thr_misclick); | |
254 | 256 | exit(0); |
255 | 257 | } else |
256 | 258 |
@@ -271,7 +273,7 @@ Calibrator* main_common(int argc, char** argv) | ||
271 | 273 | pre_device = argv[++i]; |
272 | 274 | else { |
273 | 275 | fprintf(stderr, "Error: --device needs a device name or id as argument; use --list to list the calibratable input devices.\n\n"); |
274 | - usage(argv[0]); | |
276 | + usage(argv[0], thr_misclick); | |
275 | 277 | exit(1); |
276 | 278 | } |
277 | 279 | } else |
@@ -289,6 +291,17 @@ Calibrator* main_common(int argc, char** argv) | ||
289 | 291 | pre_axys.y_max = atoi(argv[++i]); |
290 | 292 | } else |
291 | 293 | |
294 | + // Get mis-click threshold ? | |
295 | + if (strcmp("--misclick", argv[i]) == 0) { | |
296 | + if (argc > i+1) | |
297 | + thr_misclick = atoi(argv[++i]); | |
298 | + else { | |
299 | + fprintf(stderr, "Error: --misclick needs a number (the pixel threshold) as argument. Set to 0 to disable mis-click detection.\n\n"); | |
300 | + usage(argv[0], thr_misclick); | |
301 | + exit(1); | |
302 | + } | |
303 | + } else | |
304 | + | |
292 | 305 | // Fake calibratable device ? |
293 | 306 | if (strcmp("--fake", argv[i]) == 0) { |
294 | 307 | fake = true; |
@@ -297,7 +310,7 @@ Calibrator* main_common(int argc, char** argv) | ||
297 | 310 | // unknown option |
298 | 311 | else { |
299 | 312 | fprintf(stderr, "Unknown option: %s\n\n", argv[i]); |
300 | - usage(argv[0]); | |
313 | + usage(argv[0], thr_misclick); | |
301 | 314 | exit(0); |
302 | 315 | } |
303 | 316 | } |