mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-08 07:00:14 +01:00
Add helper function for time to timeval conversion
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
4ed0f7ee0e
commit
407649e599
2 changed files with 12 additions and 2 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue