• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
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

Revisiond7bc8bbd0f5a825f0e8993f31df812e8640316ed (tree)
Time2012-03-09 08:51:58
AuthorTias Guns <tias@ulys...>
CommiterTias Guns

Log Message

new_axys now contains the axys value to write

previously, new_axys.swap_xy meant that the old swap_xy value needed to
be swapped.
Now, new_axys is initialised to old_axys,
such that setting new_axys.do_swap_xy() swaps the axys and hence
new_axys contains the axys values to write.
Similar for invert_x, invert_y

Changes to Usbtouchscreen were not needed as it resets swap/inversion
values to 'false' before doing calibration.

Change Summary

Incremental Difference

--- a/src/calibrator.cpp
+++ b/src/calibrator.cpp
@@ -137,12 +137,18 @@ bool Calibrator::finish(int width, int height)
137137 return false;
138138 }
139139
140- XYinfo new_axys; // new axys origin and scaling
140+ // new axys origin and scaling
141+ // based on old_axys: inversion/swapping is relative to the old axys
142+ XYinfo new_axys(old_axys);
141143
142144 // Should x and y be swapped?
143- new_axys.swap_xy = (abs (clicked.x[UL] - clicked.x[UR]) < abs (clicked.y[UL] - clicked.y[UR]));
145+ bool do_swap_xy = false;
146+ if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - clicked.y[UR])) {
147+ do_swap_xy = true;
148+ new_axys.do_swap_xy();
149+ }
144150
145- if (new_axys.swap_xy) {
151+ if (do_swap_xy) {
146152 std::swap(clicked.x[LL], clicked.x[UR]);
147153 std::swap(clicked.y[LL], clicked.y[UR]);
148154 }
@@ -167,7 +173,7 @@ bool Calibrator::finish(int width, int height)
167173
168174
169175 // If x and y has to be swapped we also have to swap the parameters
170- if (new_axys.swap_xy) {
176+ if (do_swap_xy) {
171177 std::swap(new_axys.x.min, new_axys.y.max);
172178 std::swap(new_axys.y.min, new_axys.x.max);
173179 }
--- a/src/calibrator/Evdev.cpp
+++ b/src/calibrator/Evdev.cpp
@@ -154,14 +154,10 @@ bool CalibratorEvdev::finish_data(const XYinfo new_axys)
154154 {
155155 bool success = true;
156156
157- // swap x and y axis, indicated by swap_xy
158- // new value is old value (could have been 0 or 1) swapped:
159- int new_swap_xy = 1 - old_axys.swap_xy;
160-
161157 printf("\nDoing dynamic recalibration:\n");
162158 // Evdev Axes Swap
163- if (new_axys.swap_xy) {
164- success &= set_swapxy(new_swap_xy);
159+ if (old_axys.swap_xy != new_axys.swap_xy) {
160+ success &= set_swapxy(new_axys.swap_xy);
165161 }
166162
167163 // Evdev Axis Calibration
@@ -177,19 +173,19 @@ bool CalibratorEvdev::finish_data(const XYinfo new_axys)
177173 case OUTYPE_AUTO:
178174 // xorg.conf.d or alternatively xinput commands
179175 if (has_xorgconfd_support()) {
180- success &= output_xorgconfd(new_axys, new_swap_xy);
176+ success &= output_xorgconfd(new_axys);
181177 } else {
182- success &= output_xinput(new_axys, new_swap_xy);
178+ success &= output_xinput(new_axys);
183179 }
184180 break;
185181 case OUTYPE_XORGCONFD:
186- success &= output_xorgconfd(new_axys, new_swap_xy);
182+ success &= output_xorgconfd(new_axys);
187183 break;
188184 case OUTYPE_HAL:
189- success &= output_hal(new_axys, new_swap_xy);
185+ success &= output_hal(new_axys);
190186 break;
191187 case OUTYPE_XINPUT:
192- success &= output_xinput(new_axys, new_swap_xy);
188+ success &= output_xinput(new_axys);
193189 break;
194190 default:
195191 fprintf(stderr, "ERROR: Evdev Calibrator does not support the supplied --output-type\n");
@@ -430,7 +426,7 @@ int CalibratorEvdev::xinput_do_set_prop(Display *display, Atom type, int format,
430426
431427 }
432428
433-bool CalibratorEvdev::output_xorgconfd(const XYinfo new_axys, int new_swap_xy)
429+bool CalibratorEvdev::output_xorgconfd(const XYinfo new_axys)
434430 {
435431 const char* sysfs_name = get_sysfs_name();
436432 bool not_sysfs_name = (sysfs_name == NULL);
@@ -444,8 +440,7 @@ bool CalibratorEvdev::output_xorgconfd(const XYinfo new_axys, int new_swap_xy)
444440 printf(" MatchProduct \"%s\"\n", sysfs_name);
445441 printf(" Option \"Calibration\" \"%d %d %d %d\"\n",
446442 new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);
447- if (new_axys.swap_xy != 0)
448- printf(" Option \"SwapAxes\" \"%d\"\n", new_swap_xy);
443+ printf(" Option \"SwapAxes\" \"%d\"\n", new_axys.swap_xy);
449444 printf("EndSection\n");
450445
451446 if (not_sysfs_name)
@@ -454,7 +449,7 @@ bool CalibratorEvdev::output_xorgconfd(const XYinfo new_axys, int new_swap_xy)
454449 return true;
455450 }
456451
457-bool CalibratorEvdev::output_hal(const XYinfo new_axys, int new_swap_xy)
452+bool CalibratorEvdev::output_hal(const XYinfo new_axys)
458453 {
459454 const char* sysfs_name = get_sysfs_name();
460455 bool not_sysfs_name = (sysfs_name == NULL);
@@ -466,8 +461,7 @@ bool CalibratorEvdev::output_hal(const XYinfo new_axys, int new_swap_xy)
466461 <match key=\"info.product\" contains=\"%s\">\n\
467462 <merge key=\"input.x11_options.calibration\" type=\"string\">%d %d %d %d</merge>\n"
468463 , sysfs_name, new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);
469- if (new_axys.swap_xy != 0)
470- printf(" <merge key=\"input.x11_options.swapaxes\" type=\"string\">%d</merge>\n", new_swap_xy);
464+ printf(" <merge key=\"input.x11_options.swapaxes\" type=\"string\">%d</merge>\n", new_axys.swap_xy);
471465 printf("</match>\n");
472466
473467 if (not_sysfs_name)
@@ -476,13 +470,12 @@ bool CalibratorEvdev::output_hal(const XYinfo new_axys, int new_swap_xy)
476470 return true;
477471 }
478472
479-bool CalibratorEvdev::output_xinput(const XYinfo new_axys, int new_swap_xy)
473+bool CalibratorEvdev::output_xinput(const XYinfo new_axys)
480474 {
481475 // create startup script
482476 printf(" Install the 'xinput' tool and copy the command(s) below in a script that starts with your X session\n");
483477 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);
484- if (new_axys.swap_xy)
485- printf(" xinput set-int-prop \"%s\" \"Evdev Axes Swap\" 8 %d\n", device_name, new_swap_xy);
478+ printf(" xinput set-int-prop \"%s\" \"Evdev Axes Swap\" 8 %d\n", device_name, new_axys.swap_xy);
486479
487480 return true;
488481 }
--- a/src/calibrator/Evdev.hpp
+++ b/src/calibrator/Evdev.hpp
@@ -54,9 +54,9 @@ public:
5454 XDeviceInfo* xinput_find_device_info(Display *display, const char* name, Bool only_extended);
5555 int xinput_do_set_prop(Display *display, Atom type, int format, int argc, const char** argv);
5656 protected:
57- bool output_xorgconfd(const XYinfo new_axys, int new_swap_xy);
58- bool output_hal(const XYinfo new_axys, int new_swap_xy);
59- bool output_xinput(const XYinfo new_axys, int new_swap_xy);
57+ bool output_xorgconfd(const XYinfo new_axys);
58+ bool output_hal(const XYinfo new_axys);
59+ bool output_xinput(const XYinfo new_axys);
6060 };
6161
6262 #endif
--- a/src/calibrator/XorgPrint.cpp
+++ b/src/calibrator/XorgPrint.cpp
@@ -37,25 +37,21 @@ bool CalibratorXorgPrint::finish_data(const XYinfo new_axys)
3737 {
3838 bool success = true;
3939
40- // we suppose the previous 'swap_xy' value was 0
41- // (unfortunately there is no way to verify this (yet))
42- int new_swap_xy = new_axys.swap_xy;
43-
4440 printf("\n\n--> Making the calibration permanent <--\n");
4541 switch (output_type) {
4642 case OUTYPE_AUTO:
4743 // xorg.conf.d or alternatively hal config
4844 if (has_xorgconfd_support()) {
49- success &= output_xorgconfd(new_axys, new_swap_xy);
45+ success &= output_xorgconfd(new_axys);
5046 } else {
51- success &= output_hal(new_axys, new_swap_xy);
47+ success &= output_hal(new_axys);
5248 }
5349 break;
5450 case OUTYPE_XORGCONFD:
55- success &= output_xorgconfd(new_axys, new_swap_xy);
51+ success &= output_xorgconfd(new_axys);
5652 break;
5753 case OUTYPE_HAL:
58- success &= output_hal(new_axys, new_swap_xy);
54+ success &= output_hal(new_axys);
5955 break;
6056 default:
6157 fprintf(stderr, "ERROR: XorgPrint Calibrator does not support the supplied --output-type\n");
@@ -65,7 +61,7 @@ bool CalibratorXorgPrint::finish_data(const XYinfo new_axys)
6561 return success;
6662 }
6763
68-bool CalibratorXorgPrint::output_xorgconfd(const XYinfo new_axys, int new_swap_xy)
64+bool CalibratorXorgPrint::output_xorgconfd(const XYinfo new_axys)
6965 {
7066 const char* sysfs_name = get_sysfs_name();
7167 bool not_sysfs_name = (sysfs_name == NULL);
@@ -81,8 +77,7 @@ bool CalibratorXorgPrint::output_xorgconfd(const XYinfo new_axys, int new_swap_x
8177 printf(" Option \"MaxX\" \"%d\"\n", new_axys.x.max);
8278 printf(" Option \"MinY\" \"%d\"\n", new_axys.y.min);
8379 printf(" Option \"MaxY\" \"%d\"\n", new_axys.y.max);
84- if (new_axys.swap_xy != 0)
85- printf(" Option \"SwapXY\" \"%d\" # unless it was already set to 1\n", new_swap_xy);
80+ printf(" Option \"SwapXY\" \"%d\" # unless it was already set to 1\n", new_axys.swap_xy);
8681 printf("EndSection\n");
8782
8883 if (not_sysfs_name)
@@ -91,7 +86,7 @@ bool CalibratorXorgPrint::output_xorgconfd(const XYinfo new_axys, int new_swap_x
9186 return true;
9287 }
9388
94-bool CalibratorXorgPrint::output_hal(const XYinfo new_axys, int new_swap_xy)
89+bool CalibratorXorgPrint::output_hal(const XYinfo new_axys)
9590 {
9691 const char* sysfs_name = get_sysfs_name();
9792 bool not_sysfs_name = (sysfs_name == NULL);
@@ -106,8 +101,7 @@ bool CalibratorXorgPrint::output_hal(const XYinfo new_axys, int new_swap_xy)
106101 <merge key=\"input.x11_options.miny\" type=\"string\">%d</merge>\n\
107102 <merge key=\"input.x11_options.maxy\" type=\"string\">%d</merge>\n"
108103 , sysfs_name, new_axys.x.min, new_axys.x.max, new_axys.y.min, new_axys.y.max);
109- if (new_axys.swap_xy != 0)
110- printf(" <merge key=\"input.x11_options.swapxy\" type=\"string\">%d</merge>\n", new_swap_xy);
104+ printf(" <merge key=\"input.x11_options.swapxy\" type=\"string\">%d</merge>\n", new_axys.swap_xy);
111105 printf("</match>\n");
112106
113107 if (not_sysfs_name)
--- a/src/calibrator/XorgPrint.hpp
+++ b/src/calibrator/XorgPrint.hpp
@@ -37,9 +37,10 @@ public:
3737 const OutputType output_type=OUTYPE_AUTO, const char* geometry=0);
3838
3939 virtual bool finish_data(const XYinfo new_axys);
40+
4041 protected:
41- bool output_xorgconfd(const XYinfo new_axys, int new_swap_xy);
42- bool output_hal(const XYinfo new_axys, int new_swap_xy);
42+ bool output_xorgconfd(const XYinfo new_axys);
43+ bool output_hal(const XYinfo new_axys);
4344 };
4445
4546 #endif