From e0eb1015bf30fd0913db571b000ba6a83ea22660 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Thu, 29 Jul 2010 15:54:31 +0200 Subject: Split the code into recognizer and inserter Refactor code to make more room for gesture recognition. Also simplify public headers. Signed-off-by: Henrik Rydberg --- src/gesture-client.c | 113 --------------------------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 src/gesture-client.c (limited to 'src/gesture-client.c') diff --git a/src/gesture-client.c b/src/gesture-client.c deleted file mode 100644 index 91f1530..0000000 --- a/src/gesture-client.c +++ /dev/null @@ -1,113 +0,0 @@ -/***************************************************************************** - * - * grail - Gesture Recognition And Instantiation Library - * - * Copyright (C) 2010 Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - * Authors: - * Henrik Rydberg - * - ****************************************************************************/ - -#include -#include -#include -#include -#include "gebuf.h" - -#define GESTURE_GAP (1000 * 60 * 60) - -struct client_impl { - enum gesture_state state; - touch_time_t begin, end; - struct gebuf buf; -}; - -int client_init(struct gesture_client *client, void *priv) -{ - struct client_impl *x; - memset(client, 0, sizeof(*client)); - x = calloc(DIM_GESTURE_TYPE, sizeof(*x)); - if (!x) - return -ENOMEM; - client->impl = x; - client->priv = priv; - return 0; -} - -void client_flag(struct gesture_client *client, - const struct gesture_flag *flag) -{ - if (client->priority[flag->type]) { - struct client_impl *x = &client->impl[flag->type]; - switch(flag->state) { - case GS_BEGIN: - x->begin = flag->time; - x->end = flag->time + GESTURE_GAP; - break; - case GS_CANCEL: - x->end = x->begin; - break; - case GS_END: - x->end = flag->time; - break; - } - x->state = flag->state; - } -} - -void client_event(struct gesture_client *client, - const struct gesture_event *ev) -{ - if (client->priority[ev->type]) { - struct client_impl *x = &client->impl[ev->type]; - gebuf_put(&x->buf, ev); - } -} - -void client_sync(struct gesture_client *client) -{ - struct gesture_event ev; - struct client_impl *x = client->impl; - int i, prio = 0; - for (i = 0; i < DIM_GESTURE_TYPE; i++) { - if (x[i].begin != x[i].end) { - if (client->priority[i] > prio) - prio = client->priority[i]; - } - } - for (i = 0; i < DIM_GESTURE_TYPE; i++) { - if (client->priority[i] < prio) { - gebuf_clear(&x[i].buf); - } else if (prio && client->gesture) { - if (x[i].state == GS_END) { - while (!gebuf_empty(&x[i].buf)) { - gebuf_get(&x[i].buf, &ev); - client->gesture(client, &ev); - } - } - } - } - for (i = 0; i < DIM_GESTURE_TYPE; i++) - if (x[i].state == GS_END) - x[i].begin = x[i].end; -} - -void client_destroy(struct gesture_client *client) -{ - free(client->impl); - memset(client, 0, sizeof(*client)); -} -- cgit v1.2.3