A generic touchscreen calibration program for X.Org
Révision | 57bb872b60635955adfebdb30269362fcbd5d8f9 (tree) |
---|---|
l'heure | 2010-03-01 01:25:40 |
Auteur | tias <tias@pock...> |
Commiter | tias |
misclick detection in calibrator, now in GUI's
@@ -45,7 +45,7 @@ int Calibrator::get_numclicks() | ||
45 | 45 | |
46 | 46 | bool Calibrator::add_click(int x, int y) |
47 | 47 | { |
48 | - // Double-click check | |
48 | + // Double-click detection | |
49 | 49 | if (num_clicks > 0 && threshold_doubleclick > 0 |
50 | 50 | && abs (x - clicked_x[num_clicks-1]) < threshold_doubleclick |
51 | 51 | && abs (y - clicked_y[num_clicks-1]) < threshold_doubleclick) { |
@@ -57,31 +57,37 @@ bool Calibrator::add_click(int x, int y) | ||
57 | 57 | } |
58 | 58 | |
59 | 59 | // Mis-click detection, check second and third point with first point |
60 | - if (num_clicks == 1 || num_clicks == 2) { | |
61 | - if (abs (x - clicked_x[0]) > threshold_misclick | |
60 | + if ((num_clicks == 1 || num_clicks == 2) && | |
61 | + (abs (x - clicked_x[0]) > threshold_misclick | |
62 | 62 | && abs (x - clicked_y[0]) > threshold_misclick |
63 | 63 | && abs (y - clicked_x[0]) > threshold_misclick |
64 | - && abs (y - clicked_y[0]) > threshold_misclick) { | |
65 | - printf("%i: misclick0, %i,%i to %i,%i\n", num_clicks, x, y, clicked_x[num_clicks-1], clicked_y[num_clicks-1]); | |
66 | - } else { | |
67 | - printf("%i: goodclick0, %i,%i to %i,%i\n", num_clicks, x, y, clicked_x[num_clicks-1], clicked_y[num_clicks-1]); | |
68 | - } | |
64 | + && abs (y - clicked_y[0]) > threshold_misclick)) { | |
65 | + if (verbose) { | |
66 | + printf("DEBUG: Mis-click detected, click %i (X=%i, Y=%i) not aligned with click 0 (X=%i, Y=%i) (threshold=%i)\n", num_clicks, x, y, clicked_x[0], clicked_y[0], threshold_misclick); | |
67 | + } | |
68 | + | |
69 | + num_clicks = 0; | |
70 | + // Alert user: Mis-click detected, restarting calibration. | |
71 | + return false; | |
69 | 72 | } |
70 | 73 | |
71 | 74 | // Mis-click check, check last point with second and third |
72 | - if (num_clicks == 3) { | |
73 | - if ((abs (x - clicked_x[1]) > threshold_misclick | |
75 | + if (num_clicks == 3 && | |
76 | + ((abs (x - clicked_x[1]) > threshold_misclick | |
74 | 77 | && abs (x - clicked_y[1]) > threshold_misclick |
75 | 78 | && abs (y - clicked_x[1]) > threshold_misclick |
76 | 79 | && abs (y - clicked_y[1]) > threshold_misclick) || |
77 | - (abs (x - clicked_x[2]) > threshold_misclick | |
80 | + (abs (x - clicked_x[2]) > threshold_misclick | |
78 | 81 | && abs (x - clicked_y[2]) > threshold_misclick |
79 | 82 | && abs (y - clicked_x[2]) > threshold_misclick |
80 | - && abs (y - clicked_y[2]) > threshold_misclick)) { | |
81 | - printf("%i: misclick3, %i,%i to %i,%i\n", num_clicks, x, y, clicked_x[num_clicks-2], clicked_y[num_clicks-1]); | |
82 | - } else { | |
83 | - printf("%i: goodclick3, %i,%i to %i,%i\n", num_clicks, x, y, clicked_x[num_clicks-2], clicked_y[num_clicks-1]); | |
84 | - } | |
83 | + && abs (y - clicked_y[2]) > threshold_misclick))) { | |
84 | + if (verbose) { | |
85 | + printf("DEBUG: Mis-click detected, click %i (X=%i, Y=%i) not aligned with click 1 (X=%i, Y=%i) or click 2 (X=%i, Y=%i) (threshold=%i)\n", num_clicks, x, y, clicked_x[1], clicked_y[1], clicked_x[2], clicked_y[2], threshold_misclick); | |
86 | + } | |
87 | + | |
88 | + num_clicks = 0; | |
89 | + // Alert user: Mis-click detected, restarting calibration. | |
90 | + return false; | |
85 | 91 | } |
86 | 92 | |
87 | 93 | clicked_x[num_clicks] = x; |
@@ -182,6 +182,9 @@ GuiCalibratorX11::~GuiCalibratorX11() | ||
182 | 182 | |
183 | 183 | void GuiCalibratorX11::redraw() |
184 | 184 | { |
185 | + // TODO: clear the area first ! | |
186 | + // (needed when restarting calibration) | |
187 | + | |
185 | 188 | // Print the text |
186 | 189 | int text_height = font_info->ascent + font_info->descent; |
187 | 190 | int text_width = -1; |