• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine 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

Revision496d4401731c6e5ed550e446cc2fc4b12d999ad8 (tree)
Zeit2010-03-01 07:14:10
AutorTias Guns <tias@ulys...>
CommiterTias Guns

Log Message

rudimentary mis-click GUI for x11

Ändern Zusammenfassung

Diff

--- a/src/calibrator.cpp
+++ b/src/calibrator.cpp
@@ -46,6 +46,7 @@ int Calibrator::get_numclicks()
4646 bool Calibrator::add_click(int x, int y)
4747 {
4848 // Double-click detection
49+ // actually, it is still possible to click on a previous point
4950 if (num_clicks > 0 && threshold_doubleclick > 0
5051 && abs (x - clicked_x[num_clicks-1]) < threshold_doubleclick
5152 && abs (y - clicked_y[num_clicks-1]) < threshold_doubleclick) {
@@ -57,6 +58,8 @@ bool Calibrator::add_click(int x, int y)
5758 }
5859
5960 // Mis-click detection, check second and third point with first point
61+ // actually, check that different axes...
62+ // and check that threshold_misclick > 0
6063 if ((num_clicks == 1 || num_clicks == 2) &&
6164 (abs (x - clicked_x[0]) > threshold_misclick
6265 && abs (x - clicked_y[0]) > threshold_misclick
--- a/src/gui/gui_x11.cpp
+++ b/src/gui/gui_x11.cpp
@@ -95,6 +95,7 @@ protected:
9595
9696 // Helper functions
9797 void redraw();
98+ void draw_message(const char* msg);
9899
99100 private:
100101 static GuiCalibratorX11* instance;
@@ -261,14 +262,22 @@ bool GuiCalibratorX11::on_timer_signal()
261262
262263 bool GuiCalibratorX11::on_button_press_event(XEvent event)
263264 {
265+ // Clear window, maybe a bit overdone, but easiest for me atm.
266+ // (goal is to clear possible message and other clicks)
267+ XClearWindow(display, win);
268+
264269 // Handle click
265270 time_elapsed = 0;
266- calibrator->add_click(event.xbutton.x, event.xbutton.y);
271+ bool success = calibrator->add_click(event.xbutton.x, event.xbutton.y);
272+
273+ if (!success && calibrator->get_numclicks() == 0) {
274+ draw_message("Mis-click detected, restarting...");
275+ }
267276
268277 // Are we done yet?
269278 if (calibrator->get_numclicks() >= 4) {
270279 // Recalibrate
271- bool success = calibrator->finish(display_width, display_height);
280+ success = calibrator->finish(display_width, display_height);
272281
273282 if (success) {
274283 exit(0);
@@ -285,6 +294,21 @@ bool GuiCalibratorX11::on_button_press_event(XEvent event)
285294 return true;
286295 }
287296
297+void GuiCalibratorX11::draw_message(const char* msg)
298+{
299+ int text_height = font_info->ascent + font_info->descent;
300+ int text_width = XTextWidth(font_info, msg, strlen(msg));
301+
302+ int x = (display_width - text_width) / 2;
303+ int y = (display_height - text_height) / 2 + clock_radius + 60;
304+ XSetForeground(display, gc, pixel[BLACK]);
305+ XSetLineAttributes(display, gc, 2, LineSolid, CapRound, JoinRound);
306+ XDrawRectangle(display, win, gc, x - 10, y - text_height - 10,
307+ text_width + 20, text_height + 25);
308+
309+ XDrawString(display, win, gc, x, y, msg, strlen(msg));
310+}
311+
288312 void GuiCalibratorX11::give_timer_signal()
289313 {
290314 if (instance != NULL) {