Commit 407649e5 authored by Peter Hutterer's avatar Peter Hutterer

Add helper function for time to timeval conversion

Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 4ed0f7ee
......@@ -1056,8 +1056,7 @@ tp_notify_clickpadbutton(struct tp_dispatch *tp,
struct evdev_dispatch *dispatch = tp->buttons.trackpoint->dispatch;
struct input_event event;
event.time.tv_sec = time / ms2us(1000);
event.time.tv_usec = time % ms2us(1000);
event.time = us2tv(time);
event.type = EV_KEY;
event.code = button;
event.value = (state == LIBINPUT_BUTTON_STATE_PRESSED) ? 1 : 0;
......
......@@ -473,6 +473,17 @@ tv2us(const struct timeval *tv)
return s2us(tv->tv_sec) + tv->tv_usec;
}
static inline struct timeval
us2tv(uint64_t time)
{
struct timeval tv;
tv.tv_sec = time / ms2us(1000);
tv.tv_usec = time % ms2us(1000);
return tv;
}
static inline bool
safe_atoi_base(const char *str, int *val, int base)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment