• 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

Revisión07978b90b81237d83071426643416161087e45dd (tree)
Tiempo2012-06-27 04:59:28
AutorTias Guns <tias@ulys...>
CommiterTias Guns

Log Message

Rewrite and simplify swapping

Inspired by forest bond's 'calibrator: Convert to device coordinates
immediately.' patch:
https://github.com/forest-bond/xinput_calibrator/commit/12832527fba6dd1b3135751257ca6a734aa571cd

Cambiar Resumen

Diferencia incremental

--- a/src/calibrator.cpp
+++ b/src/calibrator.cpp
@@ -142,17 +142,6 @@ bool Calibrator::finish(int width, int height)
142142 // based on old_axys: inversion/swapping is relative to the old axis
143143 XYinfo new_axis(old_axys);
144144
145- // Should x and y be swapped?
146- bool do_swap_xy = false;
147- if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - clicked.y[UR])) {
148- do_swap_xy = true;
149- new_axis.do_swap_xy();
150- }
151-
152- if (do_swap_xy) {
153- std::swap(clicked.x[LL], clicked.x[UR]);
154- std::swap(clicked.y[LL], clicked.y[UR]);
155- }
156145
157146 // calculate average of clicks
158147 float x_min = (clicked.x[UL] + clicked.x[LL])/2.0;
@@ -160,6 +149,13 @@ bool Calibrator::finish(int width, int height)
160149 float y_min = (clicked.y[UL] + clicked.y[UR])/2.0;
161150 float y_max = (clicked.y[LL] + clicked.y[LR])/2.0;
162151
152+ // Should x and y be swapped?
153+ if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - clicked.y[UR])) {
154+ new_axis.swap_xy = !new_axis.swap_xy;
155+ std::swap(x_min, y_min);
156+ std::swap(x_max, y_max);
157+ }
158+
163159 // the screen was divided in num_blocks blocks, and the touch points were at
164160 // one block away from the true edges of the screen.
165161 const float block_x = width/(float)num_blocks;
@@ -184,12 +180,7 @@ bool Calibrator::finish(int width, int height)
184180 y_max = scaleAxis(y_max, old_axys.y.max, old_axys.y.min, height, 0);
185181
186182
187- // If x and y has to be swapped we also have to swap the parameters
188- if (do_swap_xy) {
189- std::swap(x_min, y_max);
190- std::swap(y_min, x_max);
191- }
192-
183+ // round and put in new_axis struct
193184 new_axis.x.min = round(x_min); new_axis.x.max = round(x_max);
194185 new_axis.y.min = round(y_min); new_axis.y.max = round(y_max);
195186