#include "evdev.h"
-#define MIDDLEBUTTON_TIMEOUT 50
+#define MIDDLEBUTTON_TIMEOUT ms2us(50)
/*****************************************
* BEFORE YOU EDIT THIS FILE, look at the state diagram in
#include "evdev-mt-touchpad.h"
-#define DEFAULT_BUTTON_ENTER_TIMEOUT 100 /* ms */
-#define DEFAULT_BUTTON_LEAVE_TIMEOUT 300 /* ms */
+#define DEFAULT_BUTTON_ENTER_TIMEOUT ms2us(100)
+#define DEFAULT_BUTTON_LEAVE_TIMEOUT ms2us(300)
/*****************************************
* BEFORE YOU EDIT THIS FILE, look at the state diagram in
struct evdev_dispatch *dispatch = tp->buttons.trackpoint->dispatch;
struct input_event event;
- event.time.tv_sec = time/1000;
- event.time.tv_usec = (time % 1000) * 1000;
+ event.time.tv_sec = time / ms2us(1000);
+ event.time.tv_usec = time % ms2us(1000);
event.type = EV_KEY;
event.code = button;
event.value = (state == LIBINPUT_BUTTON_STATE_PRESSED) ? 1 : 0;
tp_edge_scroll_set_timer(struct tp_dispatch *tp,
struct tp_touch *t)
{
- const int DEFAULT_SCROLL_LOCK_TIMEOUT = 300; /* ms */
+ const int DEFAULT_SCROLL_LOCK_TIMEOUT = ms2us(300);
/* if we use software buttons, we disable timeout-based
* edge scrolling. A finger resting on the button areas is
* likely there to trigger a button event.
#include "evdev-mt-touchpad.h"
-#define DEFAULT_GESTURE_SWITCH_TIMEOUT 100 /* ms */
-#define DEFAULT_GESTURE_2FG_SCROLL_TIMEOUT 1000 /* ms */
+#define DEFAULT_GESTURE_SWITCH_TIMEOUT ms2us(100)
+#define DEFAULT_GESTURE_2FG_SCROLL_TIMEOUT ms2us(1000)
static inline const char*
gesture_state_to_str(enum tp_gesture_2fg_state state)
#include "evdev-mt-touchpad.h"
-#define DEFAULT_TAP_TIMEOUT_PERIOD 180
-#define DEFAULT_DRAG_TIMEOUT_PERIOD 300
+#define DEFAULT_TAP_TIMEOUT_PERIOD ms2us(180)
+#define DEFAULT_DRAG_TIMEOUT_PERIOD ms2us(300)
#define DEFAULT_TAP_MOVE_THRESHOLD TP_MM_TO_DPI_NORMALIZED(3)
enum tap_event {
#include "evdev-mt-touchpad.h"
-#define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT 300 /* ms */
-#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_1 200 /* ms */
-#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_2 500 /* ms */
+#define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT ms2us(300)
+#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_1 ms2us(200)
+#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_2 ms2us(500)
#define FAKE_FINGER_OVERFLOW (1 << 7)
static inline int
static void
tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
{
- const int PALM_TIMEOUT = 200; /* ms */
+ const int PALM_TIMEOUT = ms2us(200);
const int DIRECTIONS = NE|E|SE|SW|W|NW;
struct device_float_coords delta;
int dirs;
#include "libinput-private.h"
#define DEFAULT_WHEEL_CLICK_ANGLE 15
-#define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT 200
+#define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT ms2us(200)
enum evdev_key_type {
EVDEV_KEY_TYPE_NONE,
{
if (is_press) {
libinput_timer_set(&device->scroll.timer,
- time + DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT);
+ time + DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT);
device->scroll.button_down_time = time;
} else {
libinput_timer_cancel(&device->scroll.timer);
evdev_process_event(struct evdev_device *device, struct input_event *e)
{
struct evdev_dispatch *dispatch = device->dispatch;
- uint64_t time = e->time.tv_sec * 1000ULL + e->time.tv_usec / 1000;
+ uint64_t time = s2us(e->time.tv_sec) + e->time.tv_usec;
#if 0
if (libevdev_event_is_code(e, EV_SYN, SYN_REPORT))
device->dpi = DEFAULT_MOUSE_DPI;
/* at most 5 SYN_DROPPED log-messages per 30s */
- ratelimit_init(&device->syn_drop_limit, 30ULL * 1000, 5);
+ ratelimit_init(&device->syn_drop_limit, s2us(30), 5);
matrix_init_identity(&device->abs.calibration);
matrix_init_identity(&device->abs.usermatrix);
* Default parameters for pointer acceleration profiles.
*/
-#define DEFAULT_THRESHOLD 0.4 /* in units/ms */
+#define DEFAULT_THRESHOLD 0.0004 /* in units/us */
#define DEFAULT_ACCELERATION 2.0 /* unitless factor */
#define DEFAULT_INCLINE 1.1 /* unitless factor */
* Pointer acceleration filter constants
*/
-#define MAX_VELOCITY_DIFF 1.0 /* units/ms */
-#define MOTION_TIMEOUT 1000 /* (ms) */
+#define MAX_VELOCITY_DIFF 0.001 /* units/us */
+#define MOTION_TIMEOUT ms2us(1000)
#define NUM_POINTER_TRACKERS 16
struct pointer_tracker {
struct normalized_coords delta; /* delta to most recent event */
- uint64_t time; /* ms */
+ uint64_t time; /* us */
int dir;
};
accel_profile_func_t profile;
- double velocity; /* units/ms */
- double last_velocity; /* units/ms */
+ double velocity; /* units/us */
+ double last_velocity; /* units/us */
struct normalized_coords last;
struct pointer_tracker *trackers;
int cur_tracker;
- double threshold; /* units/ms */
+ double threshold; /* units/us */
double accel; /* unitless factor */
double incline; /* incline of the function */
calculate_tracker_velocity(struct pointer_tracker *tracker, uint64_t time)
{
double tdelta = time - tracker->time + 1;
-
- return normalized_length(tracker->delta) / tdelta; /* units/ms */
+ return normalized_length(tracker->delta) / tdelta; /* units/us */
}
static inline double
}
}
- return result; /* units/ms */
+ return result; /* units/us */
}
static double
{
struct pointer_accelerator *accel =
(struct pointer_accelerator *) filter;
- double velocity; /* units/ms */
+ double velocity; /* units/us */
double accel_value; /* unitless factor */
struct normalized_coords accelerated;
struct normalized_coords unnormalized;
assert(speed >= -1.0 && speed <= 1.0);
/* delay when accel kicks in */
- accel_filter->threshold = DEFAULT_THRESHOLD - speed / 4.0;
- if (accel_filter->threshold < 0.2)
- accel_filter->threshold = 0.2;
+ accel_filter->threshold = DEFAULT_THRESHOLD - speed / 4000.0;
+ if (accel_filter->threshold < 0.0002)
+ accel_filter->threshold = 0.0002;
/* adjust max accel factor */
accel_filter->accel = DEFAULT_ACCELERATION + speed * 1.5;
double
pointer_accel_profile_linear_low_dpi(struct motion_filter *filter,
void *data,
- double speed_in, /* in device units */
+ double speed_in, /* in device units (units/us) */
uint64_t time)
{
struct pointer_accelerator *accel_filter =
double s1, s2;
double max_accel = accel_filter->accel; /* unitless factor */
- const double threshold = accel_filter->threshold; /* units/ms */
+ const double threshold = accel_filter->threshold; /* units/us */
const double incline = accel_filter->incline;
double factor;
double dpi_factor = accel_filter->dpi_factor;
max_accel /= dpi_factor;
- s1 = min(1, 0.3 + speed_in * 10);
- s2 = 1 + (speed_in - threshold * dpi_factor) * incline;
+ s1 = min(1, 0.3 + speed_in * 10000.0);
+ s2 = 1 + (speed_in * 1000.0 - threshold * dpi_factor * 1000.0) * incline;
factor = min(max_accel, s2 > 1 ? s2 : s1);
double s1, s2;
const double max_accel = accel_filter->accel; /* unitless factor */
- const double threshold = accel_filter->threshold; /* units/ms */
+ const double threshold = accel_filter->threshold; /* units/us */
const double incline = accel_filter->incline;
double factor;
- s1 = min(1, 0.3 + speed_in * 10);
- s2 = 1 + (speed_in - threshold) * incline;
+ s1 = min(1, 0.3 + speed_in * 10 * 1000.0);
+ s2 = 1 + (speed_in * 1000.0 - threshold * 1000.0) * incline;
factor = min(max_accel, s2 > 1 ? s2 : s1);
const double max_accel = accel_filter->accel *
TP_MAGIC_LOW_RES_FACTOR; /* unitless factor */
const double threshold = accel_filter->threshold /
- TP_MAGIC_LOW_RES_FACTOR; /* units/ms */
+ TP_MAGIC_LOW_RES_FACTOR; /* units/us */
const double incline = accel_filter->incline * TP_MAGIC_LOW_RES_FACTOR;
speed_in *= TP_MAGIC_SLOWDOWN / TP_MAGIC_LOW_RES_FACTOR;
return 0;
}
- return ts.tv_sec * 1000ULL + ts.tv_nsec / 1000000;
+ return s2us(ts.tv_sec) + ns2us(ts.tv_nsec);
}
static inline struct device_float_coords
}
void
-ratelimit_init(struct ratelimit *r, uint64_t ival_ms, unsigned int burst)
+ratelimit_init(struct ratelimit *r, uint64_t ival_us, unsigned int burst)
{
- r->interval = ival_ms;
+ r->interval = ival_us;
r->begin = 0;
r->burst = burst;
r->num = 0;
ratelimit_test(struct ratelimit *r)
{
struct timespec ts;
- uint64_t mtime;
+ uint64_t utime;
if (r->interval <= 0 || r->burst <= 0)
return RATELIMIT_PASS;
clock_gettime(CLOCK_MONOTONIC, &ts);
- mtime = ts.tv_sec * 1000 + ts.tv_nsec / 1000 / 1000;
+ utime = s2us(ts.tv_sec) + ns2us(ts.tv_nsec);
- if (r->begin <= 0 || r->begin + r->interval < mtime) {
+ if (r->begin <= 0 || r->begin + r->interval < utime) {
/* reset counter */
- r->begin = mtime;
+ r->begin = utime;
r->num = 1;
return RATELIMIT_PASS;
} else if (r->num < r->burst) {
double parse_trackpoint_accel_property(const char *prop);
bool parse_dimension_property(const char *prop, size_t *width, size_t *height);
+static inline uint64_t
+us(uint64_t us)
+{
+ return us;
+}
+
+static inline uint64_t
+ns2us(uint64_t ns)
+{
+ return us(ns / 1000);
+}
+
+static inline uint64_t
+ms2us(uint64_t ms)
+{
+ return us(ms * 1000);
+}
+
+static inline uint64_t
+s2us(uint64_t s)
+{
+ return ms2us(s * 1000);
+}
+
+static inline uint32_t
+us2ms(uint64_t us)
+{
+ return (uint32_t)(us / 1000);
+}
+
#endif /* LIBINPUT_UTIL_H */
struct libinput_event_keyboard {
struct libinput_event base;
- uint32_t time;
+ uint64_t time;
uint32_t key;
uint32_t seat_key_count;
enum libinput_key_state state;
struct libinput_event_pointer {
struct libinput_event base;
- uint32_t time;
+ uint64_t time;
struct normalized_coords delta;
struct device_float_coords delta_raw;
struct device_coords absolute;
struct libinput_event_touch {
struct libinput_event base;
- uint32_t time;
+ uint64_t time;
int32_t slot;
int32_t seat_slot;
struct device_coords point;
struct libinput_event_gesture {
struct libinput_event base;
- uint32_t time;
+ uint64_t time;
int finger_count;
int cancelled;
struct normalized_coords delta;
LIBINPUT_EXPORT uint32_t
libinput_event_keyboard_get_time(struct libinput_event_keyboard *event)
+{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_KEYBOARD_KEY);
+
+ return us2ms(event->time);
+}
+
+LIBINPUT_EXPORT uint64_t
+libinput_event_keyboard_get_time_usec(struct libinput_event_keyboard *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
LIBINPUT_EXPORT uint32_t
libinput_event_pointer_get_time(struct libinput_event_pointer *event)
+{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_POINTER_MOTION,
+ LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
+ LIBINPUT_EVENT_POINTER_BUTTON,
+ LIBINPUT_EVENT_POINTER_AXIS);
+
+ return us2ms(event->time);
+}
+
+LIBINPUT_EXPORT uint64_t
+libinput_event_pointer_get_time_usec(struct libinput_event_pointer *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
LIBINPUT_EXPORT uint32_t
libinput_event_touch_get_time(struct libinput_event_touch *event)
+{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_TOUCH_DOWN,
+ LIBINPUT_EVENT_TOUCH_UP,
+ LIBINPUT_EVENT_TOUCH_MOTION,
+ LIBINPUT_EVENT_TOUCH_CANCEL,
+ LIBINPUT_EVENT_TOUCH_FRAME);
+
+ return us2ms(event->time);
+}
+
+LIBINPUT_EXPORT uint64_t
+libinput_event_touch_get_time_usec(struct libinput_event_touch *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
LIBINPUT_EXPORT uint32_t
libinput_event_gesture_get_time(struct libinput_event_gesture *event)
+{
+ require_event_type(libinput_event_get_context(&event->base),
+ event->base.type,
+ 0,
+ LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
+ LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
+ LIBINPUT_EVENT_GESTURE_PINCH_END,
+ LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
+ LIBINPUT_EVENT_GESTURE_SWIPE_END);
+
+ return us2ms(event->time);
+}
+
+LIBINPUT_EXPORT uint64_t
+libinput_event_gesture_get_time_usec(struct libinput_event_gesture *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
uint32_t
libinput_event_keyboard_get_time(struct libinput_event_keyboard *event);
+/**
+ * @ingroup event_keyboard
+ *
+ * @return The event time for this event in microseconds
+ */
+uint64_t
+libinput_event_keyboard_get_time_usec(struct libinput_event_keyboard *event);
+
/**
* @ingroup event_keyboard
*
uint32_t
libinput_event_pointer_get_time(struct libinput_event_pointer *event);
+/**
+ * @ingroup event_pointer
+ *
+ * @return The event time for this event in microseconds
+ */
+uint64_t
+libinput_event_pointer_get_time_usec(struct libinput_event_pointer *event);
+
/**
* @ingroup event_pointer
*
uint32_t
libinput_event_touch_get_time(struct libinput_event_touch *event);
+/**
+ * @ingroup event_touch
+ *
+ * @return The event time for this event in microseconds
+ */
+uint64_t
+libinput_event_touch_get_time_usec(struct libinput_event_touch *event);
+
/**
* @ingroup event_touch
*
uint32_t
libinput_event_gesture_get_time(struct libinput_event_gesture *event);
+/**
+ * @ingroup event_gesture
+ *
+ * @return The event time for this event in microseconds
+ */
+uint64_t
+libinput_event_gesture_get_time_usec(struct libinput_event_gesture *event);
+
/**
* @ingroup event_gesture
*
libinput_device_config_dwt_set_enabled;
libinput_device_config_dwt_get_enabled;
libinput_device_config_dwt_get_default_enabled;
+ libinput_event_gesture_get_time_usec;
+ libinput_event_keyboard_get_time_usec;
+ libinput_event_pointer_get_time_usec;
+ libinput_event_touch_get_time_usec;
} LIBINPUT_0.20.0;
}
if (earliest_expire != UINT64_MAX) {
- its.it_value.tv_sec = earliest_expire / 1000;
- its.it_value.tv_nsec = (earliest_expire % 1000) * 1000 * 1000;
+ its.it_value.tv_sec = earliest_expire / ms2us(1000);
+ its.it_value.tv_nsec = (earliest_expire % ms2us(1000)) * 1000;
}
r = timerfd_settime(libinput->timer.fd, TFD_TIMER_ABSTIME, &its, NULL);
if (expire < now)
log_bug_libinput(timer->libinput,
"timer offset negative\n");
- else if ((expire - now) > 5000ULL)
+ else if ((expire - now) > ms2us(5000))
log_bug_libinput(timer->libinput,
"timer offset more than 5s, now %"
PRIu64 " expire %" PRIu64 "\n",
struct libinput_timer {
struct libinput *libinput;
struct list link;
- uint64_t expire; /* in absolute ms CLOCK_MONOTONIC */
+ uint64_t expire; /* in absolute us CLOCK_MONOTONIC */
void (*timer_func)(uint64_t now, void *timer_func_data);
void *timer_func_data;
};
void (*timer_func)(uint64_t now, void *timer_func_data),
void *timer_func_data);
-/* Set timer expire time, in absolute ms CLOCK_MONOTONIC */
+/* Set timer expire time, in absolute us CLOCK_MONOTONIC */
void
libinput_timer_set(struct libinput_timer *timer, uint64_t expire);
}
END_TEST
+START_TEST(gestures_time_usec)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+ struct libinput_event *event;
+ struct libinput_event_gesture *gevent;
+
+ if (libevdev_get_num_slots(dev->evdev) < 3)
+ return;
+
+ litest_drain_events(li);
+
+ litest_touch_down(dev, 0, 40, 40);
+ litest_touch_down(dev, 1, 40, 50);
+ litest_touch_down(dev, 2, 40, 60);
+ libinput_dispatch(li);
+ litest_touch_move_three_touches(dev,
+ 40, 40,
+ 40, 50,
+ 40, 60,
+ 0, 30,
+ 4, 2);
+
+ litest_wait_for_event(li);
+
+ event = libinput_get_event(li);
+ gevent = litest_is_gesture_event(event,
+ LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
+ 3);
+ ck_assert_int_eq(libinput_event_gesture_get_time(gevent),
+ libinput_event_gesture_get_time_usec(gevent) / 1000);
+ libinput_event_destroy(event);
+}
+END_TEST
+
void
litest_setup_tests(void)
{
litest_add_ranged("gestures:swipe", gestures_swipe_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
litest_add_ranged("gestures:pinch", gestures_pinch, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
litest_add_ranged("gestures:pinch", gestures_spread, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &cardinals);
+
+ litest_add("gesture:time", gestures_time_usec, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
}
}
END_TEST
+START_TEST(keyboard_time_usec)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+ struct libinput_event_keyboard *kev;
+ struct libinput_event *event;
+
+ if (!libevdev_has_event_code(dev->evdev, EV_KEY, KEY_A))
+ return;
+
+ litest_drain_events(dev->libinput);
+
+ litest_keyboard_key(dev, KEY_A, true);
+
+ litest_wait_for_event(li);
+
+ event = libinput_get_event(li);
+ kev = litest_is_keyboard_event(event,
+ KEY_A,
+ LIBINPUT_KEY_STATE_PRESSED);
+
+ ck_assert_int_eq(libinput_event_keyboard_get_time(kev),
+ libinput_event_keyboard_get_time_usec(kev) / 1000);
+
+ libinput_event_destroy(event);
+ litest_drain_events(dev->libinput);
+}
+END_TEST
+
void
litest_setup_tests(void)
{
litest_add_no_device("keyboard:key counting", keyboard_key_auto_release);
litest_add("keyboard:keys", keyboard_has_key, LITEST_KEYS, LITEST_ANY);
litest_add("keyboard:keys", keyboard_keys_bad_device, LITEST_ANY, LITEST_ANY);
+ litest_add("keyboard:time", keyboard_time_usec, LITEST_KEYS, LITEST_ANY);
}
unsigned int i, j;
/* 10 attempts every 100ms */
- ratelimit_init(&rl, 100, 10);
+ ratelimit_init(&rl, ms2us(100), 10);
for (j = 0; j < 3; ++j) {
/* a burst of 9 attempts must succeed */
}
END_TEST
+START_TEST(time_conversion)
+{
+ ck_assert_int_eq(us(10), 10);
+ ck_assert_int_eq(ns2us(10000), 10);
+ ck_assert_int_eq(ms2us(10), 10000);
+ ck_assert_int_eq(s2us(1), 1000000);
+ ck_assert_int_eq(us2ms(10000), 10);
+}
+END_TEST
+
void
litest_setup_tests(void)
{
litest_add_no_device("misc:parser", wheel_click_parser);
litest_add_no_device("misc:parser", trackpoint_accel_parser);
litest_add_no_device("misc:parser", dimension_prop_parser);
+ litest_add_no_device("misc:time", time_conversion);
}
}
END_TEST
+START_TEST(pointer_time_usec)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+ struct libinput_event_pointer *ptrev;
+ struct libinput_event *event;
+
+ litest_drain_events(dev->libinput);
+
+ litest_event(dev, EV_REL, REL_X, 1);
+ litest_event(dev, EV_REL, REL_Y, 1);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+
+ litest_wait_for_event(li);
+
+ event = libinput_get_event(li);
+ ptrev = litest_is_motion_event(event);
+
+ ck_assert_int_eq(libinput_event_pointer_get_time(ptrev),
+ libinput_event_pointer_get_time_usec(ptrev) / 1000);
+
+ libinput_event_destroy(event);
+ litest_drain_events(dev->libinput);
+}
+END_TEST
+
void
litest_setup_tests(void)
{
litest_add_for_device("pointer:middlebutton", middlebutton_default_alps, LITEST_ALPS_SEMI_MT);
litest_add_ranged("pointer:state", pointer_absolute_initial_state, LITEST_ABSOLUTE, LITEST_ANY, &axis_range);
+
+ litest_add("pointer:time", pointer_time_usec, LITEST_RELATIVE, LITEST_ANY);
}
}
END_TEST
+START_TEST(touch_time_usec)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+ struct libinput_event *event;
+ struct libinput_event_touch *tev;
+
+ litest_drain_events(dev->libinput);
+
+ litest_touch_down(dev, 0, 10, 10);
+
+ litest_wait_for_event(li);
+
+ event = libinput_get_event(li);
+ tev = litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_DOWN);
+ ck_assert_int_eq(libinput_event_touch_get_time(tev),
+ libinput_event_touch_get_time_usec(tev) / 1000);
+ libinput_event_destroy(event);
+}
+END_TEST
+
void
litest_setup_tests(void)
{
litest_add("touch:protocol a", touch_protocol_a_2fg_touch, LITEST_PROTOCOL_A, LITEST_ANY);
litest_add_ranged("touch:state", touch_initial_state, LITEST_TOUCH, LITEST_PROTOCOL_A, &axes);
+
+ litest_add("touch:time", touch_time_usec, LITEST_TOUCH, LITEST_TOUCHPAD);
}
}
END_TEST
+START_TEST(touchpad_time_usec)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+ struct libinput_event *event;
+ struct libinput_event_pointer *ptrev;
+
+ litest_disable_tap(dev->libinput_device);
+
+ litest_drain_events(li);
+
+ litest_touch_down(dev, 0, 50, 50);
+ litest_touch_move_to(dev, 0, 50, 50, 80, 50, 5, 0);
+ litest_touch_up(dev, 0);
+
+ libinput_dispatch(li);
+
+ event = libinput_get_event(li);
+ ck_assert_notnull(event);
+
+ while (event) {
+ uint64_t utime;
+
+ ptrev = litest_is_motion_event(event);
+ utime = libinput_event_pointer_get_time_usec(ptrev);
+
+ ck_assert_int_eq(libinput_event_pointer_get_time(ptrev),
+ utime / 1000);
+ libinput_event_destroy(event);
+ event = libinput_get_event(li);
+ }
+}
+END_TEST
+
void
litest_setup_tests(void)
{
litest_add("touchpad:thumb", touchpad_thumb_tap_hold_2ndfg_tap, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH);
litest_add_for_device("touchpad:bugs", touchpad_tool_tripletap_touch_count, LITEST_SYNAPTICS_TOPBUTTONPAD);
+
+ litest_add("touchpad:time", touchpad_time_usec, LITEST_TOUCHPAD, LITEST_ANY);
}
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
-#include <filter.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <filter.h>
+#include <libinput-util.h>
+
static void
print_ptraccel_deltas(struct motion_filter *filter, double step)
{
for (i = 0.0; i < 15.0; i += step) {
motion.x = i;
motion.y = 0;
- time += 12; /* pretend 80Hz data */
+ time += us(12500); /* pretend 80Hz data */
motion = filter_dispatch(filter, &motion, NULL, time);
for (i = 0; i < nevents; i++) {
motion.x = dx;
motion.y = 0;
- time += 12; /* pretend 80Hz data */
+ time += us(12500); /* pretend 80Hz data */
motion = filter_dispatch(filter, &motion, NULL, time);
for (i = 0; i < nevents; i++, dx++) {
motion.x = *dx;
motion.y = 0;
- time += 12; /* pretend 80Hz data */
+ time += us(12500); /* pretend 80Hz data */
motion = filter_dispatch(filter, &motion, NULL, time);