• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A generic touchscreen calibration program for X.Org


Commit MetaInfo

Révision57bb872b60635955adfebdb30269362fcbd5d8f9 (tree)
l'heure2010-03-01 01:25:40
Auteurtias <tias@pock...>
Commitertias

Message de Log

misclick detection in calibrator, now in GUI's

Change Summary

Modification

--- a/src/calibrator.cpp
+++ b/src/calibrator.cpp
@@ -45,7 +45,7 @@ int Calibrator::get_numclicks()
4545
4646 bool Calibrator::add_click(int x, int y)
4747 {
48- // Double-click check
48+ // Double-click detection
4949 if (num_clicks > 0 && threshold_doubleclick > 0
5050 && abs (x - clicked_x[num_clicks-1]) < threshold_doubleclick
5151 && abs (y - clicked_y[num_clicks-1]) < threshold_doubleclick) {
@@ -57,31 +57,37 @@ bool Calibrator::add_click(int x, int y)
5757 }
5858
5959 // 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
6262 && abs (x - clicked_y[0]) > threshold_misclick
6363 && 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;
6972 }
7073
7174 // 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
7477 && abs (x - clicked_y[1]) > threshold_misclick
7578 && abs (y - clicked_x[1]) > threshold_misclick
7679 && abs (y - clicked_y[1]) > threshold_misclick) ||
77- (abs (x - clicked_x[2]) > threshold_misclick
80+ (abs (x - clicked_x[2]) > threshold_misclick
7881 && abs (x - clicked_y[2]) > threshold_misclick
7982 && 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;
8591 }
8692
8793 clicked_x[num_clicks] = x;
--- a/src/gui/gui_x11.cpp
+++ b/src/gui/gui_x11.cpp
@@ -182,6 +182,9 @@ GuiCalibratorX11::~GuiCalibratorX11()
182182
183183 void GuiCalibratorX11::redraw()
184184 {
185+ // TODO: clear the area first !
186+ // (needed when restarting calibration)
187+
185188 // Print the text
186189 int text_height = font_info->ascent + font_info->descent;
187190 int text_width = -1;