diff options
| -rw-r--r-- | src/hwdata.c | 9 | ||||
| -rw-r--r-- | src/hwdata.h | 4 | ||||
| -rw-r--r-- | src/state.c | 3 | ||||
| -rw-r--r-- | src/state.h | 1 |
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 | ||
| 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) |
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 */ | ||
| 55 | typedef __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 | ||
| 72 | void init_hwdata(struct HWData *hw); | 76 | 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, | |||
| 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 | ||
