aboutsummaryrefslogtreecommitdiffstats
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)
downloadxorg-input-kobomultitouch-0587ab0488c46b61d175793f2deedc3a7aa9b600.tar.gz
xorg-input-kobomultitouch-0587ab0488c46b61d175793f2deedc3a7aa9b600.tar.bz2
xorg-input-kobomultitouch-0587ab0488c46b61d175793f2deedc3a7aa9b600.zip
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)
memset(hw, 0, sizeof(struct HWData));
}
+static mstime_t get_mstime()
+{
+ static const mstime_t ms = 1000;
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ return now.tv_usec / ms + now.tv_sec * ms;
+}
+
static void set_value(struct HWData *hw, int code, int value)
{
if (hw->nread < DIM_FINGER) {
@@ -50,6 +58,7 @@ static void accept_packet(struct HWData *hw)
{
hw->nread = 0;
hw->mread[hw->nread] = 0;
+ hw->evtime = get_mstime();
}
int 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 {
int position_x, position_y;
};
+/* year-proof millisecond event time */
+typedef __u64 mstime_t;
+
/**
* struct HWData - hardware reads
*
@@ -67,6 +70,7 @@ struct HWData {
unsigned mask[DIM_FINGER], mread[DIM_FINGER];
unsigned button;
int nfinger, nread;
+ mstime_t evtime;
};
void 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,
s->button = hw->button;
s->nfinger = hw->nfinger;
+ s->evtime = hw->evtime;
/* sort fingers in touching order */
qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp);
@@ -141,6 +142,8 @@ void output_state(const struct State *s)
GETBIT(s->button, MT_BUTTON_RIGHT));
xf86Msg(X_INFO, "fingers: %d\n",
s->nfinger);
+ xf86Msg(X_INFO, "evtime: %lld\n",
+ s->evtime);
for (i = 0; i < s->nfinger; i++) {
xf86Msg(X_INFO,
" %+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 {
struct FingerState finger[DIM_FINGER];
unsigned button;
int nfinger;
+ mstime_t evtime;
int lastid;
};