• 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ón9e15947b55f6847013d28aa0fea79dda432acecd (tree)
Tiempo2012-06-27 04:59:28
AutorTias Guns <tias@ulys...>
CommiterTias Guns

Log Message

calib calculation: calculate average of clicks first

Cambiar Resumen

Diferencia incremental

--- a/src/calibrator.cpp
+++ b/src/calibrator.cpp
@@ -27,6 +27,7 @@
2727 #include <iostream>
2828 #include <fstream>
2929 #include <cstring>
30+#include <cmath>
3031
3132 #include "calibrator.hh"
3233
@@ -153,14 +154,20 @@ bool Calibrator::finish(int width, int height)
153154 std::swap(clicked.y[LL], clicked.y[UR]);
154155 }
155156
157+ // calculate average of clicks
158+ new_axis.x.min = round( (clicked.x[UL] + clicked.x[LL])/2.0 );
159+ new_axis.x.max = round( (clicked.x[UR] + clicked.x[LR])/2.0 );
160+ new_axis.y.min = round( (clicked.y[UL] + clicked.y[UR])/2.0 );
161+ new_axis.y.max = round( (clicked.y[LL] + clicked.y[LR])/2.0 );
162+
156163 // Compute min/max coordinates.
157164 // These are scaled using the values of old_axys
158165 const float scale_x = (old_axys.x.max - old_axys.x.min)/(float)width;
159- new_axis.x.min = ((clicked.x[UL] + clicked.x[LL]) * scale_x/2) + old_axys.x.min;
160- new_axis.x.max = ((clicked.x[UR] + clicked.x[LR]) * scale_x/2) + old_axys.x.min;
166+ new_axis.x.min = (new_axis.x.min * scale_x) + old_axys.x.min;
167+ new_axis.x.max = (new_axis.x.max * scale_x) + old_axys.x.min;
161168 const float scale_y = (old_axys.y.max - old_axys.y.min)/(float)height;
162- new_axis.y.min = ((clicked.y[UL] + clicked.y[UR]) * scale_y/2) + old_axys.y.min;
163- new_axis.y.max = ((clicked.y[LL] + clicked.y[LR]) * scale_y/2) + old_axys.y.min;
169+ new_axis.y.min = (new_axis.y.min * scale_y) + old_axys.y.min;
170+ new_axis.y.max = (new_axis.y.max * scale_y) + old_axys.y.min;
164171
165172 // Add/subtract the offset that comes from not having the points in the
166173 // corners (using the same coordinate system they are currently in)