@@ -142,24 +142,20 @@ 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 ;
159148 float x_max = (clicked.x [UR] + clicked.x [LR])/2.0 ;
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
0 commit comments