• 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ón552ff156c5a993afa8471f197beedb869054f580 (tree)
Tiempo2012-06-19 06:33:52
AutorTias Guns <tias@ulys...>
CommiterTias Guns

Log Message

driver emulation implementation

Cambiar Resumen

Diferencia incremental

--- a/src/calibrator.hh
+++ b/src/calibrator.hh
@@ -30,6 +30,9 @@
3030 #include <stdio.h>
3131 #include <vector>
3232
33+int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
34+int scaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
35+
3336 /*
3437 * Number of blocks. We partition the screen into 'num_blocks' x 'num_blocks'
3538 * rectangles of equal size. We then ask the user to press points that are
@@ -93,6 +96,13 @@ struct XYinfo {
9396 swap_xy = !swap_xy;
9497 }
9598
99+ void do_xf86ScaleAxis(XYinfo& to, XYinfo& from) {
100+ x.min = xf86ScaleAxis(x.min, to.x.max, to.x.min, from.x.max, from.x.min);
101+ x.max = xf86ScaleAxis(x.max, to.x.max, to.x.min, from.x.max, from.x.min);
102+ y.min = xf86ScaleAxis(y.min, to.y.max, to.y.min, from.y.max, from.y.min);
103+ y.max = xf86ScaleAxis(y.max, to.y.max, to.y.min, from.y.max, from.y.min);
104+ }
105+
96106 void print(const char* xtra="\n") {
97107 printf("XYinfo: x.min=%i, x.max=%i, y.min=%i, y.max=%i, swap_xy=%i, invert_x=%i, invert_y=%i%s",
98108 x.min, x.max, y.min, y.max, swap_xy, x.invert, y.invert, xtra);
@@ -122,9 +132,6 @@ class WrongCalibratorException : public std::invalid_argument {
122132 std::invalid_argument(msg) {}
123133 };
124134
125-int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
126-int scaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
127-
128135 /// Base class for calculating new calibration parameters
129136 class Calibrator
130137 {
--- a/src/calibrator/Tester.cpp
+++ b/src/calibrator/Tester.cpp
@@ -37,7 +37,36 @@ bool CalibratorTester::finish_data(const XYinfo axis)
3737 return true;
3838 }
3939
40-XYinfo CalibratorTester::emulate_driver(XYinfo raw, bool useNewAxis) {
41- // filler
42- return XYinfo(0,0,0,0);
40+XYinfo CalibratorTester::emulate_driver(XYinfo& raw, bool useNewAxis, XYinfo screen, XYinfo device) {
41+ XYinfo calibAxis;
42+ if (useNewAxis)
43+ calibAxis = new_axis;
44+ else
45+ calibAxis = old_axys;
46+
47+ /**
48+ * The most simple and intuitive calibration implementation
49+ * if only all drivers sticked to this...
50+ * Note that axis inversion is automatically supported
51+ * by the ScaleAxis implementation (swapping max/min on
52+ * one axis will result in the inversion being calculated)
53+ */
54+
55+ // placeholder for the new coordinates
56+ XYinfo result(raw);
57+
58+ // swap coordinates if asked
59+ if (calibAxis.swap_xy) {
60+ result.x.min = raw.y.min;
61+ result.x.max = raw.y.max;
62+ result.y.min = raw.x.min;
63+ result.y.max = raw.x.max;
64+ }
65+
66+ result.do_xf86ScaleAxis(device, calibAxis);
67+
68+ // the last step is usually done by the X server,
69+ // or transparently somewhere on the way
70+ result.do_xf86ScaleAxis(screen, device);
71+ return result;
4372 }
--- a/src/calibrator/Tester.hpp
+++ b/src/calibrator/Tester.hpp
@@ -43,7 +43,7 @@ public:
4343 virtual bool finish_data(const XYinfo new_axis);
4444
4545 // emulate the driver processing the coordinates in 'raw'
46- XYinfo emulate_driver(XYinfo raw, bool useNewAxis);
46+ XYinfo emulate_driver(XYinfo& raw, bool useNewAxis, XYinfo screen, XYinfo device);
4747 };
4848
4949 #endif
--- a/src/tester.cpp
+++ b/src/tester.cpp
@@ -35,15 +35,15 @@ int main() {
3535 raw_coords.push_back( XYinfo(883, 233, 105, 783) );
3636 raw_coords.push_back( XYinfo(883, 233, 783, 105) );
3737
38- CalibratorTester calib("Tester", old_axis);
39-
4038 for (unsigned c=0; c != raw_coords.size(); c++) {
39+ CalibratorTester calib("Tester", old_axis);
40+
4141 XYinfo raw(raw_coords[c]);
4242 printf("Raw: "); raw.print();
4343
4444 // clicked from raw
45- XYinfo clicked = calib.emulate_driver(raw, false);//false=old_axis, screen_res, dev_res);
46- printf("Clicked: "); clicked.print();
45+ XYinfo clicked = calib.emulate_driver(raw, false, screen_res, dev_res);// false=old_axis
46+ //printf("\tClicked: "); clicked.print();
4747
4848 // emulate screen clicks
4949 calib.add_click(clicked.x.min, clicked.y.min);
@@ -53,7 +53,7 @@ int main() {
5353 calib.finish(width, height);
5454
5555 // test result
56- XYinfo result = calib.emulate_driver(raw, true); // true=new_axis
56+ XYinfo result = calib.emulate_driver(raw, true, screen_res, dev_res); // true=new_axis
5757
5858 if (abs(target.x.min - result.x.min) > slack ||
5959 abs(target.x.max - result.x.max) > slack ||