Closed SimonHyde-BBC closed 8 months ago
Hi, thank for the patch.
I don't have hardware to test it, but my impression is that the "post-scaling" should be done more easily inside the add_click() lambda:
gui.set_add_click([&](int x, int y) -> bool{
auto x1 = (x - monitor_x)/monitor_width * overall_width;
auto y1 = (y - monitor_y)/monitor_height * overall_height;
return calib.add_click(x1, y1);
});
without touching the Calibration class.
That tweak would be even simpler than that, as the x/y coming from gui_x11 are already relative to the window, and therefore you don't need to subtract monitor_x or monitor_y, but:
I created the multimonitor branch. I started from your code but I removed the change inside calibrator.*. I tested it and to me seems that it behaves like your code. But if you can test it too, it would be really appreciated.
In the log I give you the credit for the idea and for the original code. Let me know if it is OK for you.
This didn't work with any monitor with a rotated or flipped touchscreen, producing an incorrect translation, but it seems swapping the matrix product the other way around resolves all that. See my new pull request: https://github.com/kreijack/xlibinput_calibrator/pull/14
Multiple monitors with different resolutions wouldn't work, because clicks were generated with odd values in corners where no monitor existed. This fixes the calibration so it works correctly on a single monitor on multi-monitor setups