summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-03-21 14:54:15 +0100
committerHenrik Rydberg <rydberg@euromail.se>2010-03-21 14:59:09 +0100
commit0587ab0488c46b61d175793f2deedc3a7aa9b600 (patch)
tree6077295316cc1420a4cd5010a3772c460c759b75
parentc7ed4cec501f10479a98e380d760670312101136 (diff)
Add millisecond event times
Expand the (x, y) notion of the current hardware events to the more useful (x, y, t) notion. This patch was inspired by a gesture patch from Arturo Castro <arturo@openframeworks.cc>. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/hwdata.c9
-rw-r--r--src/hwdata.h4
-rw-r--r--src/state.c3
-rw-r--r--src/state.h1
4 files changed, 17 insertions, 0 deletions
diff --git a/src/hwdata.c b/src/hwdata.c
index e76bcd8..f204884 100644
--- a/src/hwdata.c
+++ b/src/hwdata.c
@@ -26,6 +26,14 @@ void init_hwdata(struct HWData *hw)
26 memset(hw, 0, sizeof(struct HWData)); 26 memset(hw, 0, sizeof(struct HWData));
27} 27}
28 28
29static mstime_t get_mstime()
30{
31 static const mstime_t ms = 1000;
32 struct timeval now;
33 gettimeofday(&now, NULL);
34 return now.tv_usec / ms + now.tv_sec * ms;
35}
36
29static void set_value(struct HWData *hw, int code, int value) 37static void set_value(struct HWData *hw, int code, int value)
30{ 38{
31 if (hw->nread < DIM_FINGER) { 39 if (hw->nread < DIM_FINGER) {
@@ -50,6 +58,7 @@ static void accept_packet(struct HWData *hw)
50{ 58{
51 hw->nread = 0; 59 hw->nread = 0;
52 hw->mread[hw->nread] = 0; 60 hw->mread[hw->nread] = 0;
61 hw->evtime = get_mstime();
53} 62}
54 63
55int read_hwdata(struct HWData *hw, const struct input_event* ev) 64int read_hwdata(struct HWData *hw, const struct input_event* ev)
diff --git a/src/hwdata.h b/src/hwdata.h
index aa589e0..c00fb39 100644
--- a/src/hwdata.h
+++ b/src/hwdata.h
@@ -51,6 +51,9 @@ struct FingerData {
51 int position_x, position_y; 51 int position_x, position_y;
52}; 52};
53 53
54/* year-proof millisecond event time */
55typedef __u64 mstime_t;
56
54/** 57/**
55 * struct HWData - hardware reads 58 * struct HWData - hardware reads
56 * 59 *
@@ -67,6 +70,7 @@ struct HWData {
67 unsigned mask[DIM_FINGER], mread[DIM_FINGER]; 70 unsigned mask[DIM_FINGER], mread[DIM_FINGER];
68 unsigned button; 71 unsigned button;
69 int nfinger, nread; 72 int nfinger, nread;
73 mstime_t evtime;
70}; 74};
71 75
72void init_hwdata(struct HWData *hw); 76void init_hwdata(struct HWData *hw);
diff --git a/src/state.c b/src/state.c
index 31eca70..182a508 100644
--- a/src/state.c
+++ b/src/state.c
@@ -105,6 +105,7 @@ void modify_state(struct State *s,
105 105
106 s->button = hw->button; 106 s->button = hw->button;
107 s->nfinger = hw->nfinger; 107 s->nfinger = hw->nfinger;
108 s->evtime = hw->evtime;
108 109
109 /* sort fingers in touching order */ 110 /* sort fingers in touching order */
110 qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp); 111 qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp);
@@ -141,6 +142,8 @@ void output_state(const struct State *s)
141 GETBIT(s->button, MT_BUTTON_RIGHT)); 142 GETBIT(s->button, MT_BUTTON_RIGHT));
142 xf86Msg(X_INFO, "fingers: %d\n", 143 xf86Msg(X_INFO, "fingers: %d\n",
143 s->nfinger); 144 s->nfinger);
145 xf86Msg(X_INFO, "evtime: %lld\n",
146 s->evtime);
144 for (i = 0; i < s->nfinger; i++) { 147 for (i = 0; i < s->nfinger; i++) {
145 xf86Msg(X_INFO, 148 xf86Msg(X_INFO,
146 " %+02d %+05d:%+05d +%05d:%+05d " 149 " %+02d %+05d:%+05d +%05d:%+05d "
diff --git a/src/state.h b/src/state.h
index 340803a..2c2d2b7 100644
--- a/src/state.h
+++ b/src/state.h
@@ -35,6 +35,7 @@ struct State {
35 struct FingerState finger[DIM_FINGER]; 35 struct FingerState finger[DIM_FINGER];
36 unsigned button; 36 unsigned button;
37 int nfinger; 37 int nfinger;
38 mstime_t evtime;
38 int lastid; 39 int lastid;
39}; 40};
40 41