A generic touchscreen calibration program for X.Org
Revision | c8701d10faaa1389f7f56680b427981a7c12f73a (tree) |
---|---|
Time | 2012-03-09 08:51:57 |
Author | Antoine Hue <antoine@peti...> |
Commiter | Tias Guns |
Some refactoring of the Calibrator object
Make find_device a static function of Calibrator, and move some
functions around
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>
@@ -41,26 +41,6 @@ Calibrator::Calibrator(const char* const device_name0, const XYinfo& axys0, | ||
41 | 41 | //clicked.y(NUM_POINTS); |
42 | 42 | } |
43 | 43 | |
44 | -void Calibrator::set_threshold_doubleclick(int t) | |
45 | -{ | |
46 | - threshold_doubleclick = t; | |
47 | -} | |
48 | - | |
49 | -void Calibrator::set_threshold_misclick(int t) | |
50 | -{ | |
51 | - threshold_misclick = t; | |
52 | -} | |
53 | - | |
54 | -int Calibrator::get_numclicks() | |
55 | -{ | |
56 | - return clicked.num; | |
57 | -} | |
58 | - | |
59 | -const char* Calibrator::get_geometry() | |
60 | -{ | |
61 | - return geometry; | |
62 | -} | |
63 | - | |
64 | 44 | bool Calibrator::add_click(int x, int y) |
65 | 45 | { |
66 | 46 | // Double-click detection |
@@ -122,16 +122,20 @@ public: | ||
122 | 122 | ~Calibrator() {} |
123 | 123 | |
124 | 124 | /// set the doubleclick treshold |
125 | - void set_threshold_doubleclick(int t); | |
125 | + void set_threshold_doubleclick(int t) | |
126 | + { threshold_doubleclick = t; } | |
126 | 127 | |
127 | 128 | /// set the misclick treshold |
128 | - void set_threshold_misclick(int t); | |
129 | + void set_threshold_misclick(int t) | |
130 | + { threshold_misclick = t; } | |
129 | 131 | |
130 | 132 | /// get the number of clicks already registered |
131 | - int get_numclicks(); | |
133 | + int get_numclicks() const | |
134 | + { return clicked.num; } | |
132 | 135 | |
133 | 136 | /// return geometry string or NULL |
134 | - const char* get_geometry(); | |
137 | + const char* get_geometry() const | |
138 | + { return geometry; } | |
135 | 139 | |
136 | 140 | /// reset clicks |
137 | 141 | void reset() |
@@ -146,17 +150,32 @@ public: | ||
146 | 150 | const char* get_sysfs_name(); |
147 | 151 | |
148 | 152 | protected: |
149 | - // check whether the coordinates are along the respective axis | |
153 | + /// check whether the coordinates are along the respective axis | |
150 | 154 | bool along_axis(int xy, int x0, int y0); |
151 | 155 | |
152 | - // overloaded function that applies the new calibration | |
156 | + /// Apply new calibration, implementation dependent | |
153 | 157 | virtual bool finish_data(const XYinfo new_axys) =0; |
154 | 158 | |
155 | - // name of the device (driver) | |
159 | + /// Compute calibration on 1 axis | |
160 | + void process_axys( int screen_dim, const AxisInfo &previous, std::vector<int> &clicked, AxisInfo &updated ); | |
161 | + | |
162 | + /// Check whether the given name is a sysfs device name | |
163 | + bool is_sysfs_name(const char* name); | |
164 | + | |
165 | + /// Check whether the X server has xorg.conf.d support | |
166 | + bool has_xorgconfd_support(Display* display=NULL); | |
167 | + | |
168 | + static int find_device(const char* pre_device, bool verbose, bool list_devices, | |
169 | + XID& device_id, const char*& device_name, XYinfo& device_axys); | |
170 | + | |
171 | +protected: | |
172 | + /// Name of the device (driver) | |
156 | 173 | const char* const device_name; |
157 | - // original axys values | |
174 | + | |
175 | + /// Original values | |
158 | 176 | XYinfo old_axys; |
159 | - // be verbose or not | |
177 | + | |
178 | + /// Be verbose or not | |
160 | 179 | bool verbose; |
161 | 180 | |
162 | 181 | /// Clicked values (screen coordinates) |
@@ -181,12 +200,6 @@ protected: | ||
181 | 200 | |
182 | 201 | // manually specified geometry string |
183 | 202 | const char* geometry; |
184 | - | |
185 | - // Check whether the given name is a sysfs device name | |
186 | - bool is_sysfs_name(const char* name); | |
187 | - | |
188 | - // Check whether the X server has xorg.conf.d support | |
189 | - bool has_xorgconfd_support(Display* display=NULL); | |
190 | 203 | }; |
191 | 204 | |
192 | 205 | #endif |
@@ -54,7 +54,7 @@ static char* my_strdup(const char* s) { | ||
54 | 54 | * retuns number of devices found, |
55 | 55 | * the data of the device is returned in the last 3 function parameters |
56 | 56 | */ |
57 | -static int find_device(const char* pre_device, bool verbose, bool list_devices, | |
57 | +int Calibrator::find_device(const char* pre_device, bool verbose, bool list_devices, | |
58 | 58 | XID& device_id, const char*& device_name, XYinfo& device_axys) |
59 | 59 | { |
60 | 60 | bool pre_device_is_id = true; |