A generic touchscreen calibration program for X.Org
修订版 | 76ab69cd863a70bb941e8d8ea5b7f5bd20b36705 (tree) |
---|---|
时间 | 2014-02-14 07:10:12 |
作者 | Tias Guns <tias@ulys...> |
Commiter | Tias Guns |
Merge pull request #58 from austriancoder/master
Some small fixes
@@ -193,7 +193,7 @@ protected: | ||
193 | 193 | bool along_axis(int xy, int x0, int y0); |
194 | 194 | |
195 | 195 | /// Apply new calibration, implementation dependent |
196 | - virtual bool finish_data(const XYinfo new_axys) =0; | |
196 | + virtual bool finish_data(const XYinfo &new_axys) =0; | |
197 | 197 | |
198 | 198 | /// Check whether the given name is a sysfs device name |
199 | 199 | bool is_sysfs_name(const char* name); |
@@ -258,7 +258,7 @@ bool CalibratorEvdev::finish(int width, int height) | ||
258 | 258 | } |
259 | 259 | |
260 | 260 | // Activate calibrated data and output it |
261 | -bool CalibratorEvdev::finish_data(const XYinfo new_axys) | |
261 | +bool CalibratorEvdev::finish_data(const XYinfo &new_axys) | |
262 | 262 | { |
263 | 263 | bool success = true; |
264 | 264 |
@@ -336,7 +336,7 @@ bool CalibratorEvdev::set_invert_xy(const int invert_x, const int invert_y) | ||
336 | 336 | arr_cmd[0] = invert_x; |
337 | 337 | arr_cmd[1] = invert_y; |
338 | 338 | |
339 | - int ret = xinput_do_set_int_prop("Evdev Axis Inversion", display, 8, 2, arr_cmd); | |
339 | + bool ret = xinput_do_set_int_prop("Evdev Axis Inversion", display, 8, 2, arr_cmd); | |
340 | 340 | |
341 | 341 | if (verbose) { |
342 | 342 | if (ret == true) |
@@ -359,7 +359,7 @@ bool CalibratorEvdev::set_calibration(const XYinfo new_axys) | ||
359 | 359 | arr_cmd[2] = new_axys.y.min; |
360 | 360 | arr_cmd[3] = new_axys.y.max; |
361 | 361 | |
362 | - int ret = xinput_do_set_int_prop("Evdev Axis Calibration", display, 32, 4, arr_cmd); | |
362 | + bool ret = xinput_do_set_int_prop("Evdev Axis Calibration", display, 32, 4, arr_cmd); | |
363 | 363 | |
364 | 364 | if (verbose) { |
365 | 365 | if (ret == true) |
@@ -64,7 +64,7 @@ public: | ||
64 | 64 | |
65 | 65 | /// calculate and apply the calibration |
66 | 66 | virtual bool finish(int width, int height); |
67 | - virtual bool finish_data(const XYinfo new_axys); | |
67 | + virtual bool finish_data(const XYinfo &new_axys); | |
68 | 68 | |
69 | 69 | bool set_swapxy(const int swap_xy); |
70 | 70 | bool set_invert_xy(const int invert_x, const int invert_y); |
@@ -31,7 +31,7 @@ CalibratorEvdevTester::CalibratorEvdevTester(const char* const device_name0, con | ||
31 | 31 | //printf("Starting test driver\n"); |
32 | 32 | } |
33 | 33 | |
34 | -bool CalibratorEvdevTester::finish_data(const XYinfo axis) | |
34 | +bool CalibratorEvdevTester::finish_data(const XYinfo &axis) | |
35 | 35 | { |
36 | 36 | new_axis = axis; |
37 | 37 |
@@ -41,7 +41,7 @@ public: | ||
41 | 41 | const int thr_misclick=0, const int thr_doubleclick=0, |
42 | 42 | const OutputType output_type=OUTYPE_AUTO, const char* geometry=0); |
43 | 43 | |
44 | - virtual bool finish_data(const XYinfo new_axis); | |
44 | + virtual bool finish_data(const XYinfo &new_axis); | |
45 | 45 | |
46 | 46 | // emulate the driver processing the coordinates in 'raw' |
47 | 47 | virtual XYinfo emulate_driver(const XYinfo& raw, bool useNewAxis, const XYinfo& screen, const XYinfo& device); |
@@ -30,7 +30,7 @@ CalibratorTester::CalibratorTester(const char* const device_name0, const XYinfo& | ||
30 | 30 | //printf("Starting test driver\n"); |
31 | 31 | } |
32 | 32 | |
33 | -bool CalibratorTester::finish_data(const XYinfo axis) | |
33 | +bool CalibratorTester::finish_data(const XYinfo &axis) | |
34 | 34 | { |
35 | 35 | new_axis = axis; |
36 | 36 |
@@ -40,7 +40,7 @@ public: | ||
40 | 40 | const int thr_misclick=0, const int thr_doubleclick=0, |
41 | 41 | const OutputType output_type=OUTYPE_AUTO, const char* geometry=0); |
42 | 42 | |
43 | - virtual bool finish_data(const XYinfo new_axis); | |
43 | + virtual bool finish_data(const XYinfo &new_axis); | |
44 | 44 | |
45 | 45 | // emulate the driver processing the coordinates in 'raw' |
46 | 46 | virtual XYinfo emulate_driver(const XYinfo& raw, |
@@ -77,7 +77,7 @@ CalibratorUsbtouchscreen::~CalibratorUsbtouchscreen() | ||
77 | 77 | write_bool_parameter (p_swap_xy, val_swap_xy); |
78 | 78 | } |
79 | 79 | |
80 | -bool CalibratorUsbtouchscreen::finish_data(const XYinfo new_axys) | |
80 | +bool CalibratorUsbtouchscreen::finish_data(const XYinfo &new_axys) | |
81 | 81 | { |
82 | 82 | if (output_type != OUTYPE_AUTO) { |
83 | 83 | fprintf(stderr, "ERROR: Usbtouchscreen Calibrator does not support the supplied --output-type\n"); |
@@ -38,7 +38,7 @@ public: | ||
38 | 38 | const bool use_timeout=false, const char* output_filename = 0); |
39 | 39 | virtual ~CalibratorUsbtouchscreen(); |
40 | 40 | |
41 | - virtual bool finish_data(const XYinfo new_axys); | |
41 | + virtual bool finish_data(const XYinfo &new_axys); | |
42 | 42 | |
43 | 43 | protected: |
44 | 44 | // Globals for kernel parameters from startup. |
@@ -33,7 +33,7 @@ CalibratorXorgPrint::CalibratorXorgPrint(const char* const device_name0, const X | ||
33 | 33 | printf("\tIf these values are estimated wrong, either supply it manually with the --precalib option, or run the 'get_precalib.sh' script to automatically get it (through HAL).\n"); |
34 | 34 | } |
35 | 35 | |
36 | -bool CalibratorXorgPrint::finish_data(const XYinfo new_axys) | |
36 | +bool CalibratorXorgPrint::finish_data(const XYinfo &new_axys) | |
37 | 37 | { |
38 | 38 | bool success = true; |
39 | 39 |
@@ -37,7 +37,7 @@ public: | ||
37 | 37 | const OutputType output_type=OUTYPE_AUTO, const char* geometry=0, |
38 | 38 | const bool use_timeout=false, const char* output_filename = 0); |
39 | 39 | |
40 | - virtual bool finish_data(const XYinfo new_axys); | |
40 | + virtual bool finish_data(const XYinfo &new_axys); | |
41 | 41 | |
42 | 42 | protected: |
43 | 43 | bool output_xorgconfd(const XYinfo new_axys); |
@@ -36,7 +36,7 @@ class CalibrationArea : public Gtk::DrawingArea | ||
36 | 36 | public: |
37 | 37 | CalibrationArea(Calibrator* w); |
38 | 38 | |
39 | -protected: | |
39 | +private: | |
40 | 40 | // Data |
41 | 41 | Calibrator* calibrator; |
42 | 42 | double X[4], Y[4]; |
@@ -270,14 +270,12 @@ void GuiCalibratorX11::redraw() | ||
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | -bool GuiCalibratorX11::on_expose_event() | |
273 | +void GuiCalibratorX11::on_expose_event() | |
274 | 274 | { |
275 | 275 | redraw(); |
276 | - | |
277 | - return true; | |
278 | 276 | } |
279 | 277 | |
280 | -bool GuiCalibratorX11::on_timer_signal() | |
278 | +void GuiCalibratorX11::on_timer_signal() | |
281 | 279 | { |
282 | 280 | // Update clock |
283 | 281 | if(calibrator->get_use_timeout()) { |
@@ -295,11 +293,9 @@ bool GuiCalibratorX11::on_timer_signal() | ||
295 | 293 | clock_radius-clock_line_width, clock_radius-clock_line_width, |
296 | 294 | 90*64, ((double)time_elapsed/(double)max_time) * -360 * 64); |
297 | 295 | } |
298 | - | |
299 | - return true; | |
300 | 296 | } |
301 | 297 | |
302 | -bool GuiCalibratorX11::on_button_press_event(XEvent event) | |
298 | +void GuiCalibratorX11::on_button_press_event(XEvent event) | |
303 | 299 | { |
304 | 300 | // Clear window, maybe a bit overdone, but easiest for me atm. |
305 | 301 | // (goal is to clear possible message and other clicks) |
@@ -329,8 +325,6 @@ bool GuiCalibratorX11::on_button_press_event(XEvent event) | ||
329 | 325 | |
330 | 326 | // Force a redraw |
331 | 327 | redraw(); |
332 | - | |
333 | - return true; | |
334 | 328 | } |
335 | 329 | |
336 | 330 | void GuiCalibratorX11::draw_message(const char* msg) |
@@ -35,7 +35,7 @@ public: | ||
35 | 35 | static void make_instance(Calibrator* w); |
36 | 36 | static void give_timer_signal(); |
37 | 37 | |
38 | -protected: | |
38 | +private: | |
39 | 39 | GuiCalibratorX11(Calibrator* w); |
40 | 40 | ~GuiCalibratorX11(); |
41 | 41 |
@@ -63,16 +63,15 @@ protected: | ||
63 | 63 | unsigned long pixel[NUM_COLORS]; |
64 | 64 | |
65 | 65 | // Signal handlers |
66 | - bool on_timer_signal(); | |
67 | - bool on_expose_event(); | |
68 | - bool on_button_press_event(XEvent event); | |
66 | + void on_timer_signal(); | |
67 | + void on_expose_event(); | |
68 | + void on_button_press_event(XEvent event); | |
69 | 69 | |
70 | 70 | // Helper functions |
71 | 71 | void set_display_size(int width, int height); |
72 | 72 | void redraw(); |
73 | 73 | void draw_message(const char* msg); |
74 | 74 | |
75 | -private: | |
76 | 75 | static GuiCalibratorX11* instance; |
77 | 76 | }; |
78 | 77 |
@@ -117,4 +117,6 @@ int main() { | ||
117 | 117 | |
118 | 118 | printf("\n"); |
119 | 119 | } // loop over calibrators |
120 | + | |
121 | + delete calib; | |
120 | 122 | } |