A generic touchscreen calibration program for X.Org
Revisão | faeca8a6d473d30592cf5184cbee130a06d6dc28 (tree) |
---|---|
Hora | 2012-03-09 08:51:58 |
Autor | Antoine Hue <antoine@peti...> |
Commiter | Tias Guns |
Various remaining cleanups from Antoine
This patch was originally part of Antoine Hue's commit with message
Managing correctly X/Y swap and X or Y inversion: - detect swap and
inversion modification - take into account for inversion in calibration
computation since Evdev is doing inversion after calibration. - Mainly
tested for Evdev based driver. To be tested for USB.
Signed-off-by: Tias Guns <tias@ulyssis.org>
@@ -26,7 +26,6 @@ | ||
26 | 26 | |
27 | 27 | #include <X11/Xlib.h> |
28 | 28 | #include <X11/Xatom.h> |
29 | -//#include <X11/Xutil.h> | |
30 | 29 | #include <ctype.h> |
31 | 30 | #include <cstdio> |
32 | 31 | #include <cstring> |
@@ -39,6 +38,7 @@ | ||
39 | 38 | #define EXIT_FAILURE 0 |
40 | 39 | #endif |
41 | 40 | |
41 | +// Constructor | |
42 | 42 | CalibratorEvdev::CalibratorEvdev(const char* const device_name0, |
43 | 43 | const XYinfo& axys0, |
44 | 44 | XID device_id, |
@@ -56,12 +56,12 @@ CalibratorEvdev::CalibratorEvdev(const char* const device_name0, | ||
56 | 56 | |
57 | 57 | // normaly, we already have the device id |
58 | 58 | if (device_id == (XID)-1) { |
59 | - info = xinput_find_device_info(display, device_name, False); | |
60 | - if (!info) { | |
59 | + devInfo = xinput_find_device_info(display, device_name, False); | |
60 | + if (!devInfo) { | |
61 | 61 | XCloseDisplay(display); |
62 | 62 | throw WrongCalibratorException("Evdev: Unable to find device"); |
63 | 63 | } |
64 | - device_id = info->id; | |
64 | + device_id = devInfo->id; | |
65 | 65 | } |
66 | 66 | |
67 | 67 | dev = XOpenDevice(display, device_id); |
@@ -103,7 +103,7 @@ CalibratorEvdev::CalibratorEvdev(const char* const device_name0, | ||
103 | 103 | |
104 | 104 | // No axis calibration set, set it to the default one |
105 | 105 | // QUIRK: when my machine resumes from a sleep, |
106 | - // the calibration property is no longer exported thourgh xinput, but still active | |
106 | + // the calibration property is no longer exported through xinput, but still active | |
107 | 107 | // not setting the values here would result in a wrong first calibration |
108 | 108 | (void) set_calibration(old_axys); |
109 | 109 |
@@ -161,11 +161,13 @@ CalibratorEvdev::CalibratorEvdev(const char* const device_name0, | ||
161 | 161 | |
162 | 162 | } |
163 | 163 | |
164 | +// Destructor | |
164 | 165 | CalibratorEvdev::~CalibratorEvdev () { |
165 | 166 | XCloseDevice(display, dev); |
166 | 167 | XCloseDisplay(display); |
167 | 168 | } |
168 | 169 | |
170 | +// Activate calibrated data and output it | |
169 | 171 | bool CalibratorEvdev::finish_data(const XYinfo new_axys) |
170 | 172 | { |
171 | 173 | bool success = true; |
@@ -188,9 +190,7 @@ bool CalibratorEvdev::finish_data(const XYinfo new_axys) | ||
188 | 190 | // close |
189 | 191 | XSync(display, False); |
190 | 192 | |
191 | - | |
192 | - | |
193 | - printf("\n\n--> Making the calibration permanent <--\n"); | |
193 | + printf("\t--> Making the calibration permanent <--\n"); | |
194 | 194 | switch (output_type) { |
195 | 195 | case OUTYPE_AUTO: |
196 | 196 | // xorg.conf.d or alternatively xinput commands |
@@ -298,7 +298,8 @@ bool CalibratorEvdev::set_calibration(const XYinfo new_axys) | ||
298 | 298 | return (ret == EXIT_SUCCESS); |
299 | 299 | } |
300 | 300 | |
301 | -Atom CalibratorEvdev::xinput_parse_atom(Display *display, const char *name) { | |
301 | +Atom CalibratorEvdev::xinput_parse_atom(Display *display, const char *name) | |
302 | +{ | |
302 | 303 | Bool is_atom = True; |
303 | 304 | int i; |
304 | 305 |
@@ -345,9 +346,9 @@ Display *display, const char *name, Bool only_extended) | ||
345 | 346 | (is_id && devices[loop].id == id))) { |
346 | 347 | if (found) { |
347 | 348 | fprintf(stderr, |
348 | - "Warning: There are multiple devices named \"%s\".\n" | |
349 | - "To ensure the correct one is selected, please use " | |
350 | - "the device ID instead.\n\n", name); | |
349 | + "Warning: There are multiple devices named \"%s\".\n" | |
350 | + "To ensure the correct one is selected, please use " | |
351 | + "the device ID instead.\n\n", name); | |
351 | 352 | return NULL; |
352 | 353 | } else { |
353 | 354 | found = &devices[loop]; |
@@ -35,7 +35,7 @@ class CalibratorEvdev: public Calibrator | ||
35 | 35 | { |
36 | 36 | private: |
37 | 37 | Display *display; |
38 | - XDeviceInfo *info; | |
38 | + XDeviceInfo *devInfo; | |
39 | 39 | XDevice *dev; |
40 | 40 | |
41 | 41 | public: |
@@ -37,7 +37,7 @@ bool CalibratorXorgPrint::finish_data(const XYinfo new_axys) | ||
37 | 37 | { |
38 | 38 | bool success = true; |
39 | 39 | |
40 | - printf("\n\n--> Making the calibration permanent <--\n"); | |
40 | + printf("\t--> Making the calibration permanent <--\n"); | |
41 | 41 | switch (output_type) { |
42 | 42 | case OUTYPE_AUTO: |
43 | 43 | // xorg.conf.d or alternatively hal config |
@@ -314,7 +314,7 @@ Calibrator* Calibrator::make_calibrator(int argc, char** argv) | ||
314 | 314 | // printed the list in find_device |
315 | 315 | if (nr_found == 0) |
316 | 316 | printf("No calibratable devices found.\n"); |
317 | - exit(0); | |
317 | + exit(2); | |
318 | 318 | } |
319 | 319 | |
320 | 320 | if (nr_found == 0) { |