diff options
author | Henrik Rydberg <rydberg@alnilam.(none)> | 2010-02-01 20:19:45 +0100 |
---|---|---|
committer | Henrik Rydberg <rydberg@alnilam.(none)> | 2010-02-01 20:44:42 +0100 |
commit | a7eb5d7a955a2b90ebfbeb5177c3d01e5c287e30 (patch) | |
tree | bc9777c1767c95f3c89056847fd6d4b26a8e0152 /src | |
parent | 8dcaab4219c3827c0661917542a28b1276703d8b (diff) |
common: add some more bit utilities
Diffstat (limited to 'src')
-rw-r--r-- | src/common.h | 8 | ||||
-rw-r--r-- | src/gestures.c | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/common.h b/src/common.h index f9d9f77..b1c3273 100644 --- a/src/common.h +++ b/src/common.h @@ -54,9 +54,11 @@ #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) -#define GETBIT(m, x) ((m>>(x))&1U) -#define SETBIT(m, x) (m|=(1U<<(x))) -#define CLEARBIT(m, x) (m&=~(1U<<(x))) +#define BITMASK(x) (1U << (x)) +#define BITONES(x) (BITMASK(x) - 1U) +#define GETBIT(m, x) (((m) >> (x)) & 1U) +#define SETBIT(m, x) (m |= BITMASK(x)) +#define CLEARBIT(m, x) (m &= ~BITMASK(x)) //////////////////////////////////////////////////////// diff --git a/src/gestures.c b/src/gestures.c index 8ba32f3..89dad1a 100644 --- a/src/gestures.c +++ b/src/gestures.c @@ -51,11 +51,11 @@ void extract_gestures(struct Gestures *gs, struct MTouch* mt) if (nsf == 3) SETBIT(gs->type, GS_HSCROLL); } - if (mt->ns.button == (1U << MT_BUTTON_LEFT)) { + if (mt->ns.button == BITMASK(MT_BUTTON_LEFT)) { if (nsf == 2) - mt->ns.button = (1U << MT_BUTTON_RIGHT); + mt->ns.button = BITMASK(MT_BUTTON_RIGHT); if (nsf == 3) - mt->ns.button = (1U << MT_BUTTON_MIDDLE); + 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)) { |