From 011634a6f8df4fb6b6c24dc173680b96c7fb16f1 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Mon, 1 Feb 2010 20:26:21 +0100 Subject: button: simplify button handling Make better use of the bit representation, reducing one layer of conversion. --- src/gestures.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/gestures.c') diff --git a/src/gestures.c b/src/gestures.c index 89dad1a..0b0ba1d 100644 --- a/src/gestures.c +++ b/src/gestures.c @@ -57,14 +57,8 @@ void extract_gestures(struct Gestures *gs, struct MTouch* mt) if (nsf == 3) mt->ns.button = BITMASK(MT_BUTTON_MIDDLE); } - for (i = 0; i < DIM_BUTTON; i++) { - if (GETBIT(mt->ns.button, i) != GETBIT(mt->os.button, i)) { - SETBIT(gs->type, GS_BUTTON); - gs->btix[gs->nbt] = i + 1; - gs->btval[gs->nbt] = GETBIT(mt->ns.button, i); - gs->nbt++; - } - } + gs->btmask = (mt->ns.button ^ mt->os.button) & BITONES(DIM_BUTTON); + gs->btdata = mt->ns.button & BITONES(DIM_BUTTON); mt->os = mt->ns; } -- cgit v1.2.3