summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-04-10 23:18:02 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-04-15 06:10:07 +0200
commit030f4fdbe44d1af41c55cdda5baf71ba3225829f (patch)
tree8e5c28b70fbdd3fe0ce5a3e55a0b4b39ef65de83 /src
parent32d5f821c5bbefc6eae2319209288ec74079529a (diff)
Keep logical buttons separate from the hardware ones
The button extraction currently modifies the MTState buttons, upsetting the semantics in a bad way. This patch adds the logical button state to the Memory structure, and uses it to compute the logical button change. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-rw-r--r--src/gestures.c12
-rw-r--r--src/memory.c1
-rw-r--r--src/memory.h1
3 files changed, 10 insertions, 4 deletions
diff --git a/src/gestures.c b/src/gestures.c
index c837d6c..e032214 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -50,16 +50,20 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt)
50 50
51static void extract_buttons(struct Gestures *gs, struct MTouch* mt) 51static void extract_buttons(struct Gestures *gs, struct MTouch* mt)
52{ 52{
53 unsigned btdata = mt->state.button & BITONES(DIM_BUTTON);
53 if (mt->state.button == BITMASK(MT_BUTTON_LEFT)) { 54 if (mt->state.button == BITMASK(MT_BUTTON_LEFT)) {
54 if (mt->state.nfinger == 2) 55 if (mt->state.nfinger == 2)
55 mt->state.button = BITMASK(MT_BUTTON_RIGHT); 56 btdata = BITMASK(MT_BUTTON_RIGHT);
56 if (mt->state.nfinger == 3) 57 if (mt->state.nfinger == 3)
57 mt->state.button = BITMASK(MT_BUTTON_MIDDLE); 58 btdata = BITMASK(MT_BUTTON_MIDDLE);
58 } 59 }
59 gs->btmask = (mt->state.button ^ mt->prev_state.button) & BITONES(DIM_BUTTON); 60 gs->btmask = (btdata ^ mt->mem.btdata) & BITONES(DIM_BUTTON);
60 gs->btdata = mt->state.button & BITONES(DIM_BUTTON); 61 gs->btdata = btdata;
62 mt->mem.btdata = btdata;
61} 63}
62 64
65/******************************************************/
66
63static void extract_type(struct Gestures *gs, struct MTouch* mt) 67static void extract_type(struct Gestures *gs, struct MTouch* mt)
64{ 68{
65 if (gs->dx || gs->dy) { 69 if (gs->dx || gs->dy) {
diff --git a/src/memory.c b/src/memory.c
index 6b502d8..b213694 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -23,4 +23,5 @@
23 23
24void init_memory(struct Memory *mem) 24void init_memory(struct Memory *mem)
25{ 25{
26 memset(mem, 0, sizeof(struct Memory));
26} 27}
diff --git a/src/memory.h b/src/memory.h
index 46dd312..a6c51ec 100644
--- a/src/memory.h
+++ b/src/memory.h
@@ -25,6 +25,7 @@
25#include "mtstate.h" 25#include "mtstate.h"
26 26
27struct Memory { 27struct Memory {
28 unsigned btdata;
28}; 29};
29 30
30void init_memory(struct Memory *mem); 31void init_memory(struct Memory *mem);