A generic touchscreen calibration program for X.Org
修订版 | 1f4a9b8acfa01eba0f6a62d4a36287208628c74e (tree) |
---|---|
时间 | 2012-06-27 04:59:28 |
作者 | Tias Guns <tias@ulys...> |
Commiter | Tias Guns |
calib calculation: move min/max correction before transformation
@@ -160,15 +160,6 @@ bool Calibrator::finish(int width, int height) | ||
160 | 160 | new_axis.y.min = round( (clicked.y[UL] + clicked.y[UR])/2.0 ); |
161 | 161 | new_axis.y.max = round( (clicked.y[LL] + clicked.y[LR])/2.0 ); |
162 | 162 | |
163 | - // Compute min/max coordinates. | |
164 | - // These are scaled using the values of old_axys | |
165 | - const float scale_x = (old_axys.x.max - old_axys.x.min)/(float)width; | |
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; | |
168 | - const float scale_y = (old_axys.y.max - old_axys.y.min)/(float)height; | |
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; | |
171 | - | |
172 | 163 | // Add/subtract the offset that comes from not having the points in the |
173 | 164 | // corners (using the same coordinate system they are currently in) |
174 | 165 | const int delta_x = (new_axis.x.max - new_axis.x.min) / (float)(num_blocks - 2); |
@@ -178,6 +169,15 @@ bool Calibrator::finish(int width, int height) | ||
178 | 169 | new_axis.y.min -= delta_y; |
179 | 170 | new_axis.y.max += delta_y; |
180 | 171 | |
172 | + // Compute min/max coordinates. | |
173 | + // These are scaled using the values of old_axys | |
174 | + const float scale_x = (old_axys.x.max - old_axys.x.min)/(float)width; | |
175 | + new_axis.x.min = (new_axis.x.min * scale_x) + old_axys.x.min; | |
176 | + new_axis.x.max = (new_axis.x.max * scale_x) + old_axys.x.min; | |
177 | + const float scale_y = (old_axys.y.max - old_axys.y.min)/(float)height; | |
178 | + new_axis.y.min = (new_axis.y.min * scale_y) + old_axys.y.min; | |
179 | + new_axis.y.max = (new_axis.y.max * scale_y) + old_axys.y.min; | |
180 | + | |
181 | 181 | |
182 | 182 | // If x and y has to be swapped we also have to swap the parameters |
183 | 183 | if (do_swap_xy) { |