From e7d652c5efdb402a14a20cc3dbc7b3f084f5a47e Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Mon, 14 Feb 2011 13:05:19 +0100 Subject: Add set slot by touch id utility Signed-off-by: Henrik Rydberg --- include/utouch/frame.h | 11 +++++++++++ src/frame.c | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/utouch/frame.h b/include/utouch/frame.h index 5b5f4d2..03a44aa 100644 --- a/include/utouch/frame.h +++ b/include/utouch/frame.h @@ -249,6 +249,17 @@ struct utouch_contact *utouch_frame_get_current_slot(utouch_frame_handle fh); */ int utouch_frame_set_current_slot(utouch_frame_handle fh, int slot); +/** + * utouch_frame_set_current_id - set the current slot by touch id + * @fh: the frame engine in use + * @id: the touch id + * + * Sets the slot currently being modified, by touch id. If the id is + * not currently in use (does not have an active slot), a new slot is + * assigned. Returns zero if successful, negative error otherwise. + */ +int utouch_frame_set_current_id(utouch_frame_handle fh, int id); + /** * utouch_frame_sync - synchronize and return new frame * @fh: the frame engine in use diff --git a/src/frame.c b/src/frame.c index e722adf..061b170 100644 --- a/src/frame.c +++ b/src/frame.c @@ -205,6 +205,26 @@ int utouch_frame_set_current_slot(utouch_frame_handle fh, int slot) return 0; } +int utouch_frame_set_current_id(utouch_frame_handle fh, int id) +{ + struct utouch_contact *t; + int i; + + for (i = 0; i < fh->num_slots; i++) { + t = fh->next->slots[i]; + if (t->id == id) + return utouch_frame_set_current_slot(fh, i); + } + for (i = 0; i < fh->num_slots; i++) { + t = fh->next->slots[i]; + if (t->id < 0) { + t->id = id; + return utouch_frame_set_current_slot(fh, i); + } + } + return -ENOMEM; +} + static void transform_slot(struct utouch_contact *slot, const struct utouch_surface *s) { -- cgit v1.2.3