diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-03-21 14:54:15 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-03-21 14:59:09 +0100 |
| commit | 0587ab0488c46b61d175793f2deedc3a7aa9b600 (patch) | |
| tree | 6077295316cc1420a4cd5010a3772c460c759b75 /src/hwdata.c | |
| parent | c7ed4cec501f10479a98e380d760670312101136 (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>
Diffstat (limited to 'src/hwdata.c')
| -rw-r--r-- | src/hwdata.c | 9 |
1 files changed, 9 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 | ||
| 29 | static 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 | |||
| 29 | static void set_value(struct HWData *hw, int code, int value) | 37 | static 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 | ||
| 55 | int read_hwdata(struct HWData *hw, const struct input_event* ev) | 64 | int read_hwdata(struct HWData *hw, const struct input_event* ev) |
