Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/calibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ bool Calibrator::finish(int width, int height)
// Should x and y be swapped?
if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - clicked.y[UR])) {
new_axis.swap_xy = !new_axis.swap_xy;
std::swap(x_min, y_min);
std::swap(x_max, y_max);
x_min = (clicked.x[UL] + clicked.x[UR])/2.0;
x_max = (clicked.x[LL] + clicked.x[LR])/2.0;
y_min = (clicked.y[UL] + clicked.y[LL])/2.0;
y_max = (clicked.y[UR] + clicked.y[LR])/2.0;

}

// the screen was divided in num_blocks blocks, and the touch points were at
Expand Down
19 changes: 12 additions & 7 deletions src/calibrator/Evdev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ bool CalibratorEvdev::finish(int width, int height)
float y_min = (clicked.y[UL] + clicked.y[UR])/2.0;
float y_max = (clicked.y[LL] + clicked.y[LR])/2.0;

// Should x and y be swapped?
if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - clicked.y[UR])) {
fprintf(stderr, "INFO: swap axes\n");
new_axis.swap_xy = !new_axis.swap_xy;
// calculate average of clicks
x_min = (clicked.x[UL] + clicked.x[UR])/2.0;
x_max = (clicked.x[LL] + clicked.x[LR])/2.0;
y_min = (clicked.y[UL] + clicked.y[LL])/2.0;
y_max = (clicked.y[UR] + clicked.y[LR])/2.0;

}


// When evdev detects an invert_X/Y option,
// it performs the following *crazy* code just before returning
Expand All @@ -218,13 +230,6 @@ bool CalibratorEvdev::finish(int width, int height)
// end of evdev inversion crazyness


// Should x and y be swapped?
if (abs(clicked.x[UL] - clicked.x[UR]) < abs(clicked.y[UL] - clicked.y[UR])) {
new_axis.swap_xy = !new_axis.swap_xy;
std::swap(x_min, y_min);
std::swap(x_max, y_max);
}

// the screen was divided in num_blocks blocks, and the touch points were at
// one block away from the true edges of the screen.
const float block_x = width/(float)num_blocks;
Expand Down