• 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

修订版6ca429f54c523268e87c76395bbd2a822d7d04d3 (tree)
时间2013-02-08 05:32:56
作者Tias Guns <tias@ulys...>
CommiterTias Guns

Log Message

Merge pull request #47 from schnitzeltony/write-file-param

Add a new parameter --output-filename

更改概述

差异

--- a/src/calibrator.cpp
+++ b/src/calibrator.cpp
@@ -37,10 +37,11 @@ bool Calibrator::verbose = false;
3737 Calibrator::Calibrator(const char* const device_name0, const XYinfo& axys0,
3838 const int thr_misclick, const int thr_doubleclick,
3939 const OutputType output_type0, const char* geometry0,
40- const bool use_timeout0)
40+ const bool use_timeout0, const char* output_filename0)
4141 : device_name(device_name0),
4242 threshold_doubleclick(thr_doubleclick), threshold_misclick(thr_misclick),
43- output_type(output_type0), geometry(geometry0), use_timeout(use_timeout0)
43+ output_type(output_type0), geometry(geometry0), use_timeout(use_timeout0),
44+ output_filename(output_filename0)
4445 {
4546 old_axys = axys0;
4647
--- a/src/calibrator.hh
+++ b/src/calibrator.hh
@@ -30,6 +30,9 @@
3030 #include <stdio.h>
3131 #include <vector>
3232
33+// XXX: we currently don't handle lines that are longer than this
34+#define MAX_LINE_LEN 1024
35+
3336 int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
3437 float scaleAxis(float Cx, int to_max, int to_min, int from_max, int from_min);
3538
@@ -145,9 +148,10 @@ public:
145148 const int thr_doubleclick=0,
146149 const OutputType output_type=OUTYPE_AUTO,
147150 const char* geometry=0,
148- const bool use_timeout=1);
151+ const bool use_timeout=1,
152+ const char* output_filename = 0);
149153
150- ~Calibrator() {}
154+ virtual ~Calibrator() {}
151155
152156 /// set the doubleclick treshold
153157 void set_threshold_doubleclick(int t)
@@ -180,6 +184,10 @@ public:
180184 const bool get_use_timeout() const
181185 { return use_timeout; }
182186
187+ /// get output filename set at cmdline or NULL
188+ const char* get_output_filename() const
189+ { return output_filename; }
190+
183191 protected:
184192 /// check whether the coordinates are along the respective axis
185193 bool along_axis(int xy, int x0, int y0);
@@ -230,6 +238,9 @@ protected:
230238 const char* geometry;
231239
232240 const bool use_timeout;
241+
242+ // manually specified output filename
243+ const char* output_filename;
233244 };
234245
235246 // Interfance for a CalibratorTester
--- a/src/calibrator/Evdev.cpp
+++ b/src/calibrator/Evdev.cpp
@@ -47,8 +47,9 @@ CalibratorEvdev::CalibratorEvdev(const char* const device_name0,
4747 const int thr_doubleclick,
4848 const OutputType output_type,
4949 const char* geometry,
50- const bool use_timeout)
51- : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, use_timeout)
50+ const bool use_timeout,
51+ const char* output_filename)
52+ : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, use_timeout, output_filename)
5253 {
5354 // init
5455 display = XOpenDisplay(NULL);
@@ -166,8 +167,9 @@ CalibratorEvdev::CalibratorEvdev(const char* const device_name0,
166167 const int thr_doubleclick,
167168 const OutputType output_type,
168169 const char* geometry,
169- const bool use_timeout)
170- : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry) { }
170+ const bool use_timeout,
171+ const char* output_filename)
172+ : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, output_filename) { }
171173
172174 // Destructor
173175 CalibratorEvdev::~CalibratorEvdev () {
@@ -515,18 +517,41 @@ bool CalibratorEvdev::output_xorgconfd(const XYinfo new_axys)
515517 if (not_sysfs_name)
516518 sysfs_name = "!!Name_Of_TouchScreen!!";
517519
520+ if(output_filename == NULL || not_sysfs_name)
521+ printf(" copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)\n");
522+ else
523+ printf(" writing xorg.conf calibration data to '%s'\n", output_filename);
524+
518525 // xorg.conf.d snippet
519- printf(" copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)\n");
520- printf("Section \"InputClass\"\n");
521- printf(" Identifier \"calibration\"\n");
522- printf(" MatchProduct \"%s\"\n", sysfs_name);
523- printf(" Option \"Calibration\" \"%d %d %d %d\"\n",
526+ char line[MAX_LINE_LEN];
527+ std::string outstr;
528+
529+ outstr += "Section \"InputClass\"\n";
530+ outstr += " Identifier \"calibration\"\n";
531+ sprintf(line, " MatchProduct \"%s\"\n", sysfs_name);
532+ outstr += line;
533+ sprintf(line, " Option \"Calibration\" \"%d %d %d %d\"\n",
524534 new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);
525- printf(" Option \"SwapAxes\" \"%d\"\n", new_axys.swap_xy);
526- printf("EndSection\n");
535+ outstr += line;
536+ sprintf(line, " Option \"SwapAxes\" \"%d\"\n", new_axys.swap_xy);
537+ outstr += line;
538+ outstr += "EndSection\n";
527539
540+ // console out
541+ printf("%s", outstr.c_str());
528542 if (not_sysfs_name)
529543 printf("\nChange '%s' to your device's name in the snippet above.\n", sysfs_name);
544+ // file out
545+ else if(output_filename != NULL) {
546+ FILE* fid = fopen(output_filename, "w");
547+ if (fid == NULL) {
548+ fprintf(stderr, "Error: Can't open '%s' for writing. Make sure you have the necessary rights\n", output_filename);
549+ fprintf(stderr, "New calibration data NOT saved\n");
550+ return false;
551+ }
552+ fprintf(fid, "%s", outstr.c_str());
553+ fclose(fid);
554+ }
530555
531556 return true;
532557 }
@@ -538,26 +563,71 @@ bool CalibratorEvdev::output_hal(const XYinfo new_axys)
538563 if (not_sysfs_name)
539564 sysfs_name = "!!Name_Of_TouchScreen!!";
540565
541- // HAL policy output
542- printf(" copy the policy below into '/etc/hal/fdi/policy/touchscreen.fdi'\n\
543-<match key=\"info.product\" contains=\"%s\">\n\
544- <merge key=\"input.x11_options.calibration\" type=\"string\">%d %d %d %d</merge>\n"
545- , sysfs_name, new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);
546- printf(" <merge key=\"input.x11_options.swapaxes\" type=\"string\">%d</merge>\n", new_axys.swap_xy);
547- printf("</match>\n");
566+ if(output_filename == NULL || not_sysfs_name)
567+ printf(" copy the policy below into '/etc/hal/fdi/policy/touchscreen.fdi'\n");
568+ else
569+ printf(" writing HAL calibration data to '%s'\n", output_filename);
548570
571+ // HAL policy output
572+ char line[MAX_LINE_LEN];
573+ std::string outstr;
574+
575+ sprintf(line, "<match key=\"info.product\" contains=\"%s\">\n", sysfs_name);
576+ outstr += line;
577+ sprintf(line, " <merge key=\"input.x11_options.calibration\" type=\"string\">%d %d %d %d</merge>\n",
578+ new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);
579+ outstr += line;
580+ sprintf(line, " <merge key=\"input.x11_options.swapaxes\" type=\"string\">%d</merge>\n",
581+ new_axys.swap_xy);
582+ outstr += "</match>\n";
583+ // console out
584+ printf("%s", outstr.c_str());
549585 if (not_sysfs_name)
550586 printf("\nChange '%s' to your device's name in the config above.\n", sysfs_name);
587+ // file out
588+ else if(output_filename != NULL) {
589+ FILE* fid = fopen(output_filename, "w");
590+ if (fid == NULL) {
591+ fprintf(stderr, "Error: Can't open '%s' for writing. Make sure you have the necessary rights\n", output_filename);
592+ fprintf(stderr, "New calibration data NOT saved\n");
593+ return false;
594+ }
595+ fprintf(fid, "%s", outstr.c_str());
596+ fclose(fid);
597+ }
551598
552599 return true;
553600 }
554601
555602 bool CalibratorEvdev::output_xinput(const XYinfo new_axys)
556603 {
604+ if(output_filename == NULL)
605+ printf(" Install the 'xinput' tool and copy the command(s) below in a script that starts with your X session\n");
606+ else
607+ printf(" writing calibration script to '%s'\n", output_filename);
608+
557609 // create startup script
558- printf(" Install the 'xinput' tool and copy the command(s) below in a script that starts with your X session\n");
559- printf(" xinput set-int-prop \"%s\" \"Evdev Axis Calibration\" 32 %d %d %d %d\n", device_name, new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);
560- printf(" xinput set-int-prop \"%s\" \"Evdev Axes Swap\" 8 %d\n", device_name, new_axys.swap_xy);
610+ char line[MAX_LINE_LEN];
611+ std::string outstr;
612+
613+ sprintf(line, " xinput set-int-prop \"%s\" \"Evdev Axis Calibration\" 32 %d %d %d %d\n", device_name, new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);
614+ outstr += line;
615+ sprintf(line, " xinput set-int-prop \"%s\" \"Evdev Axes Swap\" 8 %d\n", device_name, new_axys.swap_xy);
616+ outstr += line;
617+
618+ // console out
619+ printf("%s", outstr.c_str());
620+ // file out
621+ if(output_filename != NULL) {
622+ FILE* fid = fopen(output_filename, "w");
623+ if (fid == NULL) {
624+ fprintf(stderr, "Error: Can't open '%s' for writing. Make sure you have the necessary rights\n", output_filename);
625+ fprintf(stderr, "New calibration data NOT saved\n");
626+ return false;
627+ }
628+ fprintf(fid, "%s", outstr.c_str());
629+ fclose(fid);
630+ }
561631
562632 return true;
563633 }
--- a/src/calibrator/Evdev.hpp
+++ b/src/calibrator/Evdev.hpp
@@ -47,7 +47,8 @@ protected:
4747 const int thr_doubleclick=0,
4848 const OutputType output_type=OUTYPE_AUTO,
4949 const char* geometry=0,
50- const bool use_timeout=false);
50+ const bool use_timeout=false,
51+ const char* output_filename = 0);
5152
5253 public:
5354 CalibratorEvdev(const char* const device_name,
@@ -57,8 +58,9 @@ public:
5758 const int thr_doubleclick=0,
5859 const OutputType output_type=OUTYPE_AUTO,
5960 const char* geometry=0,
60- const bool use_timeout=false);
61- ~CalibratorEvdev();
61+ const bool use_timeout=false,
62+ const char* output_filename = 0);
63+ virtual ~CalibratorEvdev();
6264
6365 /// calculate and apply the calibration
6466 virtual bool finish(int width, int height);
--- 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, const bool use_timeout)
52- : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, use_timeout)
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, const char* output_filename)
52+ : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, use_timeout, output_filename)
5353 {
5454 if (strcmp(device_name, "Usbtouchscreen") != 0)
5555 throw WrongCalibratorException("Not a usbtouchscreen device");
@@ -104,16 +104,17 @@ bool CalibratorUsbtouchscreen::finish_data(const XYinfo new_axys)
104104 write_bool_parameter(p_swap_xy, new_axys.swap_xy);
105105
106106 // Read, then write calibration parameters to modprobe_conf_local,
107- // to keep the for the next boot
108- FILE *fid = fopen(modprobe_conf_local, "r");
107+ // or the file set by --output-filename to keep the for the next boot
108+ const char* filename = output_filename == NULL ? modprobe_conf_local : output_filename;
109+ FILE *fid = fopen(filename, "r");
109110 if (fid == NULL) {
110- fprintf(stderr, "Error: Can't open '%s' for reading. Make sure you have the necessary rights\n", modprobe_conf_local);
111+ fprintf(stderr, "Error: Can't open '%s' for reading. Make sure you have the necessary rights\n", filename);
111112 fprintf(stderr, "New calibration data NOT saved\n");
112113 return false;
113114 }
114115
115116 std::string new_contents;
116- const int len = 1024; // XXX: we currently don't handle lines that are longer than this
117+ const int len = MAX_LINE_LEN;
117118 char line[len];
118119 const char *opt = "options usbtouchscreen";
119120 const int opt_len = strlen(opt);
@@ -135,9 +136,9 @@ bool CalibratorUsbtouchscreen::finish_data(const XYinfo new_axys)
135136 p_flip_y, yesno(flip_y), p_swap_xy, yesno(new_axys.swap_xy));
136137 new_contents += new_opt;
137138
138- fid = fopen(modprobe_conf_local, "w");
139+ fid = fopen(filename, "w");
139140 if (fid == NULL) {
140- fprintf(stderr, "Error: Can't open '%s' for writing. Make sure you have the necessary rights\n", modprobe_conf_local);
141+ fprintf(stderr, "Error: Can't open '%s' for writing. Make sure you have the necessary rights\n", filename);
141142 fprintf(stderr, "New calibration data NOT saved\n");
142143 return false;
143144 }
--- a/src/calibrator/Usbtouchscreen.hpp
+++ b/src/calibrator/Usbtouchscreen.hpp
@@ -35,8 +35,8 @@ public:
3535 CalibratorUsbtouchscreen(const char* const device_name, const XYinfo& axys,
3636 const int thr_misclick=0, const int thr_doubleclick=0,
3737 const OutputType output_type=OUTYPE_AUTO, const char* geometry=0,
38- const bool use_timeout=false);
39- ~CalibratorUsbtouchscreen();
38+ const bool use_timeout=false, const char* output_filename = 0);
39+ virtual ~CalibratorUsbtouchscreen();
4040
4141 virtual bool finish_data(const XYinfo new_axys);
4242
--- 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, const bool use_timeout)
28- : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, use_timeout)
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, const char* output_filename)
28+ : Calibrator(device_name0, axys0, thr_misclick, thr_doubleclick, output_type, geometry, use_timeout, output_filename)
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",
@@ -69,22 +69,50 @@ bool CalibratorXorgPrint::output_xorgconfd(const XYinfo new_axys)
6969 if (not_sysfs_name)
7070 sysfs_name = "!!Name_Of_TouchScreen!!";
7171
72+ if(output_filename == NULL || not_sysfs_name)
73+ printf(" copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)\n");
74+ else
75+ printf(" writing calibration script to '%s'\n", output_filename);
76+
7277 // xorg.conf.d snippet
73- printf(" copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)\n");
74- printf("Section \"InputClass\"\n");
75- printf(" Identifier \"calibration\"\n");
76- printf(" MatchProduct \"%s\"\n", sysfs_name);
77- printf(" Option \"MinX\" \"%d\"\n", new_axys.x.min);
78- printf(" Option \"MaxX\" \"%d\"\n", new_axys.x.max);
79- printf(" Option \"MinY\" \"%d\"\n", new_axys.y.min);
80- printf(" Option \"MaxY\" \"%d\"\n", new_axys.y.max);
81- printf(" Option \"SwapXY\" \"%d\" # unless it was already set to 1\n", new_axys.swap_xy);
82- printf(" Option \"InvertX\" \"%d\" # unless it was already set\n", new_axys.x.invert);
83- printf(" Option \"InvertY\" \"%d\" # unless it was already set\n", new_axys.y.invert);
84- printf("EndSection\n");
78+ char line[MAX_LINE_LEN];
79+ std::string outstr;
80+
81+ outstr += "Section \"InputClass\"\n";
82+ outstr += " Identifier \"calibration\"\n";
83+ sprintf(line, " MatchProduct \"%s\"\n", sysfs_name);
84+ outstr += line;
85+ sprintf(line, " Option \"MinX\" \"%d\"\n", new_axys.x.min);
86+ outstr += line;
87+ sprintf(line, " Option \"MaxX\" \"%d\"\n", new_axys.x.max);
88+ outstr += line;
89+ sprintf(line, " Option \"MinY\" \"%d\"\n", new_axys.y.min);
90+ outstr += line;
91+ sprintf(line, " Option \"MaxY\" \"%d\"\n", new_axys.y.max);
92+ outstr += line;
93+ sprintf(line, " Option \"SwapXY\" \"%d\" # unless it was already set to 1\n", new_axys.swap_xy);
94+ outstr += line;
95+ sprintf(line, " Option \"InvertX\" \"%d\" # unless it was already set\n", new_axys.x.invert);
96+ outstr += line;
97+ sprintf(line, " Option \"InvertY\" \"%d\" # unless it was already set\n", new_axys.y.invert);
98+ outstr += line;
99+ outstr += "EndSection\n";
85100
101+ // console out
102+ printf("%s", outstr.c_str());
86103 if (not_sysfs_name)
87104 printf("\nChange '%s' to your device's name in the config above.\n", sysfs_name);
105+ // file out
106+ else if(output_filename != NULL) {
107+ FILE* fid = fopen(output_filename, "w");
108+ if (fid == NULL) {
109+ fprintf(stderr, "Error: Can't open '%s' for writing. Make sure you have the necessary rights\n", output_filename);
110+ fprintf(stderr, "New calibration data NOT saved\n");
111+ return false;
112+ }
113+ fprintf(fid, "%s", outstr.c_str());
114+ fclose(fid);
115+ }
88116
89117 return true;
90118 }
@@ -96,21 +124,48 @@ bool CalibratorXorgPrint::output_hal(const XYinfo new_axys)
96124 if (not_sysfs_name)
97125 sysfs_name = "!!Name_Of_TouchScreen!!";
98126
127+ if(output_filename == NULL || not_sysfs_name)
128+ printf(" copy the policy below into '/etc/hal/fdi/policy/touchscreen.fdi'\n");
129+ else
130+ printf(" writing HAL calibration data to '%s'\n", output_filename);
131+
99132 // HAL policy output
100- printf(" copy the policy below into '/etc/hal/fdi/policy/touchscreen.fdi'\n\
101-<match key=\"info.product\" contains=\"%s\">\n\
102- <merge key=\"input.x11_options.minx\" type=\"string\">%d</merge>\n\
103- <merge key=\"input.x11_options.maxx\" type=\"string\">%d</merge>\n\
104- <merge key=\"input.x11_options.miny\" type=\"string\">%d</merge>\n\
105- <merge key=\"input.x11_options.maxy\" type=\"string\">%d</merge>\n"
106- , sysfs_name, new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);
107- printf(" <merge key=\"input.x11_options.swapxy\" type=\"string\">%d</merge>\n", new_axys.swap_xy);
108- printf(" <merge key=\"input.x11_options.invertx\" type=\"string\">%d</merge>\n", new_axys.x.invert);
109- printf(" <merge key=\"input.x11_options.inverty\" type=\"string\">%d</merge>\n", new_axys.y.invert);
110- printf("</match>\n");
133+ char line[MAX_LINE_LEN];
134+ std::string outstr;
135+
136+ sprintf(line, "<match key=\"info.product\" contains=\"%s\">\n", sysfs_name);
137+ outstr += line;
138+ sprintf(line, " <merge key=\"input.x11_options.minx\" type=\"string\">%d</merge>\n", new_axys.x.min);
139+ outstr += line;
140+ sprintf(line, " <merge key=\"input.x11_options.maxx\" type=\"string\">%d</merge>\n", new_axys.x.max);
141+ outstr += line;
142+ sprintf(line, " <merge key=\"input.x11_options.miny\" type=\"string\">%d</merge>\n", new_axys.y.min);
143+ outstr += line;
144+ sprintf(line, " <merge key=\"input.x11_options.maxy\" type=\"string\">%d</merge>\n", new_axys.y.max);
145+ outstr += line;
146+ sprintf(line, " <merge key=\"input.x11_options.swapxy\" type=\"string\">%d</merge>\n", new_axys.swap_xy);
147+ outstr += line;
148+ sprintf(line, " <merge key=\"input.x11_options.invertx\" type=\"string\">%d</merge>\n", new_axys.x.invert);
149+ outstr += line;
150+ sprintf(line, " <merge key=\"input.x11_options.inverty\" type=\"string\">%d</merge>\n", new_axys.y.invert);
151+ outstr += line;
152+ outstr += "</match>\n";
111153
154+ // console out
155+ printf("%s", outstr.c_str());
112156 if (not_sysfs_name)
113157 printf("\nChange '%s' to your device's name in the config above.\n", sysfs_name);
158+ // file out
159+ else if(output_filename != NULL) {
160+ FILE* fid = fopen(output_filename, "w");
161+ if (fid == NULL) {
162+ fprintf(stderr, "Error: Can't open '%s' for writing. Make sure you have the necessary rights\n", output_filename);
163+ fprintf(stderr, "New calibration data NOT saved\n");
164+ return false;
165+ }
166+ fprintf(fid, "%s", outstr.c_str());
167+ fclose(fid);
168+ }
114169
115170 return true;
116171 }
--- a/src/calibrator/XorgPrint.hpp
+++ b/src/calibrator/XorgPrint.hpp
@@ -35,7 +35,7 @@ public:
3535 CalibratorXorgPrint(const char* const device_name, const XYinfo& axys,
3636 const int thr_misclick=0, const int thr_doubleclick=0,
3737 const OutputType output_type=OUTYPE_AUTO, const char* geometry=0,
38- const bool use_timeout=false);
38+ const bool use_timeout=false, const char* output_filename = 0);
3939
4040 virtual bool finish_data(const XYinfo new_axys);
4141
--- a/src/main_common.cpp
+++ b/src/main_common.cpp
@@ -180,6 +180,7 @@ static void usage(char* cmd, unsigned thr_misclick)
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");
182182 fprintf(stderr, "\t--no-timeout: turns off the timeout\n");
183+ fprintf(stderr, "\t--output-filename: write calibration data to file (USB: override default /etc/modprobe.conf.local\n");
183184 }
184185
185186 Calibrator* Calibrator::make_calibrator(int argc, char** argv)
@@ -191,6 +192,7 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
191192 XYinfo pre_axys;
192193 const char* pre_device = NULL;
193194 const char* geometry = NULL;
195+ const char* output_filename = NULL;
194196 unsigned thr_misclick = 15;
195197 unsigned thr_doubleclick = 7;
196198 OutputType output_type = OUTYPE_AUTO;
@@ -289,6 +291,11 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
289291 // Disable timeout
290292 if (strcmp("--no-timeout", argv[i]) == 0) {
291293 use_timeout = false;
294+ } else
295+
296+ // Output file
297+ if (strcmp("--output-filename", argv[i]) == 0) {
298+ output_filename = argv[++i];
292299 }
293300
294301 // unknown option
@@ -363,7 +370,8 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
363370 try {
364371 // try Usbtouchscreen driver
365372 return new CalibratorUsbtouchscreen(device_name, device_axys,
366- thr_misclick, thr_doubleclick, output_type, geometry, use_timeout);
373+ thr_misclick, thr_doubleclick, output_type, geometry,
374+ use_timeout, output_filename);
367375
368376 } catch(WrongCalibratorException& x) {
369377 if (verbose)
@@ -373,7 +381,8 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
373381 try {
374382 // next, try Evdev driver (with XID)
375383 return new CalibratorEvdev(device_name, device_axys, device_id,
376- thr_misclick, thr_doubleclick, output_type, geometry, use_timeout);
384+ thr_misclick, thr_doubleclick, output_type, geometry,
385+ use_timeout, output_filename);
377386
378387 } catch(WrongCalibratorException& x) {
379388 if (verbose)
@@ -382,5 +391,6 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv)
382391
383392 // lastly, presume a standard Xorg driver (evtouch, mutouch, ...)
384393 return new CalibratorXorgPrint(device_name, device_axys,
385- thr_misclick, thr_doubleclick, output_type, geometry, use_timeout);
394+ thr_misclick, thr_doubleclick, output_type, geometry,
395+ use_timeout, output_filename);
386396 }