• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

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

修订版898c61f1aee6aac352d49fdb25342a7bc61deb04 (tree)
时间2010-07-07 05:16:18
作者Tias Guns <tias@ulys...>
CommiterTias Guns

Log Message

support common setting of thresholds for doubleclick and misclick detection

更改概述

差异

--- a/src/calibrator.cpp
+++ b/src/calibrator.cpp
@@ -23,8 +23,9 @@
2323 #include <algorithm>
2424 #include "calibrator.hh"
2525
26-Calibrator::Calibrator(const char* const device_name0, const XYinfo& axys0, const bool verbose0)
27- : device_name(device_name0), old_axys(axys0), verbose(verbose0), num_clicks(0), threshold_doubleclick(7), threshold_misclick(15)
26+Calibrator::Calibrator(const char* const device_name0, const XYinfo& axys0,
27+ const bool verbose0, const int thr_misclick, const int thr_doubleclick)
28+ : device_name(device_name0), old_axys(axys0), verbose(verbose0), num_clicks(0), threshold_doubleclick(thr_doubleclick), threshold_misclick(thr_misclick)
2829 {
2930 }
3031
@@ -66,7 +67,7 @@ bool Calibrator::add_click(int x, int y)
6667 bool misclick = true;
6768
6869 if (num_clicks == 1) {
69- // check that along one axis of first pointV
70+ // check that along one axis of first point
7071 if (along_axis(x,clicked_x[0],clicked_y[0]) ||
7172 along_axis(y,clicked_x[0],clicked_y[0]))
7273 misclick = false;
@@ -88,7 +89,12 @@ bool Calibrator::add_click(int x, int y)
8889
8990 if (misclick) {
9091 if (verbose) {
91- 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);
92+ if (num_clicks == 1)
93+ 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);
94+ else if (num_clicks == 2)
95+ printf("DEBUG: Mis-click detected, click %i (X=%i, Y=%i) not aligned with click 0 (X=%i, Y=%i) or click 1 (X=%i, Y=%i) (threshold=%i)\n", num_clicks, x, y, clicked_x[0], clicked_y[0], clicked_x[1], clicked_y[1], threshold_misclick);
96+ else if (num_clicks == 3)
97+ 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);
9298 }
9399
94100 num_clicks = 0;
--- a/src/calibrator.hh
+++ b/src/calibrator.hh
@@ -33,7 +33,8 @@ public:
3333 * The constructor will throw an exception,
3434 * if the touchscreen is not of the type it supports
3535 */
36- Calibrator(const char* const device_name, const XYinfo& axys, const bool verbose);
36+ Calibrator(const char* const device_name, const XYinfo& axys,
37+ const bool verbose, const int thr_misclick=0, const int thr_doubleclick=0);
3738 ~Calibrator() {}
3839
3940 // set the doubleclick treshold
@@ -70,7 +71,8 @@ protected:
7071 int threshold_doubleclick;
7172
7273 // Threshold to detect mis-clicks (clicks not along axes)
73- // Set to zero to ignore, lower is more precise calibration
74+ // A lower value forces more precise calibration
75+ // Set to zero if you don't want this check
7476 int threshold_misclick;
7577 };
7678
--- a/src/calibrator/calibratorEvdev.cpp
+++ b/src/calibrator/calibratorEvdev.cpp
@@ -47,7 +47,8 @@ private:
4747
4848 int old_swap_xy;
4949 public:
50- CalibratorEvdev(const char* const device_name, const XYinfo& axys, const bool verbose, XID device_id=(XID)-1);
50+ CalibratorEvdev(const char* const device_name, const XYinfo& axys, const bool verbose,
51+ XID device_id=(XID)-1, const int thr_misclick=0, const int thr_doubleclick=0);
5152 ~CalibratorEvdev();
5253
5354 virtual bool finish_data(const XYinfo new_axys, int swap_xy);
@@ -61,8 +62,8 @@ public:
6162 int xinput_do_set_prop(Display *display, Atom type, int format, int argc, char* argv[]);
6263 };
6364
64-CalibratorEvdev::CalibratorEvdev(const char* const device_name0, const XYinfo& axys0, const bool verbose0, XID device_id)
65- : Calibrator(device_name0, axys0, verbose0), old_swap_xy(0)
65+CalibratorEvdev::CalibratorEvdev(const char* const device_name0, const XYinfo& axys0, const bool verbose0, XID device_id, const int thr_misclick, const int thr_doubleclick)
66+ : Calibrator(device_name0, axys0, verbose0, thr_misclick, thr_doubleclick), old_swap_xy(0)
6667 {
6768 // init
6869 display = XOpenDisplay(NULL);
--- a/src/calibrator/calibratorUsbtouchscreen.cpp
+++ b/src/calibrator/calibratorUsbtouchscreen.cpp
@@ -51,7 +51,8 @@ const char *p_swap_xy = "swap_xy";
5151 class CalibratorUsbtouchscreen: public Calibrator
5252 {
5353 public:
54- CalibratorUsbtouchscreen(const char* const device_name, const XYinfo& axys, const bool verbose);
54+ CalibratorUsbtouchscreen(const char* const device_name, const XYinfo& axys,
55+ const bool verbose, const int thr_misclick=0, const int thr_doubleclick=0);
5556 ~CalibratorUsbtouchscreen();
5657
5758 virtual bool finish_data(const XYinfo new_axys, int swap_xy);
@@ -132,8 +133,8 @@ protected:
132133 }
133134 };
134135
135-CalibratorUsbtouchscreen::CalibratorUsbtouchscreen(const char* const device_name0, const XYinfo& axys0, const bool verbose0)
136- : Calibrator(device_name0, axys0, verbose0)
136+CalibratorUsbtouchscreen::CalibratorUsbtouchscreen(const char* const device_name0, const XYinfo& axys0, const bool verbose0, const int thr_misclick, const int thr_doubleclick)
137+ : Calibrator(device_name0, axys0, verbose0, thr_misclick, thr_doubleclick)
137138 {
138139 if (strcmp(device_name, "Usbtouchscreen") != 0)
139140 throw WrongCalibratorException("Not a usbtouchscreen device");
--- a/src/calibrator/calibratorXorgPrint.cpp
+++ b/src/calibrator/calibratorXorgPrint.cpp
@@ -27,13 +27,14 @@
2727 class CalibratorXorgPrint: public Calibrator
2828 {
2929 public:
30- CalibratorXorgPrint(const char* const device_name, const XYinfo& axys, const bool verbose);
30+ CalibratorXorgPrint(const char* const device_name, const XYinfo& axys,
31+ const bool verbose, const int thr_misclick=0, const int thr_doubleclick=0);
3132
3233 virtual bool finish_data(const XYinfo new_axys, int swap_xy);
3334 };
3435
35-CalibratorXorgPrint::CalibratorXorgPrint(const char* const device_name0, const XYinfo& axys0, const bool verbose0)
36- : Calibrator(device_name0, axys0, verbose0)
36+CalibratorXorgPrint::CalibratorXorgPrint(const char* const device_name0, const XYinfo& axys0, const bool verbose0, const int thr_misclick, const int thr_doubleclick)
37+ : Calibrator(device_name0, axys0, verbose0, thr_misclick, thr_doubleclick)
3738 {
3839 printf("Calibrating standard Xorg driver \"%s\"\n", device_name);
3940 printf("\tcurrent calibration values: min_x=%d, max_x=%d and min_y=%d, max_y=%d\n",
--- a/src/main_common.hpp
+++ b/src/main_common.hpp
@@ -240,6 +240,8 @@ Calibrator* main_common(int argc, char** argv)
240240 bool precalib = false;
241241 XYinfo pre_axys;
242242 const char* pre_device = NULL;
243+ unsigned thr_misclick = 15;
244+ unsigned thr_doubleclick = 7;
243245
244246 // parse input
245247 if (argc > 1) {
@@ -363,7 +365,8 @@ Calibrator* main_common(int argc, char** argv)
363365 // Different device/driver, different ways to apply the calibration values
364366 try {
365367 // try Usbtouchscreen driver
366- return new CalibratorUsbtouchscreen(device_name, device_axys, verbose);
368+ return new CalibratorUsbtouchscreen(device_name, device_axys,
369+ verbose, thr_misclick, thr_doubleclick);
367370
368371 } catch(WrongCalibratorException& x) {
369372 if (verbose)
@@ -372,7 +375,8 @@ Calibrator* main_common(int argc, char** argv)
372375
373376 try {
374377 // next, try Evdev driver (with XID)
375- return new CalibratorEvdev(device_name, device_axys, verbose, device_id);
378+ return new CalibratorEvdev(device_name, device_axys, verbose, device_id,
379+ thr_misclick, thr_doubleclick);
376380
377381 } catch(WrongCalibratorException& x) {
378382 if (verbose)
@@ -380,5 +384,6 @@ Calibrator* main_common(int argc, char** argv)
380384 }
381385
382386 // lastly, presume a standard Xorg driver (evtouch, mutouch, ...)
383- return new CalibratorXorgPrint(device_name, device_axys, verbose);
387+ return new CalibratorXorgPrint(device_name, device_axys,
388+ verbose, thr_misclick, thr_doubleclick);
384389 }