• 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

修订版bb9537380e4000f8b371a9d23051d1682a31cc44 (tree)
时间2013-01-04 06:32:01
作者Tias Guns <tias@ulys...>
CommiterTias Guns

Log Message

Merge pull request #44 from felipelerena/master

no-timeout parameter

更改概述

差异

--- a/src/calibrator.cpp
+++ b/src/calibrator.cpp
@@ -35,10 +35,12 @@
3535 bool Calibrator::verbose = false;
3636
3737 Calibrator::Calibrator(const char* const device_name0, const XYinfo& axys0,
38- const int thr_misclick, const int thr_doubleclick, const OutputType output_type0, const char* geometry0)
38+ const int thr_misclick, const int thr_doubleclick,
39+ const OutputType output_type0, const char* geometry0,
40+ const bool use_timeout0)
3941 : device_name(device_name0),
4042 threshold_doubleclick(thr_doubleclick), threshold_misclick(thr_misclick),
41- output_type(output_type0), geometry(geometry0)
43+ output_type(output_type0), geometry(geometry0), use_timeout(use_timeout0)
4244 {
4345 old_axys = axys0;
4446
--- a/src/calibrator.hh
+++ b/src/calibrator.hh
@@ -144,7 +144,8 @@ public:
144144 const int thr_misclick=0,
145145 const int thr_doubleclick=0,
146146 const OutputType output_type=OUTYPE_AUTO,
147- const char* geometry=0);
147+ const char* geometry=0,
148+ const bool use_timeout=1);
148149
149150 ~Calibrator() {}
150151
@@ -176,6 +177,9 @@ public:
176177 /// returns NULL if it can not be found
177178 const char* get_sysfs_name();
178179
180+ const bool get_use_timeout() const
181+ { return use_timeout; }
182+
179183 protected:
180184 /// check whether the coordinates are along the respective axis
181185 bool along_axis(int xy, int x0, int y0);
@@ -224,6 +228,8 @@ protected:
224228
225229 // manually specified geometry string
226230 const char* geometry;
231+
232+ const bool use_timeout;
227233 };
228234
229235 // Interfance for a CalibratorTester
--- a/src/calibrator/Evdev.cpp
+++ b/src/calibrator/Evdev.cpp
@@ -46,8 +46,9 @@ CalibratorEvdev::CalibratorEvdev(const char* const device_name0,
4646 const int thr_misclick,
4747 const int thr_doubleclick,
4848 const OutputType output_type,
49- const char* geometry)
50- : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry)
49+ const char* geometry,
50+ const bool use_timeout)
51+ : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, use_timeout)
5152 {
5253 // init
5354 display = XOpenDisplay(NULL);
@@ -164,7 +165,8 @@ CalibratorEvdev::CalibratorEvdev(const char* const device_name0,
164165 const int thr_misclick,
165166 const int thr_doubleclick,
166167 const OutputType output_type,
167- const char* geometry)
168+ const char* geometry,
169+ const bool use_timeout)
168170 : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry) { }
169171
170172 // Destructor
--- a/src/calibrator/Evdev.hpp
+++ b/src/calibrator/Evdev.hpp
@@ -46,7 +46,8 @@ protected:
4646 const int thr_misclick=0,
4747 const int thr_doubleclick=0,
4848 const OutputType output_type=OUTYPE_AUTO,
49- const char* geometry=0);
49+ const char* geometry=0,
50+ const bool use_timeout=false);
5051
5152 public:
5253 CalibratorEvdev(const char* const device_name,
@@ -55,7 +56,8 @@ public:
5556 const int thr_misclick=0,
5657 const int thr_doubleclick=0,
5758 const OutputType output_type=OUTYPE_AUTO,
58- const char* geometry=0);
59+ const char* geometry=0,
60+ const bool use_timeout=false);
5961 ~CalibratorEvdev();
6062
6163 /// calculate and apply the calibration
--- a/src/calibrator/Usbtouchscreen.cpp
+++ b/src/calibrator/Usbtouchscreen.cpp
@@ -48,8 +48,8 @@ static const char *p_flip_x = "flip_x";
4848 static const char *p_flip_y = "flip_y";
4949 static const char *p_swap_xy = "swap_xy";
5050
51-CalibratorUsbtouchscreen::CalibratorUsbtouchscreen(const char* const device_name0, const XYinfo& axys0, const int thr_misclick, const int thr_doubleclick, const OutputType output_type, const char* geometry)
52- : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry)
51+CalibratorUsbtouchscreen::CalibratorUsbtouchscreen(const char* const device_name0, const XYinfo& axys0, const int thr_misclick, const int thr_doubleclick, const OutputType output_type, const char* geometry, const bool use_timeout)
52+ : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, use_timeout)
5353 {
5454 if (strcmp(device_name, "Usbtouchscreen") != 0)
5555 throw WrongCalibratorException("Not a usbtouchscreen device");
--- a/src/calibrator/Usbtouchscreen.hpp
+++ b/src/calibrator/Usbtouchscreen.hpp
@@ -34,7 +34,8 @@ class CalibratorUsbtouchscreen: public Calibrator
3434 public:
3535 CalibratorUsbtouchscreen(const char* const device_name, const XYinfo& axys,
3636 const int thr_misclick=0, const int thr_doubleclick=0,
37- const OutputType output_type=OUTYPE_AUTO, const char* geometry=0);
37+ const OutputType output_type=OUTYPE_AUTO, const char* geometry=0,
38+ const bool use_timeout=false);
3839 ~CalibratorUsbtouchscreen();
3940
4041 virtual bool finish_data(const XYinfo new_axys);
--- a/src/calibrator/XorgPrint.cpp
+++ b/src/calibrator/XorgPrint.cpp
@@ -24,8 +24,8 @@
2424
2525 #include <cstdio>
2626
27-CalibratorXorgPrint::CalibratorXorgPrint(const char* const device_name0, const XYinfo& axys0, const int thr_misclick, const int thr_doubleclick, const OutputType output_type, const char* geometry)
28- : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry)
27+CalibratorXorgPrint::CalibratorXorgPrint(const char* const device_name0, const XYinfo& axys0, const int thr_misclick, const int thr_doubleclick, const OutputType output_type, const char* geometry, const bool use_timeout)
28+ : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, use_timeout)
2929 {
3030 printf("Calibrating standard Xorg driver \"%s\"\n", device_name);
3131 printf("\tcurrent calibration values: min_x=%d, max_x=%d and min_y=%d, max_y=%d\n",
--- a/src/calibrator/XorgPrint.hpp
+++ b/src/calibrator/XorgPrint.hpp
@@ -34,7 +34,8 @@ class CalibratorXorgPrint: public Calibrator
3434 public:
3535 CalibratorXorgPrint(const char* const device_name, const XYinfo& axys,
3636 const int thr_misclick=0, const int thr_doubleclick=0,
37- const OutputType output_type=OUTYPE_AUTO, const char* geometry=0);
37+ const OutputType output_type=OUTYPE_AUTO, const char* geometry=0,
38+ const bool use_timeout=false);
3839
3940 virtual bool finish_data(const XYinfo new_axys);
4041
--- a/src/gui/gtkmm.cpp
+++ b/src/gui/gtkmm.cpp
@@ -66,8 +66,10 @@ CalibrationArea::CalibrationArea(Calibrator* calibrator0)
6666 set_display_size(get_width(), get_height());
6767
6868 // Setup timer for animation
69- sigc::slot<bool> slot = sigc::mem_fun(*this, &CalibrationArea::on_timer_signal);
70- Glib::signal_timeout().connect(slot, time_step);
69+ if(calibrator->get_use_timeout()){
70+ sigc::slot<bool> slot = sigc::mem_fun(*this, &CalibrationArea::on_timer_signal);
71+ Glib::signal_timeout().connect(slot, time_step);
72+ }
7173 }
7274
7375 void CalibrationArea::set_display_size(int width, int height) {
@@ -149,12 +151,13 @@ bool CalibrationArea::on_expose_event(GdkEventExpose *event)
149151 cr->arc(X[i], Y[i], cross_circle, 0.0, 2.0 * M_PI);
150152 cr->stroke();
151153 }
152-
153- // Draw the clock background
154- cr->arc(display_width/2, display_height/2, clock_radius/2, 0.0, 2.0 * M_PI);
155- cr->set_source_rgb(0.5, 0.5, 0.5);
156- cr->fill_preserve();
157- cr->stroke();
154+ if(calibrator->get_use_timeout()){
155+ // Draw the clock background
156+ cr->arc(display_width/2, display_height/2, clock_radius/2, 0.0, 2.0 * M_PI);
157+ cr->set_source_rgb(0.5, 0.5, 0.5);
158+ cr->fill_preserve();
159+ cr->stroke();
160+ }
158161
159162 cr->set_line_width(clock_line_width);
160163 cr->arc(display_width/2, display_height/2, (clock_radius - clock_line_width)/2,
--- a/src/main_common.cpp
+++ b/src/main_common.cpp
@@ -168,7 +168,7 @@ int Calibrator::find_device(const char* pre_device, bool list_devices,
168168
169169 static void usage(char* cmd, unsigned thr_misclick)
170170 {
171- fprintf(stderr, "Usage: %s [-h|--help] [-v|--verbose] [--list] [--device <device name or id>] [--precalib <minx> <maxx> <miny> <maxy>] [--misclick <nr of pixels>] [--output-type <auto|xorg.conf.d|hal|xinput>] [--fake] [--geometry <w>x<h>]\n", cmd);
171+ fprintf(stderr, "Usage: %s [-h|--help] [-v|--verbose] [--list] [--device <device name or id>] [--precalib <minx> <maxx> <miny> <maxy>] [--misclick <nr of pixels>] [--output-type <auto|xorg.conf.d|hal|xinput>] [--fake] [--geometry <w>x<h>] [--no-timeout]\n", cmd);
172172 fprintf(stderr, "\t-h, --help: print this help message\n");
173173 fprintf(stderr, "\t-v, --verbose: print debug messages during the process\n");
174174 fprintf(stderr, "\t--list: list calibratable input devices and quit\n");
@@ -179,6 +179,7 @@ static void usage(char* cmd, unsigned thr_misclick)
179179 fprintf(stderr, "\t--output-type <auto|xorg.conf.d|hal|xinput>: type of config to ouput (auto=automatically detect, default: auto)\n");
180180 fprintf(stderr, "\t--fake: emulate a fake device (for testing purposes)\n");
181181 fprintf(stderr, "\t--geometry: manually provide the geometry (width and height) for the calibration window\n");
182+ fprintf(stderr, "\t--no-timeout: turns off the timeout if parameter pressent\n");
182183 }
183184
184185 Calibrator* Calibrator::make_calibrator(int argc, char** argv)
@@ -186,6 +187,7 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
186187 bool list_devices = false;
187188 bool fake = false;
188189 bool precalib = false;
190+ bool use_timeout = true;
189191 XYinfo pre_axys;
190192 const char* pre_device = NULL;
191193 const char* geometry = NULL;
@@ -282,7 +284,12 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
282284 // Fake calibratable device ?
283285 if (strcmp("--fake", argv[i]) == 0) {
284286 fake = true;
285- }
287+ } else
288+
289+ // Disable timeout
290+ if (strcmp("--no-timeout", argv[i]) == 0) {
291+ use_timeout = false;
292+ }
286293
287294 // unknown option
288295 else {
@@ -356,7 +363,7 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
356363 try {
357364 // try Usbtouchscreen driver
358365 return new CalibratorUsbtouchscreen(device_name, device_axys,
359- thr_misclick, thr_doubleclick, output_type, geometry);
366+ thr_misclick, thr_doubleclick, output_type, geometry, use_timeout);
360367
361368 } catch(WrongCalibratorException& x) {
362369 if (verbose)
@@ -366,7 +373,7 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
366373 try {
367374 // next, try Evdev driver (with XID)
368375 return new CalibratorEvdev(device_name, device_axys, device_id,
369- thr_misclick, thr_doubleclick, output_type, geometry);
376+ thr_misclick, thr_doubleclick, output_type, geometry, use_timeout);
370377
371378 } catch(WrongCalibratorException& x) {
372379 if (verbose)
@@ -375,5 +382,5 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
375382
376383 // lastly, presume a standard Xorg driver (evtouch, mutouch, ...)
377384 return new CalibratorXorgPrint(device_name, device_axys,
378- thr_misclick, thr_doubleclick, output_type, geometry);
385+ thr_misclick, thr_doubleclick, output_type, geometry, use_timeout);
379386 }