From 3ba12634383a0939e6a7e5f8faa0396686914957 Mon Sep 17 00:00:00 2001 From: Rusty Lynch Date: Thu, 8 Aug 2013 21:24:19 -0700 Subject: [PATCH] calibrator: Add touch support to calibrator --- clients/calibrator.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/clients/calibrator.c b/clients/calibrator.c index cc6f4edd..781475e8 100644 --- a/clients/calibrator.c +++ b/clients/calibrator.c @@ -162,6 +162,22 @@ button_handler(struct widget *widget, widget_schedule_redraw(widget); } +static void +touch_handler(struct widget *widget, uint32_t serial, uint32_t time, + int32_t id, float x, float y, void *data) +{ + struct calibrator *calibrator = data; + + calibrator->tests[calibrator->current_test].clicked_x = x; + calibrator->tests[calibrator->current_test].clicked_y = y; + calibrator->current_test--; + + if (calibrator->current_test < 0) + finish_calibration(calibrator); + + widget_schedule_redraw(widget); +} + static void redraw_handler(struct widget *widget, void *data) { @@ -216,6 +232,7 @@ calibrator_create(struct display *display) calibrator->current_test = ARRAY_LENGTH(test_ratios) - 1; widget_set_button_handler(calibrator->widget, button_handler); + widget_set_touch_down_handler(calibrator->widget, touch_handler); widget_set_redraw_handler(calibrator->widget, redraw_handler); window_set_fullscreen(calibrator->window, 1);