mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 06:50:05 +01:00
Use a newtype usec_t for timestamps for better type-safety
This avoids mixing up milliseconds and usec, both by failing if we're providing just a number somewhere we expect usecs and also by making the API blindingly obvious that we're in usecs now. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1373>
This commit is contained in:
parent
c0c809aaa1
commit
a202ed6115
52 changed files with 1336 additions and 1080 deletions
|
|
@ -33,7 +33,7 @@
|
||||||
static void
|
static void
|
||||||
fallback_keyboard_notify_key(struct fallback_dispatch *dispatch,
|
fallback_keyboard_notify_key(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t usage,
|
evdev_usage_t usage,
|
||||||
enum libinput_key_state state)
|
enum libinput_key_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +53,7 @@ fallback_keyboard_notify_key(struct fallback_dispatch *dispatch,
|
||||||
static void
|
static void
|
||||||
fallback_lid_notify_toggle(struct fallback_dispatch *dispatch,
|
fallback_lid_notify_toggle(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (dispatch->lid.is_closed ^ dispatch->lid.is_closed_client_state) {
|
if (dispatch->lid.is_closed ^ dispatch->lid.is_closed_client_state) {
|
||||||
switch_notify_toggle(&device->base,
|
switch_notify_toggle(&device->base,
|
||||||
|
|
@ -67,7 +67,7 @@ fallback_lid_notify_toggle(struct fallback_dispatch *dispatch,
|
||||||
void
|
void
|
||||||
fallback_notify_physical_button(struct fallback_dispatch *dispatch,
|
fallback_notify_physical_button(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -98,7 +98,7 @@ fallback_interface_get_switch_state(struct evdev_dispatch *evdev_dispatch,
|
||||||
static inline bool
|
static inline bool
|
||||||
post_button_scroll(struct evdev_device *device,
|
post_button_scroll(struct evdev_device *device,
|
||||||
struct device_float_coords raw,
|
struct device_float_coords raw,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (device->scroll.method != LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)
|
if (device->scroll.method != LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -174,7 +174,7 @@ fallback_rotate_relative(struct fallback_dispatch *dispatch,
|
||||||
static void
|
static void
|
||||||
fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
|
fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct normalized_coords accel;
|
struct normalized_coords accel;
|
||||||
|
|
@ -208,7 +208,7 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
|
||||||
static void
|
static void
|
||||||
fallback_flush_wheels(struct fallback_dispatch *dispatch,
|
fallback_flush_wheels(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (!libinput_device_has_capability(&device->base, LIBINPUT_DEVICE_CAP_POINTER))
|
if (!libinput_device_has_capability(&device->base, LIBINPUT_DEVICE_CAP_POINTER))
|
||||||
return;
|
return;
|
||||||
|
|
@ -325,7 +325,7 @@ fallback_flush_wheels(struct fallback_dispatch *dispatch,
|
||||||
static void
|
static void
|
||||||
fallback_flush_absolute_motion(struct fallback_dispatch *dispatch,
|
fallback_flush_absolute_motion(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct device_coords point;
|
struct device_coords point;
|
||||||
|
|
@ -343,7 +343,7 @@ static bool
|
||||||
fallback_flush_mt_down(struct fallback_dispatch *dispatch,
|
fallback_flush_mt_down(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
int slot_idx,
|
int slot_idx,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct libinput_seat *seat = base->seat;
|
struct libinput_seat *seat = base->seat;
|
||||||
|
|
@ -382,7 +382,7 @@ static bool
|
||||||
fallback_flush_mt_motion(struct fallback_dispatch *dispatch,
|
fallback_flush_mt_motion(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
int slot_idx,
|
int slot_idx,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct device_coords point;
|
struct device_coords point;
|
||||||
|
|
@ -412,7 +412,7 @@ static bool
|
||||||
fallback_flush_mt_up(struct fallback_dispatch *dispatch,
|
fallback_flush_mt_up(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
int slot_idx,
|
int slot_idx,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct libinput_seat *seat = base->seat;
|
struct libinput_seat *seat = base->seat;
|
||||||
|
|
@ -440,7 +440,7 @@ static bool
|
||||||
fallback_flush_mt_cancel(struct fallback_dispatch *dispatch,
|
fallback_flush_mt_cancel(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
int slot_idx,
|
int slot_idx,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct libinput_seat *seat = base->seat;
|
struct libinput_seat *seat = base->seat;
|
||||||
|
|
@ -467,7 +467,7 @@ fallback_flush_mt_cancel(struct fallback_dispatch *dispatch,
|
||||||
static bool
|
static bool
|
||||||
fallback_flush_st_down(struct fallback_dispatch *dispatch,
|
fallback_flush_st_down(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct libinput_seat *seat = base->seat;
|
struct libinput_seat *seat = base->seat;
|
||||||
|
|
@ -503,7 +503,7 @@ fallback_flush_st_down(struct fallback_dispatch *dispatch,
|
||||||
static bool
|
static bool
|
||||||
fallback_flush_st_motion(struct fallback_dispatch *dispatch,
|
fallback_flush_st_motion(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct device_coords point;
|
struct device_coords point;
|
||||||
|
|
@ -525,7 +525,7 @@ fallback_flush_st_motion(struct fallback_dispatch *dispatch,
|
||||||
static bool
|
static bool
|
||||||
fallback_flush_st_up(struct fallback_dispatch *dispatch,
|
fallback_flush_st_up(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct libinput_seat *seat = base->seat;
|
struct libinput_seat *seat = base->seat;
|
||||||
|
|
@ -550,7 +550,7 @@ fallback_flush_st_up(struct fallback_dispatch *dispatch,
|
||||||
static bool
|
static bool
|
||||||
fallback_flush_st_cancel(struct fallback_dispatch *dispatch,
|
fallback_flush_st_cancel(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct libinput_seat *seat = base->seat;
|
struct libinput_seat *seat = base->seat;
|
||||||
|
|
@ -575,7 +575,7 @@ fallback_flush_st_cancel(struct fallback_dispatch *dispatch,
|
||||||
static void
|
static void
|
||||||
fallback_process_touch_button(struct fallback_dispatch *dispatch,
|
fallback_process_touch_button(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int value)
|
int value)
|
||||||
{
|
{
|
||||||
dispatch->pending_event |=
|
dispatch->pending_event |=
|
||||||
|
|
@ -586,7 +586,7 @@ static inline void
|
||||||
fallback_process_key(struct fallback_dispatch *dispatch,
|
fallback_process_key(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
/* ignore kernel key repeat */
|
/* ignore kernel key repeat */
|
||||||
if (e->value == 2)
|
if (e->value == 2)
|
||||||
|
|
@ -628,7 +628,7 @@ static void
|
||||||
fallback_process_touch(struct fallback_dispatch *dispatch,
|
fallback_process_touch(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct mt_slot *slot = &dispatch->mt.slots[dispatch->mt.slot];
|
struct mt_slot *slot = &dispatch->mt.slots[dispatch->mt.slot];
|
||||||
|
|
||||||
|
|
@ -729,7 +729,7 @@ fallback_process_absolute_motion(struct fallback_dispatch *dispatch,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fallback_lid_keyboard_event(uint64_t time, struct libinput_event *event, void *data)
|
fallback_lid_keyboard_event(usec_t time, struct libinput_event *event, void *data)
|
||||||
{
|
{
|
||||||
struct fallback_dispatch *dispatch = fallback_dispatch(data);
|
struct fallback_dispatch *dispatch = fallback_dispatch(data);
|
||||||
|
|
||||||
|
|
@ -744,8 +744,8 @@ fallback_lid_keyboard_event(uint64_t time, struct libinput_event *event, void *d
|
||||||
int rc;
|
int rc;
|
||||||
struct input_event ev[2];
|
struct input_event ev[2];
|
||||||
|
|
||||||
ev[0] = input_event_init(0, EV_SW, SW_LID, 0);
|
ev[0] = input_event_init(usec_from_uint64_t(0), EV_SW, SW_LID, 0);
|
||||||
ev[1] = input_event_init(0, EV_SYN, SYN_REPORT, 0);
|
ev[1] = input_event_init(usec_from_uint64_t(0), EV_SYN, SYN_REPORT, 0);
|
||||||
|
|
||||||
rc = write(fd, ev, sizeof(ev));
|
rc = write(fd, ev, sizeof(ev));
|
||||||
|
|
||||||
|
|
@ -803,7 +803,7 @@ static inline void
|
||||||
fallback_process_switch(struct fallback_dispatch *dispatch,
|
fallback_process_switch(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum libinput_switch_state state;
|
enum libinput_switch_state state;
|
||||||
bool is_closed;
|
bool is_closed;
|
||||||
|
|
@ -858,7 +858,7 @@ fallback_process_switch(struct fallback_dispatch *dispatch,
|
||||||
static inline bool
|
static inline bool
|
||||||
fallback_reject_relative(struct evdev_device *device,
|
fallback_reject_relative(struct evdev_device *device,
|
||||||
const struct evdev_event *e,
|
const struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (evdev_usage_enum(e->usage)) {
|
switch (evdev_usage_enum(e->usage)) {
|
||||||
case EVDEV_REL_X:
|
case EVDEV_REL_X:
|
||||||
|
|
@ -893,7 +893,7 @@ static inline void
|
||||||
fallback_process_relative(struct fallback_dispatch *dispatch,
|
fallback_process_relative(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (fallback_reject_relative(device, e, time))
|
if (fallback_reject_relative(device, e, time))
|
||||||
return;
|
return;
|
||||||
|
|
@ -932,7 +932,7 @@ static inline void
|
||||||
fallback_process_absolute(struct fallback_dispatch *dispatch,
|
fallback_process_absolute(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (device->is_mt) {
|
if (device->is_mt) {
|
||||||
fallback_process_touch(dispatch, device, e, time);
|
fallback_process_touch(dispatch, device, e, time);
|
||||||
|
|
@ -976,7 +976,7 @@ fallback_arbitrate_touch(struct fallback_dispatch *dispatch, struct mt_slot *slo
|
||||||
static inline bool
|
static inline bool
|
||||||
fallback_flush_mt_events(struct fallback_dispatch *dispatch,
|
fallback_flush_mt_events(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
bool sent = false;
|
bool sent = false;
|
||||||
|
|
||||||
|
|
@ -1047,7 +1047,7 @@ fallback_flush_mt_events(struct fallback_dispatch *dispatch,
|
||||||
static void
|
static void
|
||||||
fallback_handle_state(struct fallback_dispatch *dispatch,
|
fallback_handle_state(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
bool need_touch_frame = false;
|
bool need_touch_frame = false;
|
||||||
|
|
||||||
|
|
@ -1115,7 +1115,7 @@ static void
|
||||||
fallback_interface_process_event(struct evdev_dispatch *evdev_dispatch,
|
fallback_interface_process_event(struct evdev_dispatch *evdev_dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *event,
|
struct evdev_event *event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
||||||
static bool warned = false;
|
static bool warned = false;
|
||||||
|
|
@ -1155,7 +1155,7 @@ static void
|
||||||
fallback_interface_process(struct evdev_dispatch *dispatch,
|
fallback_interface_process(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
size_t nevents;
|
size_t nevents;
|
||||||
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
||||||
|
|
@ -1169,7 +1169,7 @@ static void
|
||||||
cancel_touches(struct fallback_dispatch *dispatch,
|
cancel_touches(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
const struct device_coord_rect *rect,
|
const struct device_coord_rect *rect,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
bool need_frame = false;
|
bool need_frame = false;
|
||||||
|
|
@ -1200,7 +1200,7 @@ cancel_touches(struct fallback_dispatch *dispatch,
|
||||||
static void
|
static void
|
||||||
release_pressed_keys(struct fallback_dispatch *dispatch,
|
release_pressed_keys(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
for (evdev_usage_t usage = evdev_usage_from(EVDEV_KEY_RESERVED);
|
for (evdev_usage_t usage = evdev_usage_from(EVDEV_KEY_RESERVED);
|
||||||
evdev_usage_le(usage, EVDEV_KEY_MAX);
|
evdev_usage_le(usage, EVDEV_KEY_MAX);
|
||||||
|
|
@ -1250,9 +1250,9 @@ fallback_return_to_neutral_state(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device)
|
struct evdev_device *device)
|
||||||
{
|
{
|
||||||
struct libinput *libinput = evdev_libinput_context(device);
|
struct libinput *libinput = evdev_libinput_context(device);
|
||||||
uint64_t time;
|
usec_t time = libinput_now(libinput);
|
||||||
|
|
||||||
if ((time = libinput_now(libinput)) == 0)
|
if (usec_is_zero(time))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cancel_touches(dispatch, device, NULL, time);
|
cancel_touches(dispatch, device, NULL, time);
|
||||||
|
|
@ -1292,7 +1292,7 @@ fallback_interface_sync_initial_state(struct evdev_device *device,
|
||||||
struct evdev_dispatch *evdev_dispatch)
|
struct evdev_dispatch *evdev_dispatch)
|
||||||
{
|
{
|
||||||
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
||||||
uint64_t time = libinput_now(evdev_libinput_context(device));
|
usec_t time = libinput_now(evdev_libinput_context(device));
|
||||||
|
|
||||||
if (device->tags & EVDEV_TAG_LID_SWITCH) {
|
if (device->tags & EVDEV_TAG_LID_SWITCH) {
|
||||||
struct libevdev *evdev = device->evdev;
|
struct libevdev *evdev = device->evdev;
|
||||||
|
|
@ -1333,7 +1333,7 @@ static void
|
||||||
fallback_interface_update_rect(struct evdev_dispatch *evdev_dispatch,
|
fallback_interface_update_rect(struct evdev_dispatch *evdev_dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
const struct phys_rect *phys_rect,
|
const struct phys_rect *phys_rect,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
||||||
struct device_coord_rect rect;
|
struct device_coord_rect rect;
|
||||||
|
|
@ -1352,7 +1352,7 @@ fallback_interface_toggle_touch(struct evdev_dispatch *evdev_dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
enum evdev_arbitration_state which,
|
enum evdev_arbitration_state which,
|
||||||
const struct phys_rect *phys_rect,
|
const struct phys_rect *phys_rect,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
||||||
struct device_coord_rect rect = { 0 };
|
struct device_coord_rect rect = { 0 };
|
||||||
|
|
@ -1371,7 +1371,7 @@ fallback_interface_toggle_touch(struct evdev_dispatch *evdev_dispatch,
|
||||||
* arbitration by just a little bit so that any touch in
|
* arbitration by just a little bit so that any touch in
|
||||||
* event is caught as palm touch. */
|
* event is caught as palm touch. */
|
||||||
libinput_timer_set(&dispatch->arbitration.arbitration_timer,
|
libinput_timer_set(&dispatch->arbitration.arbitration_timer,
|
||||||
time + ms2us(90));
|
usec_add_millis(time, 90));
|
||||||
state = "not-active";
|
state = "not-active";
|
||||||
break;
|
break;
|
||||||
case ARBITRATION_IGNORE_RECT:
|
case ARBITRATION_IGNORE_RECT:
|
||||||
|
|
@ -1465,9 +1465,7 @@ fallback_suspend(struct fallback_dispatch *dispatch, struct evdev_device *device
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fallback_tablet_mode_switch_event(uint64_t time,
|
fallback_tablet_mode_switch_event(usec_t time, struct libinput_event *event, void *data)
|
||||||
struct libinput_event *event,
|
|
||||||
void *data)
|
|
||||||
{
|
{
|
||||||
struct fallback_dispatch *dispatch = data;
|
struct fallback_dispatch *dispatch = data;
|
||||||
struct evdev_device *device = dispatch->device;
|
struct evdev_device *device = dispatch->device;
|
||||||
|
|
@ -1766,7 +1764,7 @@ fallback_dispatch_init_switch(struct fallback_dispatch *dispatch,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fallback_arbitration_timeout(uint64_t now, void *data)
|
fallback_arbitration_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct fallback_dispatch *dispatch = data;
|
struct fallback_dispatch *dispatch = data;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -220,11 +220,11 @@ get_key_down_count(struct evdev_device *device, evdev_usage_t usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fallback_debounce_handle_state(struct fallback_dispatch *dispatch, uint64_t time);
|
fallback_debounce_handle_state(struct fallback_dispatch *dispatch, usec_t time);
|
||||||
void
|
void
|
||||||
fallback_notify_physical_button(struct fallback_dispatch *dispatch,
|
fallback_notify_physical_button(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state);
|
enum libinput_button_state state);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -394,9 +394,9 @@ evdev_event_get_code_name(const struct evdev_event *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct input_event
|
static inline struct input_event
|
||||||
evdev_event_to_input_event(const struct evdev_event *e, uint64_t time)
|
evdev_event_to_input_event(const struct evdev_event *e, usec_t time)
|
||||||
{
|
{
|
||||||
struct timeval tv = us2tv(time);
|
struct timeval tv = usec_to_timeval(time);
|
||||||
return (struct input_event){
|
return (struct input_event){
|
||||||
.type = evdev_event_type(e),
|
.type = evdev_event_type(e),
|
||||||
.code = evdev_event_code(e),
|
.code = evdev_event_code(e),
|
||||||
|
|
@ -407,7 +407,7 @@ evdev_event_to_input_event(const struct evdev_event *e, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct evdev_event
|
static inline struct evdev_event
|
||||||
evdev_event_from_input_event(const struct input_event *e, uint64_t *time)
|
evdev_event_from_input_event(const struct input_event *e, usec_t *time)
|
||||||
{
|
{
|
||||||
if (time)
|
if (time)
|
||||||
*time = input_event_time(e);
|
*time = input_event_time(e);
|
||||||
|
|
@ -434,7 +434,7 @@ struct evdev_frame {
|
||||||
int refcount;
|
int refcount;
|
||||||
size_t max_size;
|
size_t max_size;
|
||||||
size_t count;
|
size_t count;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
struct evdev_event events[];
|
struct evdev_event events[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -487,12 +487,12 @@ evdev_frame_get_events(struct evdev_frame *frame, size_t *nevents)
|
||||||
* Set the timestamp for all events in this event frame.
|
* Set the timestamp for all events in this event frame.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
evdev_frame_set_time(struct evdev_frame *frame, uint64_t time)
|
evdev_frame_set_time(struct evdev_frame *frame, usec_t time)
|
||||||
{
|
{
|
||||||
frame->time = time;
|
frame->time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t
|
static inline usec_t
|
||||||
evdev_frame_get_time(const struct evdev_frame *frame)
|
evdev_frame_get_time(const struct evdev_frame *frame)
|
||||||
{
|
{
|
||||||
return frame->time;
|
return frame->time;
|
||||||
|
|
@ -592,7 +592,7 @@ evdev_frame_append_input_event(struct evdev_frame *frame,
|
||||||
{
|
{
|
||||||
struct evdev_event e = evdev_event_from_input_event(event, NULL);
|
struct evdev_event e = evdev_event_from_input_event(event, NULL);
|
||||||
if (evdev_usage_as_uint32_t(e.usage) == EVDEV_SYN_REPORT) {
|
if (evdev_usage_as_uint32_t(e.usage) == EVDEV_SYN_REPORT) {
|
||||||
uint64_t time = input_event_time(event);
|
usec_t time = input_event_time(event);
|
||||||
evdev_frame_set_time(frame, time);
|
evdev_frame_set_time(frame, time);
|
||||||
}
|
}
|
||||||
return evdev_frame_append(frame, &e, 1);
|
return evdev_frame_append(frame, &e, 1);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include "evdev.h"
|
#include "evdev.h"
|
||||||
|
|
||||||
#define MIDDLEBUTTON_TIMEOUT ms2us(50)
|
#define MIDDLEBUTTON_TIMEOUT usec_from_millis(50)
|
||||||
|
|
||||||
/*****************************************
|
/*****************************************
|
||||||
* BEFORE YOU EDIT THIS FILE, look at the state diagram in
|
* BEFORE YOU EDIT THIS FILE, look at the state diagram in
|
||||||
|
|
@ -88,9 +88,10 @@ middlebutton_state_error(struct evdev_device *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
middlebutton_timer_set(struct evdev_device *device, uint64_t now)
|
middlebutton_timer_set(struct evdev_device *device, usec_t now)
|
||||||
{
|
{
|
||||||
libinput_timer_set(&device->middlebutton.timer, now + MIDDLEBUTTON_TIMEOUT);
|
libinput_timer_set(&device->middlebutton.timer,
|
||||||
|
usec_add(now, MIDDLEBUTTON_TIMEOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -102,7 +103,7 @@ middlebutton_timer_cancel(struct evdev_device *device)
|
||||||
static inline void
|
static inline void
|
||||||
middlebutton_set_state(struct evdev_device *device,
|
middlebutton_set_state(struct evdev_device *device,
|
||||||
enum evdev_middlebutton_state state,
|
enum evdev_middlebutton_state state,
|
||||||
uint64_t now)
|
usec_t now)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case MIDDLEBUTTON_LEFT_DOWN:
|
case MIDDLEBUTTON_LEFT_DOWN:
|
||||||
|
|
@ -127,7 +128,7 @@ middlebutton_set_state(struct evdev_device *device,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
middlebutton_post_event(struct evdev_device *device,
|
middlebutton_post_event(struct evdev_device *device,
|
||||||
uint64_t now,
|
usec_t now,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -136,7 +137,7 @@ middlebutton_post_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_idle_handle_event(struct evdev_device *device,
|
evdev_middlebutton_idle_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -162,7 +163,7 @@ evdev_middlebutton_idle_handle_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_ldown_handle_event(struct evdev_device *device,
|
evdev_middlebutton_ldown_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -214,7 +215,7 @@ evdev_middlebutton_ldown_handle_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
|
evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -266,7 +267,7 @@ evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_middle_handle_event(struct evdev_device *device,
|
evdev_middlebutton_middle_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -308,7 +309,7 @@ evdev_middlebutton_middle_handle_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_lup_pending_handle_event(struct evdev_device *device,
|
evdev_middlebutton_lup_pending_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -344,7 +345,7 @@ evdev_middlebutton_lup_pending_handle_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_rup_pending_handle_event(struct evdev_device *device,
|
evdev_middlebutton_rup_pending_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -380,7 +381,7 @@ evdev_middlebutton_rup_pending_handle_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_passthrough_handle_event(struct evdev_device *device,
|
evdev_middlebutton_passthrough_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -403,7 +404,7 @@ evdev_middlebutton_passthrough_handle_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_ignore_lr_handle_event(struct evdev_device *device,
|
evdev_middlebutton_ignore_lr_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -432,7 +433,7 @@ evdev_middlebutton_ignore_lr_handle_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_ignore_l_handle_event(struct evdev_device *device,
|
evdev_middlebutton_ignore_l_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -457,7 +458,7 @@ evdev_middlebutton_ignore_l_handle_event(struct evdev_device *device,
|
||||||
}
|
}
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_ignore_r_handle_event(struct evdev_device *device,
|
evdev_middlebutton_ignore_r_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -483,7 +484,7 @@ evdev_middlebutton_ignore_r_handle_event(struct evdev_device *device,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_middlebutton_handle_event(struct evdev_device *device,
|
evdev_middlebutton_handle_event(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum evdev_middlebutton_event event)
|
enum evdev_middlebutton_event event)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
@ -553,7 +554,7 @@ evdev_middlebutton_apply_config(struct evdev_device *device)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
evdev_middlebutton_filter_button(struct evdev_device *device,
|
evdev_middlebutton_filter_button(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -616,7 +617,7 @@ evdev_middlebutton_filter_button(struct evdev_device *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evdev_middlebutton_handle_timeout(uint64_t now, void *data)
|
evdev_middlebutton_handle_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct evdev_device *device = evdev_device(data);
|
struct evdev_device *device = evdev_device(data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@
|
||||||
#include "evdev-mt-touchpad.h"
|
#include "evdev-mt-touchpad.h"
|
||||||
#include "linux/input.h"
|
#include "linux/input.h"
|
||||||
|
|
||||||
#define DEFAULT_BUTTON_ENTER_TIMEOUT ms2us(100)
|
#define DEFAULT_BUTTON_ENTER_TIMEOUT usec_from_millis(100)
|
||||||
#define DEFAULT_BUTTON_LEAVE_TIMEOUT ms2us(300)
|
#define DEFAULT_BUTTON_LEAVE_TIMEOUT usec_from_millis(300)
|
||||||
|
|
||||||
/*****************************************
|
/*****************************************
|
||||||
* BEFORE YOU EDIT THIS FILE, look at the state diagram in
|
* BEFORE YOU EDIT THIS FILE, look at the state diagram in
|
||||||
|
|
@ -121,15 +121,17 @@ is_inside_top_middle_area(const struct tp_dispatch *tp, const struct tp_touch *t
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_button_set_enter_timer(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_button_set_enter_timer(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
libinput_timer_set(&t->button.timer, time + DEFAULT_BUTTON_ENTER_TIMEOUT);
|
libinput_timer_set(&t->button.timer,
|
||||||
|
usec_add(time, DEFAULT_BUTTON_ENTER_TIMEOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_button_set_leave_timer(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_button_set_leave_timer(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
libinput_timer_set(&t->button.timer, time + DEFAULT_BUTTON_LEAVE_TIMEOUT);
|
libinput_timer_set(&t->button.timer,
|
||||||
|
usec_add(time, DEFAULT_BUTTON_LEAVE_TIMEOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -141,7 +143,7 @@ tp_button_set_state(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum button_state new_state,
|
enum button_state new_state,
|
||||||
enum button_event event,
|
enum button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
libinput_timer_cancel(&t->button.timer);
|
libinput_timer_cancel(&t->button.timer);
|
||||||
|
|
||||||
|
|
@ -176,7 +178,7 @@ static void
|
||||||
tp_button_none_handle_event(struct tp_dispatch *tp,
|
tp_button_none_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum button_event event,
|
enum button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BUTTON_EVENT_IN_BOTTOM_R:
|
case BUTTON_EVENT_IN_BOTTOM_R:
|
||||||
|
|
@ -206,7 +208,7 @@ static void
|
||||||
tp_button_area_handle_event(struct tp_dispatch *tp,
|
tp_button_area_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum button_event event,
|
enum button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BUTTON_EVENT_IN_BOTTOM_R:
|
case BUTTON_EVENT_IN_BOTTOM_R:
|
||||||
|
|
@ -233,23 +235,22 @@ tp_button_area_handle_event(struct tp_dispatch *tp,
|
||||||
* that triggered this call).
|
* that triggered this call).
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
tp_button_release_other_bottom_touches(struct tp_dispatch *tp,
|
tp_button_release_other_bottom_touches(struct tp_dispatch *tp, usec_t other_start_time)
|
||||||
uint64_t other_start_time)
|
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
||||||
tp_for_each_touch(tp, t) {
|
tp_for_each_touch(tp, t) {
|
||||||
uint64_t tdelta;
|
usec_t tdelta;
|
||||||
|
|
||||||
if (t->button.state != BUTTON_STATE_BOTTOM || t->button.has_moved)
|
if (t->button.state != BUTTON_STATE_BOTTOM || t->button.has_moved)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (other_start_time > t->button.initial_time)
|
if (usec_cmp(other_start_time, t->button.initial_time) > 0)
|
||||||
tdelta = other_start_time - t->button.initial_time;
|
tdelta = usec_delta(other_start_time, t->button.initial_time);
|
||||||
else
|
else
|
||||||
tdelta = t->button.initial_time - other_start_time;
|
tdelta = usec_delta(t->button.initial_time, other_start_time);
|
||||||
|
|
||||||
if (tdelta > ms2us(80))
|
if (usec_cmp(tdelta, usec_from_millis(80)) > 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
t->button.has_moved = true;
|
t->button.has_moved = true;
|
||||||
|
|
@ -260,7 +261,7 @@ static void
|
||||||
tp_button_bottom_handle_event(struct tp_dispatch *tp,
|
tp_button_bottom_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum button_event event,
|
enum button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BUTTON_EVENT_IN_BOTTOM_R:
|
case BUTTON_EVENT_IN_BOTTOM_R:
|
||||||
|
|
@ -296,7 +297,7 @@ static void
|
||||||
tp_button_top_handle_event(struct tp_dispatch *tp,
|
tp_button_top_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum button_event event,
|
enum button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BUTTON_EVENT_IN_BOTTOM_R:
|
case BUTTON_EVENT_IN_BOTTOM_R:
|
||||||
|
|
@ -327,7 +328,7 @@ static void
|
||||||
tp_button_top_new_handle_event(struct tp_dispatch *tp,
|
tp_button_top_new_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum button_event event,
|
enum button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BUTTON_EVENT_IN_BOTTOM_R:
|
case BUTTON_EVENT_IN_BOTTOM_R:
|
||||||
|
|
@ -362,7 +363,7 @@ static void
|
||||||
tp_button_top_to_ignore_handle_event(struct tp_dispatch *tp,
|
tp_button_top_to_ignore_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum button_event event,
|
enum button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BUTTON_EVENT_IN_TOP_R:
|
case BUTTON_EVENT_IN_TOP_R:
|
||||||
|
|
@ -394,7 +395,7 @@ static void
|
||||||
tp_button_ignore_handle_event(struct tp_dispatch *tp,
|
tp_button_ignore_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum button_event event,
|
enum button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BUTTON_EVENT_IN_BOTTOM_R:
|
case BUTTON_EVENT_IN_BOTTOM_R:
|
||||||
|
|
@ -422,7 +423,7 @@ static void
|
||||||
tp_button_handle_event(struct tp_dispatch *tp,
|
tp_button_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum button_event event,
|
enum button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum button_state current = t->button.state;
|
enum button_state current = t->button.state;
|
||||||
|
|
||||||
|
|
@ -496,7 +497,7 @@ tp_button_check_for_movement(struct tp_dispatch *tp, struct tp_touch *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_button_handle_state(struct tp_dispatch *tp, uint64_t time)
|
tp_button_handle_state(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
||||||
|
|
@ -547,7 +548,7 @@ tp_button_handle_state(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_button_handle_timeout(uint64_t now, void *data)
|
tp_button_handle_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct tp_touch *t = data;
|
struct tp_touch *t = data;
|
||||||
|
|
||||||
|
|
@ -555,7 +556,7 @@ tp_button_handle_timeout(uint64_t now, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_process_button(struct tp_dispatch *tp, const struct evdev_event *e, uint64_t time)
|
tp_process_button(struct tp_dispatch *tp, const struct evdev_event *e, usec_t time)
|
||||||
{
|
{
|
||||||
uint32_t mask = bit(evdev_usage_enum(e->usage) - EVDEV_BTN_LEFT);
|
uint32_t mask = bit(evdev_usage_enum(e->usage) - EVDEV_BTN_LEFT);
|
||||||
|
|
||||||
|
|
@ -577,7 +578,7 @@ tp_process_button(struct tp_dispatch *tp, const struct evdev_event *e, uint64_t
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_release_all_buttons(struct tp_dispatch *tp, uint64_t time)
|
tp_release_all_buttons(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
if (tp->buttons.state) {
|
if (tp->buttons.state) {
|
||||||
tp->buttons.state = 0;
|
tp->buttons.state = 0;
|
||||||
|
|
@ -1032,7 +1033,7 @@ tp_remove_buttons(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
tp_post_physical_buttons(struct tp_dispatch *tp, uint64_t time)
|
tp_post_physical_buttons(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
uint32_t current, old, button;
|
uint32_t current, old, button;
|
||||||
|
|
||||||
|
|
@ -1180,7 +1181,7 @@ out:
|
||||||
|
|
||||||
static int
|
static int
|
||||||
tp_notify_clickpadbutton(struct tp_dispatch *tp,
|
tp_notify_clickpadbutton(struct tp_dispatch *tp,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
uint32_t is_topbutton,
|
uint32_t is_topbutton,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
|
|
@ -1227,7 +1228,7 @@ tp_notify_clickpadbutton(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
|
tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
uint32_t current, old, is_top;
|
uint32_t current, old, is_top;
|
||||||
evdev_usage_t button;
|
evdev_usage_t button;
|
||||||
|
|
@ -1332,7 +1333,7 @@ tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
tp_post_button_events(struct tp_dispatch *tp, uint64_t time)
|
tp_post_button_events(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
if (tp->buttons.is_clickpad ||
|
if (tp->buttons.is_clickpad ||
|
||||||
tp->device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON)
|
tp->device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON)
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,9 @@ tp_touch_get_edge(const struct tp_dispatch *tp, const struct tp_touch *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
tp_edge_scroll_set_timer(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_edge_scroll_set_timer(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
const int DEFAULT_SCROLL_LOCK_TIMEOUT = ms2us(300);
|
const usec_t DEFAULT_SCROLL_LOCK_TIMEOUT = usec_from_millis(300);
|
||||||
/* if we use software buttons, we disable timeout-based
|
/* if we use software buttons, we disable timeout-based
|
||||||
* edge scrolling. A finger resting on the button areas is
|
* edge scrolling. A finger resting on the button areas is
|
||||||
* likely there to trigger a button event.
|
* likely there to trigger a button event.
|
||||||
|
|
@ -97,14 +97,15 @@ tp_edge_scroll_set_timer(struct tp_dispatch *tp, struct tp_touch *t, uint64_t ti
|
||||||
if (tp->buttons.click_method == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)
|
if (tp->buttons.click_method == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
libinput_timer_set(&t->scroll.timer, time + DEFAULT_SCROLL_LOCK_TIMEOUT);
|
libinput_timer_set(&t->scroll.timer,
|
||||||
|
usec_add(time, DEFAULT_SCROLL_LOCK_TIMEOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_edge_scroll_set_state(struct tp_dispatch *tp,
|
tp_edge_scroll_set_state(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tp_edge_scroll_touch_state state,
|
enum tp_edge_scroll_touch_state state,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
libinput_timer_cancel(&t->scroll.timer);
|
libinput_timer_cancel(&t->scroll.timer);
|
||||||
|
|
||||||
|
|
@ -131,7 +132,7 @@ static void
|
||||||
tp_edge_scroll_handle_none(struct tp_dispatch *tp,
|
tp_edge_scroll_handle_none(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum scroll_event event,
|
enum scroll_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case SCROLL_EVENT_TOUCH:
|
case SCROLL_EVENT_TOUCH:
|
||||||
|
|
@ -164,7 +165,7 @@ static void
|
||||||
tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp,
|
tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum scroll_event event,
|
enum scroll_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case SCROLL_EVENT_TOUCH:
|
case SCROLL_EVENT_TOUCH:
|
||||||
|
|
@ -196,7 +197,7 @@ static void
|
||||||
tp_edge_scroll_handle_edge(struct tp_dispatch *tp,
|
tp_edge_scroll_handle_edge(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum scroll_event event,
|
enum scroll_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case SCROLL_EVENT_TOUCH:
|
case SCROLL_EVENT_TOUCH:
|
||||||
|
|
@ -230,7 +231,7 @@ static void
|
||||||
tp_edge_scroll_handle_area(struct tp_dispatch *tp,
|
tp_edge_scroll_handle_area(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum scroll_event event,
|
enum scroll_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case SCROLL_EVENT_TOUCH:
|
case SCROLL_EVENT_TOUCH:
|
||||||
|
|
@ -252,7 +253,7 @@ static void
|
||||||
tp_edge_scroll_handle_event(struct tp_dispatch *tp,
|
tp_edge_scroll_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum scroll_event event,
|
enum scroll_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum tp_edge_scroll_touch_state current = t->scroll.edge_state;
|
enum tp_edge_scroll_touch_state current = t->scroll.edge_state;
|
||||||
|
|
||||||
|
|
@ -281,7 +282,7 @@ tp_edge_scroll_handle_event(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_edge_scroll_handle_timeout(uint64_t now, void *data)
|
tp_edge_scroll_handle_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct tp_touch *t = data;
|
struct tp_touch *t = data;
|
||||||
|
|
||||||
|
|
@ -349,7 +350,7 @@ tp_remove_edge_scroll(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_edge_scroll_handle_state(struct tp_dispatch *tp, uint64_t time)
|
tp_edge_scroll_handle_state(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
||||||
|
|
@ -393,7 +394,7 @@ tp_edge_scroll_handle_state(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
|
tp_edge_scroll_post_events(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct evdev_device *device = tp->device;
|
struct evdev_device *device = tp->device;
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
@ -478,7 +479,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time)
|
tp_edge_scroll_stop_events(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct evdev_device *device = tp->device;
|
struct evdev_device *device = tp->device;
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@ enum gesture_cancelled {
|
||||||
CANCEL_GESTURE = 1,
|
CANCEL_GESTURE = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define QUICK_GESTURE_HOLD_TIMEOUT ms2us(40)
|
#define QUICK_GESTURE_HOLD_TIMEOUT usec_from_millis(40)
|
||||||
#define DEFAULT_GESTURE_HOLD_TIMEOUT ms2us(180)
|
#define DEFAULT_GESTURE_HOLD_TIMEOUT usec_from_millis(180)
|
||||||
#define DEFAULT_GESTURE_SWITCH_TIMEOUT ms2us(100)
|
#define DEFAULT_GESTURE_SWITCH_TIMEOUT usec_from_millis(100)
|
||||||
#define DEFAULT_GESTURE_SWIPE_TIMEOUT ms2us(150)
|
#define DEFAULT_GESTURE_SWIPE_TIMEOUT usec_from_millis(150)
|
||||||
#define DEFAULT_GESTURE_PINCH_TIMEOUT ms2us(300)
|
#define DEFAULT_GESTURE_PINCH_TIMEOUT usec_from_millis(300)
|
||||||
|
|
||||||
#define HOLD_AND_MOTION_THRESHOLD 0.5 /* mm */
|
#define HOLD_AND_MOTION_THRESHOLD 0.5 /* mm */
|
||||||
#define PINCH_DISAMBIGUATION_MOVE_THRESHOLD 1.5 /* mm */
|
#define PINCH_DISAMBIGUATION_MOVE_THRESHOLD 1.5 /* mm */
|
||||||
|
|
@ -152,10 +152,10 @@ tp_gesture_init_scroll(struct tp_dispatch *tp)
|
||||||
struct phys_coords zero = { 0.0, 0.0 };
|
struct phys_coords zero = { 0.0, 0.0 };
|
||||||
tp->scroll.active.h = false;
|
tp->scroll.active.h = false;
|
||||||
tp->scroll.active.v = false;
|
tp->scroll.active.v = false;
|
||||||
tp->scroll.duration.h = 0;
|
tp->scroll.duration.h = usec_from_uint64_t(0);
|
||||||
tp->scroll.duration.v = 0;
|
tp->scroll.duration.v = usec_from_uint64_t(0);
|
||||||
tp->scroll.vector = zero;
|
tp->scroll.vector = zero;
|
||||||
tp->scroll.time_prev = 0;
|
tp->scroll.time_prev = usec_from_uint64_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct device_float_coords
|
static inline struct device_float_coords
|
||||||
|
|
@ -185,7 +185,7 @@ tp_get_raw_pointer_motion(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
tp_has_pending_pointer_motion(struct tp_dispatch *tp, uint64_t time)
|
tp_has_pending_pointer_motion(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct device_float_coords raw;
|
struct device_float_coords raw;
|
||||||
|
|
||||||
|
|
@ -202,7 +202,7 @@ tp_has_pending_pointer_motion(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_post_pointer_motion(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct device_float_coords raw;
|
struct device_float_coords raw;
|
||||||
struct normalized_coords delta;
|
struct normalized_coords delta;
|
||||||
|
|
@ -316,12 +316,12 @@ tp_gesture_init_pinch(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
tp_gesture_init_3fg_drag(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_init_3fg_drag(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
tp_gesture_stop_3fg_drag(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_stop_3fg_drag(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -344,24 +344,27 @@ static void
|
||||||
tp_gesture_apply_scroll_constraints(struct tp_dispatch *tp,
|
tp_gesture_apply_scroll_constraints(struct tp_dispatch *tp,
|
||||||
struct device_float_coords *raw,
|
struct device_float_coords *raw,
|
||||||
struct normalized_coords *delta,
|
struct normalized_coords *delta,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
uint64_t tdelta = 0;
|
usec_t tdelta = usec_from_millis(0);
|
||||||
struct phys_coords delta_mm, vector;
|
struct phys_coords delta_mm, vector;
|
||||||
double vector_decay, vector_length, slope;
|
double vector_decay, vector_length, slope;
|
||||||
|
|
||||||
const uint64_t ACTIVE_THRESHOLD = ms2us(100), INACTIVE_THRESHOLD = ms2us(50),
|
const usec_t ACTIVE_THRESHOLD = usec_from_millis(100),
|
||||||
EVENT_TIMEOUT = ms2us(100);
|
INACTIVE_THRESHOLD = usec_from_millis(50),
|
||||||
|
EVENT_TIMEOUT = usec_from_millis(100);
|
||||||
|
|
||||||
/* Both axes active == true means free scrolling is enabled */
|
/* Both axes active == true means free scrolling is enabled */
|
||||||
if (tp->scroll.active.h && tp->scroll.active.v)
|
if (tp->scroll.active.h && tp->scroll.active.v)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Determine time delta since last movement event */
|
/* Determine time delta since last movement event */
|
||||||
if (tp->scroll.time_prev != 0)
|
if (!usec_is_zero(tp->scroll.time_prev)) {
|
||||||
tdelta = time - tp->scroll.time_prev;
|
usec_t diff = usec_delta(time, tp->scroll.time_prev);
|
||||||
if (tdelta > EVENT_TIMEOUT)
|
if (usec_cmp(diff, EVENT_TIMEOUT) <= 0)
|
||||||
tdelta = 0;
|
tdelta = diff;
|
||||||
|
}
|
||||||
|
|
||||||
tp->scroll.time_prev = time;
|
tp->scroll.time_prev = time;
|
||||||
|
|
||||||
/* Delta since last movement event in mm */
|
/* Delta since last movement event in mm */
|
||||||
|
|
@ -372,11 +375,13 @@ tp_gesture_apply_scroll_constraints(struct tp_dispatch *tp,
|
||||||
* EVENT_TIMEOUT of 100, vector_decay = (0.97)^tdelta. This linear
|
* EVENT_TIMEOUT of 100, vector_decay = (0.97)^tdelta. This linear
|
||||||
* approximation allows easier tweaking of EVENT_TIMEOUT and is faster.
|
* approximation allows easier tweaking of EVENT_TIMEOUT and is faster.
|
||||||
*/
|
*/
|
||||||
if (tdelta > 0) {
|
if (usec_gt(tdelta, 0)) {
|
||||||
|
uint64_t delta = usec_as_uint64_t(tdelta);
|
||||||
double recent, later;
|
double recent, later;
|
||||||
recent = ((EVENT_TIMEOUT / 2.0) - tdelta) / (EVENT_TIMEOUT / 2.0);
|
uint64_t timeout_us = usec_as_uint64_t(EVENT_TIMEOUT);
|
||||||
later = (EVENT_TIMEOUT - tdelta) / (EVENT_TIMEOUT * 2.0);
|
recent = ((timeout_us / 2.0) - delta) / (timeout_us / 2.0);
|
||||||
vector_decay = tdelta <= (0.33 * EVENT_TIMEOUT) ? recent : later;
|
later = (timeout_us - delta) / (timeout_us * 2.0);
|
||||||
|
vector_decay = delta <= (0.33 * timeout_us) ? recent : later;
|
||||||
} else {
|
} else {
|
||||||
vector_decay = 0.0;
|
vector_decay = 0.0;
|
||||||
}
|
}
|
||||||
|
|
@ -407,36 +412,38 @@ tp_gesture_apply_scroll_constraints(struct tp_dispatch *tp,
|
||||||
const double MIN_VECTOR = 0.15;
|
const double MIN_VECTOR = 0.15;
|
||||||
|
|
||||||
if (slope >= DEGREE_30 && vector_length > MIN_VECTOR) {
|
if (slope >= DEGREE_30 && vector_length > MIN_VECTOR) {
|
||||||
tp->scroll.duration.v += tdelta;
|
tp->scroll.duration.v = usec_add(tp->scroll.duration.v, tdelta);
|
||||||
if (tp->scroll.duration.v > ACTIVE_THRESHOLD)
|
if (usec_cmp(tp->scroll.duration.v, ACTIVE_THRESHOLD) > 0)
|
||||||
tp->scroll.duration.v = ACTIVE_THRESHOLD;
|
tp->scroll.duration.v = ACTIVE_THRESHOLD;
|
||||||
if (slope >= DEGREE_75) {
|
if (slope >= DEGREE_75) {
|
||||||
if (tp->scroll.duration.h > tdelta)
|
if (usec_cmp(tp->scroll.duration.h, tdelta) > 0)
|
||||||
tp->scroll.duration.h -= tdelta;
|
tp->scroll.duration.h =
|
||||||
|
usec_sub(tp->scroll.duration.h, tdelta);
|
||||||
else
|
else
|
||||||
tp->scroll.duration.h = 0;
|
tp->scroll.duration.h = usec_from_uint64_t(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (slope < DEGREE_60 && vector_length > MIN_VECTOR) {
|
if (slope < DEGREE_60 && vector_length > MIN_VECTOR) {
|
||||||
tp->scroll.duration.h += tdelta;
|
tp->scroll.duration.h = usec_add(tp->scroll.duration.h, tdelta);
|
||||||
if (tp->scroll.duration.h > ACTIVE_THRESHOLD)
|
if (usec_cmp(tp->scroll.duration.h, ACTIVE_THRESHOLD) > 0)
|
||||||
tp->scroll.duration.h = ACTIVE_THRESHOLD;
|
tp->scroll.duration.h = ACTIVE_THRESHOLD;
|
||||||
if (slope < DEGREE_15) {
|
if (slope < DEGREE_15) {
|
||||||
if (tp->scroll.duration.v > tdelta)
|
if (usec_cmp(tp->scroll.duration.v, tdelta) > 0)
|
||||||
tp->scroll.duration.v -= tdelta;
|
tp->scroll.duration.v =
|
||||||
|
usec_sub(tp->scroll.duration.v, tdelta);
|
||||||
else
|
else
|
||||||
tp->scroll.duration.v = 0;
|
tp->scroll.duration.v = usec_from_uint64_t(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tp->scroll.duration.h == ACTIVE_THRESHOLD) {
|
if (usec_cmp(tp->scroll.duration.h, ACTIVE_THRESHOLD) == 0) {
|
||||||
tp->scroll.active.h = true;
|
tp->scroll.active.h = true;
|
||||||
if (tp->scroll.duration.v < INACTIVE_THRESHOLD)
|
if (usec_cmp(tp->scroll.duration.v, INACTIVE_THRESHOLD) < 0)
|
||||||
tp->scroll.active.v = false;
|
tp->scroll.active.v = false;
|
||||||
}
|
}
|
||||||
if (tp->scroll.duration.v == ACTIVE_THRESHOLD) {
|
if (usec_cmp(tp->scroll.duration.v, ACTIVE_THRESHOLD) == 0) {
|
||||||
tp->scroll.active.v = true;
|
tp->scroll.active.v = true;
|
||||||
if (tp->scroll.duration.h < INACTIVE_THRESHOLD)
|
if (usec_cmp(tp->scroll.duration.h, INACTIVE_THRESHOLD) < 0)
|
||||||
tp->scroll.active.h = false;
|
tp->scroll.active.h = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -519,9 +526,9 @@ tp_gesture_use_hold_timer(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_set_hold_timer(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_set_hold_timer(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
uint64_t timeout;
|
usec_t timeout;
|
||||||
|
|
||||||
if (!tp->gesture.hold_enabled)
|
if (!tp->gesture.hold_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
@ -530,14 +537,14 @@ tp_gesture_set_hold_timer(struct tp_dispatch *tp, uint64_t time)
|
||||||
timeout = tp_gesture_is_quick_hold(tp) ? QUICK_GESTURE_HOLD_TIMEOUT
|
timeout = tp_gesture_is_quick_hold(tp) ? QUICK_GESTURE_HOLD_TIMEOUT
|
||||||
: DEFAULT_GESTURE_HOLD_TIMEOUT;
|
: DEFAULT_GESTURE_HOLD_TIMEOUT;
|
||||||
|
|
||||||
libinput_timer_set(&tp->gesture.hold_timer, time + timeout);
|
libinput_timer_set(&tp->gesture.hold_timer, usec_add(time, timeout));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_none(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_none(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -581,7 +588,7 @@ tp_gesture_handle_event_on_state_none(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_unknown(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_unknown(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -634,7 +641,7 @@ tp_gesture_handle_event_on_state_unknown(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_hold(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_hold(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -692,7 +699,7 @@ tp_gesture_handle_event_on_state_hold(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_hold_and_motion(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_hold_and_motion(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -733,7 +740,7 @@ tp_gesture_handle_event_on_state_hold_and_motion(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_pointer_motion(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_pointer_motion(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *first;
|
struct tp_touch *first;
|
||||||
struct phys_coords first_moved;
|
struct phys_coords first_moved;
|
||||||
|
|
@ -779,7 +786,7 @@ tp_gesture_handle_event_on_state_pointer_motion(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_scroll_start(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_scroll_start(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -812,7 +819,7 @@ tp_gesture_handle_event_on_state_scroll_start(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_scroll(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_scroll(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -847,7 +854,7 @@ tp_gesture_handle_event_on_state_scroll(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_pinch_start(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_pinch_start(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -875,7 +882,7 @@ tp_gesture_handle_event_on_state_pinch_start(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_pinch(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_pinch(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -914,7 +921,7 @@ tp_gesture_handle_event_on_state_pinch(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_swipe_start(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_swipe_start(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -943,7 +950,7 @@ tp_gesture_handle_event_on_state_swipe_start(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_swipe(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_swipe(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -981,7 +988,7 @@ tp_gesture_handle_event_on_state_swipe(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_3fg_drag_start(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_3fg_drag_start(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -1008,16 +1015,16 @@ tp_gesture_handle_event_on_state_3fg_drag_start(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_set_3fg_drag_timer(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_set_3fg_drag_timer(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
tp->gesture.drag_3fg_release_time = time;
|
tp->gesture.drag_3fg_release_time = time;
|
||||||
libinput_timer_set(&tp->gesture.drag_3fg_timer, time + ms2us(700));
|
libinput_timer_set(&tp->gesture.drag_3fg_timer, usec_add_millis(time, 700));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_3fg_drag(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_3fg_drag(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -1065,7 +1072,7 @@ tp_gesture_handle_event_on_state_3fg_drag(struct tp_dispatch *tp,
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event_on_state_3fg_drag_released(struct tp_dispatch *tp,
|
tp_gesture_handle_event_on_state_3fg_drag_released(struct tp_dispatch *tp,
|
||||||
enum gesture_event event,
|
enum gesture_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case GESTURE_EVENT_RESET:
|
case GESTURE_EVENT_RESET:
|
||||||
|
|
@ -1125,7 +1132,7 @@ tp_gesture_handle_event_on_state_3fg_drag_released(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_event(struct tp_dispatch *tp, enum gesture_event event, uint64_t time)
|
tp_gesture_handle_event(struct tp_dispatch *tp, enum gesture_event event, usec_t time)
|
||||||
{
|
{
|
||||||
enum tp_gesture_state oldstate;
|
enum tp_gesture_state oldstate;
|
||||||
|
|
||||||
|
|
@ -1187,7 +1194,7 @@ tp_gesture_handle_event(struct tp_dispatch *tp, enum gesture_event event, uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_hold_timeout(uint64_t now, void *data)
|
tp_gesture_hold_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
|
|
||||||
|
|
@ -1198,7 +1205,7 @@ tp_gesture_hold_timeout(uint64_t now, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_tap_timeout(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_tap_timeout(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
if (!tp->gesture.hold_enabled)
|
if (!tp->gesture.hold_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
@ -1208,7 +1215,7 @@ tp_gesture_tap_timeout(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_3fg_drag_timeout(uint64_t now, void *data)
|
tp_gesture_3fg_drag_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
|
|
||||||
|
|
@ -1216,7 +1223,7 @@ tp_gesture_3fg_drag_timeout(uint64_t now, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_detect_motion_gestures(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_detect_motion_gestures(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *first = tp->gesture.touches[0],
|
struct tp_touch *first = tp->gesture.touches[0],
|
||||||
*second = tp->gesture.touches[1], *thumb;
|
*second = tp->gesture.touches[1], *thumb;
|
||||||
|
|
@ -1281,7 +1288,9 @@ tp_gesture_detect_motion_gestures(struct tp_dispatch *tp, uint64_t time)
|
||||||
/* If both touches are within 7mm vertically and 40mm horizontally
|
/* If both touches are within 7mm vertically and 40mm horizontally
|
||||||
* past the timeout, assume scroll/swipe */
|
* past the timeout, assume scroll/swipe */
|
||||||
if ((!tp->gesture.enabled || (distance_mm.x < 40.0 && distance_mm.y < 7.0)) &&
|
if ((!tp->gesture.enabled || (distance_mm.x < 40.0 && distance_mm.y < 7.0)) &&
|
||||||
time > (tp->gesture.initial_time + DEFAULT_GESTURE_SWIPE_TIMEOUT)) {
|
usec_cmp(time,
|
||||||
|
usec_add(tp->gesture.initial_time,
|
||||||
|
DEFAULT_GESTURE_SWIPE_TIMEOUT)) > 0) {
|
||||||
if (tp->gesture.finger_count == 2)
|
if (tp->gesture.finger_count == 2)
|
||||||
tp_gesture_handle_event(tp, GESTURE_EVENT_SCROLL_START, time);
|
tp_gesture_handle_event(tp, GESTURE_EVENT_SCROLL_START, time);
|
||||||
else if (tp->drag_3fg.nfingers == tp->gesture.finger_count)
|
else if (tp->drag_3fg.nfingers == tp->gesture.finger_count)
|
||||||
|
|
@ -1416,7 +1425,7 @@ tp_gesture_is_pinch(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_none(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_none(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *first, *second;
|
struct tp_touch *first, *second;
|
||||||
struct tp_touch *touches[4];
|
struct tp_touch *touches[4];
|
||||||
|
|
@ -1485,23 +1494,21 @@ tp_gesture_handle_state_none(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_unknown(struct tp_dispatch *tp,
|
tp_gesture_handle_state_unknown(struct tp_dispatch *tp, usec_t time, bool ignore_motion)
|
||||||
uint64_t time,
|
|
||||||
bool ignore_motion)
|
|
||||||
{
|
{
|
||||||
if (!ignore_motion)
|
if (!ignore_motion)
|
||||||
tp_gesture_detect_motion_gestures(tp, time);
|
tp_gesture_detect_motion_gestures(tp, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_hold(struct tp_dispatch *tp, uint64_t time, bool ignore_motion)
|
tp_gesture_handle_state_hold(struct tp_dispatch *tp, usec_t time, bool ignore_motion)
|
||||||
{
|
{
|
||||||
if (!ignore_motion)
|
if (!ignore_motion)
|
||||||
tp_gesture_detect_motion_gestures(tp, time);
|
tp_gesture_detect_motion_gestures(tp, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_hold_and_pointer_motion(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_hold_and_pointer_motion(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
if (tp->queued & TOUCHPAD_EVENT_MOTION)
|
if (tp->queued & TOUCHPAD_EVENT_MOTION)
|
||||||
tp_gesture_post_pointer_motion(tp, time);
|
tp_gesture_post_pointer_motion(tp, time);
|
||||||
|
|
@ -1510,14 +1517,14 @@ tp_gesture_handle_state_hold_and_pointer_motion(struct tp_dispatch *tp, uint64_t
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_pointer_motion(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_pointer_motion(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
if (tp->queued & TOUCHPAD_EVENT_MOTION)
|
if (tp->queued & TOUCHPAD_EVENT_MOTION)
|
||||||
tp_gesture_post_pointer_motion(tp, time);
|
tp_gesture_post_pointer_motion(tp, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_scroll_start(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_scroll_start(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct device_float_coords raw;
|
struct device_float_coords raw;
|
||||||
struct normalized_coords delta;
|
struct normalized_coords delta;
|
||||||
|
|
@ -1528,7 +1535,9 @@ tp_gesture_handle_state_scroll_start(struct tp_dispatch *tp, uint64_t time)
|
||||||
/* We may confuse a pinch for a scroll initially,
|
/* We may confuse a pinch for a scroll initially,
|
||||||
* allow ourselves to correct our guess.
|
* allow ourselves to correct our guess.
|
||||||
*/
|
*/
|
||||||
if (time < (tp->gesture.initial_time + DEFAULT_GESTURE_PINCH_TIMEOUT) &&
|
if (usec_cmp(time,
|
||||||
|
usec_add(tp->gesture.initial_time,
|
||||||
|
DEFAULT_GESTURE_PINCH_TIMEOUT)) < 0 &&
|
||||||
tp_gesture_is_pinch(tp)) {
|
tp_gesture_is_pinch(tp)) {
|
||||||
tp_gesture_handle_event(tp, GESTURE_EVENT_PINCH_START, time);
|
tp_gesture_handle_event(tp, GESTURE_EVENT_PINCH_START, time);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1547,7 +1556,7 @@ tp_gesture_handle_state_scroll_start(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_scroll(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_scroll(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct device_float_coords raw;
|
struct device_float_coords raw;
|
||||||
struct normalized_coords delta;
|
struct normalized_coords delta;
|
||||||
|
|
@ -1558,7 +1567,9 @@ tp_gesture_handle_state_scroll(struct tp_dispatch *tp, uint64_t time)
|
||||||
/* We may confuse a pinch for a scroll initially,
|
/* We may confuse a pinch for a scroll initially,
|
||||||
* allow ourselves to correct our guess.
|
* allow ourselves to correct our guess.
|
||||||
*/
|
*/
|
||||||
if (time < (tp->gesture.initial_time + DEFAULT_GESTURE_PINCH_TIMEOUT) &&
|
if (usec_cmp(time,
|
||||||
|
usec_add(tp->gesture.initial_time,
|
||||||
|
DEFAULT_GESTURE_PINCH_TIMEOUT)) < 0 &&
|
||||||
tp_gesture_is_pinch(tp)) {
|
tp_gesture_is_pinch(tp)) {
|
||||||
tp_gesture_handle_event(tp, GESTURE_EVENT_PINCH_START, time);
|
tp_gesture_handle_event(tp, GESTURE_EVENT_PINCH_START, time);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1580,7 +1591,7 @@ tp_gesture_handle_state_scroll(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_swipe_start(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_swipe_start(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct device_float_coords raw;
|
struct device_float_coords raw;
|
||||||
struct normalized_coords delta;
|
struct normalized_coords delta;
|
||||||
|
|
@ -1601,7 +1612,7 @@ tp_gesture_handle_state_swipe_start(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_swipe(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_swipe(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct device_float_coords raw;
|
struct device_float_coords raw;
|
||||||
struct normalized_coords delta, unaccel;
|
struct normalized_coords delta, unaccel;
|
||||||
|
|
@ -1621,7 +1632,7 @@ tp_gesture_handle_state_swipe(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_pinch_start(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_pinch_start(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||||
double angle, angle_delta, distance, scale;
|
double angle, angle_delta, distance, scale;
|
||||||
|
|
@ -1662,7 +1673,7 @@ tp_gesture_handle_state_pinch_start(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_pinch(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_pinch(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
double angle, angle_delta, distance, scale;
|
double angle, angle_delta, distance, scale;
|
||||||
struct device_float_coords center, fdelta;
|
struct device_float_coords center, fdelta;
|
||||||
|
|
@ -1702,7 +1713,7 @@ tp_gesture_handle_state_pinch(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_3fg_drag_start(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_3fg_drag_start(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
evdev_pointer_notify_button(tp->device,
|
evdev_pointer_notify_button(tp->device,
|
||||||
time,
|
time,
|
||||||
|
|
@ -1713,7 +1724,7 @@ tp_gesture_handle_state_3fg_drag_start(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_3fg_drag(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_handle_state_3fg_drag(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
if (tp->queued & TOUCHPAD_EVENT_MOTION)
|
if (tp->queued & TOUCHPAD_EVENT_MOTION)
|
||||||
tp_gesture_post_pointer_motion(tp, time);
|
tp_gesture_post_pointer_motion(tp, time);
|
||||||
|
|
@ -1721,14 +1732,14 @@ tp_gesture_handle_state_3fg_drag(struct tp_dispatch *tp, uint64_t time)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state_3fg_drag_released(struct tp_dispatch *tp,
|
tp_gesture_handle_state_3fg_drag_released(struct tp_dispatch *tp,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
bool ignore_motion)
|
bool ignore_motion)
|
||||||
{
|
{
|
||||||
tp_gesture_detect_motion_gestures(tp, time);
|
tp_gesture_detect_motion_gestures(tp, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time, bool ignore_motion)
|
tp_gesture_handle_state(struct tp_dispatch *tp, usec_t time, bool ignore_motion)
|
||||||
{
|
{
|
||||||
enum tp_gesture_state oldstate = tp->gesture.state;
|
enum tp_gesture_state oldstate = tp->gesture.state;
|
||||||
enum tp_gesture_state transitions[16] = { 0 };
|
enum tp_gesture_state transitions[16] = { 0 };
|
||||||
|
|
@ -1839,7 +1850,7 @@ tp_gesture_thumb_moved(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time, bool ignore_motion)
|
tp_gesture_post_events(struct tp_dispatch *tp, usec_t time, bool ignore_motion)
|
||||||
{
|
{
|
||||||
if (tp->gesture.finger_count == 0)
|
if (tp->gesture.finger_count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
@ -1867,7 +1878,9 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time, bool ignore_motion
|
||||||
/* When pinching, the thumb tends to move slower than the finger,
|
/* When pinching, the thumb tends to move slower than the finger,
|
||||||
* so we may suppress it too early. Give it some time to move.
|
* so we may suppress it too early. Give it some time to move.
|
||||||
*/
|
*/
|
||||||
if (time < (tp->gesture.initial_time + DEFAULT_GESTURE_PINCH_TIMEOUT) &&
|
if (usec_cmp(time,
|
||||||
|
usec_add(tp->gesture.initial_time,
|
||||||
|
DEFAULT_GESTURE_PINCH_TIMEOUT)) < 0 &&
|
||||||
tp_gesture_thumb_moved(tp))
|
tp_gesture_thumb_moved(tp))
|
||||||
tp_thumb_reset(tp);
|
tp_thumb_reset(tp);
|
||||||
|
|
||||||
|
|
@ -1876,7 +1889,7 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time, bool ignore_motion
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_2FG)
|
if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_2FG)
|
||||||
return;
|
return;
|
||||||
|
|
@ -1885,7 +1898,7 @@ tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_end(struct tp_dispatch *tp, uint64_t time, enum gesture_cancelled cancelled)
|
tp_gesture_end(struct tp_dispatch *tp, usec_t time, enum gesture_cancelled cancelled)
|
||||||
{
|
{
|
||||||
switch (tp->gesture.state) {
|
switch (tp->gesture.state) {
|
||||||
case GESTURE_STATE_NONE:
|
case GESTURE_STATE_NONE:
|
||||||
|
|
@ -1917,13 +1930,13 @@ tp_gesture_end(struct tp_dispatch *tp, uint64_t time, enum gesture_cancelled can
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_cancel(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_cancel(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
tp_gesture_end(tp, time, CANCEL_GESTURE);
|
tp_gesture_end(tp, time, CANCEL_GESTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_cancel_motion_gestures(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_cancel_motion_gestures(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (tp->gesture.state) {
|
switch (tp->gesture.state) {
|
||||||
|
|
@ -1952,13 +1965,13 @@ tp_gesture_cancel_motion_gestures(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_stop(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_stop(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
tp_gesture_end(tp, time, END_GESTURE);
|
tp_gesture_end(tp, time, END_GESTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_gesture_finger_count_switch_timeout(uint64_t now, void *data)
|
tp_gesture_finger_count_switch_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
|
|
||||||
|
|
@ -1996,7 +2009,7 @@ tp_gesture_debounce_finger_changes(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_update_finger_state(struct tp_dispatch *tp, uint64_t time)
|
tp_gesture_update_finger_state(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
unsigned int active_touches = 0;
|
unsigned int active_touches = 0;
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
@ -2026,8 +2039,9 @@ tp_gesture_update_finger_state(struct tp_dispatch *tp, uint64_t time)
|
||||||
/* Else debounce finger changes */
|
/* Else debounce finger changes */
|
||||||
} else if (active_touches != tp->gesture.finger_count_pending) {
|
} else if (active_touches != tp->gesture.finger_count_pending) {
|
||||||
tp->gesture.finger_count_pending = active_touches;
|
tp->gesture.finger_count_pending = active_touches;
|
||||||
libinput_timer_set(&tp->gesture.finger_count_switch_timer,
|
libinput_timer_set(
|
||||||
time + DEFAULT_GESTURE_SWITCH_TIMEOUT);
|
&tp->gesture.finger_count_switch_timer,
|
||||||
|
usec_add(time, DEFAULT_GESTURE_SWITCH_TIMEOUT));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tp->gesture.finger_count_pending = 0;
|
tp->gesture.finger_count_pending = 0;
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,10 @@
|
||||||
|
|
||||||
#include "evdev-mt-touchpad.h"
|
#include "evdev-mt-touchpad.h"
|
||||||
|
|
||||||
#define DEFAULT_TAP_TIMEOUT_PERIOD ms2us(180)
|
#define DEFAULT_TAP_TIMEOUT_PERIOD usec_from_millis(180)
|
||||||
#define DEFAULT_DRAG_TIMEOUT_PERIOD_BASE ms2us(160)
|
#define DEFAULT_DRAG_TIMEOUT_PERIOD_BASE usec_from_millis(160)
|
||||||
#define DEFAULT_DRAG_TIMEOUT_PERIOD_PERFINGER ms2us(20)
|
#define DEFAULT_DRAG_TIMEOUT_PERIOD_PERFINGER usec_from_millis(20)
|
||||||
#define DEFAULT_DRAGLOCK_TIMEOUT_PERIOD ms2us(300)
|
#define DEFAULT_DRAGLOCK_TIMEOUT_PERIOD usec_from_millis(300)
|
||||||
#define DEFAULT_TAP_MOVE_THRESHOLD 1.3 /* mm */
|
#define DEFAULT_TAP_MOVE_THRESHOLD 1.3 /* mm */
|
||||||
|
|
||||||
enum tap_event {
|
enum tap_event {
|
||||||
|
|
@ -120,7 +120,7 @@ log_tap_bug(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_tap_notify(struct tp_dispatch *tp,
|
tp_tap_notify(struct tp_dispatch *tp,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int nfingers,
|
int nfingers,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -151,24 +151,25 @@ tp_tap_notify(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_tap_set_timer(struct tp_dispatch *tp, uint64_t time)
|
tp_tap_set_timer(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
libinput_timer_set(&tp->tap.timer, time + DEFAULT_TAP_TIMEOUT_PERIOD);
|
libinput_timer_set(&tp->tap.timer, usec_add(time, DEFAULT_TAP_TIMEOUT_PERIOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_tap_set_drag_timer(struct tp_dispatch *tp, uint64_t time, int nfingers_tapped)
|
tp_tap_set_drag_timer(struct tp_dispatch *tp, usec_t time, int nfingers_tapped)
|
||||||
{
|
{
|
||||||
libinput_timer_set(
|
usec_t per_finger_timeout =
|
||||||
&tp->tap.timer,
|
usec_mul(DEFAULT_DRAG_TIMEOUT_PERIOD_PERFINGER, nfingers_tapped);
|
||||||
time + DEFAULT_DRAG_TIMEOUT_PERIOD_BASE +
|
usec_t timeout = usec_add(DEFAULT_DRAG_TIMEOUT_PERIOD_BASE, per_finger_timeout);
|
||||||
(nfingers_tapped * DEFAULT_DRAG_TIMEOUT_PERIOD_PERFINGER));
|
libinput_timer_set(&tp->tap.timer, usec_add(time, timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_tap_set_draglock_timer(struct tp_dispatch *tp, uint64_t time)
|
tp_tap_set_draglock_timer(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
libinput_timer_set(&tp->tap.timer, time + DEFAULT_DRAGLOCK_TIMEOUT_PERIOD);
|
libinput_timer_set(&tp->tap.timer,
|
||||||
|
usec_add(time, DEFAULT_DRAGLOCK_TIMEOUT_PERIOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -189,7 +190,7 @@ static void
|
||||||
tp_tap_idle_handle_event(struct tp_dispatch *tp,
|
tp_tap_idle_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case TAP_EVENT_TOUCH:
|
case TAP_EVENT_TOUCH:
|
||||||
|
|
@ -222,7 +223,7 @@ static void
|
||||||
tp_tap_touch_handle_event(struct tp_dispatch *tp,
|
tp_tap_touch_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -276,7 +277,7 @@ static void
|
||||||
tp_tap_hold_handle_event(struct tp_dispatch *tp,
|
tp_tap_hold_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -314,7 +315,7 @@ static void
|
||||||
tp_tap_tapped_handle_event(struct tp_dispatch *tp,
|
tp_tap_tapped_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int nfingers_tapped)
|
int nfingers_tapped)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -363,7 +364,7 @@ static void
|
||||||
tp_tap_touch2_handle_event(struct tp_dispatch *tp,
|
tp_tap_touch2_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -401,7 +402,7 @@ static void
|
||||||
tp_tap_touch2_hold_handle_event(struct tp_dispatch *tp,
|
tp_tap_touch2_hold_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -436,7 +437,7 @@ static void
|
||||||
tp_tap_touch2_release_handle_event(struct tp_dispatch *tp,
|
tp_tap_touch2_release_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -505,7 +506,7 @@ static void
|
||||||
tp_tap_touch3_handle_event(struct tp_dispatch *tp,
|
tp_tap_touch3_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -543,7 +544,7 @@ static void
|
||||||
tp_tap_touch3_hold_handle_event(struct tp_dispatch *tp,
|
tp_tap_touch3_hold_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -576,7 +577,7 @@ static void
|
||||||
tp_tap_touch3_release_handle_event(struct tp_dispatch *tp,
|
tp_tap_touch3_release_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -644,7 +645,7 @@ static void
|
||||||
tp_tap_touch3_release2_handle_event(struct tp_dispatch *tp,
|
tp_tap_touch3_release2_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -742,7 +743,7 @@ static void
|
||||||
tp_tap_dragging_or_doubletap_handle_event(struct tp_dispatch *tp,
|
tp_tap_dragging_or_doubletap_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int nfingers_tapped)
|
int nfingers_tapped)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -808,7 +809,7 @@ static void
|
||||||
tp_tap_dragging_handle_event(struct tp_dispatch *tp,
|
tp_tap_dragging_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int nfingers_tapped)
|
int nfingers_tapped)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -872,7 +873,7 @@ static void
|
||||||
tp_tap_dragging_wait_handle_event(struct tp_dispatch *tp,
|
tp_tap_dragging_wait_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int nfingers_tapped)
|
int nfingers_tapped)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -919,7 +920,7 @@ static void
|
||||||
tp_tap_dragging_tap_handle_event(struct tp_dispatch *tp,
|
tp_tap_dragging_tap_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int nfingers_tapped)
|
int nfingers_tapped)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -979,7 +980,7 @@ static void
|
||||||
tp_tap_dragging2_handle_event(struct tp_dispatch *tp,
|
tp_tap_dragging2_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int nfingers_tapped)
|
int nfingers_tapped)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -1033,7 +1034,7 @@ static void
|
||||||
tp_tap_dead_handle_event(struct tp_dispatch *tp,
|
tp_tap_dead_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -1060,7 +1061,7 @@ static void
|
||||||
tp_tap_handle_event(struct tp_dispatch *tp,
|
tp_tap_handle_event(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
enum tap_event event,
|
enum tap_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum tp_tap_state current;
|
enum tp_tap_state current;
|
||||||
|
|
||||||
|
|
@ -1206,7 +1207,7 @@ tp_tap_enabled(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
|
tp_tap_handle_state(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
int filter_motion = 0;
|
int filter_motion = 0;
|
||||||
|
|
@ -1341,7 +1342,7 @@ tp_tap_post_process_state(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_tap_handle_timeout(uint64_t time, void *data)
|
tp_tap_handle_timeout(usec_t time, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
@ -1357,10 +1358,7 @@ tp_tap_handle_timeout(uint64_t time, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_tap_enabled_update(struct tp_dispatch *tp,
|
tp_tap_enabled_update(struct tp_dispatch *tp, bool suspended, bool enabled, usec_t time)
|
||||||
bool suspended,
|
|
||||||
bool enabled,
|
|
||||||
uint64_t time)
|
|
||||||
{
|
{
|
||||||
bool was_enabled = tp_tap_enabled(tp);
|
bool was_enabled = tp_tap_enabled(tp);
|
||||||
|
|
||||||
|
|
@ -1599,7 +1597,7 @@ tp_remove_tap(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_release_all_taps(struct tp_dispatch *tp, uint64_t now)
|
tp_release_all_taps(struct tp_dispatch *tp, usec_t now)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -1626,13 +1624,13 @@ tp_release_all_taps(struct tp_dispatch *tp, uint64_t now)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_tap_suspend(struct tp_dispatch *tp, uint64_t time)
|
tp_tap_suspend(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
tp_tap_enabled_update(tp, true, tp->tap.enabled, time);
|
tp_tap_enabled_update(tp, true, tp->tap.enabled, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_tap_resume(struct tp_dispatch *tp, uint64_t time)
|
tp_tap_resume(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
tp_tap_enabled_update(tp, false, tp->tap.enabled, time);
|
tp_tap_enabled_update(tp, false, tp->tap.enabled, time);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
/* distance between fingers to assume it is not a scroll */
|
/* distance between fingers to assume it is not a scroll */
|
||||||
#define SCROLL_MM_X 35
|
#define SCROLL_MM_X 35
|
||||||
#define SCROLL_MM_Y 25
|
#define SCROLL_MM_Y 25
|
||||||
#define THUMB_TIMEOUT ms2us(100)
|
#define THUMB_TIMEOUT usec_from_millis(100)
|
||||||
|
|
||||||
static inline const char *
|
static inline const char *
|
||||||
thumb_state_to_str(enum tp_thumb_state state)
|
thumb_state_to_str(enum tp_thumb_state state)
|
||||||
|
|
@ -193,7 +193,7 @@ tp_thumb_revive(struct tp_dispatch *tp, struct tp_touch *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_thumb_update_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_thumb_update_touch(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
if (!tp->thumb.detect_thumbs)
|
if (!tp->thumb.detect_thumbs)
|
||||||
return;
|
return;
|
||||||
|
|
@ -274,7 +274,7 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp)
|
||||||
speed_exceeded_count =
|
speed_exceeded_count =
|
||||||
max(speed_exceeded_count, t->speed.exceeded_count);
|
max(speed_exceeded_count, t->speed.exceeded_count);
|
||||||
|
|
||||||
if (!oldest || t->initial_time < oldest->initial_time) {
|
if (!oldest || usec_cmp(t->initial_time, oldest->initial_time) < 0) {
|
||||||
oldest = t;
|
oldest = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -337,10 +337,13 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp)
|
||||||
* the behavior of the other touches.)
|
* the behavior of the other touches.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (newest && (newest->initial_time - oldest->initial_time) < THUMB_TIMEOUT &&
|
if (newest) {
|
||||||
first->point.y < tp->thumb.lower_thumb_line) {
|
usec_t delta = usec_delta(newest->initial_time, oldest->initial_time);
|
||||||
tp_thumb_lift(tp);
|
if (usec_cmp(delta, THUMB_TIMEOUT) < 0 &&
|
||||||
return;
|
first->point.y < tp->thumb.lower_thumb_line) {
|
||||||
|
tp_thumb_lift(tp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're past the THUMB_TIMEOUT, and the touches are relatively far
|
/* If we're past the THUMB_TIMEOUT, and the touches are relatively far
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@
|
||||||
#include "libinput-feature.h"
|
#include "libinput-feature.h"
|
||||||
#include "quirks.h"
|
#include "quirks.h"
|
||||||
|
|
||||||
#define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT ms2us(300)
|
#define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT usec_from_millis(300)
|
||||||
#define DEFAULT_TRACKPOINT_EVENT_TIMEOUT ms2us(40)
|
#define DEFAULT_TRACKPOINT_EVENT_TIMEOUT usec_from_millis(40)
|
||||||
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_1 ms2us(200)
|
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_1 usec_from_millis(200)
|
||||||
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_2 ms2us(500)
|
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_2 usec_from_millis(500)
|
||||||
#define FAKE_FINGER_OVERFLOW bit(7)
|
#define FAKE_FINGER_OVERFLOW bit(7)
|
||||||
#define THUMB_IGNORE_SPEED_THRESHOLD 20 /* mm/s */
|
#define THUMB_IGNORE_SPEED_THRESHOLD 20 /* mm/s */
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ tp_motion_history_offset(struct tp_touch *t, int offset)
|
||||||
struct normalized_coords
|
struct normalized_coords
|
||||||
tp_filter_motion(struct tp_dispatch *tp,
|
tp_filter_motion(struct tp_dispatch *tp,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct device_float_coords raw;
|
struct device_float_coords raw;
|
||||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||||
|
|
@ -79,7 +79,7 @@ tp_filter_motion(struct tp_dispatch *tp,
|
||||||
struct normalized_coords
|
struct normalized_coords
|
||||||
tp_filter_motion_unaccelerated(struct tp_dispatch *tp,
|
tp_filter_motion_unaccelerated(struct tp_dispatch *tp,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct device_float_coords raw;
|
struct device_float_coords raw;
|
||||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||||
|
|
@ -96,7 +96,7 @@ tp_filter_motion_unaccelerated(struct tp_dispatch *tp,
|
||||||
struct normalized_coords
|
struct normalized_coords
|
||||||
tp_filter_scroll(struct tp_dispatch *tp,
|
tp_filter_scroll(struct tp_dispatch *tp,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct device_float_coords raw;
|
struct device_float_coords raw;
|
||||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||||
|
|
@ -115,13 +115,11 @@ tp_filter_scroll(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
tp_calculate_motion_speed(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_calculate_motion_speed(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
const struct tp_history_point *last;
|
const struct tp_history_point *last;
|
||||||
struct device_coords delta;
|
struct device_coords delta;
|
||||||
struct phys_coords mm;
|
struct phys_coords mm;
|
||||||
double distance;
|
|
||||||
double speed;
|
|
||||||
|
|
||||||
/* Don't do this on single-touch or semi-mt devices */
|
/* Don't do this on single-touch or semi-mt devices */
|
||||||
if (!tp->has_mt || tp->semi_mt)
|
if (!tp->has_mt || tp->semi_mt)
|
||||||
|
|
@ -149,15 +147,16 @@ tp_calculate_motion_speed(struct tp_dispatch *tp, struct tp_touch *t, uint64_t t
|
||||||
delta.y = abs(t->point.y - last->point.y);
|
delta.y = abs(t->point.y - last->point.y);
|
||||||
mm = evdev_device_unit_delta_to_mm(tp->device, &delta);
|
mm = evdev_device_unit_delta_to_mm(tp->device, &delta);
|
||||||
|
|
||||||
distance = length_in_mm(mm);
|
usec_t tdelta = usec_delta(time, last->time);
|
||||||
speed = distance / (time - last->time); /* mm/us */
|
double distance = length_in_mm(mm);
|
||||||
speed *= 1000000; /* mm/s */
|
double speed = distance / usec_as_uint64_t(tdelta); /* mm/us */
|
||||||
|
speed *= 1000000; /* mm/s */
|
||||||
|
|
||||||
t->speed.last_speed = speed;
|
t->speed.last_speed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
tp_motion_history_push(struct tp_touch *t, uint64_t time)
|
tp_motion_history_push(struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
int motion_index = (t->history.index + 1) % TOUCHPAD_HISTORY_LENGTH;
|
int motion_index = (t->history.index + 1) % TOUCHPAD_HISTORY_LENGTH;
|
||||||
|
|
||||||
|
|
@ -181,10 +180,9 @@ tp_motion_history_push(struct tp_touch *t, uint64_t time)
|
||||||
* This only looks at x changes, y changes are ignored.
|
* This only looks at x changes, y changes are ignored.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
tp_detect_wobbling(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_detect_wobbling(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
uint64_t dtime;
|
|
||||||
const struct device_coords *prev_point;
|
const struct device_coords *prev_point;
|
||||||
|
|
||||||
if (tp->nfingers_down != 1 || tp->nfingers_down != tp->old_nfingers_down)
|
if (tp->nfingers_down != 1 || tp->nfingers_down != tp->old_nfingers_down)
|
||||||
|
|
@ -201,11 +199,11 @@ tp_detect_wobbling(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
prev_point = &tp_motion_history_offset(t, 0)->point;
|
prev_point = &tp_motion_history_offset(t, 0)->point;
|
||||||
dx = prev_point->x - t->point.x;
|
dx = prev_point->x - t->point.x;
|
||||||
dy = prev_point->y - t->point.y;
|
dy = prev_point->y - t->point.y;
|
||||||
dtime = time - tp->hysteresis.last_motion_time;
|
usec_t dtime = usec_delta(time, tp->hysteresis.last_motion_time);
|
||||||
|
|
||||||
tp->hysteresis.last_motion_time = time;
|
tp->hysteresis.last_motion_time = time;
|
||||||
|
|
||||||
if ((dx == 0 && dy != 0) || dtime > ms2us(40)) {
|
if ((dx == 0 && dy != 0) || usec_cmp(dtime, usec_from_millis(40)) > 0) {
|
||||||
t->hysteresis.x_motion_history = 0;
|
t->hysteresis.x_motion_history = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +321,7 @@ tp_fake_finger_set(struct tp_dispatch *tp, evdev_usage_t usage, bool is_press)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
tp_new_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_new_touch(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
if (t->state == TOUCH_BEGIN || t->state == TOUCH_UPDATE ||
|
if (t->state == TOUCH_BEGIN || t->state == TOUCH_UPDATE ||
|
||||||
t->state == TOUCH_HOVERING)
|
t->state == TOUCH_HOVERING)
|
||||||
|
|
@ -358,7 +356,7 @@ tp_new_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
tp_begin_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_begin_touch(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
t->dirty = true;
|
t->dirty = true;
|
||||||
t->state = TOUCH_BEGIN;
|
t->state = TOUCH_BEGIN;
|
||||||
|
|
@ -382,7 +380,7 @@ tp_begin_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
* need.
|
* need.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
tp_maybe_end_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_maybe_end_touch(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
switch (t->state) {
|
switch (t->state) {
|
||||||
case TOUCH_NONE:
|
case TOUCH_NONE:
|
||||||
|
|
@ -427,7 +425,7 @@ tp_recover_ended_touch(struct tp_dispatch *tp, struct tp_touch *t)
|
||||||
* Use tp_maybe_end_touch() instead.
|
* Use tp_maybe_end_touch() instead.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
tp_end_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_end_touch(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
if (t->state != TOUCH_MAYBE_END) {
|
if (t->state != TOUCH_MAYBE_END) {
|
||||||
evdev_log_bug_libinput(tp->device,
|
evdev_log_bug_libinput(tp->device,
|
||||||
|
|
@ -441,7 +439,7 @@ tp_end_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
t->palm.state = PALM_NONE;
|
t->palm.state = PALM_NONE;
|
||||||
t->state = TOUCH_END;
|
t->state = TOUCH_END;
|
||||||
t->pinned.is_pinned = false;
|
t->pinned.is_pinned = false;
|
||||||
t->palm.time = 0;
|
t->palm.time = usec_from_uint64_t(0);
|
||||||
t->speed.exceeded_count = 0;
|
t->speed.exceeded_count = 0;
|
||||||
tp->queued |= TOUCHPAD_EVENT_MOTION;
|
tp->queued |= TOUCHPAD_EVENT_MOTION;
|
||||||
}
|
}
|
||||||
|
|
@ -450,14 +448,14 @@ tp_end_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
* End the touch sequence on ABS_MT_TRACKING_ID -1 or when the BTN_TOOL_* 0 is received.
|
* End the touch sequence on ABS_MT_TRACKING_ID -1 or when the BTN_TOOL_* 0 is received.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
tp_end_sequence(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_end_sequence(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
t->has_ended = true;
|
t->has_ended = true;
|
||||||
tp_maybe_end_touch(tp, t, time);
|
tp_maybe_end_touch(tp, t, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_stop_actions(struct tp_dispatch *tp, uint64_t time)
|
tp_stop_actions(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
tp_edge_scroll_stop_events(tp, time);
|
tp_edge_scroll_stop_events(tp, time);
|
||||||
tp_gesture_cancel(tp, time);
|
tp_gesture_cancel(tp, time);
|
||||||
|
|
@ -505,7 +503,7 @@ rotated(struct tp_dispatch *tp, evdev_usage_t usage, int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_process_absolute(struct tp_dispatch *tp, const struct evdev_event *e, uint64_t time)
|
tp_process_absolute(struct tp_dispatch *tp, const struct evdev_event *e, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t = tp_current_touch(tp);
|
struct tp_touch *t = tp_current_touch(tp);
|
||||||
|
|
||||||
|
|
@ -560,9 +558,7 @@ tp_process_absolute(struct tp_dispatch *tp, const struct evdev_event *e, uint64_
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_process_absolute_st(struct tp_dispatch *tp,
|
tp_process_absolute_st(struct tp_dispatch *tp, const struct evdev_event *e, usec_t time)
|
||||||
const struct evdev_event *e,
|
|
||||||
uint64_t time)
|
|
||||||
{
|
{
|
||||||
struct tp_touch *t = tp_current_touch(tp);
|
struct tp_touch *t = tp_current_touch(tp);
|
||||||
|
|
||||||
|
|
@ -590,7 +586,7 @@ tp_process_absolute_st(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
tp_restore_synaptics_touches(struct tp_dispatch *tp, uint64_t time)
|
tp_restore_synaptics_touches(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int nfake_touches;
|
unsigned int nfake_touches;
|
||||||
|
|
@ -624,7 +620,7 @@ tp_restore_synaptics_touches(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_process_fake_touches(struct tp_dispatch *tp, uint64_t time)
|
tp_process_fake_touches(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
unsigned int nfake_touches;
|
unsigned int nfake_touches;
|
||||||
|
|
@ -677,7 +673,7 @@ tp_process_fake_touches(struct tp_dispatch *tp, uint64_t time)
|
||||||
static void
|
static void
|
||||||
tp_process_trackpoint_button(struct tp_dispatch *tp,
|
tp_process_trackpoint_button(struct tp_dispatch *tp,
|
||||||
const struct evdev_event *e,
|
const struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct evdev_dispatch *dispatch;
|
struct evdev_dispatch *dispatch;
|
||||||
evdev_usage_t button;
|
evdev_usage_t button;
|
||||||
|
|
@ -709,7 +705,7 @@ tp_process_trackpoint_button(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_process_key(struct tp_dispatch *tp, const struct evdev_event *e, uint64_t time)
|
tp_process_key(struct tp_dispatch *tp, const struct evdev_event *e, usec_t time)
|
||||||
{
|
{
|
||||||
/* ignore kernel key repeat */
|
/* ignore kernel key repeat */
|
||||||
if (e->value == 2)
|
if (e->value == 2)
|
||||||
|
|
@ -740,12 +736,12 @@ tp_process_key(struct tp_dispatch *tp, const struct evdev_event *e, uint64_t tim
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_process_msc(struct tp_dispatch *tp, const struct evdev_event *e, uint64_t time)
|
tp_process_msc(struct tp_dispatch *tp, const struct evdev_event *e, usec_t time)
|
||||||
{
|
{
|
||||||
if (evdev_usage_eq(e->usage, EVDEV_MSC_TIMESTAMP))
|
if (evdev_usage_eq(e->usage, EVDEV_MSC_TIMESTAMP))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tp->quirks.msc_timestamp.now = e->value;
|
tp->quirks.msc_timestamp.now = usec_from_uint64_t(e->value);
|
||||||
tp->queued |= TOUCHPAD_EVENT_TIMESTAMP;
|
tp->queued |= TOUCHPAD_EVENT_TIMESTAMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -831,7 +827,7 @@ tp_palm_in_edge(const struct tp_dispatch *tp, const struct tp_touch *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
tp_palm_detect_dwt_triggered(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_palm_detect_dwt_triggered(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
if (tp->dwt.dwt_enabled && tp->dwt.keyboard_active && t->state == TOUCH_BEGIN) {
|
if (tp->dwt.dwt_enabled && tp->dwt.keyboard_active && t->state == TOUCH_BEGIN) {
|
||||||
t->palm.state = PALM_TYPING;
|
t->palm.state = PALM_TYPING;
|
||||||
|
|
@ -847,8 +843,8 @@ tp_palm_detect_dwt_triggered(struct tp_dispatch *tp, struct tp_touch *t, uint64_
|
||||||
started once we stop typing will be able to control the
|
started once we stop typing will be able to control the
|
||||||
pointer (alas not tap, etc.).
|
pointer (alas not tap, etc.).
|
||||||
*/
|
*/
|
||||||
if (t->palm.time == 0 ||
|
if (usec_is_zero(t->palm.time) ||
|
||||||
t->palm.time > tp->dwt.keyboard_last_press_time) {
|
usec_cmp(t->palm.time, tp->dwt.keyboard_last_press_time) > 0) {
|
||||||
t->palm.state = PALM_NONE;
|
t->palm.state = PALM_NONE;
|
||||||
evdev_log_debug(
|
evdev_log_debug(
|
||||||
tp->device,
|
tp->device,
|
||||||
|
|
@ -863,7 +859,7 @@ tp_palm_detect_dwt_triggered(struct tp_dispatch *tp, struct tp_touch *t, uint64_
|
||||||
static bool
|
static bool
|
||||||
tp_palm_detect_trackpoint_triggered(struct tp_dispatch *tp,
|
tp_palm_detect_trackpoint_triggered(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (!tp->palm.monitor_trackpoint)
|
if (!tp->palm.monitor_trackpoint)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -877,8 +873,8 @@ tp_palm_detect_trackpoint_triggered(struct tp_dispatch *tp,
|
||||||
if (t->palm.state == PALM_TRACKPOINT && t->state == TOUCH_UPDATE &&
|
if (t->palm.state == PALM_TRACKPOINT && t->state == TOUCH_UPDATE &&
|
||||||
!tp->palm.trackpoint_active) {
|
!tp->palm.trackpoint_active) {
|
||||||
|
|
||||||
if (t->palm.time == 0 ||
|
if (usec_is_zero(t->palm.time) ||
|
||||||
t->palm.time > tp->palm.trackpoint_last_event_time) {
|
usec_cmp(t->palm.time, tp->palm.trackpoint_last_event_time) > 0) {
|
||||||
t->palm.state = PALM_NONE;
|
t->palm.state = PALM_NONE;
|
||||||
evdev_log_debug(
|
evdev_log_debug(
|
||||||
tp->device,
|
tp->device,
|
||||||
|
|
@ -891,7 +887,7 @@ tp_palm_detect_trackpoint_triggered(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
tp_palm_detect_tool_triggered(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_palm_detect_tool_triggered(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
if (!tp->palm.use_mt_tool)
|
if (!tp->palm.use_mt_tool)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -908,16 +904,15 @@ tp_palm_detect_tool_triggered(struct tp_dispatch *tp, struct tp_touch *t, uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
tp_palm_detect_move_out_of_edge(struct tp_dispatch *tp,
|
tp_palm_detect_move_out_of_edge(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
struct tp_touch *t,
|
|
||||||
uint64_t time)
|
|
||||||
{
|
{
|
||||||
const int PALM_TIMEOUT = ms2us(200);
|
const usec_t PALM_TIMEOUT = usec_from_millis(200);
|
||||||
int directions = 0;
|
int directions = 0;
|
||||||
struct device_float_coords delta;
|
struct device_float_coords delta;
|
||||||
int dirs;
|
int dirs;
|
||||||
|
|
||||||
if (time < t->palm.time + PALM_TIMEOUT && !tp_palm_in_edge(tp, t)) {
|
if (usec_cmp(time, usec_add(t->palm.time, PALM_TIMEOUT)) < 0 &&
|
||||||
|
!tp_palm_in_edge(tp, t)) {
|
||||||
if (tp_palm_was_in_side_edge(tp, t))
|
if (tp_palm_was_in_side_edge(tp, t))
|
||||||
directions = NE | E | SE | SW | W | NW;
|
directions = NE | E | SE | SW | W | NW;
|
||||||
else if (tp_palm_was_in_top_edge(tp, t))
|
else if (tp_palm_was_in_top_edge(tp, t))
|
||||||
|
|
@ -935,7 +930,7 @@ tp_palm_detect_move_out_of_edge(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
tp_palm_detect_multifinger(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_palm_detect_multifinger(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *other;
|
struct tp_touch *other;
|
||||||
|
|
||||||
|
|
@ -965,7 +960,7 @@ tp_palm_detect_multifinger(struct tp_dispatch *tp, struct tp_touch *t, uint64_t
|
||||||
static inline bool
|
static inline bool
|
||||||
tp_palm_detect_touch_size_triggered(struct tp_dispatch *tp,
|
tp_palm_detect_touch_size_triggered(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (!tp->palm.use_size)
|
if (!tp->palm.use_size)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -988,7 +983,7 @@ tp_palm_detect_touch_size_triggered(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
tp_palm_detect_edge(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_palm_detect_edge(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
if (t->palm.state == PALM_EDGE) {
|
if (t->palm.state == PALM_EDGE) {
|
||||||
if (tp_palm_detect_multifinger(tp, t, time)) {
|
if (tp_palm_detect_multifinger(tp, t, time)) {
|
||||||
|
|
@ -1035,7 +1030,7 @@ tp_palm_detect_edge(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
static bool
|
static bool
|
||||||
tp_palm_detect_pressure_triggered(struct tp_dispatch *tp,
|
tp_palm_detect_pressure_triggered(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (!tp->palm.use_pressure)
|
if (!tp->palm.use_pressure)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1052,7 +1047,7 @@ tp_palm_detect_pressure_triggered(struct tp_dispatch *tp,
|
||||||
static bool
|
static bool
|
||||||
tp_palm_detect_arbitration_triggered(struct tp_dispatch *tp,
|
tp_palm_detect_arbitration_triggered(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (tp->arbitration.state == ARBITRATION_NOT_ACTIVE)
|
if (tp->arbitration.state == ARBITRATION_NOT_ACTIVE)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1063,7 +1058,7 @@ tp_palm_detect_arbitration_triggered(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
const char *palm_state;
|
const char *palm_state;
|
||||||
enum touch_palm_state oldstate = t->palm.state;
|
enum touch_palm_state oldstate = t->palm.state;
|
||||||
|
|
@ -1139,7 +1134,7 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_unhover_pressure(struct tp_dispatch *tp, uint64_t time)
|
tp_unhover_pressure(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -1223,7 +1218,7 @@ tp_unhover_pressure(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_unhover_size(struct tp_dispatch *tp, uint64_t time)
|
tp_unhover_size(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
int low = tp->touch_size.low, high = tp->touch_size.high;
|
int low = tp->touch_size.low, high = tp->touch_size.high;
|
||||||
|
|
@ -1263,7 +1258,7 @@ tp_unhover_size(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_unhover_fake_touches(struct tp_dispatch *tp, uint64_t time)
|
tp_unhover_fake_touches(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
unsigned int nfake_touches;
|
unsigned int nfake_touches;
|
||||||
|
|
@ -1317,7 +1312,7 @@ tp_unhover_fake_touches(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_unhover_touches(struct tp_dispatch *tp, uint64_t time)
|
tp_unhover_touches(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
if (tp->pressure.use_pressure)
|
if (tp->pressure.use_pressure)
|
||||||
tp_unhover_pressure(tp, time);
|
tp_unhover_pressure(tp, time);
|
||||||
|
|
@ -1403,17 +1398,17 @@ tp_need_motion_history_reset(struct tp_dispatch *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t, usec_t time)
|
||||||
{
|
{
|
||||||
struct device_coords delta;
|
struct device_coords delta;
|
||||||
struct phys_coords mm;
|
struct phys_coords mm;
|
||||||
struct tp_history_point *last;
|
struct tp_history_point *last;
|
||||||
double abs_distance, rel_distance;
|
double abs_distance, rel_distance;
|
||||||
bool is_jump = false;
|
bool is_jump = false;
|
||||||
uint64_t tdelta;
|
usec_t tdelta;
|
||||||
/* Reference interval from the touchpad the various thresholds
|
/* Reference interval from the touchpad the various thresholds
|
||||||
* were measured from */
|
* were measured from */
|
||||||
unsigned int reference_interval = ms2us(12);
|
usec_t reference_interval = usec_from_millis(12);
|
||||||
|
|
||||||
/* On some touchpads the firmware does funky stuff and we cannot
|
/* On some touchpads the firmware does funky stuff and we cannot
|
||||||
* have our own jump detection, e.g. Lenovo Carbon X1 Gen 6 (see
|
* have our own jump detection, e.g. Lenovo Carbon X1 Gen 6 (see
|
||||||
|
|
@ -1436,7 +1431,7 @@ tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
/* called before tp_motion_history_push, so offset 0 is the most
|
/* called before tp_motion_history_push, so offset 0 is the most
|
||||||
* recent coordinate */
|
* recent coordinate */
|
||||||
last = tp_motion_history_offset(t, 0);
|
last = tp_motion_history_offset(t, 0);
|
||||||
tdelta = time - last->time;
|
tdelta = usec_delta(time, last->time);
|
||||||
|
|
||||||
/* For test devices we always force the time delta to 12, at least
|
/* For test devices we always force the time delta to 12, at least
|
||||||
until the test suite actually does proper intervals. */
|
until the test suite actually does proper intervals. */
|
||||||
|
|
@ -1446,7 +1441,8 @@ tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
/* If the last frame is more than 30ms ago, we have irregular
|
/* If the last frame is more than 30ms ago, we have irregular
|
||||||
* frames, who knows what's a pointer jump here and what's
|
* frames, who knows what's a pointer jump here and what's
|
||||||
* legitimate movement.... */
|
* legitimate movement.... */
|
||||||
if (tdelta > 2.5 * reference_interval || tdelta == 0)
|
if (usec_cmp(tdelta, usec_mul(reference_interval, 2.5)) > 0 ||
|
||||||
|
usec_is_zero(tdelta))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* We historically expected ~12ms frame intervals, so the numbers
|
/* We historically expected ~12ms frame intervals, so the numbers
|
||||||
|
|
@ -1455,7 +1451,8 @@ tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
delta.x = abs(t->point.x - last->point.x);
|
delta.x = abs(t->point.x - last->point.x);
|
||||||
delta.y = abs(t->point.y - last->point.y);
|
delta.y = abs(t->point.y - last->point.y);
|
||||||
mm = evdev_device_unit_delta_to_mm(tp->device, &delta);
|
mm = evdev_device_unit_delta_to_mm(tp->device, &delta);
|
||||||
abs_distance = hypot(mm.x, mm.y) * reference_interval / tdelta;
|
abs_distance = hypot(mm.x, mm.y) * usec_as_uint64_t(reference_interval) /
|
||||||
|
usec_as_uint64_t(tdelta);
|
||||||
rel_distance = abs_distance - t->jumps.last_delta_mm;
|
rel_distance = abs_distance - t->jumps.last_delta_mm;
|
||||||
|
|
||||||
/* Special case for the ALPS devices in the Lenovo ThinkPad E465,
|
/* Special case for the ALPS devices in the Lenovo ThinkPad E465,
|
||||||
|
|
@ -1496,9 +1493,9 @@ tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
||||||
static inline void
|
static inline void
|
||||||
tp_motion_history_fix_last(struct tp_dispatch *tp,
|
tp_motion_history_fix_last(struct tp_dispatch *tp,
|
||||||
struct tp_touch *t,
|
struct tp_touch *t,
|
||||||
unsigned int jumping_interval,
|
usec_t jumping_interval,
|
||||||
unsigned int normal_interval,
|
usec_t normal_interval,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (t->state != TOUCH_UPDATE)
|
if (t->state != TOUCH_UPDATE)
|
||||||
return;
|
return;
|
||||||
|
|
@ -1514,12 +1511,13 @@ tp_motion_history_fix_last(struct tp_dispatch *tp,
|
||||||
struct tp_history_point *p;
|
struct tp_history_point *p;
|
||||||
|
|
||||||
p = tp_motion_history_offset(t, i);
|
p = tp_motion_history_offset(t, i);
|
||||||
p->time = time - jumping_interval - normal_interval * i;
|
p->time = usec_sub(usec_sub(time, jumping_interval),
|
||||||
|
usec_mul(normal_interval, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_process_msc_timestamp(struct tp_dispatch *tp, uint64_t time)
|
tp_process_msc_timestamp(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct msc_timestamp *m = &tp->quirks.msc_timestamp;
|
struct msc_timestamp *m = &tp->quirks.msc_timestamp;
|
||||||
|
|
||||||
|
|
@ -1553,15 +1551,15 @@ tp_process_msc_timestamp(struct tp_dispatch *tp, uint64_t time)
|
||||||
delta is equivalent to 10 events and the movement is x, we
|
delta is equivalent to 10 events and the movement is x, we
|
||||||
instead pretend there was movement of x/10.
|
instead pretend there was movement of x/10.
|
||||||
*/
|
*/
|
||||||
if (m->now == 0) {
|
if (usec_is_zero(m->now)) {
|
||||||
m->state = JUMP_STATE_EXPECT_FIRST;
|
m->state = JUMP_STATE_EXPECT_FIRST;
|
||||||
m->interval = 0;
|
m->interval = usec_from_uint64_t(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (m->state) {
|
switch (m->state) {
|
||||||
case JUMP_STATE_EXPECT_FIRST:
|
case JUMP_STATE_EXPECT_FIRST:
|
||||||
if (m->now > ms2us(20)) {
|
if (usec_cmp(m->now, usec_from_millis(20)) > 0) {
|
||||||
m->state = JUMP_STATE_IGNORE;
|
m->state = JUMP_STATE_IGNORE;
|
||||||
} else {
|
} else {
|
||||||
m->state = JUMP_STATE_EXPECT_DELAY;
|
m->state = JUMP_STATE_EXPECT_DELAY;
|
||||||
|
|
@ -1569,13 +1567,13 @@ tp_process_msc_timestamp(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JUMP_STATE_EXPECT_DELAY:
|
case JUMP_STATE_EXPECT_DELAY:
|
||||||
if (m->now > m->interval * 2) {
|
if (usec_cmp(m->now, usec_mul(m->interval, 2)) > 0) {
|
||||||
uint32_t tdelta; /* µs */
|
usec_t tdelta; /* µs */
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
||||||
/* The current time is > 2 times the interval so we
|
/* The current time is > 2 times the interval so we
|
||||||
* have a jump. Fix the motion history */
|
* have a jump. Fix the motion history */
|
||||||
tdelta = m->now - m->interval;
|
tdelta = usec_delta(m->now, m->interval);
|
||||||
|
|
||||||
tp_for_each_touch(tp, t) {
|
tp_for_each_touch(tp, t) {
|
||||||
tp_motion_history_fix_last(tp,
|
tp_motion_history_fix_last(tp,
|
||||||
|
|
@ -1593,7 +1591,9 @@ tp_process_msc_timestamp(struct tp_dispatch *tp, uint64_t time)
|
||||||
* only ever see those jumps over the first three events it
|
* only ever see those jumps over the first three events it
|
||||||
* doesn't matter.
|
* doesn't matter.
|
||||||
*/
|
*/
|
||||||
filter_restart(tp->device->pointer.filter, tp, time - tdelta);
|
filter_restart(tp->device->pointer.filter,
|
||||||
|
tp,
|
||||||
|
usec_sub(time, tdelta));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JUMP_STATE_IGNORE:
|
case JUMP_STATE_IGNORE:
|
||||||
|
|
@ -1602,7 +1602,7 @@ tp_process_msc_timestamp(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_pre_process_state(struct tp_dispatch *tp, uint64_t time)
|
tp_pre_process_state(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
||||||
|
|
@ -1624,7 +1624,7 @@ tp_pre_process_state(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_process_state(struct tp_dispatch *tp, uint64_t time)
|
tp_process_state(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
bool restart_filter = false;
|
bool restart_filter = false;
|
||||||
|
|
@ -1735,7 +1735,7 @@ tp_process_state(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_post_process_state(struct tp_dispatch *tp, uint64_t time)
|
tp_post_process_state(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
||||||
|
|
@ -1769,7 +1769,7 @@ tp_post_process_state(struct tp_dispatch *tp, uint64_t time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_post_events(struct tp_dispatch *tp, uint64_t time)
|
tp_post_events(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
bool ignore_motion = false;
|
bool ignore_motion = false;
|
||||||
|
|
||||||
|
|
@ -1820,7 +1820,7 @@ tp_apply_rotation(struct evdev_device *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_handle_state(struct tp_dispatch *tp, uint64_t time)
|
tp_handle_state(struct tp_dispatch *tp, usec_t time)
|
||||||
{
|
{
|
||||||
tp_pre_process_state(tp, time);
|
tp_pre_process_state(tp, time);
|
||||||
tp_process_state(tp, time);
|
tp_process_state(tp, time);
|
||||||
|
|
@ -1858,7 +1858,7 @@ static void
|
||||||
tp_interface_process_event(struct evdev_dispatch *dispatch,
|
tp_interface_process_event(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = tp_dispatch(dispatch);
|
struct tp_dispatch *tp = tp_dispatch(dispatch);
|
||||||
|
|
||||||
|
|
@ -1889,7 +1889,7 @@ static void
|
||||||
tp_interface_process(struct evdev_dispatch *dispatch,
|
tp_interface_process(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
size_t nevents;
|
size_t nevents;
|
||||||
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
||||||
|
|
@ -1982,7 +1982,7 @@ tp_release_fake_touches(struct tp_dispatch *tp)
|
||||||
static void
|
static void
|
||||||
tp_clear_state(struct tp_dispatch *tp)
|
tp_clear_state(struct tp_dispatch *tp)
|
||||||
{
|
{
|
||||||
uint64_t now = libinput_now(tp_libinput_context(tp));
|
usec_t now = libinput_now(tp_libinput_context(tp));
|
||||||
struct tp_touch *t;
|
struct tp_touch *t;
|
||||||
|
|
||||||
/* Unroll the touchpad state.
|
/* Unroll the touchpad state.
|
||||||
|
|
@ -2106,7 +2106,7 @@ tp_resume(struct tp_dispatch *tp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_trackpoint_timeout(uint64_t now, void *data)
|
tp_trackpoint_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
|
|
||||||
|
|
@ -2118,7 +2118,7 @@ tp_trackpoint_timeout(uint64_t now, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_trackpoint_event(uint64_t time, struct libinput_event *event, void *data)
|
tp_trackpoint_event(usec_t time, struct libinput_event *event, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
|
|
||||||
|
|
@ -2136,7 +2136,7 @@ tp_trackpoint_event(uint64_t time, struct libinput_event *event, void *data)
|
||||||
/* Require at least three events before enabling palm detection */
|
/* Require at least three events before enabling palm detection */
|
||||||
if (tp->palm.trackpoint_event_count < 3) {
|
if (tp->palm.trackpoint_event_count < 3) {
|
||||||
libinput_timer_set(&tp->palm.trackpoint_timer,
|
libinput_timer_set(&tp->palm.trackpoint_timer,
|
||||||
time + DEFAULT_TRACKPOINT_EVENT_TIMEOUT);
|
usec_add(time, DEFAULT_TRACKPOINT_EVENT_TIMEOUT));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2145,17 +2145,19 @@ tp_trackpoint_event(uint64_t time, struct libinput_event *event, void *data)
|
||||||
tp->palm.trackpoint_active = true;
|
tp->palm.trackpoint_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
libinput_timer_set(&tp->palm.trackpoint_timer, time + tp->palm.timeout);
|
libinput_timer_set(&tp->palm.trackpoint_timer,
|
||||||
|
usec_add(time, tp->palm.timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_keyboard_timeout(uint64_t now, void *data)
|
tp_keyboard_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
|
|
||||||
if (tp->dwt.dwt_enabled &&
|
if (tp->dwt.dwt_enabled &&
|
||||||
long_any_bit_set(tp->dwt.key_mask, ARRAY_LENGTH(tp->dwt.key_mask))) {
|
long_any_bit_set(tp->dwt.key_mask, ARRAY_LENGTH(tp->dwt.key_mask))) {
|
||||||
libinput_timer_set(&tp->dwt.keyboard_timer, now + tp->dwt.timeout);
|
libinput_timer_set(&tp->dwt.keyboard_timer,
|
||||||
|
usec_add(now, tp->dwt.timeout));
|
||||||
tp->dwt.keyboard_last_press_time = now;
|
tp->dwt.keyboard_last_press_time = now;
|
||||||
evdev_log_debug(tp->device, "palm: keyboard timeout refresh\n");
|
evdev_log_debug(tp->device, "palm: keyboard timeout refresh\n");
|
||||||
return;
|
return;
|
||||||
|
|
@ -2217,11 +2219,11 @@ tp_key_ignore_for_dwt(unsigned int keycode)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_keyboard_event(uint64_t time, struct libinput_event *event, void *data)
|
tp_keyboard_event(usec_t time, struct libinput_event *event, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
struct libinput_event_keyboard *kbdev;
|
struct libinput_event_keyboard *kbdev;
|
||||||
unsigned int timeout;
|
usec_t timeout;
|
||||||
unsigned int key;
|
unsigned int key;
|
||||||
bool is_modifier;
|
bool is_modifier;
|
||||||
|
|
||||||
|
|
@ -2275,7 +2277,7 @@ tp_keyboard_event(uint64_t time, struct libinput_event *event, void *data)
|
||||||
|
|
||||||
tp->dwt.keyboard_last_press_time = time;
|
tp->dwt.keyboard_last_press_time = time;
|
||||||
long_set_bit(tp->dwt.key_mask, key);
|
long_set_bit(tp->dwt.key_mask, key);
|
||||||
libinput_timer_set(&tp->dwt.keyboard_timer, time + timeout);
|
libinput_timer_set(&tp->dwt.keyboard_timer, usec_add(time, timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
@ -2361,7 +2363,7 @@ tp_pair_trackpoint(struct evdev_device *touchpad, struct evdev_device *trackpoin
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_lid_switch_event(uint64_t time, struct libinput_event *event, void *data)
|
tp_lid_switch_event(usec_t time, struct libinput_event *event, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
struct libinput_event_switch *swev;
|
struct libinput_event_switch *swev;
|
||||||
|
|
@ -2386,7 +2388,7 @@ tp_lid_switch_event(uint64_t time, struct libinput_event *event, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_tablet_mode_switch_event(uint64_t time, struct libinput_event *event, void *data)
|
tp_tablet_mode_switch_event(usec_t time, struct libinput_event *event, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
struct libinput_event_switch *swev;
|
struct libinput_event_switch *swev;
|
||||||
|
|
@ -2692,7 +2694,7 @@ evdev_tag_touchpad(struct evdev_device *device, struct udev_device *udev_device)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tp_arbitration_timeout(uint64_t now, void *data)
|
tp_arbitration_timeout(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = data;
|
struct tp_dispatch *tp = data;
|
||||||
|
|
||||||
|
|
@ -2705,7 +2707,7 @@ tp_interface_toggle_touch(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
enum evdev_arbitration_state which,
|
enum evdev_arbitration_state which,
|
||||||
const struct phys_rect *rect,
|
const struct phys_rect *rect,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = tp_dispatch(dispatch);
|
struct tp_dispatch *tp = tp_dispatch(dispatch);
|
||||||
|
|
||||||
|
|
@ -2728,7 +2730,7 @@ tp_interface_toggle_touch(struct evdev_dispatch *dispatch,
|
||||||
* arbitration by just a little bit so that any touch in
|
* arbitration by just a little bit so that any touch in
|
||||||
* event is caught as palm touch. */
|
* event is caught as palm touch. */
|
||||||
libinput_timer_set(&tp->arbitration.arbitration_timer,
|
libinput_timer_set(&tp->arbitration.arbitration_timer,
|
||||||
time + ms2us(90));
|
usec_add_millis(time, 90));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2936,12 +2938,12 @@ tp_init_accel(struct tp_dispatch *tp, enum libinput_config_accel_profile which)
|
||||||
tp->device->model_flags & EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81) {
|
tp->device->model_flags & EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81) {
|
||||||
filter = create_pointer_accelerator_filter_lenovo_x230(dpi, use_v_avg);
|
filter = create_pointer_accelerator_filter_lenovo_x230(dpi, use_v_avg);
|
||||||
} else {
|
} else {
|
||||||
uint64_t eds_threshold = 0;
|
usec_t eds_threshold = usec_from_uint64_t(0);
|
||||||
uint64_t eds_value = 0;
|
usec_t eds_value = usec_from_uint64_t(0);
|
||||||
|
|
||||||
if (libevdev_get_id_bustype(device->evdev) == BUS_BLUETOOTH) {
|
if (libevdev_get_id_bustype(device->evdev) == BUS_BLUETOOTH) {
|
||||||
eds_threshold = ms2us(50);
|
eds_threshold = usec_from_millis(50);
|
||||||
eds_value = ms2us(10);
|
eds_value = usec_from_millis(10);
|
||||||
}
|
}
|
||||||
filter = create_pointer_accelerator_filter_touchpad(dpi,
|
filter = create_pointer_accelerator_filter_touchpad(dpi,
|
||||||
eds_threshold,
|
eds_threshold,
|
||||||
|
|
@ -3030,7 +3032,7 @@ tp_scroll_config_scroll_method_set_method(struct libinput_device *device,
|
||||||
{
|
{
|
||||||
struct evdev_device *evdev = evdev_device(device);
|
struct evdev_device *evdev = evdev_device(device);
|
||||||
struct tp_dispatch *tp = (struct tp_dispatch *)evdev->dispatch;
|
struct tp_dispatch *tp = (struct tp_dispatch *)evdev->dispatch;
|
||||||
uint64_t time = libinput_now(tp_libinput_context(tp));
|
usec_t time = libinput_now(tp_libinput_context(tp));
|
||||||
|
|
||||||
if (method == tp->scroll.method)
|
if (method == tp->scroll.method)
|
||||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||||
|
|
@ -3169,12 +3171,13 @@ tp_dwt_config_get_default(struct libinput_device *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum libinput_config_status
|
static enum libinput_config_status
|
||||||
tp_dwt_config_set_timeout(struct libinput_device *device, uint64_t timeout)
|
tp_dwt_config_set_timeout(struct libinput_device *device, usec_t timeout)
|
||||||
{
|
{
|
||||||
struct evdev_device *evdev = evdev_device(device);
|
struct evdev_device *evdev = evdev_device(device);
|
||||||
struct tp_dispatch *tp = (struct tp_dispatch *)evdev->dispatch;
|
struct tp_dispatch *tp = (struct tp_dispatch *)evdev->dispatch;
|
||||||
|
|
||||||
if (timeout < ms2us(100) || timeout > ms2us(5000))
|
if (usec_cmp(timeout, usec_from_millis(100)) < 0 ||
|
||||||
|
usec_cmp(timeout, usec_from_millis(5000)) > 0)
|
||||||
return LIBINPUT_CONFIG_STATUS_INVALID;
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
||||||
|
|
||||||
tp->dwt.timeout = timeout;
|
tp->dwt.timeout = timeout;
|
||||||
|
|
@ -3182,7 +3185,7 @@ tp_dwt_config_set_timeout(struct libinput_device *device, uint64_t timeout)
|
||||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t
|
static usec_t
|
||||||
tp_dwt_config_get_timeout(struct libinput_device *device)
|
tp_dwt_config_get_timeout(struct libinput_device *device)
|
||||||
{
|
{
|
||||||
struct evdev_device *evdev = evdev_device(device);
|
struct evdev_device *evdev = evdev_device(device);
|
||||||
|
|
@ -3244,12 +3247,13 @@ tp_dwtp_config_get_default(struct libinput_device *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum libinput_config_status
|
static enum libinput_config_status
|
||||||
tp_dwtp_config_set_timeout(struct libinput_device *device, uint64_t timeout)
|
tp_dwtp_config_set_timeout(struct libinput_device *device, usec_t timeout)
|
||||||
{
|
{
|
||||||
struct evdev_device *evdev = evdev_device(device);
|
struct evdev_device *evdev = evdev_device(device);
|
||||||
struct tp_dispatch *tp = (struct tp_dispatch *)evdev->dispatch;
|
struct tp_dispatch *tp = (struct tp_dispatch *)evdev->dispatch;
|
||||||
|
|
||||||
if (timeout < ms2us(100) || timeout > ms2us(5000))
|
if (usec_cmp(timeout, usec_from_millis(100)) < 0 ||
|
||||||
|
usec_cmp(timeout, usec_from_millis(5000)) > 0)
|
||||||
return LIBINPUT_CONFIG_STATUS_INVALID;
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
||||||
|
|
||||||
tp->palm.timeout = timeout;
|
tp->palm.timeout = timeout;
|
||||||
|
|
@ -3257,7 +3261,7 @@ tp_dwtp_config_set_timeout(struct libinput_device *device, uint64_t timeout)
|
||||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t
|
static usec_t
|
||||||
tp_dwtp_config_get_timeout(struct libinput_device *device)
|
tp_dwtp_config_get_timeout(struct libinput_device *device)
|
||||||
{
|
{
|
||||||
struct evdev_device *evdev = evdev_device(device);
|
struct evdev_device *evdev = evdev_device(device);
|
||||||
|
|
@ -3705,7 +3709,7 @@ tp_init(struct tp_dispatch *tp, struct evdev_device *device)
|
||||||
tp_init_pressure(tp, device);
|
tp_init_pressure(tp, device);
|
||||||
|
|
||||||
/* 5 warnings per 24 hours should be enough */
|
/* 5 warnings per 24 hours should be enough */
|
||||||
ratelimit_init(&tp->jump.warning, h2us(24), 5);
|
ratelimit_init(&tp->jump.warning, usec_from_hours(24), 5);
|
||||||
|
|
||||||
/* Set the dpi to that of the x axis, because that's what we normalize
|
/* Set the dpi to that of the x axis, because that's what we normalize
|
||||||
to when needed*/
|
to when needed*/
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ struct tp_touch {
|
||||||
bool has_ended; /* TRACKING_ID == -1 */
|
bool has_ended; /* TRACKING_ID == -1 */
|
||||||
bool dirty;
|
bool dirty;
|
||||||
struct device_coords point;
|
struct device_coords point;
|
||||||
uint64_t initial_time;
|
usec_t initial_time;
|
||||||
int pressure;
|
int pressure;
|
||||||
bool is_tool_palm; /* MT_TOOL_PALM */
|
bool is_tool_palm; /* MT_TOOL_PALM */
|
||||||
int major, minor;
|
int major, minor;
|
||||||
|
|
@ -213,7 +213,7 @@ struct tp_touch {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct tp_history_point {
|
struct tp_history_point {
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
struct device_coords point;
|
struct device_coords point;
|
||||||
} samples[TOUCHPAD_HISTORY_LENGTH];
|
} samples[TOUCHPAD_HISTORY_LENGTH];
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
|
|
@ -246,7 +246,7 @@ struct tp_touch {
|
||||||
struct libinput_timer timer;
|
struct libinput_timer timer;
|
||||||
struct device_coords initial;
|
struct device_coords initial;
|
||||||
bool has_moved; /* has moved more than threshold */
|
bool has_moved; /* has moved more than threshold */
|
||||||
uint64_t initial_time;
|
usec_t initial_time;
|
||||||
} button;
|
} button;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -267,7 +267,7 @@ struct tp_touch {
|
||||||
struct {
|
struct {
|
||||||
enum touch_palm_state state;
|
enum touch_palm_state state;
|
||||||
struct device_coords first; /* first coordinates if is_palm == true */
|
struct device_coords first; /* first coordinates if is_palm == true */
|
||||||
uint64_t time; /* first timestamp if is_palm == true */
|
usec_t time; /* first timestamp if is_palm == true */
|
||||||
} palm;
|
} palm;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -344,7 +344,7 @@ struct tp_dispatch {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
struct device_coords margin;
|
struct device_coords margin;
|
||||||
unsigned int other_event_count;
|
unsigned int other_event_count;
|
||||||
uint64_t last_motion_time;
|
usec_t last_motion_time;
|
||||||
} hysteresis;
|
} hysteresis;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -361,7 +361,7 @@ struct tp_dispatch {
|
||||||
struct libinput_timer finger_count_switch_timer;
|
struct libinput_timer finger_count_switch_timer;
|
||||||
enum tp_gesture_state state;
|
enum tp_gesture_state state;
|
||||||
struct tp_touch *touches[2];
|
struct tp_touch *touches[2];
|
||||||
uint64_t initial_time;
|
usec_t initial_time;
|
||||||
double initial_distance;
|
double initial_distance;
|
||||||
double prev_scale;
|
double prev_scale;
|
||||||
double angle;
|
double angle;
|
||||||
|
|
@ -370,7 +370,7 @@ struct tp_dispatch {
|
||||||
bool hold_enabled;
|
bool hold_enabled;
|
||||||
|
|
||||||
struct libinput_timer drag_3fg_timer;
|
struct libinput_timer drag_3fg_timer;
|
||||||
uint64_t drag_3fg_release_time;
|
usec_t drag_3fg_release_time;
|
||||||
} gesture;
|
} gesture;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -421,9 +421,9 @@ struct tp_dispatch {
|
||||||
bool h, v;
|
bool h, v;
|
||||||
} active;
|
} active;
|
||||||
struct phys_coords vector;
|
struct phys_coords vector;
|
||||||
uint64_t time_prev;
|
usec_t time_prev;
|
||||||
struct {
|
struct {
|
||||||
uint64_t h, v;
|
usec_t h, v;
|
||||||
} duration;
|
} duration;
|
||||||
} scroll;
|
} scroll;
|
||||||
|
|
||||||
|
|
@ -436,7 +436,7 @@ struct tp_dispatch {
|
||||||
struct libinput_timer timer;
|
struct libinput_timer timer;
|
||||||
enum tp_tap_state state;
|
enum tp_tap_state state;
|
||||||
uint32_t buttons_pressed;
|
uint32_t buttons_pressed;
|
||||||
uint64_t saved_press_time, saved_release_time;
|
usec_t saved_press_time, saved_release_time;
|
||||||
|
|
||||||
enum libinput_config_tap_button_map map;
|
enum libinput_config_tap_button_map map;
|
||||||
enum libinput_config_tap_button_map want_map;
|
enum libinput_config_tap_button_map want_map;
|
||||||
|
|
@ -457,7 +457,7 @@ struct tp_dispatch {
|
||||||
struct {
|
struct {
|
||||||
struct libinput_device_config_dwtp config;
|
struct libinput_device_config_dwtp config;
|
||||||
bool dwtp_enabled;
|
bool dwtp_enabled;
|
||||||
uint64_t timeout;
|
usec_t timeout;
|
||||||
|
|
||||||
int32_t right_edge; /* in device coordinates */
|
int32_t right_edge; /* in device coordinates */
|
||||||
int32_t left_edge; /* in device coordinates */
|
int32_t left_edge; /* in device coordinates */
|
||||||
|
|
@ -466,7 +466,7 @@ struct tp_dispatch {
|
||||||
bool trackpoint_active;
|
bool trackpoint_active;
|
||||||
struct libinput_event_listener trackpoint_listener;
|
struct libinput_event_listener trackpoint_listener;
|
||||||
struct libinput_timer trackpoint_timer;
|
struct libinput_timer trackpoint_timer;
|
||||||
uint64_t trackpoint_last_event_time;
|
usec_t trackpoint_last_event_time;
|
||||||
uint32_t trackpoint_event_count;
|
uint32_t trackpoint_event_count;
|
||||||
bool monitor_trackpoint;
|
bool monitor_trackpoint;
|
||||||
|
|
||||||
|
|
@ -487,7 +487,7 @@ struct tp_dispatch {
|
||||||
struct {
|
struct {
|
||||||
struct libinput_device_config_dwt config;
|
struct libinput_device_config_dwt config;
|
||||||
bool dwt_enabled;
|
bool dwt_enabled;
|
||||||
uint64_t timeout;
|
usec_t timeout;
|
||||||
|
|
||||||
/* We have to allow for more than one device node to be the
|
/* We have to allow for more than one device node to be the
|
||||||
* internal dwt keyboard (Razer Blade). But they're the same
|
* internal dwt keyboard (Razer Blade). But they're the same
|
||||||
|
|
@ -500,7 +500,7 @@ struct tp_dispatch {
|
||||||
unsigned long mod_mask[NLONGS(KEY_CNT)];
|
unsigned long mod_mask[NLONGS(KEY_CNT)];
|
||||||
bool keyboard_active;
|
bool keyboard_active;
|
||||||
struct libinput_timer keyboard_timer;
|
struct libinput_timer keyboard_timer;
|
||||||
uint64_t keyboard_last_press_time;
|
usec_t keyboard_last_press_time;
|
||||||
} dwt;
|
} dwt;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -531,8 +531,8 @@ struct tp_dispatch {
|
||||||
|
|
||||||
struct msc_timestamp {
|
struct msc_timestamp {
|
||||||
enum tp_jump_state state;
|
enum tp_jump_state state;
|
||||||
uint32_t interval;
|
usec_t interval;
|
||||||
uint32_t now;
|
usec_t now;
|
||||||
} msc_timestamp;
|
} msc_timestamp;
|
||||||
} quirks;
|
} quirks;
|
||||||
|
|
||||||
|
|
@ -616,17 +616,17 @@ tp_get_delta(struct tp_touch *t);
|
||||||
struct normalized_coords
|
struct normalized_coords
|
||||||
tp_filter_motion(struct tp_dispatch *tp,
|
tp_filter_motion(struct tp_dispatch *tp,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
|
|
||||||
struct normalized_coords
|
struct normalized_coords
|
||||||
tp_filter_motion_unaccelerated(struct tp_dispatch *tp,
|
tp_filter_motion_unaccelerated(struct tp_dispatch *tp,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
|
|
||||||
struct normalized_coords
|
struct normalized_coords
|
||||||
tp_filter_scroll(struct tp_dispatch *tp,
|
tp_filter_scroll(struct tp_dispatch *tp,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
|
tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
|
||||||
|
|
@ -635,7 +635,7 @@ bool
|
||||||
tp_touch_active_for_gesture(const struct tp_dispatch *tp, const struct tp_touch *t);
|
tp_touch_active_for_gesture(const struct tp_dispatch *tp, const struct tp_touch *t);
|
||||||
|
|
||||||
int
|
int
|
||||||
tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time);
|
tp_tap_handle_state(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_tap_post_process_state(struct tp_dispatch *tp);
|
tp_tap_post_process_state(struct tp_dispatch *tp);
|
||||||
|
|
@ -661,16 +661,16 @@ void
|
||||||
tp_remove_buttons(struct tp_dispatch *tp);
|
tp_remove_buttons(struct tp_dispatch *tp);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_process_button(struct tp_dispatch *tp, const struct evdev_event *e, uint64_t time);
|
tp_process_button(struct tp_dispatch *tp, const struct evdev_event *e, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_release_all_buttons(struct tp_dispatch *tp, uint64_t time);
|
tp_release_all_buttons(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
int
|
int
|
||||||
tp_post_button_events(struct tp_dispatch *tp, uint64_t time);
|
tp_post_button_events(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_button_handle_state(struct tp_dispatch *tp, uint64_t time);
|
tp_button_handle_state(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
tp_button_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
|
tp_button_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
|
||||||
|
|
@ -680,13 +680,13 @@ tp_button_is_inside_softbutton_area(const struct tp_dispatch *tp,
|
||||||
const struct tp_touch *t);
|
const struct tp_touch *t);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_release_all_taps(struct tp_dispatch *tp, uint64_t now);
|
tp_release_all_taps(struct tp_dispatch *tp, usec_t now);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_tap_suspend(struct tp_dispatch *tp, uint64_t time);
|
tp_tap_suspend(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_tap_resume(struct tp_dispatch *tp, uint64_t time);
|
tp_tap_resume(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
tp_tap_dragging(const struct tp_dispatch *tp);
|
tp_tap_dragging(const struct tp_dispatch *tp);
|
||||||
|
|
@ -701,13 +701,13 @@ void
|
||||||
tp_remove_edge_scroll(struct tp_dispatch *tp);
|
tp_remove_edge_scroll(struct tp_dispatch *tp);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_edge_scroll_handle_state(struct tp_dispatch *tp, uint64_t time);
|
tp_edge_scroll_handle_state(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
int
|
int
|
||||||
tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time);
|
tp_edge_scroll_post_events(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time);
|
tp_edge_scroll_stop_events(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
int
|
int
|
||||||
tp_edge_scroll_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
|
tp_edge_scroll_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
|
||||||
|
|
@ -722,25 +722,25 @@ void
|
||||||
tp_remove_gesture(struct tp_dispatch *tp);
|
tp_remove_gesture(struct tp_dispatch *tp);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_stop(struct tp_dispatch *tp, uint64_t time);
|
tp_gesture_stop(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_cancel(struct tp_dispatch *tp, uint64_t time);
|
tp_gesture_cancel(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_cancel_motion_gestures(struct tp_dispatch *tp, uint64_t time);
|
tp_gesture_cancel_motion_gestures(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_update_finger_state(struct tp_dispatch *tp, uint64_t time);
|
tp_gesture_update_finger_state(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time, bool ignore_motion);
|
tp_gesture_post_events(struct tp_dispatch *tp, usec_t time, bool ignore_motion);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time);
|
tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_gesture_tap_timeout(struct tp_dispatch *tp, uint64_t time);
|
tp_gesture_tap_timeout(struct tp_dispatch *tp, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_clickpad_middlebutton_apply_config(struct evdev_device *device);
|
tp_clickpad_middlebutton_apply_config(struct evdev_device *device);
|
||||||
|
|
@ -761,7 +761,7 @@ void
|
||||||
tp_thumb_suppress(struct tp_dispatch *tp, struct tp_touch *t);
|
tp_thumb_suppress(struct tp_dispatch *tp, struct tp_touch *t);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_thumb_update_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time);
|
tp_thumb_update_touch(struct tp_dispatch *tp, struct tp_touch *t, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
tp_detect_thumb_while_moving(struct tp_dispatch *tp);
|
tp_detect_thumb_while_moving(struct tp_dispatch *tp);
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,7 @@
|
||||||
#include "evdev.h"
|
#include "evdev.h"
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
evdev_process_frame(struct evdev_device *device,
|
evdev_process_frame(struct evdev_device *device, struct evdev_frame *frame, usec_t time)
|
||||||
struct evdev_frame *frame,
|
|
||||||
uint64_t time)
|
|
||||||
{
|
{
|
||||||
struct evdev_dispatch *dispatch = device->dispatch;
|
struct evdev_dispatch *dispatch = device->dispatch;
|
||||||
|
|
||||||
|
|
@ -47,7 +45,7 @@ evdev_device_dispatch_frame(struct libinput_plugin *plugin,
|
||||||
struct evdev_frame *frame)
|
struct evdev_frame *frame)
|
||||||
{
|
{
|
||||||
struct evdev_device *device = evdev_device(libinput_device);
|
struct evdev_device *device = evdev_device(libinput_device);
|
||||||
uint64_t time = evdev_frame_get_time(frame);
|
usec_t time = evdev_frame_get_time(frame);
|
||||||
evdev_process_frame(device, frame, time);
|
evdev_process_frame(device, frame, time);
|
||||||
|
|
||||||
/* Discard event to make the plugin system aware we're done */
|
/* Discard event to make the plugin system aware we're done */
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ static void
|
||||||
pad_process_relative(struct pad_dispatch *pad,
|
pad_process_relative(struct pad_dispatch *pad,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (evdev_usage_enum(e->usage)) {
|
switch (evdev_usage_enum(e->usage)) {
|
||||||
case EVDEV_REL_DIAL:
|
case EVDEV_REL_DIAL:
|
||||||
|
|
@ -172,7 +172,7 @@ static void
|
||||||
pad_process_absolute(struct pad_dispatch *pad,
|
pad_process_absolute(struct pad_dispatch *pad,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum pad_axes axis = PAD_AXIS_NONE;
|
enum pad_axes axis = PAD_AXIS_NONE;
|
||||||
|
|
||||||
|
|
@ -357,7 +357,7 @@ pad_strip_get_mode_group(struct pad_dispatch *pad, unsigned int strip)
|
||||||
static void
|
static void
|
||||||
pad_check_notify_axes(struct pad_dispatch *pad,
|
pad_check_notify_axes(struct pad_dispatch *pad,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_device *base = &device->base;
|
struct libinput_device *base = &device->base;
|
||||||
struct libinput_tablet_pad_mode_group *group;
|
struct libinput_tablet_pad_mode_group *group;
|
||||||
|
|
@ -452,7 +452,7 @@ static void
|
||||||
pad_process_key(struct pad_dispatch *pad,
|
pad_process_key(struct pad_dispatch *pad,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
uint32_t is_press = e->value != 0;
|
uint32_t is_press = e->value != 0;
|
||||||
|
|
||||||
|
|
@ -481,7 +481,7 @@ pad_button_get_mode_group(struct pad_dispatch *pad, unsigned int button)
|
||||||
static void
|
static void
|
||||||
pad_notify_button_mask(struct pad_dispatch *pad,
|
pad_notify_button_mask(struct pad_dispatch *pad,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
const struct button_state *buttons,
|
const struct button_state *buttons,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -537,7 +537,7 @@ pad_notify_button_mask(struct pad_dispatch *pad,
|
||||||
static void
|
static void
|
||||||
pad_notify_buttons(struct pad_dispatch *pad,
|
pad_notify_buttons(struct pad_dispatch *pad,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
struct button_state buttons;
|
struct button_state buttons;
|
||||||
|
|
@ -565,7 +565,7 @@ pad_change_to_left_handed(struct evdev_device *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pad_flush(struct pad_dispatch *pad, struct evdev_device *device, uint64_t time)
|
pad_flush(struct pad_dispatch *pad, struct evdev_device *device, usec_t time)
|
||||||
{
|
{
|
||||||
if (pad_has_status(pad, PAD_AXES_UPDATED)) {
|
if (pad_has_status(pad, PAD_AXES_UPDATED)) {
|
||||||
pad_check_notify_axes(pad, device, time);
|
pad_check_notify_axes(pad, device, time);
|
||||||
|
|
@ -594,7 +594,7 @@ static void
|
||||||
pad_process_event(struct evdev_dispatch *dispatch,
|
pad_process_event(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct pad_dispatch *pad = pad_dispatch(dispatch);
|
struct pad_dispatch *pad = pad_dispatch(dispatch);
|
||||||
|
|
||||||
|
|
@ -629,7 +629,7 @@ static void
|
||||||
pad_process(struct evdev_dispatch *dispatch,
|
pad_process(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
size_t nevents;
|
size_t nevents;
|
||||||
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
||||||
|
|
@ -822,7 +822,7 @@ pad_init(struct pad_dispatch *pad, struct evdev_device *device)
|
||||||
pad->device = device;
|
pad->device = device;
|
||||||
pad->status = PAD_NONE;
|
pad->status = PAD_NONE;
|
||||||
pad->changed_axes = PAD_AXIS_NONE;
|
pad->changed_axes = PAD_AXIS_NONE;
|
||||||
ratelimit_init(&pad->modes.group_not_found, h2us(1), 3);
|
ratelimit_init(&pad->modes.group_not_found, usec_from_hours(1), 3);
|
||||||
|
|
||||||
/* We expect the kernel to either give us both axes as hires or neither.
|
/* We expect the kernel to either give us both axes as hires or neither.
|
||||||
* Getting one is a kernel bug we don't need to care about */
|
* Getting one is a kernel bug we don't need to care about */
|
||||||
|
|
@ -842,7 +842,7 @@ pad_init(struct pad_dispatch *pad, struct evdev_device *device)
|
||||||
rc = pad_init_leds(pad, device, wacom);
|
rc = pad_init_leds(pad, device, wacom);
|
||||||
|
|
||||||
/* at most 5 "Multiple EV_ABS events" log messages per hour */
|
/* at most 5 "Multiple EV_ABS events" log messages per hour */
|
||||||
ratelimit_init(&pad->duplicate_abs_limit, s2us(60 * 60), 5);
|
ratelimit_init(&pad->duplicate_abs_limit, usec_from_seconds(60 * 60), 5);
|
||||||
|
|
||||||
#ifdef HAVE_LIBWACOM
|
#ifdef HAVE_LIBWACOM
|
||||||
if (wacom)
|
if (wacom)
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ static void
|
||||||
tablet_process_absolute(struct tablet_dispatch *tablet,
|
tablet_process_absolute(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum libinput_tablet_tool_axis axis;
|
enum libinput_tablet_tool_axis axis;
|
||||||
|
|
||||||
|
|
@ -557,7 +557,7 @@ tablet_tool_process_delta(struct tablet_dispatch *tablet,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
const struct evdev_device *device,
|
const struct evdev_device *device,
|
||||||
struct tablet_axes *axes,
|
struct tablet_axes *axes,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||||
struct device_coords delta = { 0, 0 };
|
struct device_coords delta = { 0, 0 };
|
||||||
|
|
@ -759,7 +759,7 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
struct tablet_axes *axes_out,
|
struct tablet_axes *axes_out,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct tablet_axes axes = { 0 };
|
struct tablet_axes axes = { 0 };
|
||||||
const char tmp[sizeof(tablet->changed_axes)] = { 0 };
|
const char tmp[sizeof(tablet->changed_axes)] = { 0 };
|
||||||
|
|
@ -884,7 +884,7 @@ static void
|
||||||
tablet_process_key(struct tablet_dispatch *tablet,
|
tablet_process_key(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum libinput_tablet_tool_type type;
|
enum libinput_tablet_tool_type type;
|
||||||
|
|
||||||
|
|
@ -930,7 +930,7 @@ static void
|
||||||
tablet_process_relative(struct tablet_dispatch *tablet,
|
tablet_process_relative(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum libinput_tablet_tool_axis axis;
|
enum libinput_tablet_tool_axis axis;
|
||||||
|
|
||||||
|
|
@ -960,7 +960,7 @@ static void
|
||||||
tablet_process_misc(struct tablet_dispatch *tablet,
|
tablet_process_misc(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (evdev_usage_enum(e->usage)) {
|
switch (evdev_usage_enum(e->usage)) {
|
||||||
case EVDEV_MSC_SERIAL:
|
case EVDEV_MSC_SERIAL:
|
||||||
|
|
@ -1522,7 +1522,7 @@ tablet_get_tool(struct tablet_dispatch *tablet,
|
||||||
static void
|
static void
|
||||||
tablet_notify_button_mask(struct tablet_dispatch *tablet,
|
tablet_notify_button_mask(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
const struct button_state *buttons,
|
const struct button_state *buttons,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
|
|
@ -1556,7 +1556,7 @@ tablet_notify_button_mask(struct tablet_dispatch *tablet,
|
||||||
static void
|
static void
|
||||||
tablet_notify_buttons(struct tablet_dispatch *tablet,
|
tablet_notify_buttons(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -1917,7 +1917,7 @@ tablet_calculate_arbitration_rect(struct tablet_dispatch *tablet)
|
||||||
static inline void
|
static inline void
|
||||||
tablet_update_touch_device_rect(struct tablet_dispatch *tablet,
|
tablet_update_touch_device_rect(struct tablet_dispatch *tablet,
|
||||||
const struct tablet_axes *axes,
|
const struct tablet_axes *axes,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct evdev_dispatch *dispatch;
|
struct evdev_dispatch *dispatch;
|
||||||
struct phys_rect rect = { 0 };
|
struct phys_rect rect = { 0 };
|
||||||
|
|
@ -1941,7 +1941,7 @@ tablet_send_proximity_in(struct tablet_dispatch *tablet,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct tablet_axes *axes,
|
struct tablet_axes *axes,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (!tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY))
|
if (!tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY))
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1969,7 +1969,7 @@ tablet_send_proximity_out(struct tablet_dispatch *tablet,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct tablet_axes *axes,
|
struct tablet_axes *axes,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY) &&
|
if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY) &&
|
||||||
!tablet_has_status(tablet, TABLET_TOOL_OUTSIDE_AREA)) {
|
!tablet_has_status(tablet, TABLET_TOOL_OUTSIDE_AREA)) {
|
||||||
|
|
@ -1989,7 +1989,7 @@ tablet_send_tip(struct tablet_dispatch *tablet,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct tablet_axes *axes,
|
struct tablet_axes *axes,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT)) {
|
if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT)) {
|
||||||
tablet_notify_tip(&device->base,
|
tablet_notify_tip(&device->base,
|
||||||
|
|
@ -2039,7 +2039,7 @@ tablet_send_axes(struct tablet_dispatch *tablet,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct tablet_axes *axes,
|
struct tablet_axes *axes,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum libinput_tablet_tool_tip_state tip_state;
|
enum libinput_tablet_tool_tip_state tip_state;
|
||||||
|
|
||||||
|
|
@ -2069,7 +2069,7 @@ static inline void
|
||||||
tablet_send_buttons(struct tablet_dispatch *tablet,
|
tablet_send_buttons(struct tablet_dispatch *tablet,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (tablet_has_status(tablet, TABLET_BUTTONS_RELEASED)) {
|
if (tablet_has_status(tablet, TABLET_BUTTONS_RELEASED)) {
|
||||||
tablet_notify_buttons(tablet,
|
tablet_notify_buttons(tablet,
|
||||||
|
|
@ -2094,7 +2094,7 @@ static void
|
||||||
tablet_send_events(struct tablet_dispatch *tablet,
|
tablet_send_events(struct tablet_dispatch *tablet,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct tablet_axes axes = { 0 };
|
struct tablet_axes axes = { 0 };
|
||||||
|
|
||||||
|
|
@ -2131,7 +2131,7 @@ tablet_send_events(struct tablet_dispatch *tablet,
|
||||||
static void
|
static void
|
||||||
tablet_update_tool_state(struct tablet_dispatch *tablet,
|
tablet_update_tool_state(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum libinput_tablet_tool_type type;
|
enum libinput_tablet_tool_type type;
|
||||||
uint32_t changed;
|
uint32_t changed;
|
||||||
|
|
@ -2206,7 +2206,7 @@ update_pressure_range(struct tablet_dispatch *tablet,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tablet_flush(struct tablet_dispatch *tablet, struct evdev_device *device, uint64_t time)
|
tablet_flush(struct tablet_dispatch *tablet, struct evdev_device *device, usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_tablet_tool *tool;
|
struct libinput_tablet_tool *tool;
|
||||||
|
|
||||||
|
|
@ -2290,7 +2290,7 @@ static inline void
|
||||||
tablet_set_touch_device_enabled(struct tablet_dispatch *tablet,
|
tablet_set_touch_device_enabled(struct tablet_dispatch *tablet,
|
||||||
enum evdev_arbitration_state which,
|
enum evdev_arbitration_state which,
|
||||||
const struct phys_rect *rect,
|
const struct phys_rect *rect,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct evdev_device *touch_device = tablet->touch_device;
|
struct evdev_device *touch_device = tablet->touch_device;
|
||||||
struct evdev_dispatch *dispatch;
|
struct evdev_dispatch *dispatch;
|
||||||
|
|
@ -2312,7 +2312,7 @@ tablet_set_touch_device_enabled(struct tablet_dispatch *tablet,
|
||||||
static inline void
|
static inline void
|
||||||
tablet_toggle_touch_device(struct tablet_dispatch *tablet,
|
tablet_toggle_touch_device(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *tablet_device,
|
struct evdev_device *tablet_device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum evdev_arbitration_state which;
|
enum evdev_arbitration_state which;
|
||||||
struct phys_rect r = { 0 };
|
struct phys_rect r = { 0 };
|
||||||
|
|
@ -2359,7 +2359,7 @@ static void
|
||||||
tablet_process_event(struct evdev_dispatch *dispatch,
|
tablet_process_event(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct tablet_dispatch *tablet = tablet_dispatch(dispatch);
|
struct tablet_dispatch *tablet = tablet_dispatch(dispatch);
|
||||||
|
|
||||||
|
|
@ -2395,7 +2395,7 @@ static void
|
||||||
tablet_process(struct evdev_dispatch *dispatch,
|
tablet_process(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
size_t nevents;
|
size_t nevents;
|
||||||
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
||||||
|
|
@ -2410,7 +2410,7 @@ tablet_suspend(struct evdev_dispatch *dispatch, struct evdev_device *device)
|
||||||
{
|
{
|
||||||
struct tablet_dispatch *tablet = tablet_dispatch(dispatch);
|
struct tablet_dispatch *tablet = tablet_dispatch(dispatch);
|
||||||
struct libinput *li = tablet_libinput_context(tablet);
|
struct libinput *li = tablet_libinput_context(tablet);
|
||||||
uint64_t now = libinput_now(li);
|
usec_t now = libinput_now(li);
|
||||||
|
|
||||||
tablet_set_touch_device_enabled(tablet, ARBITRATION_NOT_ACTIVE, NULL, now);
|
tablet_set_touch_device_enabled(tablet, ARBITRATION_NOT_ACTIVE, NULL, now);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ totem_new_tool(struct totem_dispatch *totem)
|
||||||
static inline void
|
static inline void
|
||||||
totem_set_touch_device_enabled(struct totem_dispatch *totem,
|
totem_set_touch_device_enabled(struct totem_dispatch *totem,
|
||||||
bool enable_touch_device,
|
bool enable_touch_device,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct evdev_device *touch_device = totem->touch_device;
|
struct evdev_device *touch_device = totem->touch_device;
|
||||||
struct evdev_dispatch *dispatch;
|
struct evdev_dispatch *dispatch;
|
||||||
|
|
@ -183,7 +183,7 @@ static void
|
||||||
totem_process_key(struct totem_dispatch *totem,
|
totem_process_key(struct totem_dispatch *totem,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
/* ignore kernel key repeat */
|
/* ignore kernel key repeat */
|
||||||
if (e->value == 2)
|
if (e->value == 2)
|
||||||
|
|
@ -205,7 +205,7 @@ static void
|
||||||
totem_process_abs(struct totem_dispatch *totem,
|
totem_process_abs(struct totem_dispatch *totem,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct totem_slot *slot = &totem->slots[totem->slot];
|
struct totem_slot *slot = &totem->slots[totem->slot];
|
||||||
|
|
||||||
|
|
@ -263,7 +263,7 @@ totem_slot_fetch_axes(struct totem_dispatch *totem,
|
||||||
struct totem_slot *slot,
|
struct totem_slot *slot,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
struct tablet_axes *axes_out,
|
struct tablet_axes *axes_out,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct evdev_device *device = totem->device;
|
struct evdev_device *device = totem->device;
|
||||||
const char tmp[sizeof(slot->changed_axes)] = { 0 };
|
const char tmp[sizeof(slot->changed_axes)] = { 0 };
|
||||||
|
|
@ -358,7 +358,7 @@ slot_axes_initialize(struct totem_dispatch *totem, struct totem_slot *slot)
|
||||||
static enum totem_slot_state
|
static enum totem_slot_state
|
||||||
totem_handle_slot_state(struct totem_dispatch *totem,
|
totem_handle_slot_state(struct totem_dispatch *totem,
|
||||||
struct totem_slot *slot,
|
struct totem_slot *slot,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct evdev_device *device = totem->device;
|
struct evdev_device *device = totem->device;
|
||||||
struct tablet_axes axes;
|
struct tablet_axes axes;
|
||||||
|
|
@ -493,7 +493,7 @@ totem_handle_slot_state(struct totem_dispatch *totem,
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum totem_slot_state
|
static enum totem_slot_state
|
||||||
totem_handle_state(struct totem_dispatch *totem, uint64_t time)
|
totem_handle_state(struct totem_dispatch *totem, usec_t time)
|
||||||
{
|
{
|
||||||
enum totem_slot_state global_state = SLOT_STATE_NONE;
|
enum totem_slot_state global_state = SLOT_STATE_NONE;
|
||||||
|
|
||||||
|
|
@ -514,7 +514,7 @@ static void
|
||||||
totem_process_event(struct evdev_dispatch *dispatch,
|
totem_process_event(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct totem_dispatch *totem = totem_dispatch(dispatch);
|
struct totem_dispatch *totem = totem_dispatch(dispatch);
|
||||||
enum totem_slot_state global_state;
|
enum totem_slot_state global_state;
|
||||||
|
|
@ -549,7 +549,7 @@ static void
|
||||||
totem_interface_process(struct evdev_dispatch *dispatch,
|
totem_interface_process(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
size_t nevents;
|
size_t nevents;
|
||||||
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
||||||
|
|
@ -563,7 +563,7 @@ static void
|
||||||
totem_interface_suspend(struct evdev_dispatch *dispatch, struct evdev_device *device)
|
totem_interface_suspend(struct evdev_dispatch *dispatch, struct evdev_device *device)
|
||||||
{
|
{
|
||||||
struct totem_dispatch *totem = totem_dispatch(dispatch);
|
struct totem_dispatch *totem = totem_dispatch(dispatch);
|
||||||
uint64_t now = libinput_now(evdev_libinput_context(device));
|
usec_t now = libinput_now(evdev_libinput_context(device));
|
||||||
|
|
||||||
for (size_t i = 0; i < totem->nslots; i++) {
|
for (size_t i = 0; i < totem->nslots; i++) {
|
||||||
struct totem_slot *slot = &totem->slots[i];
|
struct totem_slot *slot = &totem->slots[i];
|
||||||
|
|
@ -682,7 +682,7 @@ totem_interface_initial_proximity(struct evdev_device *device,
|
||||||
struct evdev_dispatch *dispatch)
|
struct evdev_dispatch *dispatch)
|
||||||
{
|
{
|
||||||
struct totem_dispatch *totem = totem_dispatch(dispatch);
|
struct totem_dispatch *totem = totem_dispatch(dispatch);
|
||||||
uint64_t now = libinput_now(evdev_libinput_context(device));
|
usec_t now = libinput_now(evdev_libinput_context(device));
|
||||||
bool enable_touch = true;
|
bool enable_touch = true;
|
||||||
|
|
||||||
for (size_t i = 0; i < totem->nslots; i++) {
|
for (size_t i = 0; i < totem->nslots; i++) {
|
||||||
|
|
|
||||||
44
src/evdev.c
44
src/evdev.c
|
|
@ -53,7 +53,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFAULT_WHEEL_CLICK_ANGLE 15
|
#define DEFAULT_WHEEL_CLICK_ANGLE 15
|
||||||
#define DEFAULT_BUTTON_SCROLL_TIMEOUT ms2us(200)
|
#define DEFAULT_BUTTON_SCROLL_TIMEOUT usec_from_millis(200)
|
||||||
|
|
||||||
enum evdev_device_udev_tags {
|
enum evdev_device_udev_tags {
|
||||||
EVDEV_UDEV_TAG_NONE = 0,
|
EVDEV_UDEV_TAG_NONE = 0,
|
||||||
|
|
@ -167,7 +167,7 @@ evdev_device_switch_get_state(struct evdev_device *device, enum libinput_switch
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_pointer_notify_physical_button(struct evdev_device *device,
|
evdev_pointer_notify_physical_button(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -179,7 +179,7 @@ evdev_pointer_notify_physical_button(struct evdev_device *device,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evdev_pointer_post_button(struct evdev_device *device,
|
evdev_pointer_post_button(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -205,7 +205,7 @@ evdev_pointer_post_button(struct evdev_device *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evdev_button_scroll_timeout(uint64_t time, void *data)
|
evdev_button_scroll_timeout(usec_t time, void *data)
|
||||||
{
|
{
|
||||||
struct evdev_device *device = data;
|
struct evdev_device *device = data;
|
||||||
|
|
||||||
|
|
@ -213,7 +213,7 @@ evdev_button_scroll_timeout(uint64_t time, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evdev_button_scroll_button(struct evdev_device *device, uint64_t time, int is_press)
|
evdev_button_scroll_button(struct evdev_device *device, usec_t time, int is_press)
|
||||||
{
|
{
|
||||||
/* Where the button lock is enabled, we wrap the buttons into
|
/* Where the button lock is enabled, we wrap the buttons into
|
||||||
their own little state machine and filter out the events.
|
their own little state machine and filter out the events.
|
||||||
|
|
@ -265,9 +265,10 @@ evdev_button_scroll_button(struct evdev_device *device, uint64_t time, int is_pr
|
||||||
flags = TIMER_FLAG_ALLOW_NEGATIVE;
|
flags = TIMER_FLAG_ALLOW_NEGATIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
libinput_timer_set_flags(&device->scroll.timer,
|
libinput_timer_set_flags(
|
||||||
time + DEFAULT_BUTTON_SCROLL_TIMEOUT,
|
&device->scroll.timer,
|
||||||
flags);
|
usec_add(time, DEFAULT_BUTTON_SCROLL_TIMEOUT),
|
||||||
|
flags);
|
||||||
} else {
|
} else {
|
||||||
/* For extra mouse buttons numbered 6 or more (0x115+) we assume
|
/* For extra mouse buttons numbered 6 or more (0x115+) we assume
|
||||||
* it is dedicated exclusively to scrolling, so we don't apply
|
* it is dedicated exclusively to scrolling, so we don't apply
|
||||||
|
|
@ -314,7 +315,7 @@ evdev_button_scroll_button(struct evdev_device *device, uint64_t time, int is_pr
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_pointer_notify_button(struct evdev_device *device,
|
evdev_pointer_notify_button(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -394,7 +395,7 @@ evdev_device_transform_y(struct evdev_device *device, double y, uint32_t height)
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_notify_axis_legacy_wheel(struct evdev_device *device,
|
evdev_notify_axis_legacy_wheel(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta_in,
|
const struct normalized_coords *delta_in,
|
||||||
const struct discrete_coords *discrete_in)
|
const struct discrete_coords *discrete_in)
|
||||||
|
|
@ -419,7 +420,7 @@ evdev_notify_axis_legacy_wheel(struct evdev_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_notify_axis_wheel(struct evdev_device *device,
|
evdev_notify_axis_wheel(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta_in,
|
const struct normalized_coords *delta_in,
|
||||||
const struct wheel_v120 *v120_in)
|
const struct wheel_v120 *v120_in)
|
||||||
|
|
@ -444,7 +445,7 @@ evdev_notify_axis_wheel(struct evdev_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_notify_axis_finger(struct evdev_device *device,
|
evdev_notify_axis_finger(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta_in)
|
const struct normalized_coords *delta_in)
|
||||||
{
|
{
|
||||||
|
|
@ -460,7 +461,7 @@ evdev_notify_axis_finger(struct evdev_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_notify_axis_continous(struct evdev_device *device,
|
evdev_notify_axis_continous(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta_in)
|
const struct normalized_coords *delta_in)
|
||||||
{
|
{
|
||||||
|
|
@ -1014,7 +1015,7 @@ evdev_note_time_delay(struct evdev_device *device, const struct input_event *ev)
|
||||||
{
|
{
|
||||||
struct libinput *libinput = evdev_libinput_context(device);
|
struct libinput *libinput = evdev_libinput_context(device);
|
||||||
uint32_t tdelta;
|
uint32_t tdelta;
|
||||||
uint64_t eventtime = input_event_time(ev);
|
usec_t eventtime = input_event_time(ev);
|
||||||
|
|
||||||
/* if we have a current libinput_dispatch() snapshot, compare our
|
/* if we have a current libinput_dispatch() snapshot, compare our
|
||||||
* event time with the one from the snapshot. If we have more than
|
* event time with the one from the snapshot. If we have more than
|
||||||
|
|
@ -1022,10 +1023,11 @@ evdev_note_time_delay(struct evdev_device *device, const struct input_event *ev)
|
||||||
* where there is no steady event flow and thus SYN_DROPPED may not
|
* where there is no steady event flow and thus SYN_DROPPED may not
|
||||||
* get hit by the kernel despite us being too slow.
|
* get hit by the kernel despite us being too slow.
|
||||||
*/
|
*/
|
||||||
if (libinput->dispatch_time == 0 || eventtime > libinput->dispatch_time)
|
if (usec_is_zero(libinput->dispatch_time) ||
|
||||||
|
usec_cmp(eventtime, libinput->dispatch_time) > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tdelta = us2ms(libinput->dispatch_time - eventtime);
|
tdelta = usec_to_millis(usec_delta(libinput->dispatch_time, eventtime));
|
||||||
if (tdelta > 20) {
|
if (tdelta > 20) {
|
||||||
evdev_log_bug_client_ratelimit(
|
evdev_log_bug_client_ratelimit(
|
||||||
device,
|
device,
|
||||||
|
|
@ -2313,11 +2315,11 @@ evdev_device_create(struct libinput_seat *seat, struct udev_device *udev_device)
|
||||||
device->dpi = DEFAULT_MOUSE_DPI;
|
device->dpi = DEFAULT_MOUSE_DPI;
|
||||||
|
|
||||||
/* at most 5 SYN_DROPPED log-messages per 30s */
|
/* at most 5 SYN_DROPPED log-messages per 30s */
|
||||||
ratelimit_init(&device->syn_drop_limit, s2us(30), 5);
|
ratelimit_init(&device->syn_drop_limit, usec_from_seconds(30), 5);
|
||||||
/* at most 5 "delayed processing" log messages per hour */
|
/* at most 5 "delayed processing" log messages per hour */
|
||||||
ratelimit_init(&device->delay_warning_limit, s2us(60 * 60), 5);
|
ratelimit_init(&device->delay_warning_limit, usec_from_hours(1), 5);
|
||||||
/* at most 5 log-messages per 5s */
|
/* at most 5 log-messages per 5s */
|
||||||
ratelimit_init(&device->nonpointer_rel_limit, s2us(5), 5);
|
ratelimit_init(&device->nonpointer_rel_limit, usec_from_seconds(5), 5);
|
||||||
|
|
||||||
matrix_init_identity(&device->abs.calibration);
|
matrix_init_identity(&device->abs.calibration);
|
||||||
matrix_init_identity(&device->abs.usermatrix);
|
matrix_init_identity(&device->abs.usermatrix);
|
||||||
|
|
@ -2705,7 +2707,7 @@ evdev_start_scrolling(struct evdev_device *device, enum libinput_pointer_axis ax
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_post_scroll(struct evdev_device *device,
|
evdev_post_scroll(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_pointer_axis_source source,
|
enum libinput_pointer_axis_source source,
|
||||||
const struct normalized_coords *delta)
|
const struct normalized_coords *delta)
|
||||||
{
|
{
|
||||||
|
|
@ -2779,7 +2781,7 @@ evdev_post_scroll(struct evdev_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_stop_scroll(struct evdev_device *device,
|
evdev_stop_scroll(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_pointer_axis_source source)
|
enum libinput_pointer_axis_source source)
|
||||||
{
|
{
|
||||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||||
|
|
|
||||||
32
src/evdev.h
32
src/evdev.h
|
|
@ -219,7 +219,7 @@ struct evdev_device {
|
||||||
/* Currently enabled method, button */
|
/* Currently enabled method, button */
|
||||||
enum libinput_config_scroll_method method;
|
enum libinput_config_scroll_method method;
|
||||||
evdev_usage_t button;
|
evdev_usage_t button;
|
||||||
uint64_t button_down_time;
|
usec_t button_down_time;
|
||||||
|
|
||||||
/* set during device init, used at runtime to delay changes
|
/* set during device init, used at runtime to delay changes
|
||||||
* until all buttons are up */
|
* until all buttons are up */
|
||||||
|
|
@ -279,7 +279,7 @@ struct evdev_device {
|
||||||
enum evdev_middlebutton_state state;
|
enum evdev_middlebutton_state state;
|
||||||
struct libinput_timer timer;
|
struct libinput_timer timer;
|
||||||
uint32_t button_mask;
|
uint32_t button_mask;
|
||||||
uint64_t first_event_time;
|
usec_t first_event_time;
|
||||||
} middlebutton;
|
} middlebutton;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -298,7 +298,7 @@ struct evdev_dispatch_interface {
|
||||||
void (*process)(struct evdev_dispatch *dispatch,
|
void (*process)(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
|
|
||||||
/* Device is being suspended */
|
/* Device is being suspended */
|
||||||
void (*suspend)(struct evdev_dispatch *dispatch, struct evdev_device *device);
|
void (*suspend)(struct evdev_dispatch *dispatch, struct evdev_device *device);
|
||||||
|
|
@ -337,7 +337,7 @@ struct evdev_dispatch_interface {
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
enum evdev_arbitration_state which,
|
enum evdev_arbitration_state which,
|
||||||
const struct phys_rect *rect, /* may be NULL */
|
const struct phys_rect *rect, /* may be NULL */
|
||||||
uint64_t now);
|
usec_t now);
|
||||||
|
|
||||||
/* Called when touch arbitration is on, updates the area where touch
|
/* Called when touch arbitration is on, updates the area where touch
|
||||||
* arbitration should apply.
|
* arbitration should apply.
|
||||||
|
|
@ -345,7 +345,7 @@ struct evdev_dispatch_interface {
|
||||||
void (*touch_arbitration_update_rect)(struct evdev_dispatch *dispatch,
|
void (*touch_arbitration_update_rect)(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
const struct phys_rect *rect,
|
const struct phys_rect *rect,
|
||||||
uint64_t now);
|
usec_t now);
|
||||||
|
|
||||||
/* Return the state of the given switch */
|
/* Return the state of the given switch */
|
||||||
enum libinput_switch_state (*get_switch_state)(struct evdev_dispatch *dispatch,
|
enum libinput_switch_state (*get_switch_state)(struct evdev_dispatch *dispatch,
|
||||||
|
|
@ -553,12 +553,12 @@ evdev_notify_resumed_device(struct evdev_device *device);
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_pointer_notify_button(struct evdev_device *device,
|
evdev_pointer_notify_button(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state);
|
enum libinput_button_state state);
|
||||||
void
|
void
|
||||||
evdev_pointer_notify_physical_button(struct evdev_device *device,
|
evdev_pointer_notify_physical_button(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state);
|
enum libinput_button_state state);
|
||||||
|
|
||||||
|
|
@ -579,36 +579,36 @@ evdev_update_key_down_count(struct evdev_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_notify_axis_legacy_wheel(struct evdev_device *device,
|
evdev_notify_axis_legacy_wheel(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta_in,
|
const struct normalized_coords *delta_in,
|
||||||
const struct discrete_coords *discrete_in);
|
const struct discrete_coords *discrete_in);
|
||||||
void
|
void
|
||||||
evdev_notify_axis_wheel(struct evdev_device *device,
|
evdev_notify_axis_wheel(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta_in,
|
const struct normalized_coords *delta_in,
|
||||||
const struct wheel_v120 *v120_in);
|
const struct wheel_v120 *v120_in);
|
||||||
void
|
void
|
||||||
evdev_notify_axis_finger(struct evdev_device *device,
|
evdev_notify_axis_finger(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta_in);
|
const struct normalized_coords *delta_in);
|
||||||
void
|
void
|
||||||
evdev_notify_axis_continous(struct evdev_device *device,
|
evdev_notify_axis_continous(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta_in);
|
const struct normalized_coords *delta_in);
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_post_scroll(struct evdev_device *device,
|
evdev_post_scroll(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_pointer_axis_source source,
|
enum libinput_pointer_axis_source source,
|
||||||
const struct normalized_coords *delta);
|
const struct normalized_coords *delta);
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_stop_scroll(struct evdev_device *device,
|
evdev_stop_scroll(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_pointer_axis_source source);
|
enum libinput_pointer_axis_source source);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -619,7 +619,7 @@ evdev_device_destroy(struct evdev_device *device);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
evdev_middlebutton_filter_button(struct evdev_device *device,
|
evdev_middlebutton_filter_button(struct evdev_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
evdev_usage_t button,
|
evdev_usage_t button,
|
||||||
enum libinput_button_state state);
|
enum libinput_button_state state);
|
||||||
|
|
||||||
|
|
@ -970,7 +970,9 @@ evdev_device_init_abs_range_warnings(struct evdev_device *device)
|
||||||
device->abs.warning_range.max.y = y->maximum + 0.05 * height;
|
device->abs.warning_range.max.y = y->maximum + 0.05 * height;
|
||||||
|
|
||||||
/* One warning every 5 min is enough */
|
/* One warning every 5 min is enough */
|
||||||
ratelimit_init(&device->abs.warning_range.range_warn_limit, s2us(3000), 1);
|
ratelimit_init(&device->abs.warning_range.range_warn_limit,
|
||||||
|
usec_from_seconds(3000),
|
||||||
|
1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,12 @@
|
||||||
#include "filter-private.h"
|
#include "filter-private.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
|
|
||||||
#define MOTION_TIMEOUT ms2us(1000)
|
#define MOTION_TIMEOUT usec_from_millis(1000)
|
||||||
#define FIRST_MOTION_TIME_INTERVAL ms2us(7) /* random but good enough interval for very first event */
|
#define FIRST_MOTION_TIME_INTERVAL usec_from_millis(7) /* random but good enough interval for very first event */
|
||||||
|
|
||||||
struct custom_accel_function {
|
struct custom_accel_function {
|
||||||
uint64_t last_time;
|
usec_t last_time;
|
||||||
uint64_t last_delta_time;
|
usec_t last_delta_time;
|
||||||
double step;
|
double step;
|
||||||
size_t npoints;
|
size_t npoints;
|
||||||
double points[];
|
double points[];
|
||||||
|
|
@ -58,7 +58,7 @@ create_custom_accel_function(double step, const double *points, size_t npoints)
|
||||||
|
|
||||||
struct custom_accel_function *cf =
|
struct custom_accel_function *cf =
|
||||||
zalloc(sizeof(*cf) + npoints * sizeof(*points));
|
zalloc(sizeof(*cf) + npoints * sizeof(*points));
|
||||||
cf->last_time = 0;
|
cf->last_time = usec_from_uint64_t(0);
|
||||||
cf->last_delta_time = FIRST_MOTION_TIME_INTERVAL;
|
cf->last_delta_time = FIRST_MOTION_TIME_INTERVAL;
|
||||||
cf->step = step;
|
cf->step = step;
|
||||||
cf->npoints = npoints;
|
cf->npoints = npoints;
|
||||||
|
|
@ -79,7 +79,7 @@ custom_accel_function_destroy(struct custom_accel_function *cf)
|
||||||
static double
|
static double
|
||||||
custom_accel_function_calculate_speed(struct custom_accel_function *cf,
|
custom_accel_function_calculate_speed(struct custom_accel_function *cf,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
/* Although most devices have a constant polling rate, and for fast
|
/* Although most devices have a constant polling rate, and for fast
|
||||||
* movements these distances do represent the actual speed,
|
* movements these distances do represent the actual speed,
|
||||||
|
|
@ -121,10 +121,11 @@ custom_accel_function_calculate_speed(struct custom_accel_function *cf,
|
||||||
* Reusing the last delta_time is a graceful fallback even if there are
|
* Reusing the last delta_time is a graceful fallback even if there are
|
||||||
* duplicate events or event-ordering bugs.
|
* duplicate events or event-ordering bugs.
|
||||||
*/
|
*/
|
||||||
uint64_t delta_time =
|
usec_t delta_time = usec_cmp(time, cf->last_time) > 0
|
||||||
(time > cf->last_time) ? time - cf->last_time : cf->last_delta_time;
|
? usec_delta(time, cf->last_time)
|
||||||
|
: cf->last_delta_time;
|
||||||
/* handle first event in a motion */
|
/* handle first event in a motion */
|
||||||
if (delta_time > MOTION_TIMEOUT)
|
if (usec_cmp(delta_time, MOTION_TIMEOUT) > 0)
|
||||||
delta_time = FIRST_MOTION_TIME_INTERVAL;
|
delta_time = FIRST_MOTION_TIME_INTERVAL;
|
||||||
|
|
||||||
/* speed is in device-units per ms */
|
/* speed is in device-units per ms */
|
||||||
|
|
@ -196,7 +197,7 @@ custom_accel_function_profile(struct custom_accel_function *cf, double speed_in)
|
||||||
static struct normalized_coords
|
static struct normalized_coords
|
||||||
custom_accel_function_filter(struct custom_accel_function *cf,
|
custom_accel_function_filter(struct custom_accel_function *cf,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
double speed = custom_accel_function_calculate_speed(cf, unaccelerated, time);
|
double speed = custom_accel_function_calculate_speed(cf, unaccelerated, time);
|
||||||
|
|
||||||
|
|
@ -252,7 +253,7 @@ static struct normalized_coords
|
||||||
custom_accelerator_filter(enum libinput_config_accel_type accel_type,
|
custom_accelerator_filter(enum libinput_config_accel_type accel_type,
|
||||||
struct motion_filter *filter,
|
struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct custom_accelerator *f = (struct custom_accelerator *)filter;
|
struct custom_accelerator *f = (struct custom_accelerator *)filter;
|
||||||
struct custom_accel_function *cf;
|
struct custom_accel_function *cf;
|
||||||
|
|
@ -263,7 +264,7 @@ custom_accelerator_filter(enum libinput_config_accel_type accel_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
custom_accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
|
custom_accelerator_restart(struct motion_filter *filter, void *data, usec_t time)
|
||||||
{
|
{
|
||||||
/* noop, this function has no effect in the custom interface */
|
/* noop, this function has no effect in the custom interface */
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +348,7 @@ double
|
||||||
custom_accel_profile_fallback(struct motion_filter *filter,
|
custom_accel_profile_fallback(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_FALLBACK,
|
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_FALLBACK,
|
||||||
filter,
|
filter,
|
||||||
|
|
@ -358,7 +359,7 @@ static struct normalized_coords
|
||||||
custom_accelerator_filter_fallback(struct motion_filter *filter,
|
custom_accelerator_filter_fallback(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
return custom_accelerator_filter(LIBINPUT_ACCEL_TYPE_FALLBACK,
|
return custom_accelerator_filter(LIBINPUT_ACCEL_TYPE_FALLBACK,
|
||||||
filter,
|
filter,
|
||||||
|
|
@ -370,7 +371,7 @@ double
|
||||||
custom_accel_profile_motion(struct motion_filter *filter,
|
custom_accel_profile_motion(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_MOTION, filter, speed_in);
|
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_MOTION, filter, speed_in);
|
||||||
}
|
}
|
||||||
|
|
@ -379,7 +380,7 @@ static struct normalized_coords
|
||||||
custom_accelerator_filter_motion(struct motion_filter *filter,
|
custom_accelerator_filter_motion(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
return custom_accelerator_filter(LIBINPUT_ACCEL_TYPE_MOTION,
|
return custom_accelerator_filter(LIBINPUT_ACCEL_TYPE_MOTION,
|
||||||
filter,
|
filter,
|
||||||
|
|
@ -391,7 +392,7 @@ double
|
||||||
custom_accel_profile_scroll(struct motion_filter *filter,
|
custom_accel_profile_scroll(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_SCROLL, filter, speed_in);
|
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_SCROLL, filter, speed_in);
|
||||||
}
|
}
|
||||||
|
|
@ -400,7 +401,7 @@ static struct normalized_coords
|
||||||
custom_accelerator_filter_scroll(struct motion_filter *filter,
|
custom_accelerator_filter_scroll(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
return custom_accelerator_filter(LIBINPUT_ACCEL_TYPE_SCROLL,
|
return custom_accelerator_filter(LIBINPUT_ACCEL_TYPE_SCROLL,
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_flat(struct motion_filter *filter,
|
accelerator_filter_flat(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator_flat *accel_filter =
|
struct pointer_accelerator_flat *accel_filter =
|
||||||
(struct pointer_accelerator_flat *)filter;
|
(struct pointer_accelerator_flat *)filter;
|
||||||
|
|
@ -65,7 +65,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_constant_flat(struct motion_filter *filter,
|
accelerator_filter_constant_flat(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
/* We map the unaccelerated flat filter to have the same behavior as
|
/* We map the unaccelerated flat filter to have the same behavior as
|
||||||
* the "accelerated" flat filter.
|
* the "accelerated" flat filter.
|
||||||
|
|
@ -85,7 +85,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_scroll_flat(struct motion_filter *filter,
|
accelerator_filter_scroll_flat(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
/* Scroll wheels were not historically accelerated and have different
|
/* Scroll wheels were not historically accelerated and have different
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@
|
||||||
* Default parameters for pointer acceleration profiles.
|
* Default parameters for pointer acceleration profiles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEFAULT_THRESHOLD v_ms2us(0.4) /* in units/us */
|
#define DEFAULT_THRESHOLD v_usec_from_millis(0.4) /* in units/us */
|
||||||
#define MINIMUM_THRESHOLD v_ms2us(0.2) /* in units/us */
|
#define MINIMUM_THRESHOLD v_usec_from_millis(0.2) /* in units/us */
|
||||||
#define DEFAULT_ACCELERATION 2.0 /* unitless factor */
|
#define DEFAULT_ACCELERATION 2.0 /* unitless factor */
|
||||||
#define DEFAULT_INCLINE 1.1 /* unitless factor */
|
#define DEFAULT_INCLINE 1.1 /* unitless factor */
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ double
|
||||||
pointer_accel_profile_linear_low_dpi(struct motion_filter *filter,
|
pointer_accel_profile_linear_low_dpi(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in, /* in device units (units/us) */
|
double speed_in, /* in device units (units/us) */
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator_low_dpi *accel_filter =
|
struct pointer_accelerator_low_dpi *accel_filter =
|
||||||
(struct pointer_accelerator_low_dpi *)filter;
|
(struct pointer_accelerator_low_dpi *)filter;
|
||||||
|
|
@ -107,7 +107,7 @@ static inline double
|
||||||
calculate_acceleration_factor(struct pointer_accelerator_low_dpi *accel,
|
calculate_acceleration_factor(struct pointer_accelerator_low_dpi *accel,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
double velocity; /* units/us in device-native dpi*/
|
double velocity; /* units/us in device-native dpi*/
|
||||||
double accel_factor;
|
double accel_factor;
|
||||||
|
|
@ -129,7 +129,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_low_dpi(struct motion_filter *filter,
|
accelerator_filter_low_dpi(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator_low_dpi *accel =
|
struct pointer_accelerator_low_dpi *accel =
|
||||||
(struct pointer_accelerator_low_dpi *)filter;
|
(struct pointer_accelerator_low_dpi *)filter;
|
||||||
|
|
@ -148,7 +148,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_constant(struct motion_filter *filter,
|
accelerator_filter_constant(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
const struct normalized_coords normalized = {
|
const struct normalized_coords normalized = {
|
||||||
.x = unaccelerated->x,
|
.x = unaccelerated->x,
|
||||||
|
|
@ -161,14 +161,14 @@ static struct normalized_coords
|
||||||
accelerator_filter_scroll(struct motion_filter *filter,
|
accelerator_filter_scroll(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
return accelerator_filter_constant(filter, unaccelerated, data, time);
|
return accelerator_filter_constant(filter, unaccelerated, data, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
|
accelerator_restart(struct motion_filter *filter, void *data, usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator_low_dpi *accel =
|
struct pointer_accelerator_low_dpi *accel =
|
||||||
(struct pointer_accelerator_low_dpi *)filter;
|
(struct pointer_accelerator_low_dpi *)filter;
|
||||||
|
|
@ -198,7 +198,8 @@ accelerator_set_speed(struct motion_filter *filter, double speed_adjustment)
|
||||||
don't read more into them other than "they mostly worked ok" */
|
don't read more into them other than "they mostly worked ok" */
|
||||||
|
|
||||||
/* delay when accel kicks in */
|
/* delay when accel kicks in */
|
||||||
accel_filter->threshold = DEFAULT_THRESHOLD - v_ms2us(0.25) * speed_adjustment;
|
accel_filter->threshold =
|
||||||
|
DEFAULT_THRESHOLD - v_usec_from_millis(0.25) * speed_adjustment;
|
||||||
if (accel_filter->threshold < MINIMUM_THRESHOLD)
|
if (accel_filter->threshold < MINIMUM_THRESHOLD)
|
||||||
accel_filter->threshold = MINIMUM_THRESHOLD;
|
accel_filter->threshold = MINIMUM_THRESHOLD;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@
|
||||||
* Default parameters for pointer acceleration profiles.
|
* Default parameters for pointer acceleration profiles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEFAULT_THRESHOLD v_ms2us(0.4) /* in 1000dpi units/us */
|
#define DEFAULT_THRESHOLD v_usec_from_millis(0.4) /* in 1000dpi units/us */
|
||||||
#define MINIMUM_THRESHOLD v_ms2us(0.2) /* in 1000dpi units/us */
|
#define MINIMUM_THRESHOLD v_usec_from_millis(0.2) /* in 1000dpi units/us */
|
||||||
#define DEFAULT_ACCELERATION 2.0 /* unitless factor */
|
#define DEFAULT_ACCELERATION 2.0 /* unitless factor */
|
||||||
#define DEFAULT_INCLINE 1.1 /* unitless factor */
|
#define DEFAULT_INCLINE 1.1 /* unitless factor */
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ static inline double
|
||||||
calculate_acceleration_factor(struct pointer_accelerator *accel,
|
calculate_acceleration_factor(struct pointer_accelerator *accel,
|
||||||
const struct normalized_coords *unaccelerated,
|
const struct normalized_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
double velocity; /* units/us in normalized 1000dpi units*/
|
double velocity; /* units/us in normalized 1000dpi units*/
|
||||||
double accel_factor;
|
double accel_factor;
|
||||||
|
|
@ -104,7 +104,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_linear(struct motion_filter *filter,
|
accelerator_filter_linear(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
|
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_constant(struct motion_filter *filter,
|
accelerator_filter_constant(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
|
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_scroll(struct motion_filter *filter,
|
accelerator_filter_scroll(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
/* Scroll wheels were not historically accelerated and have different
|
/* Scroll wheels were not historically accelerated and have different
|
||||||
|
|
@ -165,7 +165,7 @@ accelerator_filter_scroll(struct motion_filter *filter,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
|
accelerator_restart(struct motion_filter *filter, void *data, usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
|
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
|
||||||
|
|
||||||
|
|
@ -192,7 +192,8 @@ accelerator_set_speed(struct motion_filter *filter, double speed_adjustment)
|
||||||
don't read more into them other than "they mostly worked ok" */
|
don't read more into them other than "they mostly worked ok" */
|
||||||
|
|
||||||
/* delay when accel kicks in */
|
/* delay when accel kicks in */
|
||||||
accel_filter->threshold = DEFAULT_THRESHOLD - v_ms2us(0.25) * speed_adjustment;
|
accel_filter->threshold =
|
||||||
|
DEFAULT_THRESHOLD - v_usec_from_millis(0.25) * speed_adjustment;
|
||||||
if (accel_filter->threshold < MINIMUM_THRESHOLD)
|
if (accel_filter->threshold < MINIMUM_THRESHOLD)
|
||||||
accel_filter->threshold = MINIMUM_THRESHOLD;
|
accel_filter->threshold = MINIMUM_THRESHOLD;
|
||||||
|
|
||||||
|
|
@ -210,7 +211,7 @@ double
|
||||||
pointer_accel_profile_linear(struct motion_filter *filter,
|
pointer_accel_profile_linear(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in, /* in normalized units */
|
double speed_in, /* in normalized units */
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator *accel_filter = (struct pointer_accelerator *)filter;
|
struct pointer_accelerator *accel_filter = (struct pointer_accelerator *)filter;
|
||||||
const double max_accel = accel_filter->accel; /* unitless factor */
|
const double max_accel = accel_filter->accel; /* unitless factor */
|
||||||
|
|
|
||||||
|
|
@ -34,19 +34,19 @@ struct motion_filter_interface {
|
||||||
struct motion_filter *filter,
|
struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
struct normalized_coords (*filter_constant)(
|
struct normalized_coords (*filter_constant)(
|
||||||
struct motion_filter *filter,
|
struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
struct normalized_coords (*filter_scroll)(
|
struct normalized_coords (*filter_scroll)(
|
||||||
struct motion_filter *filter,
|
struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type);
|
enum filter_scroll_type type);
|
||||||
void (*restart)(struct motion_filter *filter, void *data, uint64_t time);
|
void (*restart)(struct motion_filter *filter, void *data, usec_t time);
|
||||||
void (*destroy)(struct motion_filter *filter);
|
void (*destroy)(struct motion_filter *filter);
|
||||||
bool (*set_speed)(struct motion_filter *filter, double speed_adjustment);
|
bool (*set_speed)(struct motion_filter *filter, double speed_adjustment);
|
||||||
bool (*set_accel_config)(struct motion_filter *filter,
|
bool (*set_accel_config)(struct motion_filter *filter,
|
||||||
|
|
@ -60,19 +60,19 @@ struct motion_filter {
|
||||||
|
|
||||||
struct pointer_tracker {
|
struct pointer_tracker {
|
||||||
struct device_float_coords delta; /* delta to most recent event */
|
struct device_float_coords delta; /* delta to most recent event */
|
||||||
uint64_t time; /* us */
|
usec_t time; /* us */
|
||||||
uint32_t dir;
|
uint32_t dir;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* For smoothing timestamps from devices with unreliable timing */
|
/* For smoothing timestamps from devices with unreliable timing */
|
||||||
struct pointer_delta_smoothener {
|
struct pointer_delta_smoothener {
|
||||||
uint64_t threshold;
|
usec_t threshold;
|
||||||
uint64_t value;
|
usec_t value;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct pointer_delta_smoothener *
|
static inline struct pointer_delta_smoothener *
|
||||||
pointer_delta_smoothener_create(uint64_t event_delta_smooth_threshold,
|
pointer_delta_smoothener_create(usec_t event_delta_smooth_threshold,
|
||||||
uint64_t event_delta_smooth_value)
|
usec_t event_delta_smooth_value)
|
||||||
{
|
{
|
||||||
struct pointer_delta_smoothener *s = zalloc(sizeof(*s));
|
struct pointer_delta_smoothener *s = zalloc(sizeof(*s));
|
||||||
s->threshold = event_delta_smooth_threshold;
|
s->threshold = event_delta_smooth_threshold;
|
||||||
|
|
@ -100,17 +100,17 @@ void
|
||||||
trackers_free(struct pointer_trackers *trackers);
|
trackers_free(struct pointer_trackers *trackers);
|
||||||
|
|
||||||
void
|
void
|
||||||
trackers_reset(struct pointer_trackers *trackers, uint64_t time);
|
trackers_reset(struct pointer_trackers *trackers, usec_t time);
|
||||||
void
|
void
|
||||||
trackers_feed(struct pointer_trackers *trackers,
|
trackers_feed(struct pointer_trackers *trackers,
|
||||||
const struct device_float_coords *delta,
|
const struct device_float_coords *delta,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
|
|
||||||
struct pointer_tracker *
|
struct pointer_tracker *
|
||||||
trackers_by_offset(struct pointer_trackers *trackers, unsigned int offset);
|
trackers_by_offset(struct pointer_trackers *trackers, unsigned int offset);
|
||||||
|
|
||||||
double
|
double
|
||||||
trackers_velocity(struct pointer_trackers *trackers, uint64_t time);
|
trackers_velocity(struct pointer_trackers *trackers, usec_t time);
|
||||||
|
|
||||||
double
|
double
|
||||||
calculate_acceleration_simpsons(struct motion_filter *filter,
|
calculate_acceleration_simpsons(struct motion_filter *filter,
|
||||||
|
|
@ -118,7 +118,7 @@ calculate_acceleration_simpsons(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double velocity,
|
double velocity,
|
||||||
double last_velocity,
|
double last_velocity,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
|
|
||||||
/* Convert speed/velocity from units/us to units/ms */
|
/* Convert speed/velocity from units/us to units/ms */
|
||||||
static inline double
|
static inline double
|
||||||
|
|
@ -135,7 +135,7 @@ v_us2s(double units_per_us)
|
||||||
|
|
||||||
/* Convert speed/velocity from units/ms to units/us */
|
/* Convert speed/velocity from units/ms to units/us */
|
||||||
static inline double
|
static inline double
|
||||||
v_ms2us(double units_per_ms)
|
v_usec_from_millis(double units_per_ms)
|
||||||
{
|
{
|
||||||
return units_per_ms / 1000.0;
|
return units_per_ms / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ static struct normalized_coords
|
||||||
tablet_accelerator_filter_flat(struct motion_filter *filter,
|
tablet_accelerator_filter_flat(struct motion_filter *filter,
|
||||||
const struct device_float_coords *units,
|
const struct device_float_coords *units,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct tablet_accelerator_flat *accel_filter =
|
struct tablet_accelerator_flat *accel_filter =
|
||||||
(struct tablet_accelerator_flat *)filter;
|
(struct tablet_accelerator_flat *)filter;
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_touchpad_flat(struct motion_filter *filter,
|
accelerator_filter_touchpad_flat(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct touchpad_accelerator_flat *accel =
|
struct touchpad_accelerator_flat *accel =
|
||||||
(struct touchpad_accelerator_flat *)filter;
|
(struct touchpad_accelerator_flat *)filter;
|
||||||
|
|
@ -69,7 +69,7 @@ accelerator_filter_constant_touchpad_flat(
|
||||||
struct motion_filter *filter,
|
struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
/* We map the unaccelerated flat filter to have the same behavior as
|
/* We map the unaccelerated flat filter to have the same behavior as
|
||||||
* the "accelerated" flat filter.
|
* the "accelerated" flat filter.
|
||||||
|
|
@ -89,7 +89,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_scroll_touchpad_flat(struct motion_filter *filter,
|
accelerator_filter_scroll_touchpad_flat(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
/* Scroll wheels were not historically accelerated and have different
|
/* Scroll wheels were not historically accelerated and have different
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,13 @@
|
||||||
* Default parameters for pointer acceleration profiles.
|
* Default parameters for pointer acceleration profiles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEFAULT_THRESHOLD v_ms2us(0.4) /* in units/us */
|
#define DEFAULT_THRESHOLD v_usec_from_millis(0.4) /* in units/us */
|
||||||
#define MINIMUM_THRESHOLD v_ms2us(0.2) /* in units/us */
|
#define MINIMUM_THRESHOLD v_usec_from_millis(0.2) /* in units/us */
|
||||||
#define DEFAULT_ACCELERATION 2.0 /* unitless factor */
|
#define DEFAULT_ACCELERATION 2.0 /* unitless factor */
|
||||||
#define DEFAULT_INCLINE 1.1 /* unitless factor */
|
#define DEFAULT_INCLINE 1.1 /* unitless factor */
|
||||||
|
|
||||||
/* for the Lenovo x230 custom accel. do not touch */
|
/* for the Lenovo x230 custom accel. do not touch */
|
||||||
#define X230_THRESHOLD v_ms2us(0.4) /* in units/us */
|
#define X230_THRESHOLD v_usec_from_millis(0.4) /* in units/us */
|
||||||
#define X230_ACCELERATION 2.0 /* unitless factor */
|
#define X230_ACCELERATION 2.0 /* unitless factor */
|
||||||
#define X230_INCLINE 1.1 /* unitless factor */
|
#define X230_INCLINE 1.1 /* unitless factor */
|
||||||
#define X230_MAGIC_SLOWDOWN 0.4 /* unitless */
|
#define X230_MAGIC_SLOWDOWN 0.4 /* unitless */
|
||||||
|
|
@ -88,7 +88,7 @@ static double
|
||||||
acceleration_profile(struct pointer_accelerator_x230 *accel,
|
acceleration_profile(struct pointer_accelerator_x230 *accel,
|
||||||
void *data,
|
void *data,
|
||||||
double velocity,
|
double velocity,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
return accel->profile(&accel->base, data, velocity, time);
|
return accel->profile(&accel->base, data, velocity, time);
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +110,7 @@ calculate_acceleration(struct pointer_accelerator_x230 *accel,
|
||||||
void *data,
|
void *data,
|
||||||
double velocity,
|
double velocity,
|
||||||
double last_velocity,
|
double last_velocity,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
double factor;
|
double factor;
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_x230(struct motion_filter *filter,
|
accelerator_filter_x230(struct motion_filter *filter,
|
||||||
const struct device_float_coords *raw,
|
const struct device_float_coords *raw,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator_x230 *accel =
|
struct pointer_accelerator_x230 *accel =
|
||||||
(struct pointer_accelerator_x230 *)filter;
|
(struct pointer_accelerator_x230 *)filter;
|
||||||
|
|
@ -171,7 +171,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_constant_x230(struct motion_filter *filter,
|
accelerator_filter_constant_x230(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator_x230 *accel =
|
struct pointer_accelerator_x230 *accel =
|
||||||
(struct pointer_accelerator_x230 *)filter;
|
(struct pointer_accelerator_x230 *)filter;
|
||||||
|
|
@ -189,7 +189,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_scroll_x230(struct motion_filter *filter,
|
accelerator_filter_scroll_x230(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
/* Scroll wheels were not historically accelerated and have different
|
/* Scroll wheels were not historically accelerated and have different
|
||||||
|
|
@ -207,7 +207,7 @@ accelerator_filter_scroll_x230(struct motion_filter *filter,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
accelerator_restart_x230(struct motion_filter *filter, void *data, uint64_t time)
|
accelerator_restart_x230(struct motion_filter *filter, void *data, usec_t time)
|
||||||
{
|
{
|
||||||
struct pointer_accelerator_x230 *accel =
|
struct pointer_accelerator_x230 *accel =
|
||||||
(struct pointer_accelerator_x230 *)filter;
|
(struct pointer_accelerator_x230 *)filter;
|
||||||
|
|
@ -216,7 +216,7 @@ accelerator_restart_x230(struct motion_filter *filter, void *data, uint64_t time
|
||||||
|
|
||||||
for (offset = 1; offset < accel->trackers.ntrackers; offset++) {
|
for (offset = 1; offset < accel->trackers.ntrackers; offset++) {
|
||||||
tracker = trackers_by_offset(&accel->trackers, offset);
|
tracker = trackers_by_offset(&accel->trackers, offset);
|
||||||
tracker->time = 0;
|
tracker->time = usec_from_uint64_t(0);
|
||||||
tracker->dir = 0;
|
tracker->dir = 0;
|
||||||
tracker->delta.x = 0;
|
tracker->delta.x = 0;
|
||||||
tracker->delta.y = 0;
|
tracker->delta.y = 0;
|
||||||
|
|
@ -249,7 +249,8 @@ accelerator_set_speed_x230(struct motion_filter *filter, double speed_adjustment
|
||||||
don't read more into them other than "they mostly worked ok" */
|
don't read more into them other than "they mostly worked ok" */
|
||||||
|
|
||||||
/* delay when accel kicks in */
|
/* delay when accel kicks in */
|
||||||
accel_filter->threshold = DEFAULT_THRESHOLD - v_ms2us(0.25) * speed_adjustment;
|
accel_filter->threshold =
|
||||||
|
DEFAULT_THRESHOLD - v_usec_from_millis(0.25) * speed_adjustment;
|
||||||
if (accel_filter->threshold < MINIMUM_THRESHOLD)
|
if (accel_filter->threshold < MINIMUM_THRESHOLD)
|
||||||
accel_filter->threshold = MINIMUM_THRESHOLD;
|
accel_filter->threshold = MINIMUM_THRESHOLD;
|
||||||
|
|
||||||
|
|
@ -267,7 +268,7 @@ double
|
||||||
touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
|
touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in, /* 1000dpi-units/µs */
|
double speed_in, /* 1000dpi-units/µs */
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
/* Those touchpads presents an actual lower resolution that what is
|
/* Those touchpads presents an actual lower resolution that what is
|
||||||
* advertised. We see some jumps from the cursor due to the big steps
|
* advertised. We see some jumps from the cursor due to the big steps
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ static inline double
|
||||||
calculate_acceleration_factor(struct touchpad_accelerator *accel,
|
calculate_acceleration_factor(struct touchpad_accelerator *accel,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
double velocity; /* units/us in device-native dpi*/
|
double velocity; /* units/us in device-native dpi*/
|
||||||
double accel_factor;
|
double accel_factor;
|
||||||
|
|
@ -94,7 +94,7 @@ static struct normalized_coords
|
||||||
accelerator_filter_touchpad(struct motion_filter *filter,
|
accelerator_filter_touchpad(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
|
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ static struct normalized_coords
|
||||||
touchpad_constant_filter(struct motion_filter *filter,
|
touchpad_constant_filter(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
|
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
|
||||||
struct normalized_coords normalized;
|
struct normalized_coords normalized;
|
||||||
|
|
@ -166,7 +166,7 @@ static struct normalized_coords
|
||||||
touchpad_scroll_filter(struct motion_filter *filter,
|
touchpad_scroll_filter(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
/* Scroll wheels were not historically accelerated and have different
|
/* Scroll wheels were not historically accelerated and have different
|
||||||
|
|
@ -184,7 +184,7 @@ touchpad_scroll_filter(struct motion_filter *filter,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
touchpad_accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
|
touchpad_accelerator_restart(struct motion_filter *filter, void *data, usec_t time)
|
||||||
{
|
{
|
||||||
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
|
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
|
||||||
|
|
||||||
|
|
@ -204,7 +204,7 @@ double
|
||||||
touchpad_accel_profile_linear(struct motion_filter *filter,
|
touchpad_accel_profile_linear(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in, /* in device units/µs */
|
double speed_in, /* in device units/µs */
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct touchpad_accelerator *accel_filter =
|
struct touchpad_accelerator *accel_filter =
|
||||||
(struct touchpad_accelerator *)filter;
|
(struct touchpad_accelerator *)filter;
|
||||||
|
|
@ -301,8 +301,8 @@ static const struct motion_filter_interface accelerator_interface_touchpad = {
|
||||||
|
|
||||||
struct motion_filter *
|
struct motion_filter *
|
||||||
create_pointer_accelerator_filter_touchpad(int dpi,
|
create_pointer_accelerator_filter_touchpad(int dpi,
|
||||||
uint64_t event_delta_smooth_threshold,
|
usec_t event_delta_smooth_threshold,
|
||||||
uint64_t event_delta_smooth_value,
|
usec_t event_delta_smooth_value,
|
||||||
bool use_velocity_averaging)
|
bool use_velocity_averaging)
|
||||||
{
|
{
|
||||||
struct touchpad_accelerator *filter;
|
struct touchpad_accelerator *filter;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ static struct normalized_coords
|
||||||
trackpoint_flat_filter(struct motion_filter *filter,
|
trackpoint_flat_filter(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct trackpoint_flat_accelerator *accel_filter =
|
struct trackpoint_flat_accelerator *accel_filter =
|
||||||
(struct trackpoint_flat_accelerator *)filter;
|
(struct trackpoint_flat_accelerator *)filter;
|
||||||
|
|
@ -63,7 +63,7 @@ static struct normalized_coords
|
||||||
trackpoint_flat_filter_constant(struct motion_filter *filter,
|
trackpoint_flat_filter_constant(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
/* We map the unaccelerated flat filter to have the same behavior as
|
/* We map the unaccelerated flat filter to have the same behavior as
|
||||||
* the "accelerated" flat filter.
|
* the "accelerated" flat filter.
|
||||||
|
|
@ -83,7 +83,7 @@ static struct normalized_coords
|
||||||
trackpoint_flat_filter_scroll(struct motion_filter *filter,
|
trackpoint_flat_filter_scroll(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
/* Scroll wheels were not historically accelerated and have different
|
/* Scroll wheels were not historically accelerated and have different
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ double
|
||||||
trackpoint_accel_profile(struct motion_filter *filter,
|
trackpoint_accel_profile(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double velocity,
|
double velocity,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct trackpoint_accelerator *accel_filter =
|
struct trackpoint_accelerator *accel_filter =
|
||||||
(struct trackpoint_accelerator *)filter;
|
(struct trackpoint_accelerator *)filter;
|
||||||
|
|
@ -74,7 +74,7 @@ static struct normalized_coords
|
||||||
trackpoint_accelerator_filter(struct motion_filter *filter,
|
trackpoint_accelerator_filter(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct trackpoint_accelerator *accel_filter =
|
struct trackpoint_accelerator *accel_filter =
|
||||||
(struct trackpoint_accelerator *)filter;
|
(struct trackpoint_accelerator *)filter;
|
||||||
|
|
@ -100,7 +100,7 @@ static struct normalized_coords
|
||||||
trackpoint_accelerator_filter_constant(struct motion_filter *filter,
|
trackpoint_accelerator_filter_constant(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
struct trackpoint_accelerator *accel_filter =
|
struct trackpoint_accelerator *accel_filter =
|
||||||
(struct trackpoint_accelerator *)filter;
|
(struct trackpoint_accelerator *)filter;
|
||||||
|
|
@ -116,7 +116,7 @@ static struct normalized_coords
|
||||||
trackpoint_accelerator_filter_scroll(struct motion_filter *filter,
|
trackpoint_accelerator_filter_scroll(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
/* Scroll wheels were not historically accelerated and have different
|
/* Scroll wheels were not historically accelerated and have different
|
||||||
|
|
@ -174,7 +174,7 @@ trackpoint_accelerator_set_speed(struct motion_filter *filter, double speed_adju
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
trackpoint_accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
|
trackpoint_accelerator_restart(struct motion_filter *filter, void *data, usec_t time)
|
||||||
{
|
{
|
||||||
struct trackpoint_accelerator *accel = (struct trackpoint_accelerator *)filter;
|
struct trackpoint_accelerator *accel = (struct trackpoint_accelerator *)filter;
|
||||||
|
|
||||||
|
|
@ -231,7 +231,8 @@ create_pointer_accelerator_filter_trackpoint(double multiplier,
|
||||||
|
|
||||||
filter->base.interface = &accelerator_interface_trackpoint;
|
filter->base.interface = &accelerator_interface_trackpoint;
|
||||||
filter->trackers.smoothener =
|
filter->trackers.smoothener =
|
||||||
pointer_delta_smoothener_create(ms2us(10), ms2us(10));
|
pointer_delta_smoothener_create(usec_from_millis(10),
|
||||||
|
usec_from_millis(10));
|
||||||
|
|
||||||
return &filter->base;
|
return &filter->base;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
38
src/filter.c
38
src/filter.c
|
|
@ -35,13 +35,13 @@
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "libinput-util.h"
|
#include "libinput-util.h"
|
||||||
|
|
||||||
#define MOTION_TIMEOUT ms2us(1000)
|
#define MOTION_TIMEOUT usec_from_millis(1000)
|
||||||
|
|
||||||
struct normalized_coords
|
struct normalized_coords
|
||||||
filter_dispatch(struct motion_filter *filter,
|
filter_dispatch(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
return filter->interface->filter(filter, unaccelerated, data, time);
|
return filter->interface->filter(filter, unaccelerated, data, time);
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ struct normalized_coords
|
||||||
filter_dispatch_constant(struct motion_filter *filter,
|
filter_dispatch_constant(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
return filter->interface->filter_constant(filter, unaccelerated, data, time);
|
return filter->interface->filter_constant(filter, unaccelerated, data, time);
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +59,7 @@ struct normalized_coords
|
||||||
filter_dispatch_scroll(struct motion_filter *filter,
|
filter_dispatch_scroll(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type)
|
enum filter_scroll_type type)
|
||||||
{
|
{
|
||||||
return filter->interface->filter_scroll(filter,
|
return filter->interface->filter_scroll(filter,
|
||||||
|
|
@ -70,7 +70,7 @@ filter_dispatch_scroll(struct motion_filter *filter,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
filter_restart(struct motion_filter *filter, void *data, uint64_t time)
|
filter_restart(struct motion_filter *filter, void *data, usec_t time)
|
||||||
{
|
{
|
||||||
if (filter->interface->restart)
|
if (filter->interface->restart)
|
||||||
filter->interface->restart(filter, data, time);
|
filter->interface->restart(filter, data, time);
|
||||||
|
|
@ -132,14 +132,14 @@ trackers_free(struct pointer_trackers *trackers)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
trackers_reset(struct pointer_trackers *trackers, uint64_t time)
|
trackers_reset(struct pointer_trackers *trackers, usec_t time)
|
||||||
{
|
{
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
struct pointer_tracker *tracker;
|
struct pointer_tracker *tracker;
|
||||||
|
|
||||||
for (offset = 1; offset < trackers->ntrackers; offset++) {
|
for (offset = 1; offset < trackers->ntrackers; offset++) {
|
||||||
tracker = trackers_by_offset(trackers, offset);
|
tracker = trackers_by_offset(trackers, offset);
|
||||||
tracker->time = 0;
|
tracker->time = usec_from_uint64_t(0);
|
||||||
tracker->dir = 0;
|
tracker->dir = 0;
|
||||||
tracker->delta.x = 0;
|
tracker->delta.x = 0;
|
||||||
tracker->delta.y = 0;
|
tracker->delta.y = 0;
|
||||||
|
|
@ -153,7 +153,7 @@ trackers_reset(struct pointer_trackers *trackers, uint64_t time)
|
||||||
void
|
void
|
||||||
trackers_feed(struct pointer_trackers *trackers,
|
trackers_feed(struct pointer_trackers *trackers,
|
||||||
const struct device_float_coords *delta,
|
const struct device_float_coords *delta,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
unsigned int i, current;
|
unsigned int i, current;
|
||||||
struct pointer_tracker *ts = trackers->trackers;
|
struct pointer_tracker *ts = trackers->trackers;
|
||||||
|
|
@ -184,16 +184,17 @@ trackers_by_offset(struct pointer_trackers *trackers, unsigned int offset)
|
||||||
|
|
||||||
static double
|
static double
|
||||||
calculate_trackers_velocity(const struct pointer_tracker *tracker,
|
calculate_trackers_velocity(const struct pointer_tracker *tracker,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct pointer_delta_smoothener *smoothener)
|
struct pointer_delta_smoothener *smoothener)
|
||||||
{
|
{
|
||||||
uint64_t tdelta = time - tracker->time + 1;
|
usec_t tdelta = usec_delta(time, tracker->time);
|
||||||
|
tdelta = usec_add(tdelta, usec_from_uint64_t(1));
|
||||||
|
|
||||||
if (smoothener && tdelta < smoothener->threshold)
|
if (smoothener && usec_cmp(tdelta, smoothener->threshold) < 0)
|
||||||
tdelta = smoothener->value;
|
tdelta = smoothener->value;
|
||||||
|
|
||||||
return hypot(tracker->delta.x, tracker->delta.y) /
|
return hypot(tracker->delta.x, tracker->delta.y) /
|
||||||
(double)tdelta; /* units/us */
|
(double)usec_as_uint64_t(tdelta); /* units/us */
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
static double
|
||||||
|
|
@ -212,7 +213,7 @@ trackers_velocity_after_timeout(const struct pointer_tracker *tracker,
|
||||||
* movement in normal use-cases (pause, move, pause, move)
|
* movement in normal use-cases (pause, move, pause, move)
|
||||||
*/
|
*/
|
||||||
return calculate_trackers_velocity(tracker,
|
return calculate_trackers_velocity(tracker,
|
||||||
tracker->time + MOTION_TIMEOUT,
|
usec_add(tracker->time, MOTION_TIMEOUT),
|
||||||
smoothener);
|
smoothener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,9 +225,9 @@ trackers_velocity_after_timeout(const struct pointer_tracker *tracker,
|
||||||
* change between events.
|
* change between events.
|
||||||
*/
|
*/
|
||||||
double
|
double
|
||||||
trackers_velocity(struct pointer_trackers *trackers, uint64_t time)
|
trackers_velocity(struct pointer_trackers *trackers, usec_t time)
|
||||||
{
|
{
|
||||||
const double MAX_VELOCITY_DIFF = v_ms2us(1); /* units/us */
|
const double MAX_VELOCITY_DIFF = v_usec_from_millis(1); /* units/us */
|
||||||
double result = 0.0;
|
double result = 0.0;
|
||||||
double initial_velocity = 0.0;
|
double initial_velocity = 0.0;
|
||||||
|
|
||||||
|
|
@ -239,11 +240,12 @@ trackers_velocity(struct pointer_trackers *trackers, uint64_t time)
|
||||||
trackers_by_offset(trackers, offset);
|
trackers_by_offset(trackers, offset);
|
||||||
|
|
||||||
/* Bug: time running backwards */
|
/* Bug: time running backwards */
|
||||||
if (tracker->time > time)
|
if (usec_cmp(tracker->time, time) > 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Stop if too far away in time */
|
/* Stop if too far away in time */
|
||||||
if (time - tracker->time > MOTION_TIMEOUT) {
|
usec_t tdelta = usec_delta(time, tracker->time);
|
||||||
|
if (usec_cmp(tdelta, MOTION_TIMEOUT) > 0) {
|
||||||
if (offset == 1)
|
if (offset == 1)
|
||||||
result = trackers_velocity_after_timeout(
|
result = trackers_velocity_after_timeout(
|
||||||
tracker,
|
tracker,
|
||||||
|
|
@ -302,7 +304,7 @@ calculate_acceleration_simpsons(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double velocity,
|
double velocity,
|
||||||
double last_velocity,
|
double last_velocity,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
double factor;
|
double factor;
|
||||||
|
|
||||||
|
|
|
||||||
30
src/filter.h
30
src/filter.h
|
|
@ -66,7 +66,7 @@ struct normalized_coords
|
||||||
filter_dispatch(struct motion_filter *filter,
|
filter_dispatch(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply constant motion filters, but no acceleration.
|
* Apply constant motion filters, but no acceleration.
|
||||||
|
|
@ -88,7 +88,7 @@ struct normalized_coords
|
||||||
filter_dispatch_constant(struct motion_filter *filter,
|
filter_dispatch_constant(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a scroll filter.
|
* Apply a scroll filter.
|
||||||
|
|
@ -112,11 +112,11 @@ struct normalized_coords
|
||||||
filter_dispatch_scroll(struct motion_filter *filter,
|
filter_dispatch_scroll(struct motion_filter *filter,
|
||||||
const struct device_float_coords *unaccelerated,
|
const struct device_float_coords *unaccelerated,
|
||||||
void *data,
|
void *data,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum filter_scroll_type type);
|
enum filter_scroll_type type);
|
||||||
|
|
||||||
void
|
void
|
||||||
filter_restart(struct motion_filter *filter, void *data, uint64_t time);
|
filter_restart(struct motion_filter *filter, void *data, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
filter_destroy(struct motion_filter *filter);
|
filter_destroy(struct motion_filter *filter);
|
||||||
|
|
@ -132,7 +132,7 @@ filter_get_type(struct motion_filter *filter);
|
||||||
typedef double (*accel_profile_func_t)(struct motion_filter *filter,
|
typedef double (*accel_profile_func_t)(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double velocity,
|
double velocity,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
filter_set_accel_config(struct motion_filter *filter,
|
filter_set_accel_config(struct motion_filter *filter,
|
||||||
|
|
@ -150,8 +150,8 @@ create_pointer_accelerator_filter_linear_low_dpi(int dpi, bool use_velocity_aver
|
||||||
|
|
||||||
struct motion_filter *
|
struct motion_filter *
|
||||||
create_pointer_accelerator_filter_touchpad(int dpi,
|
create_pointer_accelerator_filter_touchpad(int dpi,
|
||||||
uint64_t event_delta_smooth_threshold,
|
usec_t event_delta_smooth_threshold,
|
||||||
uint64_t event_delta_smooth_value,
|
usec_t event_delta_smooth_value,
|
||||||
bool use_velocity_averaging);
|
bool use_velocity_averaging);
|
||||||
|
|
||||||
struct motion_filter *
|
struct motion_filter *
|
||||||
|
|
@ -181,40 +181,40 @@ double
|
||||||
pointer_accel_profile_linear_low_dpi(struct motion_filter *filter,
|
pointer_accel_profile_linear_low_dpi(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
double
|
double
|
||||||
pointer_accel_profile_linear(struct motion_filter *filter,
|
pointer_accel_profile_linear(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
double
|
double
|
||||||
touchpad_accel_profile_linear(struct motion_filter *filter,
|
touchpad_accel_profile_linear(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
double
|
double
|
||||||
touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
|
touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
double
|
double
|
||||||
trackpoint_accel_profile(struct motion_filter *filter,
|
trackpoint_accel_profile(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double velocity,
|
double velocity,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
double
|
double
|
||||||
custom_accel_profile_fallback(struct motion_filter *filter,
|
custom_accel_profile_fallback(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
double
|
double
|
||||||
custom_accel_profile_motion(struct motion_filter *filter,
|
custom_accel_profile_motion(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
double
|
double
|
||||||
custom_accel_profile_scroll(struct motion_filter *filter,
|
custom_accel_profile_scroll(struct motion_filter *filter,
|
||||||
void *data,
|
void *data,
|
||||||
double speed_in,
|
double speed_in,
|
||||||
uint64_t time);
|
usec_t time);
|
||||||
#endif /* FILTER_H */
|
#endif /* FILTER_H */
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ struct plugin_device {
|
||||||
struct plugin_data *parent;
|
struct plugin_data *parent;
|
||||||
|
|
||||||
evdev_usage_t button_usage;
|
evdev_usage_t button_usage;
|
||||||
uint64_t button_time;
|
usec_t button_time;
|
||||||
enum debounce_state state;
|
enum debounce_state state;
|
||||||
bool spurious_enabled;
|
bool spurious_enabled;
|
||||||
|
|
||||||
|
|
@ -222,20 +222,21 @@ debounce_set_state(struct plugin_device *device, enum debounce_state new_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
debounce_set_timer(struct plugin_device *device, uint64_t time)
|
debounce_set_timer(struct plugin_device *device, usec_t time)
|
||||||
{
|
{
|
||||||
const int DEBOUNCE_TIMEOUT_BOUNCE = ms2us(25);
|
const usec_t DEBOUNCE_TIMEOUT_BOUNCE = usec_from_millis(25);
|
||||||
|
|
||||||
libinput_plugin_timer_set(device->timer, time + DEBOUNCE_TIMEOUT_BOUNCE);
|
libinput_plugin_timer_set(device->timer,
|
||||||
|
usec_add(time, DEBOUNCE_TIMEOUT_BOUNCE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
debounce_set_timer_short(struct plugin_device *device, uint64_t time)
|
debounce_set_timer_short(struct plugin_device *device, usec_t time)
|
||||||
{
|
{
|
||||||
const int DEBOUNCE_TIMEOUT_SPURIOUS = ms2us(12);
|
const usec_t DEBOUNCE_TIMEOUT_SPURIOUS = usec_from_millis(12);
|
||||||
|
|
||||||
libinput_plugin_timer_set(device->timer_short,
|
libinput_plugin_timer_set(device->timer_short,
|
||||||
time + DEBOUNCE_TIMEOUT_SPURIOUS);
|
usec_add(time, DEBOUNCE_TIMEOUT_SPURIOUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
@ -295,7 +296,7 @@ static void
|
||||||
debounce_is_up_handle_event(struct plugin_device *device,
|
debounce_is_up_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -318,7 +319,7 @@ static void
|
||||||
debounce_is_down_handle_event(struct plugin_device *device,
|
debounce_is_down_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -354,7 +355,7 @@ static void
|
||||||
debounce_is_down_waiting_handle_event(struct plugin_device *device,
|
debounce_is_down_waiting_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -383,7 +384,7 @@ static void
|
||||||
debounce_is_up_delaying_handle_event(struct plugin_device *device,
|
debounce_is_up_delaying_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -407,7 +408,7 @@ static void
|
||||||
debounce_is_up_delaying_spurious_handle_event(struct plugin_device *device,
|
debounce_is_up_delaying_spurious_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -435,7 +436,7 @@ static void
|
||||||
debounce_is_up_detecting_spurious_handle_event(struct plugin_device *device,
|
debounce_is_up_detecting_spurious_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -467,7 +468,7 @@ static void
|
||||||
debounce_is_down_detecting_spurious_handle_event(struct plugin_device *device,
|
debounce_is_down_detecting_spurious_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -496,7 +497,7 @@ static void
|
||||||
debounce_is_up_waiting_handle_event(struct plugin_device *device,
|
debounce_is_up_waiting_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -522,7 +523,7 @@ static void
|
||||||
debounce_is_down_delaying_handle_event(struct plugin_device *device,
|
debounce_is_down_delaying_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -547,7 +548,7 @@ static void
|
||||||
debounce_disabled_handle_event(struct plugin_device *device,
|
debounce_disabled_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case DEBOUNCE_EVENT_PRESS:
|
case DEBOUNCE_EVENT_PRESS:
|
||||||
|
|
@ -571,7 +572,7 @@ static void
|
||||||
debounce_handle_event(struct plugin_device *device,
|
debounce_handle_event(struct plugin_device *device,
|
||||||
enum debounce_event event,
|
enum debounce_event event,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum debounce_state current = device->state;
|
enum debounce_state current = device->state;
|
||||||
|
|
||||||
|
|
@ -632,7 +633,7 @@ debounce_handle_event(struct plugin_device *device,
|
||||||
static void
|
static void
|
||||||
debounce_plugin_handle_frame(struct plugin_device *device,
|
debounce_plugin_handle_frame(struct plugin_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
size_t nchanged = 0;
|
size_t nchanged = 0;
|
||||||
bool flushed = false;
|
bool flushed = false;
|
||||||
|
|
@ -734,7 +735,7 @@ debounce_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
debounce_timeout(struct libinput_plugin *plugin, uint64_t now, void *data)
|
debounce_timeout(struct libinput_plugin *plugin, usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct plugin_device *device = data;
|
struct plugin_device *device = data;
|
||||||
|
|
||||||
|
|
@ -742,7 +743,7 @@ debounce_timeout(struct libinput_plugin *plugin, uint64_t now, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
debounce_timeout_short(struct libinput_plugin *plugin, uint64_t now, void *data)
|
debounce_timeout_short(struct libinput_plugin *plugin, usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct plugin_device *device = data;
|
struct plugin_device *device = data;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -408,7 +408,8 @@ libinput_lua_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
|
||||||
lua_rawgeti(plugin->L, LUA_REGISTRYINDEX, evdev->frame_refid);
|
lua_rawgeti(plugin->L, LUA_REGISTRYINDEX, evdev->frame_refid);
|
||||||
lua_rawgeti(plugin->L, LUA_REGISTRYINDEX, evdev->refid);
|
lua_rawgeti(plugin->L, LUA_REGISTRYINDEX, evdev->refid);
|
||||||
lua_push_evdev_frame(plugin->L, frame);
|
lua_push_evdev_frame(plugin->L, frame);
|
||||||
lua_pushinteger(plugin->L, evdev_frame_get_time(frame));
|
lua_pushinteger(plugin->L,
|
||||||
|
usec_as_uint64_t(evdev_frame_get_time(frame)));
|
||||||
|
|
||||||
if (!libinput_lua_pcall(plugin, 3, 1))
|
if (!libinput_lua_pcall(plugin, 3, 1))
|
||||||
return;
|
return;
|
||||||
|
|
@ -464,9 +465,9 @@ libinputplugin_now(lua_State *L)
|
||||||
luaL_argcheck(L, p != NULL, 1, PLUGIN_METATABLE " expected");
|
luaL_argcheck(L, p != NULL, 1, PLUGIN_METATABLE " expected");
|
||||||
|
|
||||||
struct libinput *libinput = lua_get_libinput(L);
|
struct libinput *libinput = lua_get_libinput(L);
|
||||||
uint64_t now = libinput_now(libinput);
|
usec_t now = libinput_now(libinput);
|
||||||
|
|
||||||
lua_pushinteger(L, now);
|
lua_pushinteger(L, usec_as_uint64_t(now));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -555,19 +556,19 @@ libinputplugin_gc(lua_State *L)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
plugin_timer_func(struct libinput_plugin *libinput_plugin, uint64_t now, void *data)
|
plugin_timer_func(struct libinput_plugin *libinput_plugin, usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct libinput_lua_plugin *plugin = data;
|
struct libinput_lua_plugin *plugin = data;
|
||||||
struct lua_State *L = plugin->L;
|
struct lua_State *L = plugin->L;
|
||||||
|
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, plugin->timer_expired_refid);
|
lua_rawgeti(L, LUA_REGISTRYINDEX, plugin->timer_expired_refid);
|
||||||
lua_pushinteger(L, now);
|
lua_pushinteger(L, usec_as_uint64_t(now));
|
||||||
|
|
||||||
libinput_lua_pcall(plugin, 1, 0);
|
libinput_lua_pcall(plugin, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libinputplugin_timer_set(lua_State *L, uint64_t offset)
|
libinputplugin_timer_set(lua_State *L, usec_t offset)
|
||||||
{
|
{
|
||||||
LibinputPlugin *p = luaL_checkudata(L, 1, PLUGIN_METATABLE);
|
LibinputPlugin *p = luaL_checkudata(L, 1, PLUGIN_METATABLE);
|
||||||
luaL_argcheck(L, p != NULL, 1, PLUGIN_METATABLE " expected");
|
luaL_argcheck(L, p != NULL, 1, PLUGIN_METATABLE " expected");
|
||||||
|
|
@ -583,7 +584,8 @@ libinputplugin_timer_set(lua_State *L, uint64_t offset)
|
||||||
plugin);
|
plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
libinput_plugin_timer_set(plugin->timer, offset + timeout);
|
libinput_plugin_timer_set(plugin->timer,
|
||||||
|
usec_add(offset, usec_from_uint64_t(timeout)));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -591,7 +593,7 @@ libinputplugin_timer_set(lua_State *L, uint64_t offset)
|
||||||
static int
|
static int
|
||||||
libinputplugin_timer_set_absolute(lua_State *L)
|
libinputplugin_timer_set_absolute(lua_State *L)
|
||||||
{
|
{
|
||||||
return libinputplugin_timer_set(L, 0);
|
return libinputplugin_timer_set(L, usec_from_uint64_t(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -944,7 +946,7 @@ evdevdevice_frame(lua_State *L, struct libinput_lua_plugin *plugin, EvdevDevice
|
||||||
lua_pop_evdev_frame(plugin, device->evdev, frame);
|
lua_pop_evdev_frame(plugin, device->evdev, frame);
|
||||||
|
|
||||||
struct libinput *libinput = lua_get_libinput(L);
|
struct libinput *libinput = lua_get_libinput(L);
|
||||||
uint64_t now = libinput_now(libinput);
|
usec_t now = libinput_now(libinput);
|
||||||
evdev_frame_set_time(frame, now);
|
evdev_frame_set_time(frame, now);
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
#define ACC_V120_TRIGGER_THRESHOLD 30 /* 1/4 of a wheel detent */
|
#define ACC_V120_TRIGGER_THRESHOLD 30 /* 1/4 of a wheel detent */
|
||||||
#define ACC_V120_THRESHOLD 47 /* Good for both high-ish multipliers (8/120) and the rest of the mice (30/120, 40/120, etc) */
|
#define ACC_V120_THRESHOLD 47 /* Good for both high-ish multipliers (8/120) and the rest of the mice (30/120, 40/120, etc) */
|
||||||
#define WHEEL_SCROLL_TIMEOUT ms2us(500)
|
const usec_t WHEEL_SCROLL_TIMEOUT = { 500 * 1000 };
|
||||||
|
|
||||||
enum wheel_state {
|
enum wheel_state {
|
||||||
WHEEL_STATE_NONE,
|
WHEEL_STATE_NONE,
|
||||||
|
|
@ -126,12 +126,13 @@ log_wheel_bug(struct plugin_device *pd, enum wheel_event event)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
wheel_set_scroll_timer(struct plugin_device *pd, uint64_t time)
|
wheel_set_scroll_timer(struct plugin_device *pd, usec_t time)
|
||||||
{
|
{
|
||||||
if (!pd->scroll_timer)
|
if (!pd->scroll_timer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
libinput_plugin_timer_set(pd->scroll_timer, time + WHEEL_SCROLL_TIMEOUT);
|
libinput_plugin_timer_set(pd->scroll_timer,
|
||||||
|
usec_add(time, WHEEL_SCROLL_TIMEOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
@ -165,7 +166,7 @@ wheel_maybe_disable(struct plugin_device *device)
|
||||||
static void
|
static void
|
||||||
wheel_handle_event_on_state_none(struct plugin_device *pd,
|
wheel_handle_event_on_state_none(struct plugin_device *pd,
|
||||||
enum wheel_event event,
|
enum wheel_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case WHEEL_EVENT_SCROLL:
|
case WHEEL_EVENT_SCROLL:
|
||||||
|
|
@ -191,7 +192,7 @@ wheel_handle_event_on_state_none(struct plugin_device *pd,
|
||||||
static void
|
static void
|
||||||
wheel_handle_event_on_state_accumulating_scroll(struct plugin_device *pd,
|
wheel_handle_event_on_state_accumulating_scroll(struct plugin_device *pd,
|
||||||
enum wheel_event event,
|
enum wheel_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case WHEEL_EVENT_SCROLL_ACCUMULATED:
|
case WHEEL_EVENT_SCROLL_ACCUMULATED:
|
||||||
|
|
@ -213,7 +214,7 @@ wheel_handle_event_on_state_accumulating_scroll(struct plugin_device *pd,
|
||||||
static void
|
static void
|
||||||
wheel_handle_event_on_state_scrolling(struct plugin_device *pd,
|
wheel_handle_event_on_state_scrolling(struct plugin_device *pd,
|
||||||
enum wheel_event event,
|
enum wheel_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case WHEEL_EVENT_SCROLL:
|
case WHEEL_EVENT_SCROLL:
|
||||||
|
|
@ -233,7 +234,7 @@ wheel_handle_event_on_state_scrolling(struct plugin_device *pd,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wheel_handle_event(struct plugin_device *pd, enum wheel_event event, uint64_t time)
|
wheel_handle_event(struct plugin_device *pd, enum wheel_event event, usec_t time)
|
||||||
{
|
{
|
||||||
enum wheel_state oldstate = pd->state;
|
enum wheel_state oldstate = pd->state;
|
||||||
|
|
||||||
|
|
@ -319,14 +320,14 @@ wheel_queue_scroll_events(struct plugin_device *pd, struct evdev_frame *frame)
|
||||||
static void
|
static void
|
||||||
wheel_handle_state_none(struct plugin_device *pd,
|
wheel_handle_state_none(struct plugin_device *pd,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wheel_handle_state_accumulating_scroll(struct plugin_device *pd,
|
wheel_handle_state_accumulating_scroll(struct plugin_device *pd,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
wheel_remove_scroll_events(frame);
|
wheel_remove_scroll_events(frame);
|
||||||
|
|
||||||
|
|
@ -340,7 +341,7 @@ wheel_handle_state_accumulating_scroll(struct plugin_device *pd,
|
||||||
static void
|
static void
|
||||||
wheel_handle_state_scrolling(struct plugin_device *pd,
|
wheel_handle_state_scrolling(struct plugin_device *pd,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
wheel_remove_scroll_events(frame);
|
wheel_remove_scroll_events(frame);
|
||||||
wheel_queue_scroll_events(pd, frame);
|
wheel_queue_scroll_events(pd, frame);
|
||||||
|
|
@ -349,7 +350,7 @@ wheel_handle_state_scrolling(struct plugin_device *pd,
|
||||||
static void
|
static void
|
||||||
wheel_handle_direction_change(struct plugin_device *pd,
|
wheel_handle_direction_change(struct plugin_device *pd,
|
||||||
struct evdev_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum wheel_direction new_dir = WHEEL_DIR_UNKNOW;
|
enum wheel_direction new_dir = WHEEL_DIR_UNKNOW;
|
||||||
|
|
||||||
|
|
@ -386,7 +387,7 @@ wheel_update_strategy(struct plugin_device *pd, int32_t value)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wheel_process_relative(struct plugin_device *pd, struct evdev_event *e, uint64_t time)
|
wheel_process_relative(struct plugin_device *pd, struct evdev_event *e, usec_t time)
|
||||||
{
|
{
|
||||||
switch (evdev_usage_enum(e->usage)) {
|
switch (evdev_usage_enum(e->usage)) {
|
||||||
case EVDEV_REL_WHEEL:
|
case EVDEV_REL_WHEEL:
|
||||||
|
|
@ -417,7 +418,7 @@ wheel_process_relative(struct plugin_device *pd, struct evdev_event *e, uint64_t
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wheel_handle_state(struct plugin_device *pd, struct evdev_frame *frame, uint64_t time)
|
wheel_handle_state(struct plugin_device *pd, struct evdev_frame *frame, usec_t time)
|
||||||
{
|
{
|
||||||
struct evdev_device *evdev = evdev_device(pd->device);
|
struct evdev_device *evdev = evdev_device(pd->device);
|
||||||
|
|
||||||
|
|
@ -448,7 +449,7 @@ wheel_handle_state(struct plugin_device *pd, struct evdev_frame *frame, uint64_t
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wheel_on_scroll_timer_timeout(struct libinput_plugin *plugin, uint64_t now, void *data)
|
wheel_on_scroll_timer_timeout(struct libinput_plugin *plugin, usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct plugin_device *pd = data;
|
struct plugin_device *pd = data;
|
||||||
|
|
||||||
|
|
@ -469,7 +470,7 @@ wheel_plugin_device_create(struct libinput_plugin *libinput_plugin,
|
||||||
pd->state = WHEEL_STATE_NONE;
|
pd->state = WHEEL_STATE_NONE;
|
||||||
pd->dir = WHEEL_DIR_UNKNOW;
|
pd->dir = WHEEL_DIR_UNKNOW;
|
||||||
pd->min_movement = ACC_V120_THRESHOLD;
|
pd->min_movement = ACC_V120_THRESHOLD;
|
||||||
ratelimit_init(&pd->hires_warning_limit, s2us(24 * 60 * 60), 1);
|
ratelimit_init(&pd->hires_warning_limit, usec_from_hours(24), 1);
|
||||||
|
|
||||||
if (libinput_device_has_model_quirk(device, QUIRK_MODEL_SCROLL_ON_MIDDLE_CLICK))
|
if (libinput_device_has_model_quirk(device, QUIRK_MODEL_SCROLL_ON_MIDDLE_CLICK))
|
||||||
pd->ignore_small_hi_res_movements = ALWAYS_ACCUMULATE;
|
pd->ignore_small_hi_res_movements = ALWAYS_ACCUMULATE;
|
||||||
|
|
@ -575,7 +576,7 @@ wheel_plugin_device_removed(struct libinput_plugin *libinput_plugin,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wheel_handle_frame(struct plugin_device *pd, struct evdev_frame *frame, uint64_t time)
|
wheel_handle_frame(struct plugin_device *pd, struct evdev_frame *frame, usec_t time)
|
||||||
{
|
{
|
||||||
size_t nevents;
|
size_t nevents;
|
||||||
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
||||||
|
|
@ -602,7 +603,7 @@ wheel_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
|
||||||
{
|
{
|
||||||
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
|
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
|
||||||
struct plugin_device *pd;
|
struct plugin_device *pd;
|
||||||
uint64_t time = evdev_frame_get_time(frame);
|
usec_t time = evdev_frame_get_time(frame);
|
||||||
|
|
||||||
list_for_each(pd, &plugin->devices, link) {
|
list_for_each(pd, &plugin->devices, link) {
|
||||||
if (pd->device == device) {
|
if (pd->device == device) {
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ mtdev_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
|
||||||
struct plugin_device *device,
|
struct plugin_device *device,
|
||||||
struct evdev_frame *frame)
|
struct evdev_frame *frame)
|
||||||
{
|
{
|
||||||
uint64_t time = evdev_frame_get_time(frame);
|
usec_t time = evdev_frame_get_time(frame);
|
||||||
size_t nevents;
|
size_t nevents;
|
||||||
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
|
||||||
for (size_t i = 0; i < nevents; i++) {
|
for (size_t i = 0; i < nevents; i++) {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
#include "libinput-plugin.h"
|
#include "libinput-plugin.h"
|
||||||
#include "libinput-util.h"
|
#include "libinput-util.h"
|
||||||
|
|
||||||
static int ERASER_BUTTON_DELAY = 30 * 1000; /* µs */
|
static usec_t ERASER_BUTTON_DELAY = { 30 * 1000 }; /* µs */
|
||||||
|
|
||||||
enum frame_filter_state {
|
enum frame_filter_state {
|
||||||
DISCARD,
|
DISCARD,
|
||||||
|
|
@ -146,9 +146,9 @@ eraser_button_set_state(struct plugin_device *device, enum eraser_button_state t
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eraser_button_set_timer(struct plugin_device *device, uint64_t time)
|
eraser_button_set_timer(struct plugin_device *device, usec_t time)
|
||||||
{
|
{
|
||||||
libinput_plugin_timer_set(device->timer, time + ERASER_BUTTON_DELAY);
|
libinput_plugin_timer_set(device->timer, usec_add(time, ERASER_BUTTON_DELAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -235,7 +235,7 @@ static enum frame_filter_state
|
||||||
eraser_button_neutral_handle_event(struct plugin_device *device,
|
eraser_button_neutral_handle_event(struct plugin_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
enum eraser_button_event event,
|
enum eraser_button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case ERASER_EVENT_PEN_ENTERING_PROX:
|
case ERASER_EVENT_PEN_ENTERING_PROX:
|
||||||
|
|
@ -266,7 +266,7 @@ static enum frame_filter_state
|
||||||
eraser_button_pending_eraser_handle_event(struct plugin_device *device,
|
eraser_button_pending_eraser_handle_event(struct plugin_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
enum eraser_button_event event,
|
enum eraser_button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case ERASER_EVENT_PEN_ENTERING_PROX:
|
case ERASER_EVENT_PEN_ENTERING_PROX:
|
||||||
|
|
@ -306,7 +306,7 @@ static enum frame_filter_state
|
||||||
eraser_button_button_held_handle_event(struct plugin_device *device,
|
eraser_button_button_held_handle_event(struct plugin_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
enum eraser_button_event event,
|
enum eraser_button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case ERASER_EVENT_PEN_ENTERING_PROX:
|
case ERASER_EVENT_PEN_ENTERING_PROX:
|
||||||
|
|
@ -339,7 +339,7 @@ static enum frame_filter_state
|
||||||
eraser_button_button_released_handle_event(struct plugin_device *device,
|
eraser_button_button_released_handle_event(struct plugin_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
enum eraser_button_event event,
|
enum eraser_button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case ERASER_EVENT_PEN_ENTERING_PROX:
|
case ERASER_EVENT_PEN_ENTERING_PROX:
|
||||||
|
|
@ -379,7 +379,7 @@ static enum frame_filter_state
|
||||||
eraser_button_handle_state(struct plugin_device *device,
|
eraser_button_handle_state(struct plugin_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
enum eraser_button_event event,
|
enum eraser_button_event event,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
enum eraser_button_state state = device->state;
|
enum eraser_button_state state = device->state;
|
||||||
enum frame_filter_state ret = PROCESS;
|
enum frame_filter_state ret = PROCESS;
|
||||||
|
|
@ -426,7 +426,7 @@ eraser_button_handle_state(struct plugin_device *device,
|
||||||
static void
|
static void
|
||||||
eraser_button_handle_frame(struct plugin_device *device,
|
eraser_button_handle_frame(struct plugin_device *device,
|
||||||
struct evdev_frame *frame,
|
struct evdev_frame *frame,
|
||||||
uint64_t time)
|
usec_t time)
|
||||||
{
|
{
|
||||||
if (device->mode == LIBINPUT_CONFIG_ERASER_BUTTON_DEFAULT)
|
if (device->mode == LIBINPUT_CONFIG_ERASER_BUTTON_DEFAULT)
|
||||||
return;
|
return;
|
||||||
|
|
@ -505,7 +505,7 @@ eraser_button_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
|
||||||
{
|
{
|
||||||
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
|
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
|
||||||
struct plugin_device *pd;
|
struct plugin_device *pd;
|
||||||
uint64_t time = evdev_frame_get_time(frame);
|
usec_t time = evdev_frame_get_time(frame);
|
||||||
|
|
||||||
list_for_each(pd, &plugin->devices, link) {
|
list_for_each(pd, &plugin->devices, link) {
|
||||||
if (pd->device == device) {
|
if (pd->device == device) {
|
||||||
|
|
@ -516,7 +516,7 @@ eraser_button_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eraser_button_timer_func(struct libinput_plugin *plugin, uint64_t now, void *d)
|
eraser_button_timer_func(struct libinput_plugin *plugin, usec_t now, void *d)
|
||||||
{
|
{
|
||||||
struct plugin_device *device = d;
|
struct plugin_device *device = d;
|
||||||
|
|
||||||
|
|
@ -607,7 +607,7 @@ void
|
||||||
libinput_tablet_plugin_eraser_button(struct libinput *libinput)
|
libinput_tablet_plugin_eraser_button(struct libinput *libinput)
|
||||||
{
|
{
|
||||||
if (getenv("LIBINPUT_RUNNING_TEST_SUITE"))
|
if (getenv("LIBINPUT_RUNNING_TEST_SUITE"))
|
||||||
ERASER_BUTTON_DELAY = ms2us(150);
|
ERASER_BUTTON_DELAY = usec_from_millis(150);
|
||||||
|
|
||||||
_destroy_(plugin_data) *plugin = zalloc(sizeof(*plugin));
|
_destroy_(plugin_data) *plugin = zalloc(sizeof(*plugin));
|
||||||
list_init(&plugin->devices);
|
list_init(&plugin->devices);
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,14 @@
|
||||||
/* The tablet sends events every ~2ms , 50ms should be plenty enough to
|
/* The tablet sends events every ~2ms , 50ms should be plenty enough to
|
||||||
detect out-of-range.
|
detect out-of-range.
|
||||||
This value is higher during test suite runs */
|
This value is higher during test suite runs */
|
||||||
static int FORCED_PROXOUT_TIMEOUT = 50 * 1000; /* µs */
|
static usec_t FORCED_PROXOUT_TIMEOUT = { 50 * 1000 };
|
||||||
|
|
||||||
struct plugin_device {
|
struct plugin_device {
|
||||||
struct list link;
|
struct list link;
|
||||||
|
|
||||||
struct libinput_plugin_timer *prox_out_timer;
|
struct libinput_plugin_timer *prox_out_timer;
|
||||||
bool proximity_out_forced;
|
bool proximity_out_forced;
|
||||||
uint64_t last_event_time;
|
usec_t last_event_time;
|
||||||
|
|
||||||
bool pen_state;
|
bool pen_state;
|
||||||
bitmask_t button_state;
|
bitmask_t button_state;
|
||||||
|
|
@ -87,15 +87,15 @@ plugin_data_destroy(void *d)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
proximity_timer_plugin_set_timer(struct plugin_device *device, uint64_t time)
|
proximity_timer_plugin_set_timer(struct plugin_device *device, usec_t time)
|
||||||
{
|
{
|
||||||
libinput_plugin_timer_set(device->prox_out_timer,
|
libinput_plugin_timer_set(device->prox_out_timer,
|
||||||
time + FORCED_PROXOUT_TIMEOUT);
|
usec_add(time, FORCED_PROXOUT_TIMEOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tablet_proximity_out_quirk_timer_func(struct libinput_plugin *plugin,
|
tablet_proximity_out_quirk_timer_func(struct libinput_plugin *plugin,
|
||||||
uint64_t now,
|
usec_t now,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct plugin_device *device = data;
|
struct plugin_device *device = data;
|
||||||
|
|
@ -105,7 +105,8 @@ tablet_proximity_out_quirk_timer_func(struct libinput_plugin *plugin,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->last_event_time > now - FORCED_PROXOUT_TIMEOUT) {
|
usec_t proxout_time = usec_sub(now, FORCED_PROXOUT_TIMEOUT);
|
||||||
|
if (usec_cmp(device->last_event_time, proxout_time) > 0) {
|
||||||
proximity_timer_plugin_set_timer(device, device->last_event_time);
|
proximity_timer_plugin_set_timer(device, device->last_event_time);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -144,11 +145,10 @@ proximity_timer_plugin_device_handle_frame(struct libinput_plugin *libinput_plug
|
||||||
struct plugin_device *device,
|
struct plugin_device *device,
|
||||||
struct evdev_frame *frame)
|
struct evdev_frame *frame)
|
||||||
{
|
{
|
||||||
uint64_t time = evdev_frame_get_time(frame);
|
usec_t time = evdev_frame_get_time(frame);
|
||||||
/* First event after adding a device - by definition the pen
|
/* First event after adding a device - by definition the pen
|
||||||
*
|
|
||||||
* is in proximity if we get this one */
|
* is in proximity if we get this one */
|
||||||
if (device->last_event_time == 0)
|
if (usec_is_zero(device->last_event_time))
|
||||||
proximity_timer_plugin_set_timer(device, time);
|
proximity_timer_plugin_set_timer(device, time);
|
||||||
|
|
||||||
device->last_event_time = time;
|
device->last_event_time = time;
|
||||||
|
|
@ -303,7 +303,7 @@ libinput_tablet_plugin_proximity_timer(struct libinput *libinput)
|
||||||
|
|
||||||
/* Stop false positives caused by the forced proximity code */
|
/* Stop false positives caused by the forced proximity code */
|
||||||
if (getenv("LIBINPUT_RUNNING_TEST_SUITE"))
|
if (getenv("LIBINPUT_RUNNING_TEST_SUITE"))
|
||||||
FORCED_PROXOUT_TIMEOUT = 150 * 1000; /* µs */
|
FORCED_PROXOUT_TIMEOUT = usec_from_millis(150);
|
||||||
|
|
||||||
_unref_(libinput_plugin) *p = libinput_plugin_new(libinput,
|
_unref_(libinput_plugin) *p = libinput_plugin_new(libinput,
|
||||||
"tablet-proximity-timer",
|
"tablet-proximity-timer",
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ struct libinput_plugin_timer {
|
||||||
struct list link;
|
struct list link;
|
||||||
struct libinput_plugin *plugin;
|
struct libinput_plugin *plugin;
|
||||||
struct libinput_timer timer;
|
struct libinput_timer timer;
|
||||||
void (*func)(struct libinput_plugin *plugin, uint64_t now, void *user_data);
|
void (*func)(struct libinput_plugin *plugin, usec_t now, void *user_data);
|
||||||
void *user_data;
|
void *user_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -657,7 +657,7 @@ print_frame(struct libinput *libinput, struct evdev_frame *frame, const char *pr
|
||||||
{
|
{
|
||||||
static uint32_t offset = 0;
|
static uint32_t offset = 0;
|
||||||
static uint32_t last_time = 0;
|
static uint32_t last_time = 0;
|
||||||
uint32_t time = evdev_frame_get_time(frame) / 1000;
|
uint32_t time = usec_to_millis(evdev_frame_get_time(frame));
|
||||||
|
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
offset = time;
|
offset = time;
|
||||||
|
|
@ -756,7 +756,7 @@ plugin_system_notify_evdev_frame(struct libinput_plugin_system *system,
|
||||||
struct list queued_events = LIST_INIT(queued_events);
|
struct list queued_events = LIST_INIT(queued_events);
|
||||||
list_take_insert(&queued_events, our_event, link);
|
list_take_insert(&queued_events, our_event, link);
|
||||||
|
|
||||||
uint64_t frame_time = evdev_frame_get_time(frame);
|
usec_t frame_time = evdev_frame_get_time(frame);
|
||||||
|
|
||||||
bool delay = !!sender_plugin;
|
bool delay = !!sender_plugin;
|
||||||
|
|
||||||
|
|
@ -784,7 +784,7 @@ plugin_system_notify_evdev_frame(struct libinput_plugin_system *system,
|
||||||
list_for_each_safe(event, &queued_events, link) {
|
list_for_each_safe(event, &queued_events, link) {
|
||||||
struct list next = LIST_INIT(next);
|
struct list next = LIST_INIT(next);
|
||||||
|
|
||||||
if (evdev_frame_get_time(event->frame) == 0)
|
if (usec_is_zero(evdev_frame_get_time(event->frame)))
|
||||||
evdev_frame_set_time(event->frame, frame_time);
|
evdev_frame_set_time(event->frame, frame_time);
|
||||||
|
|
||||||
if (!bitmask_bit_is_set(device->plugin_frame_callbacks,
|
if (!bitmask_bit_is_set(device->plugin_frame_callbacks,
|
||||||
|
|
@ -848,7 +848,7 @@ libinput_plugin_system_notify_evdev_frame(struct libinput_plugin_system *system,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
plugin_timer_func(uint64_t now, void *data)
|
plugin_timer_func(usec_t now, void *data)
|
||||||
{
|
{
|
||||||
struct libinput_plugin_timer *timer = data;
|
struct libinput_plugin_timer *timer = data;
|
||||||
struct libinput_plugin *plugin = timer->plugin;
|
struct libinput_plugin *plugin = timer->plugin;
|
||||||
|
|
@ -882,7 +882,7 @@ struct libinput_plugin_timer *
|
||||||
libinput_plugin_timer_new(struct libinput_plugin *plugin,
|
libinput_plugin_timer_new(struct libinput_plugin *plugin,
|
||||||
const char *name,
|
const char *name,
|
||||||
void (*func)(struct libinput_plugin *plugin,
|
void (*func)(struct libinput_plugin *plugin,
|
||||||
uint64_t now,
|
usec_t now,
|
||||||
void *data),
|
void *data),
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
|
|
@ -942,7 +942,7 @@ libinput_plugin_timer_unref(struct libinput_plugin_timer *timer)
|
||||||
|
|
||||||
/* Set timer expire time, in absolute us CLOCK_MONOTONIC */
|
/* Set timer expire time, in absolute us CLOCK_MONOTONIC */
|
||||||
void
|
void
|
||||||
libinput_plugin_timer_set(struct libinput_plugin_timer *timer, uint64_t expire)
|
libinput_plugin_timer_set(struct libinput_plugin_timer *timer, usec_t expire)
|
||||||
{
|
{
|
||||||
libinput_timer_set(&timer->timer, expire);
|
libinput_timer_set(&timer->timer, expire);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "util-time.h"
|
||||||
|
|
||||||
/* Forward declarations instead of #includes to make
|
/* Forward declarations instead of #includes to make
|
||||||
* this header self-contained (bindgen, etc.) */
|
* this header self-contained (bindgen, etc.) */
|
||||||
struct evdev_frame;
|
struct evdev_frame;
|
||||||
|
|
@ -333,7 +335,7 @@ struct libinput_plugin_timer *
|
||||||
libinput_plugin_timer_new(struct libinput_plugin *plugin,
|
libinput_plugin_timer_new(struct libinput_plugin *plugin,
|
||||||
const char *name,
|
const char *name,
|
||||||
void (*func)(struct libinput_plugin *plugin,
|
void (*func)(struct libinput_plugin *plugin,
|
||||||
uint64_t now,
|
usec_t now,
|
||||||
void *user_data),
|
void *user_data),
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
|
|
@ -349,7 +351,7 @@ DEFINE_UNREF_CLEANUP_FUNC(libinput_plugin_timer);
|
||||||
|
|
||||||
/* Set timer expire time, in absolute us CLOCK_MONOTONIC */
|
/* Set timer expire time, in absolute us CLOCK_MONOTONIC */
|
||||||
void
|
void
|
||||||
libinput_plugin_timer_set(struct libinput_plugin_timer *timer, uint64_t expire);
|
libinput_plugin_timer_set(struct libinput_plugin_timer *timer, usec_t expire);
|
||||||
|
|
||||||
void
|
void
|
||||||
libinput_plugin_timer_set_user_data(struct libinput_plugin_timer *timer,
|
libinput_plugin_timer_set_user_data(struct libinput_plugin_timer *timer,
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ struct libinput {
|
||||||
struct list list;
|
struct list list;
|
||||||
struct libinput_source *source;
|
struct libinput_source *source;
|
||||||
int fd;
|
int fd;
|
||||||
uint64_t next_expiry;
|
usec_t next_expiry;
|
||||||
|
|
||||||
struct ratelimit expiry_in_past_limit;
|
struct ratelimit expiry_in_past_limit;
|
||||||
} timer;
|
} timer;
|
||||||
|
|
@ -221,8 +221,8 @@ struct libinput {
|
||||||
|
|
||||||
struct list device_group_list;
|
struct list device_group_list;
|
||||||
|
|
||||||
uint64_t last_event_time;
|
usec_t last_event_time;
|
||||||
uint64_t dispatch_time;
|
usec_t dispatch_time;
|
||||||
|
|
||||||
bool quirks_initialized;
|
bool quirks_initialized;
|
||||||
struct quirks_context *quirks;
|
struct quirks_context *quirks;
|
||||||
|
|
@ -464,8 +464,8 @@ struct libinput_device_config_dwt {
|
||||||
enum libinput_config_dwt_state (*get_default_enabled)(
|
enum libinput_config_dwt_state (*get_default_enabled)(
|
||||||
struct libinput_device *device);
|
struct libinput_device *device);
|
||||||
enum libinput_config_status (*set_timeout)(struct libinput_device *device,
|
enum libinput_config_status (*set_timeout)(struct libinput_device *device,
|
||||||
uint64_t timeout);
|
usec_t timeout);
|
||||||
uint64_t (*get_timeout)(struct libinput_device *device);
|
usec_t (*get_timeout)(struct libinput_device *device);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct libinput_device_config_dwtp {
|
struct libinput_device_config_dwtp {
|
||||||
|
|
@ -477,8 +477,8 @@ struct libinput_device_config_dwtp {
|
||||||
enum libinput_config_dwtp_state (*get_default_enabled)(
|
enum libinput_config_dwtp_state (*get_default_enabled)(
|
||||||
struct libinput_device *device);
|
struct libinput_device *device);
|
||||||
enum libinput_config_status (*set_timeout)(struct libinput_device *device,
|
enum libinput_config_status (*set_timeout)(struct libinput_device *device,
|
||||||
uint64_t timeout);
|
usec_t timeout);
|
||||||
uint64_t (*get_timeout)(struct libinput_device *device);
|
usec_t (*get_timeout)(struct libinput_device *device);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct libinput_device_config_rotation {
|
struct libinput_device_config_rotation {
|
||||||
|
|
@ -688,7 +688,7 @@ struct libinput_event {
|
||||||
|
|
||||||
struct libinput_event_listener {
|
struct libinput_event_listener {
|
||||||
struct list link;
|
struct list link;
|
||||||
void (*notify_func)(uint64_t time,
|
void (*notify_func)(usec_t time,
|
||||||
struct libinput_event *ev,
|
struct libinput_event *ev,
|
||||||
void *notify_func_data);
|
void *notify_func_data);
|
||||||
void *notify_func_data;
|
void *notify_func_data;
|
||||||
|
|
@ -759,7 +759,7 @@ libinput_device_init_event_listener(struct libinput_event_listener *listener);
|
||||||
void
|
void
|
||||||
libinput_device_add_event_listener(struct libinput_device *device,
|
libinput_device_add_event_listener(struct libinput_device *device,
|
||||||
struct libinput_event_listener *listener,
|
struct libinput_event_listener *listener,
|
||||||
void (*notify_func)(uint64_t time,
|
void (*notify_func)(usec_t time,
|
||||||
struct libinput_event *event,
|
struct libinput_event *event,
|
||||||
void *notify_func_data),
|
void *notify_func_data),
|
||||||
void *notify_func_data);
|
void *notify_func_data);
|
||||||
|
|
@ -775,84 +775,84 @@ notify_removed_device(struct libinput_device *device);
|
||||||
|
|
||||||
void
|
void
|
||||||
keyboard_notify_key(struct libinput_device *device,
|
keyboard_notify_key(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
keycode_t key,
|
keycode_t key,
|
||||||
enum libinput_key_state state);
|
enum libinput_key_state state);
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_motion(struct libinput_device *device,
|
pointer_notify_motion(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
const struct device_float_coords *raw);
|
const struct device_float_coords *raw);
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_motion_absolute(struct libinput_device *device,
|
pointer_notify_motion_absolute(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
const struct device_coords *point);
|
const struct device_coords *point);
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_button(struct libinput_device *device,
|
pointer_notify_button(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
button_code_t button,
|
button_code_t button,
|
||||||
enum libinput_button_state state);
|
enum libinput_button_state state);
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_axis_finger(struct libinput_device *device,
|
pointer_notify_axis_finger(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta);
|
const struct normalized_coords *delta);
|
||||||
void
|
void
|
||||||
pointer_notify_axis_continuous(struct libinput_device *device,
|
pointer_notify_axis_continuous(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta);
|
const struct normalized_coords *delta);
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_axis_legacy_wheel(struct libinput_device *device,
|
pointer_notify_axis_legacy_wheel(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
const struct discrete_coords *discrete);
|
const struct discrete_coords *discrete);
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_axis_wheel(struct libinput_device *device,
|
pointer_notify_axis_wheel(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
const struct wheel_v120 *v120);
|
const struct wheel_v120 *v120);
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_touch_down(struct libinput_device *device,
|
touch_notify_touch_down(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t slot,
|
int32_t slot,
|
||||||
int32_t seat_slot,
|
int32_t seat_slot,
|
||||||
const struct device_coords *point);
|
const struct device_coords *point);
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_touch_motion(struct libinput_device *device,
|
touch_notify_touch_motion(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t slot,
|
int32_t slot,
|
||||||
int32_t seat_slot,
|
int32_t seat_slot,
|
||||||
const struct device_coords *point);
|
const struct device_coords *point);
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_touch_up(struct libinput_device *device,
|
touch_notify_touch_up(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t slot,
|
int32_t slot,
|
||||||
int32_t seat_slot);
|
int32_t seat_slot);
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_touch_cancel(struct libinput_device *device,
|
touch_notify_touch_cancel(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t slot,
|
int32_t slot,
|
||||||
int32_t seat_slot);
|
int32_t seat_slot);
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_frame(struct libinput_device *device, uint64_t time);
|
touch_notify_frame(struct libinput_device *device, usec_t time);
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_swipe(struct libinput_device *device,
|
gesture_notify_swipe(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_event_type type,
|
enum libinput_event_type type,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
|
|
@ -860,13 +860,13 @@ gesture_notify_swipe(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_swipe_end(struct libinput_device *device,
|
gesture_notify_swipe_end(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
bool cancelled);
|
bool cancelled);
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_pinch(struct libinput_device *device,
|
gesture_notify_pinch(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_event_type type,
|
enum libinput_event_type type,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
|
|
@ -876,25 +876,25 @@ gesture_notify_pinch(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_pinch_end(struct libinput_device *device,
|
gesture_notify_pinch_end(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
double scale,
|
double scale,
|
||||||
bool cancelled);
|
bool cancelled);
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_hold_begin(struct libinput_device *device,
|
gesture_notify_hold_begin(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int finger_count);
|
int finger_count);
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_hold_end(struct libinput_device *device,
|
gesture_notify_hold_end(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
bool cancelled);
|
bool cancelled);
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_notify_axis(struct libinput_device *device,
|
tablet_notify_axis(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
enum libinput_tablet_tool_tip_state tip_state,
|
enum libinput_tablet_tool_tip_state tip_state,
|
||||||
unsigned char *changed_axes,
|
unsigned char *changed_axes,
|
||||||
|
|
@ -904,7 +904,7 @@ tablet_notify_axis(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_notify_proximity(struct libinput_device *device,
|
tablet_notify_proximity(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
enum libinput_tablet_tool_proximity_state state,
|
enum libinput_tablet_tool_proximity_state state,
|
||||||
unsigned char *changed_axes,
|
unsigned char *changed_axes,
|
||||||
|
|
@ -914,7 +914,7 @@ tablet_notify_proximity(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_notify_tip(struct libinput_device *device,
|
tablet_notify_tip(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
enum libinput_tablet_tool_tip_state tip_state,
|
enum libinput_tablet_tool_tip_state tip_state,
|
||||||
unsigned char *changed_axes,
|
unsigned char *changed_axes,
|
||||||
|
|
@ -924,7 +924,7 @@ tablet_notify_tip(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_notify_button(struct libinput_device *device,
|
tablet_notify_button(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
enum libinput_tablet_tool_tip_state tip_state,
|
enum libinput_tablet_tool_tip_state tip_state,
|
||||||
const struct tablet_axes *axes,
|
const struct tablet_axes *axes,
|
||||||
|
|
@ -935,40 +935,40 @@ tablet_notify_button(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_pad_notify_button(struct libinput_device *device,
|
tablet_pad_notify_button(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
pad_button_t button,
|
pad_button_t button,
|
||||||
enum libinput_button_state state,
|
enum libinput_button_state state,
|
||||||
struct libinput_tablet_pad_mode_group *group);
|
struct libinput_tablet_pad_mode_group *group);
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_pad_notify_dial(struct libinput_device *device,
|
tablet_pad_notify_dial(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
unsigned int number,
|
unsigned int number,
|
||||||
double value,
|
double value,
|
||||||
struct libinput_tablet_pad_mode_group *group);
|
struct libinput_tablet_pad_mode_group *group);
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_pad_notify_ring(struct libinput_device *device,
|
tablet_pad_notify_ring(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
unsigned int number,
|
unsigned int number,
|
||||||
double value,
|
double value,
|
||||||
enum libinput_tablet_pad_ring_axis_source source,
|
enum libinput_tablet_pad_ring_axis_source source,
|
||||||
struct libinput_tablet_pad_mode_group *group);
|
struct libinput_tablet_pad_mode_group *group);
|
||||||
void
|
void
|
||||||
tablet_pad_notify_strip(struct libinput_device *device,
|
tablet_pad_notify_strip(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
unsigned int number,
|
unsigned int number,
|
||||||
double value,
|
double value,
|
||||||
enum libinput_tablet_pad_strip_axis_source source,
|
enum libinput_tablet_pad_strip_axis_source source,
|
||||||
struct libinput_tablet_pad_mode_group *group);
|
struct libinput_tablet_pad_mode_group *group);
|
||||||
void
|
void
|
||||||
tablet_pad_notify_key(struct libinput_device *device,
|
tablet_pad_notify_key(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t key,
|
int32_t key,
|
||||||
enum libinput_key_state state);
|
enum libinput_key_state state);
|
||||||
void
|
void
|
||||||
switch_notify_toggle(struct libinput_device *device,
|
switch_notify_toggle(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_switch sw,
|
enum libinput_switch sw,
|
||||||
enum libinput_switch_state state);
|
enum libinput_switch_state state);
|
||||||
|
|
||||||
|
|
|
||||||
124
src/libinput.c
124
src/libinput.c
|
|
@ -174,7 +174,7 @@ struct libinput_event_device_notify {
|
||||||
|
|
||||||
struct libinput_event_keyboard {
|
struct libinput_event_keyboard {
|
||||||
struct libinput_event base;
|
struct libinput_event base;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
uint32_t key;
|
uint32_t key;
|
||||||
uint32_t seat_key_count;
|
uint32_t seat_key_count;
|
||||||
enum libinput_key_state state;
|
enum libinput_key_state state;
|
||||||
|
|
@ -182,7 +182,7 @@ struct libinput_event_keyboard {
|
||||||
|
|
||||||
struct libinput_event_pointer {
|
struct libinput_event_pointer {
|
||||||
struct libinput_event base;
|
struct libinput_event base;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
struct normalized_coords delta;
|
struct normalized_coords delta;
|
||||||
struct device_float_coords delta_raw;
|
struct device_float_coords delta_raw;
|
||||||
struct device_coords absolute;
|
struct device_coords absolute;
|
||||||
|
|
@ -197,7 +197,7 @@ struct libinput_event_pointer {
|
||||||
|
|
||||||
struct libinput_event_touch {
|
struct libinput_event_touch {
|
||||||
struct libinput_event base;
|
struct libinput_event base;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
int32_t slot;
|
int32_t slot;
|
||||||
int32_t seat_slot;
|
int32_t seat_slot;
|
||||||
struct device_coords point;
|
struct device_coords point;
|
||||||
|
|
@ -205,7 +205,7 @@ struct libinput_event_touch {
|
||||||
|
|
||||||
struct libinput_event_gesture {
|
struct libinput_event_gesture {
|
||||||
struct libinput_event base;
|
struct libinput_event base;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
int finger_count;
|
int finger_count;
|
||||||
int cancelled;
|
int cancelled;
|
||||||
struct normalized_coords delta;
|
struct normalized_coords delta;
|
||||||
|
|
@ -219,7 +219,7 @@ struct libinput_event_tablet_tool {
|
||||||
uint32_t button;
|
uint32_t button;
|
||||||
enum libinput_button_state state;
|
enum libinput_button_state state;
|
||||||
uint32_t seat_button_count;
|
uint32_t seat_button_count;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
struct tablet_axes axes;
|
struct tablet_axes axes;
|
||||||
unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_TOOL_AXIS_MAX + 1)];
|
unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_TOOL_AXIS_MAX + 1)];
|
||||||
struct libinput_tablet_tool *tool;
|
struct libinput_tablet_tool *tool;
|
||||||
|
|
@ -235,7 +235,7 @@ struct libinput_event_tablet_pad {
|
||||||
struct libinput_event base;
|
struct libinput_event base;
|
||||||
unsigned int mode;
|
unsigned int mode;
|
||||||
struct libinput_tablet_pad_mode_group *mode_group;
|
struct libinput_tablet_pad_mode_group *mode_group;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
struct {
|
struct {
|
||||||
uint32_t number;
|
uint32_t number;
|
||||||
enum libinput_button_state state;
|
enum libinput_button_state state;
|
||||||
|
|
@ -262,7 +262,7 @@ struct libinput_event_tablet_pad {
|
||||||
|
|
||||||
struct libinput_event_switch {
|
struct libinput_event_switch {
|
||||||
struct libinput_event base;
|
struct libinput_event base;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
enum libinput_switch sw;
|
enum libinput_switch sw;
|
||||||
enum libinput_switch_state state;
|
enum libinput_switch_state state;
|
||||||
};
|
};
|
||||||
|
|
@ -347,7 +347,7 @@ log_msg_ratelimit(struct libinput *libinput,
|
||||||
priority,
|
priority,
|
||||||
"WARNING: log rate limit exceeded (%d msgs per %dms). Discarding future messages.\n",
|
"WARNING: log rate limit exceeded (%d msgs per %dms). Discarding future messages.\n",
|
||||||
ratelimit->burst,
|
ratelimit->burst,
|
||||||
us2ms(ratelimit->interval));
|
usec_to_millis(ratelimit->interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT void
|
LIBINPUT_EXPORT void
|
||||||
|
|
@ -513,7 +513,7 @@ libinput_event_keyboard_get_time(struct libinput_event_keyboard *event)
|
||||||
0,
|
0,
|
||||||
LIBINPUT_EVENT_KEYBOARD_KEY);
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
||||||
|
|
||||||
return us2ms(event->time);
|
return usec_to_millis(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint64_t
|
LIBINPUT_EXPORT uint64_t
|
||||||
|
|
@ -524,7 +524,7 @@ libinput_event_keyboard_get_time_usec(struct libinput_event_keyboard *event)
|
||||||
0,
|
0,
|
||||||
LIBINPUT_EVENT_KEYBOARD_KEY);
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
||||||
|
|
||||||
return event->time;
|
return usec_as_uint64_t(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint32_t
|
LIBINPUT_EXPORT uint32_t
|
||||||
|
|
@ -574,7 +574,7 @@ libinput_event_pointer_get_time(struct libinput_event_pointer *event)
|
||||||
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
||||||
LIBINPUT_EVENT_POINTER_AXIS);
|
LIBINPUT_EVENT_POINTER_AXIS);
|
||||||
|
|
||||||
return us2ms(event->time);
|
return usec_to_millis(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint64_t
|
LIBINPUT_EXPORT uint64_t
|
||||||
|
|
@ -591,7 +591,7 @@ libinput_event_pointer_get_time_usec(struct libinput_event_pointer *event)
|
||||||
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
|
||||||
LIBINPUT_EVENT_POINTER_AXIS);
|
LIBINPUT_EVENT_POINTER_AXIS);
|
||||||
|
|
||||||
return event->time;
|
return usec_as_uint64_t(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT double
|
LIBINPUT_EXPORT double
|
||||||
|
|
@ -880,7 +880,7 @@ libinput_event_touch_get_time(struct libinput_event_touch *event)
|
||||||
LIBINPUT_EVENT_TOUCH_CANCEL,
|
LIBINPUT_EVENT_TOUCH_CANCEL,
|
||||||
LIBINPUT_EVENT_TOUCH_FRAME);
|
LIBINPUT_EVENT_TOUCH_FRAME);
|
||||||
|
|
||||||
return us2ms(event->time);
|
return usec_to_millis(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint64_t
|
LIBINPUT_EXPORT uint64_t
|
||||||
|
|
@ -895,7 +895,7 @@ libinput_event_touch_get_time_usec(struct libinput_event_touch *event)
|
||||||
LIBINPUT_EVENT_TOUCH_CANCEL,
|
LIBINPUT_EVENT_TOUCH_CANCEL,
|
||||||
LIBINPUT_EVENT_TOUCH_FRAME);
|
LIBINPUT_EVENT_TOUCH_FRAME);
|
||||||
|
|
||||||
return event->time;
|
return usec_as_uint64_t(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT int32_t
|
LIBINPUT_EXPORT int32_t
|
||||||
|
|
@ -999,7 +999,7 @@ libinput_event_gesture_get_time(struct libinput_event_gesture *event)
|
||||||
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN,
|
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN,
|
||||||
LIBINPUT_EVENT_GESTURE_HOLD_END);
|
LIBINPUT_EVENT_GESTURE_HOLD_END);
|
||||||
|
|
||||||
return us2ms(event->time);
|
return usec_to_millis(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint64_t
|
LIBINPUT_EXPORT uint64_t
|
||||||
|
|
@ -1017,7 +1017,7 @@ libinput_event_gesture_get_time_usec(struct libinput_event_gesture *event)
|
||||||
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN,
|
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN,
|
||||||
LIBINPUT_EVENT_GESTURE_HOLD_END);
|
LIBINPUT_EVENT_GESTURE_HOLD_END);
|
||||||
|
|
||||||
return event->time;
|
return usec_as_uint64_t(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT int
|
LIBINPUT_EXPORT int
|
||||||
|
|
@ -1580,7 +1580,7 @@ libinput_event_tablet_tool_get_time(struct libinput_event_tablet_tool *event)
|
||||||
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
||||||
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
||||||
|
|
||||||
return us2ms(event->time);
|
return usec_to_millis(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint64_t
|
LIBINPUT_EXPORT uint64_t
|
||||||
|
|
@ -1594,7 +1594,7 @@ libinput_event_tablet_tool_get_time_usec(struct libinput_event_tablet_tool *even
|
||||||
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
||||||
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
||||||
|
|
||||||
return event->time;
|
return usec_as_uint64_t(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint32_t
|
LIBINPUT_EXPORT uint32_t
|
||||||
|
|
@ -1782,7 +1782,7 @@ libinput_event_switch_get_time(struct libinput_event_switch *event)
|
||||||
0,
|
0,
|
||||||
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
||||||
|
|
||||||
return us2ms(event->time);
|
return usec_to_millis(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint64_t
|
LIBINPUT_EXPORT uint64_t
|
||||||
|
|
@ -1793,7 +1793,7 @@ libinput_event_switch_get_time_usec(struct libinput_event_switch *event)
|
||||||
0,
|
0,
|
||||||
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
||||||
|
|
||||||
return event->time;
|
return usec_as_uint64_t(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct libinput_source *
|
struct libinput_source *
|
||||||
|
|
@ -2193,8 +2193,8 @@ libinput_dispatch(struct libinput *libinput)
|
||||||
* timestamps */
|
* timestamps */
|
||||||
if ((++take_time_snapshot % 10) == 0)
|
if ((++take_time_snapshot % 10) == 0)
|
||||||
libinput->dispatch_time = libinput_now(libinput);
|
libinput->dispatch_time = libinput_now(libinput);
|
||||||
else if (libinput->dispatch_time)
|
else if (!usec_is_zero(libinput->dispatch_time))
|
||||||
libinput->dispatch_time = 0;
|
libinput->dispatch_time = usec_from_uint64_t(0);
|
||||||
|
|
||||||
count = epoll_wait(libinput->epoll_fd, ep, ARRAY_LENGTH(ep), 0);
|
count = epoll_wait(libinput->epoll_fd, ep, ARRAY_LENGTH(ep), 0);
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
|
|
@ -2222,7 +2222,7 @@ libinput_device_init_event_listener(struct libinput_event_listener *listener)
|
||||||
void
|
void
|
||||||
libinput_device_add_event_listener(struct libinput_device *device,
|
libinput_device_add_event_listener(struct libinput_device *device,
|
||||||
struct libinput_event_listener *listener,
|
struct libinput_event_listener *listener,
|
||||||
void (*notify_func)(uint64_t time,
|
void (*notify_func)(usec_t time,
|
||||||
struct libinput_event *event,
|
struct libinput_event *event,
|
||||||
void *notify_func_data),
|
void *notify_func_data),
|
||||||
void *notify_func_data)
|
void *notify_func_data)
|
||||||
|
|
@ -2324,7 +2324,7 @@ post_base_event(struct libinput_device *device,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
post_device_event(struct libinput_device *device,
|
post_device_event(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_event_type type,
|
enum libinput_event_type type,
|
||||||
struct libinput_event *event)
|
struct libinput_event *event)
|
||||||
{
|
{
|
||||||
|
|
@ -2431,7 +2431,7 @@ device_has_cap(struct libinput_device *device, enum libinput_device_capability c
|
||||||
|
|
||||||
void
|
void
|
||||||
keyboard_notify_key(struct libinput_device *device,
|
keyboard_notify_key(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
keycode_t keycode,
|
keycode_t keycode,
|
||||||
enum libinput_key_state state)
|
enum libinput_key_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -2457,7 +2457,7 @@ keyboard_notify_key(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_motion(struct libinput_device *device,
|
pointer_notify_motion(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
const struct device_float_coords *raw)
|
const struct device_float_coords *raw)
|
||||||
{
|
{
|
||||||
|
|
@ -2482,7 +2482,7 @@ pointer_notify_motion(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_motion_absolute(struct libinput_device *device,
|
pointer_notify_motion_absolute(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
const struct device_coords *point)
|
const struct device_coords *point)
|
||||||
{
|
{
|
||||||
struct libinput_event_pointer *motion_absolute_event;
|
struct libinput_event_pointer *motion_absolute_event;
|
||||||
|
|
@ -2505,7 +2505,7 @@ pointer_notify_motion_absolute(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_button(struct libinput_device *device,
|
pointer_notify_button(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
button_code_t button,
|
button_code_t button,
|
||||||
enum libinput_button_state state)
|
enum libinput_button_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -2534,7 +2534,7 @@ pointer_notify_button(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_axis_finger(struct libinput_device *device,
|
pointer_notify_axis_finger(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta)
|
const struct normalized_coords *delta)
|
||||||
{
|
{
|
||||||
|
|
@ -2570,7 +2570,7 @@ pointer_notify_axis_finger(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_axis_continuous(struct libinput_device *device,
|
pointer_notify_axis_continuous(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta)
|
const struct normalized_coords *delta)
|
||||||
{
|
{
|
||||||
|
|
@ -2606,7 +2606,7 @@ pointer_notify_axis_continuous(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_axis_legacy_wheel(struct libinput_device *device,
|
pointer_notify_axis_legacy_wheel(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
const struct discrete_coords *discrete)
|
const struct discrete_coords *discrete)
|
||||||
|
|
@ -2633,7 +2633,7 @@ pointer_notify_axis_legacy_wheel(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
pointer_notify_axis_wheel(struct libinput_device *device,
|
pointer_notify_axis_wheel(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
uint32_t axes,
|
uint32_t axes,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
const struct wheel_v120 *v120)
|
const struct wheel_v120 *v120)
|
||||||
|
|
@ -2665,7 +2665,7 @@ pointer_notify_axis_wheel(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_touch_down(struct libinput_device *device,
|
touch_notify_touch_down(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t slot,
|
int32_t slot,
|
||||||
int32_t seat_slot,
|
int32_t seat_slot,
|
||||||
const struct device_coords *point)
|
const struct device_coords *point)
|
||||||
|
|
@ -2689,7 +2689,7 @@ touch_notify_touch_down(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_touch_motion(struct libinput_device *device,
|
touch_notify_touch_motion(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t slot,
|
int32_t slot,
|
||||||
int32_t seat_slot,
|
int32_t seat_slot,
|
||||||
const struct device_coords *point)
|
const struct device_coords *point)
|
||||||
|
|
@ -2716,7 +2716,7 @@ touch_notify_touch_motion(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_touch_up(struct libinput_device *device,
|
touch_notify_touch_up(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t slot,
|
int32_t slot,
|
||||||
int32_t seat_slot)
|
int32_t seat_slot)
|
||||||
{
|
{
|
||||||
|
|
@ -2738,7 +2738,7 @@ touch_notify_touch_up(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_touch_cancel(struct libinput_device *device,
|
touch_notify_touch_cancel(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t slot,
|
int32_t slot,
|
||||||
int32_t seat_slot)
|
int32_t seat_slot)
|
||||||
{
|
{
|
||||||
|
|
@ -2762,7 +2762,7 @@ touch_notify_touch_cancel(struct libinput_device *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
touch_notify_frame(struct libinput_device *device, uint64_t time)
|
touch_notify_frame(struct libinput_device *device, usec_t time)
|
||||||
{
|
{
|
||||||
struct libinput_event_touch *touch_event;
|
struct libinput_event_touch *touch_event;
|
||||||
|
|
||||||
|
|
@ -2780,7 +2780,7 @@ touch_notify_frame(struct libinput_device *device, uint64_t time)
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_notify_axis(struct libinput_device *device,
|
tablet_notify_axis(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
enum libinput_tablet_tool_tip_state tip_state,
|
enum libinput_tablet_tool_tip_state tip_state,
|
||||||
unsigned char *changed_axes,
|
unsigned char *changed_axes,
|
||||||
|
|
@ -2814,7 +2814,7 @@ tablet_notify_axis(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_notify_proximity(struct libinput_device *device,
|
tablet_notify_proximity(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
enum libinput_tablet_tool_proximity_state proximity_state,
|
enum libinput_tablet_tool_proximity_state proximity_state,
|
||||||
unsigned char *changed_axes,
|
unsigned char *changed_axes,
|
||||||
|
|
@ -2847,7 +2847,7 @@ tablet_notify_proximity(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_notify_tip(struct libinput_device *device,
|
tablet_notify_tip(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
enum libinput_tablet_tool_tip_state tip_state,
|
enum libinput_tablet_tool_tip_state tip_state,
|
||||||
unsigned char *changed_axes,
|
unsigned char *changed_axes,
|
||||||
|
|
@ -2878,7 +2878,7 @@ tablet_notify_tip(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_notify_button(struct libinput_device *device,
|
tablet_notify_button(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
struct libinput_tablet_tool *tool,
|
struct libinput_tablet_tool *tool,
|
||||||
enum libinput_tablet_tool_tip_state tip_state,
|
enum libinput_tablet_tool_tip_state tip_state,
|
||||||
const struct tablet_axes *axes,
|
const struct tablet_axes *axes,
|
||||||
|
|
@ -2915,7 +2915,7 @@ tablet_notify_button(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_pad_notify_button(struct libinput_device *device,
|
tablet_pad_notify_button(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
pad_button_t button,
|
pad_button_t button,
|
||||||
enum libinput_button_state state,
|
enum libinput_button_state state,
|
||||||
struct libinput_tablet_pad_mode_group *group)
|
struct libinput_tablet_pad_mode_group *group)
|
||||||
|
|
@ -2943,7 +2943,7 @@ tablet_pad_notify_button(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_pad_notify_dial(struct libinput_device *device,
|
tablet_pad_notify_dial(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
unsigned int number,
|
unsigned int number,
|
||||||
double value,
|
double value,
|
||||||
struct libinput_tablet_pad_mode_group *group)
|
struct libinput_tablet_pad_mode_group *group)
|
||||||
|
|
@ -2971,7 +2971,7 @@ tablet_pad_notify_dial(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_pad_notify_ring(struct libinput_device *device,
|
tablet_pad_notify_ring(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
unsigned int number,
|
unsigned int number,
|
||||||
double value,
|
double value,
|
||||||
enum libinput_tablet_pad_ring_axis_source source,
|
enum libinput_tablet_pad_ring_axis_source source,
|
||||||
|
|
@ -3001,7 +3001,7 @@ tablet_pad_notify_ring(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_pad_notify_strip(struct libinput_device *device,
|
tablet_pad_notify_strip(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
unsigned int number,
|
unsigned int number,
|
||||||
double value,
|
double value,
|
||||||
enum libinput_tablet_pad_strip_axis_source source,
|
enum libinput_tablet_pad_strip_axis_source source,
|
||||||
|
|
@ -3031,7 +3031,7 @@ tablet_pad_notify_strip(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
tablet_pad_notify_key(struct libinput_device *device,
|
tablet_pad_notify_key(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int32_t key,
|
int32_t key,
|
||||||
enum libinput_key_state state)
|
enum libinput_key_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -3053,7 +3053,7 @@ tablet_pad_notify_key(struct libinput_device *device,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gesture_notify(struct libinput_device *device,
|
gesture_notify(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_event_type type,
|
enum libinput_event_type type,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
bool cancelled,
|
bool cancelled,
|
||||||
|
|
@ -3084,7 +3084,7 @@ gesture_notify(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_swipe(struct libinput_device *device,
|
gesture_notify_swipe(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_event_type type,
|
enum libinput_event_type type,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
|
|
@ -3095,7 +3095,7 @@ gesture_notify_swipe(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_swipe_end(struct libinput_device *device,
|
gesture_notify_swipe_end(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
bool cancelled)
|
bool cancelled)
|
||||||
{
|
{
|
||||||
|
|
@ -3114,7 +3114,7 @@ gesture_notify_swipe_end(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_pinch(struct libinput_device *device,
|
gesture_notify_pinch(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_event_type type,
|
enum libinput_event_type type,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
const struct normalized_coords *delta,
|
const struct normalized_coords *delta,
|
||||||
|
|
@ -3135,7 +3135,7 @@ gesture_notify_pinch(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_pinch_end(struct libinput_device *device,
|
gesture_notify_pinch_end(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
double scale,
|
double scale,
|
||||||
bool cancelled)
|
bool cancelled)
|
||||||
|
|
@ -3154,9 +3154,7 @@ gesture_notify_pinch_end(struct libinput_device *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_hold_begin(struct libinput_device *device,
|
gesture_notify_hold_begin(struct libinput_device *device, usec_t time, int finger_count)
|
||||||
uint64_t time,
|
|
||||||
int finger_count)
|
|
||||||
{
|
{
|
||||||
const struct normalized_coords zero = { 0.0, 0.0 };
|
const struct normalized_coords zero = { 0.0, 0.0 };
|
||||||
|
|
||||||
|
|
@ -3173,7 +3171,7 @@ gesture_notify_hold_begin(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
gesture_notify_hold_end(struct libinput_device *device,
|
gesture_notify_hold_end(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
int finger_count,
|
int finger_count,
|
||||||
bool cancelled)
|
bool cancelled)
|
||||||
{
|
{
|
||||||
|
|
@ -3192,7 +3190,7 @@ gesture_notify_hold_end(struct libinput_device *device,
|
||||||
|
|
||||||
void
|
void
|
||||||
switch_notify_toggle(struct libinput_device *device,
|
switch_notify_toggle(struct libinput_device *device,
|
||||||
uint64_t time,
|
usec_t time,
|
||||||
enum libinput_switch sw,
|
enum libinput_switch sw,
|
||||||
enum libinput_switch_state state)
|
enum libinput_switch_state state)
|
||||||
{
|
{
|
||||||
|
|
@ -3873,7 +3871,7 @@ libinput_event_tablet_pad_get_time(struct libinput_event_tablet_pad *event)
|
||||||
LIBINPUT_EVENT_TABLET_PAD_BUTTON,
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON,
|
||||||
LIBINPUT_EVENT_TABLET_PAD_KEY);
|
LIBINPUT_EVENT_TABLET_PAD_KEY);
|
||||||
|
|
||||||
return us2ms(event->time);
|
return usec_to_millis(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint64_t
|
LIBINPUT_EXPORT uint64_t
|
||||||
|
|
@ -3888,7 +3886,7 @@ libinput_event_tablet_pad_get_time_usec(struct libinput_event_tablet_pad *event)
|
||||||
LIBINPUT_EVENT_TABLET_PAD_BUTTON,
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON,
|
||||||
LIBINPUT_EVENT_TABLET_PAD_KEY);
|
LIBINPUT_EVENT_TABLET_PAD_KEY);
|
||||||
|
|
||||||
return event->time;
|
return usec_as_uint64_t(event->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT struct libinput_event *
|
LIBINPUT_EXPORT struct libinput_event *
|
||||||
|
|
@ -4925,7 +4923,8 @@ libinput_device_config_dwt_set_timeout(struct libinput_device *device, uint32_t
|
||||||
if (!libinput_device_config_dwt_is_available(device))
|
if (!libinput_device_config_dwt_is_available(device))
|
||||||
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
||||||
|
|
||||||
return device->config.dwt->set_timeout(device, ms2us(millis));
|
usec_t timeout = usec_from_millis(millis);
|
||||||
|
return device->config.dwt->set_timeout(device, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint32_t
|
LIBINPUT_EXPORT uint32_t
|
||||||
|
|
@ -4934,7 +4933,7 @@ libinput_device_config_dwt_get_timeout(struct libinput_device *device)
|
||||||
if (!libinput_device_config_dwt_is_available(device))
|
if (!libinput_device_config_dwt_is_available(device))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return us2ms(device->config.dwt->get_timeout(device));
|
return usec_to_millis(device->config.dwt->get_timeout(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT int
|
LIBINPUT_EXPORT int
|
||||||
|
|
@ -4988,7 +4987,8 @@ libinput_device_config_dwtp_set_timeout(struct libinput_device *device, uint32_t
|
||||||
if (!libinput_device_config_dwtp_is_available(device))
|
if (!libinput_device_config_dwtp_is_available(device))
|
||||||
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
||||||
|
|
||||||
return device->config.dwtp->set_timeout(device, ms2us(millis));
|
usec_t timeout = usec_from_millis(millis);
|
||||||
|
return device->config.dwtp->set_timeout(device, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT uint32_t
|
LIBINPUT_EXPORT uint32_t
|
||||||
|
|
@ -4997,7 +4997,7 @@ libinput_device_config_dwtp_get_timeout(struct libinput_device *device)
|
||||||
if (!libinput_device_config_dwtp_is_available(device))
|
if (!libinput_device_config_dwtp_is_available(device))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return us2ms(device->config.dwtp->get_timeout(device));
|
return usec_to_millis(device->config.dwtp->get_timeout(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT int
|
LIBINPUT_EXPORT int
|
||||||
|
|
|
||||||
73
src/timer.c
73
src/timer.c
|
|
@ -36,7 +36,7 @@ void
|
||||||
libinput_timer_init(struct libinput_timer *timer,
|
libinput_timer_init(struct libinput_timer *timer,
|
||||||
struct libinput *libinput,
|
struct libinput *libinput,
|
||||||
const char *timer_name,
|
const char *timer_name,
|
||||||
void (*timer_func)(uint64_t now, void *timer_func_data),
|
void (*timer_func)(usec_t now, void *timer_func_data),
|
||||||
void *timer_func_data)
|
void *timer_func_data)
|
||||||
{
|
{
|
||||||
timer->libinput = libinput;
|
timer->libinput = libinput;
|
||||||
|
|
@ -44,7 +44,7 @@ libinput_timer_init(struct libinput_timer *timer,
|
||||||
timer->timer_func = timer_func;
|
timer->timer_func = timer_func;
|
||||||
timer->timer_func_data = timer_func_data;
|
timer->timer_func_data = timer_func_data;
|
||||||
/* at most 5 "expiry in the past" log messages per hour */
|
/* at most 5 "expiry in the past" log messages per hour */
|
||||||
ratelimit_init(&libinput->timer.expiry_in_past_limit, s2us(60 * 60), 5);
|
ratelimit_init(&libinput->timer.expiry_in_past_limit, usec_from_hours(1), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -66,16 +66,15 @@ libinput_timer_arm_timer_fd(struct libinput *libinput)
|
||||||
int r;
|
int r;
|
||||||
struct libinput_timer *timer;
|
struct libinput_timer *timer;
|
||||||
struct itimerspec its = { { 0, 0 }, { 0, 0 } };
|
struct itimerspec its = { { 0, 0 }, { 0, 0 } };
|
||||||
uint64_t earliest_expire = UINT64_MAX;
|
usec_t earliest_expire = usec_from_uint64_t(UINT64_MAX);
|
||||||
|
|
||||||
list_for_each(timer, &libinput->timer.list, link) {
|
list_for_each(timer, &libinput->timer.list, link) {
|
||||||
if (timer->expire < earliest_expire)
|
if (usec_cmp(timer->expire, earliest_expire) < 0)
|
||||||
earliest_expire = timer->expire;
|
earliest_expire = timer->expire;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (earliest_expire != UINT64_MAX) {
|
if (usec_ne(earliest_expire, UINT64_MAX)) {
|
||||||
its.it_value.tv_sec = earliest_expire / ms2us(1000);
|
its.it_value = usec_to_timespec(earliest_expire);
|
||||||
its.it_value.tv_nsec = (earliest_expire % ms2us(1000)) * 1000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = timerfd_settime(libinput->timer.fd, TFD_TIMER_ABSTIME, &its, NULL);
|
r = timerfd_settime(libinput->timer.fd, TFD_TIMER_ABSTIME, &its, NULL);
|
||||||
|
|
@ -88,33 +87,38 @@ libinput_timer_arm_timer_fd(struct libinput *libinput)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
libinput_timer_set_flags(struct libinput_timer *timer, uint64_t expire, uint32_t flags)
|
libinput_timer_set_flags(struct libinput_timer *timer, usec_t expire, uint32_t flags)
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
/* We only warn if we're more than 20ms behind */
|
/* We only warn if we're more than 20ms behind */
|
||||||
const uint64_t timer_warning_limit = ms2us(20);
|
const usec_t timer_warning_limit = usec_from_millis(20);
|
||||||
uint64_t now = libinput_now(timer->libinput);
|
usec_t now = libinput_now(timer->libinput);
|
||||||
if (expire < now) {
|
if (usec_cmp(expire, now) < 0) {
|
||||||
|
usec_t tdelta = usec_delta(now, expire);
|
||||||
if ((flags & TIMER_FLAG_ALLOW_NEGATIVE) == 0 &&
|
if ((flags & TIMER_FLAG_ALLOW_NEGATIVE) == 0 &&
|
||||||
now - expire > timer_warning_limit)
|
usec_cmp(tdelta, timer_warning_limit) > 0)
|
||||||
log_bug_client_ratelimit(
|
log_bug_client_ratelimit(
|
||||||
timer->libinput,
|
timer->libinput,
|
||||||
&timer->libinput->timer.expiry_in_past_limit,
|
&timer->libinput->timer.expiry_in_past_limit,
|
||||||
"timer %s: scheduled expiry is in the past (-%dms), your system is too slow\n",
|
"timer %s: scheduled expiry is in the past (-%dms), your system is too slow\n",
|
||||||
timer->timer_name,
|
timer->timer_name,
|
||||||
us2ms(now - expire));
|
usec_to_millis(tdelta));
|
||||||
} else if ((expire - now) > ms2us(5000)) {
|
} else {
|
||||||
log_bug_libinput(timer->libinput,
|
usec_t tdelta = usec_delta(expire, now);
|
||||||
"timer %s: offset more than 5s, now %d expire %d\n",
|
if (usec_cmp(tdelta, usec_from_millis(5000)) > 0) {
|
||||||
timer->timer_name,
|
log_bug_libinput(
|
||||||
us2ms(now),
|
timer->libinput,
|
||||||
us2ms(expire));
|
"timer %s: offset more than 5s, now %d expire %d\n",
|
||||||
|
timer->timer_name,
|
||||||
|
usec_to_millis(now),
|
||||||
|
usec_to_millis(expire));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(expire);
|
assert(usec_ne(expire, 0));
|
||||||
|
|
||||||
if (!timer->expire)
|
if (usec_is_zero(timer->expire))
|
||||||
list_insert(&timer->libinput->timer.list, &timer->link);
|
list_insert(&timer->libinput->timer.list, &timer->link);
|
||||||
|
|
||||||
timer->expire = expire;
|
timer->expire = expire;
|
||||||
|
|
@ -122,7 +126,7 @@ libinput_timer_set_flags(struct libinput_timer *timer, uint64_t expire, uint32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
libinput_timer_set(struct libinput_timer *timer, uint64_t expire)
|
libinput_timer_set(struct libinput_timer *timer, usec_t expire)
|
||||||
{
|
{
|
||||||
libinput_timer_set_flags(timer, expire, TIMER_FLAG_NONE);
|
libinput_timer_set_flags(timer, expire, TIMER_FLAG_NONE);
|
||||||
}
|
}
|
||||||
|
|
@ -130,25 +134,25 @@ libinput_timer_set(struct libinput_timer *timer, uint64_t expire)
|
||||||
void
|
void
|
||||||
libinput_timer_cancel(struct libinput_timer *timer)
|
libinput_timer_cancel(struct libinput_timer *timer)
|
||||||
{
|
{
|
||||||
if (!timer->expire)
|
if (usec_is_zero(timer->expire))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
timer->expire = 0;
|
timer->expire = usec_from_uint64_t(0);
|
||||||
list_remove(&timer->link);
|
list_remove(&timer->link);
|
||||||
libinput_timer_arm_timer_fd(timer->libinput);
|
libinput_timer_arm_timer_fd(timer->libinput);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
libinput_timer_handler(struct libinput *libinput, uint64_t now)
|
libinput_timer_handler(struct libinput *libinput, usec_t now)
|
||||||
{
|
{
|
||||||
struct libinput_timer *timer;
|
struct libinput_timer *timer;
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
list_for_each_safe(timer, &libinput->timer.list, link) {
|
list_for_each_safe(timer, &libinput->timer.list, link) {
|
||||||
if (timer->expire == 0)
|
if (usec_is_zero(timer->expire))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (timer->expire <= now) {
|
if (usec_cmp(timer->expire, now) <= 0) {
|
||||||
/* Clear the timer before calling timer_func,
|
/* Clear the timer before calling timer_func,
|
||||||
as timer_func may re-arm it */
|
as timer_func may re-arm it */
|
||||||
libinput_timer_cancel(timer);
|
libinput_timer_cancel(timer);
|
||||||
|
|
@ -171,7 +175,7 @@ static void
|
||||||
libinput_timer_dispatch(void *data)
|
libinput_timer_dispatch(void *data)
|
||||||
{
|
{
|
||||||
struct libinput *libinput = data;
|
struct libinput *libinput = data;
|
||||||
uint64_t now;
|
usec_t now;
|
||||||
uint64_t discard;
|
uint64_t discard;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
|
@ -183,7 +187,7 @@ libinput_timer_dispatch(void *data)
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
now = libinput_now(libinput);
|
now = libinput_now(libinput);
|
||||||
if (now == 0)
|
if (usec_is_zero(now))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
libinput_timer_handler(libinput, now);
|
libinput_timer_handler(libinput, now);
|
||||||
|
|
@ -243,23 +247,24 @@ libinput_timer_subsys_destroy(struct libinput *libinput)
|
||||||
* before this time. If so, trigger the timer func.
|
* before this time. If so, trigger the timer func.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
libinput_timer_flush(struct libinput *libinput, uint64_t now)
|
libinput_timer_flush(struct libinput *libinput, usec_t now)
|
||||||
{
|
{
|
||||||
if (libinput->timer.next_expiry == 0 || libinput->timer.next_expiry > now)
|
if (usec_is_zero(libinput->timer.next_expiry) ||
|
||||||
|
usec_cmp(libinput->timer.next_expiry, now) > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
libinput_timer_handler(libinput, now);
|
libinput_timer_handler(libinput, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
usec_t
|
||||||
libinput_now(struct libinput *libinput)
|
libinput_now(struct libinput *libinput)
|
||||||
{
|
{
|
||||||
uint64_t now;
|
usec_t now;
|
||||||
int rc = now_in_us(&now);
|
int rc = now_in_us(&now);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
log_error(libinput, "clock_gettime failed: %s\n", strerror(-rc));
|
log_error(libinput, "clock_gettime failed: %s\n", strerror(-rc));
|
||||||
return 0;
|
return usec_from_uint64_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return now;
|
return now;
|
||||||
|
|
|
||||||
14
src/timer.h
14
src/timer.h
|
|
@ -36,8 +36,8 @@ struct libinput_timer {
|
||||||
struct libinput *libinput;
|
struct libinput *libinput;
|
||||||
char *timer_name;
|
char *timer_name;
|
||||||
struct list link;
|
struct list link;
|
||||||
uint64_t expire; /* in absolute us CLOCK_MONOTONIC */
|
usec_t expire; /* in absolute us CLOCK_MONOTONIC */
|
||||||
void (*timer_func)(uint64_t now, void *timer_func_data);
|
void (*timer_func)(usec_t now, void *timer_func_data);
|
||||||
void *timer_func_data;
|
void *timer_func_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ void
|
||||||
libinput_timer_init(struct libinput_timer *timer,
|
libinput_timer_init(struct libinput_timer *timer,
|
||||||
struct libinput *libinput,
|
struct libinput *libinput,
|
||||||
const char *timer_name,
|
const char *timer_name,
|
||||||
void (*timer_func)(uint64_t now, void *timer_func_data),
|
void (*timer_func)(usec_t now, void *timer_func_data),
|
||||||
void *timer_func_data);
|
void *timer_func_data);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -53,7 +53,7 @@ libinput_timer_destroy(struct libinput_timer *timer);
|
||||||
|
|
||||||
/* Set timer expire time, in absolute us CLOCK_MONOTONIC */
|
/* Set timer expire time, in absolute us CLOCK_MONOTONIC */
|
||||||
void
|
void
|
||||||
libinput_timer_set(struct libinput_timer *timer, uint64_t expire);
|
libinput_timer_set(struct libinput_timer *timer, usec_t expire);
|
||||||
|
|
||||||
enum timer_flags {
|
enum timer_flags {
|
||||||
TIMER_FLAG_NONE = 0,
|
TIMER_FLAG_NONE = 0,
|
||||||
|
|
@ -61,7 +61,7 @@ enum timer_flags {
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
libinput_timer_set_flags(struct libinput_timer *timer, uint64_t expire, uint32_t flags);
|
libinput_timer_set_flags(struct libinput_timer *timer, usec_t expire, uint32_t flags);
|
||||||
|
|
||||||
void
|
void
|
||||||
libinput_timer_cancel(struct libinput_timer *timer);
|
libinput_timer_cancel(struct libinput_timer *timer);
|
||||||
|
|
@ -73,9 +73,9 @@ void
|
||||||
libinput_timer_subsys_destroy(struct libinput *libinput);
|
libinput_timer_subsys_destroy(struct libinput *libinput);
|
||||||
|
|
||||||
void
|
void
|
||||||
libinput_timer_flush(struct libinput *libinput, uint64_t now);
|
libinput_timer_flush(struct libinput *libinput, usec_t now);
|
||||||
|
|
||||||
uint64_t
|
usec_t
|
||||||
libinput_now(struct libinput *libinput);
|
libinput_now(struct libinput *libinput);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@
|
||||||
#include "util-time.h"
|
#include "util-time.h"
|
||||||
|
|
||||||
static inline struct input_event
|
static inline struct input_event
|
||||||
input_event_init(uint64_t time, unsigned int type, unsigned int code, int value)
|
input_event_init(usec_t time, unsigned int type, unsigned int code, int value)
|
||||||
{
|
{
|
||||||
struct input_event ev;
|
struct input_event ev;
|
||||||
struct timeval tval = us2tv(time);
|
struct timeval tval = usec_to_timeval(time);
|
||||||
|
|
||||||
ev.input_event_sec = tval.tv_sec;
|
ev.input_event_sec = tval.tv_sec;
|
||||||
ev.input_event_usec = tval.tv_usec;
|
ev.input_event_usec = tval.tv_usec;
|
||||||
|
|
@ -49,7 +49,7 @@ input_event_init(uint64_t time, unsigned int type, unsigned int code, int value)
|
||||||
return ev;
|
return ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t
|
static inline usec_t
|
||||||
input_event_time(const struct input_event *e)
|
input_event_time(const struct input_event *e)
|
||||||
{
|
{
|
||||||
struct timeval tval;
|
struct timeval tval;
|
||||||
|
|
@ -57,13 +57,13 @@ input_event_time(const struct input_event *e)
|
||||||
tval.tv_sec = e->input_event_sec;
|
tval.tv_sec = e->input_event_sec;
|
||||||
tval.tv_usec = e->input_event_usec;
|
tval.tv_usec = e->input_event_usec;
|
||||||
|
|
||||||
return tv2us(&tval);
|
return usec_from_timeval(&tval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
input_event_set_time(struct input_event *e, uint64_t time)
|
input_event_set_time(struct input_event *e, usec_t time)
|
||||||
{
|
{
|
||||||
struct timeval tval = us2tv(time);
|
struct timeval tval = usec_to_timeval(time);
|
||||||
|
|
||||||
e->input_event_sec = tval.tv_sec;
|
e->input_event_sec = tval.tv_sec;
|
||||||
e->input_event_usec = tval.tv_usec;
|
e->input_event_usec = tval.tv_usec;
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@
|
||||||
#include "util-time.h"
|
#include "util-time.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
ratelimit_init(struct ratelimit *r, uint64_t ival_us, unsigned int burst)
|
ratelimit_init(struct ratelimit *r, usec_t ival_us, unsigned int burst)
|
||||||
{
|
{
|
||||||
r->interval = ival_us;
|
r->interval = ival_us;
|
||||||
r->begin = 0;
|
r->begin = usec_from_millis(0);
|
||||||
r->burst = burst;
|
r->burst = burst;
|
||||||
r->num = 0;
|
r->num = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -56,15 +56,15 @@ enum ratelimit_state
|
||||||
ratelimit_test(struct ratelimit *r)
|
ratelimit_test(struct ratelimit *r)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
uint64_t utime;
|
|
||||||
|
|
||||||
if (r->interval <= 0 || r->burst <= 0)
|
if (usec_is_zero(r->interval) || r->burst <= 0)
|
||||||
return RATELIMIT_PASS;
|
return RATELIMIT_PASS;
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
utime = s2us(ts.tv_sec) + ns2us(ts.tv_nsec);
|
usec_t utime = usec_from_timespec(&ts);
|
||||||
|
|
||||||
if (r->begin <= 0 || r->begin + r->interval < utime) {
|
if (usec_is_zero(r->begin) ||
|
||||||
|
usec_cmp(usec_add(r->begin, r->interval), utime) < 0) {
|
||||||
/* reset counter */
|
/* reset counter */
|
||||||
r->begin = utime;
|
r->begin = utime;
|
||||||
r->num = 1;
|
r->num = 1;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "util-time.h"
|
||||||
|
|
||||||
enum ratelimit_state {
|
enum ratelimit_state {
|
||||||
RATELIMIT_EXCEEDED,
|
RATELIMIT_EXCEEDED,
|
||||||
RATELIMIT_THRESHOLD,
|
RATELIMIT_THRESHOLD,
|
||||||
|
|
@ -35,13 +37,13 @@ enum ratelimit_state {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ratelimit {
|
struct ratelimit {
|
||||||
uint64_t interval;
|
usec_t interval;
|
||||||
uint64_t begin;
|
usec_t begin;
|
||||||
unsigned int burst;
|
unsigned int burst;
|
||||||
unsigned int num;
|
unsigned int num;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
ratelimit_init(struct ratelimit *r, uint64_t ival_us, unsigned int burst);
|
ratelimit_init(struct ratelimit *r, usec_t ival_us, unsigned int burst);
|
||||||
enum ratelimit_state
|
enum ratelimit_state
|
||||||
ratelimit_test(struct ratelimit *r);
|
ratelimit_test(struct ratelimit *r);
|
||||||
|
|
|
||||||
230
src/util-time.h
230
src/util-time.h
|
|
@ -28,11 +28,153 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "util-macros.h"
|
#include "util-macros.h"
|
||||||
|
#include "util-newtype.h"
|
||||||
|
|
||||||
|
DECLARE_NEWTYPE(usec, uint64_t);
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_from_millis(uint32_t millis)
|
||||||
|
{
|
||||||
|
return usec_from_uint64_t(millis * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_from_seconds(uint32_t secs)
|
||||||
|
{
|
||||||
|
return usec_from_millis(secs * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_from_hours(uint32_t hours)
|
||||||
|
{
|
||||||
|
return usec_from_seconds(hours * 3600);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
usec_to_millis(usec_t us)
|
||||||
|
{
|
||||||
|
return usec_as_uint64_t(us) / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
usec_to_seconds(usec_t us)
|
||||||
|
{
|
||||||
|
return usec_as_uint64_t(us) / 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
usec_to_minutes(usec_t us)
|
||||||
|
{
|
||||||
|
return usec_to_seconds(us) / 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t
|
||||||
|
usec_to_hours(usec_t us)
|
||||||
|
{
|
||||||
|
return usec_to_minutes(us) / 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_add_millis(usec_t us, uint32_t millis)
|
||||||
|
{
|
||||||
|
return usec_from_uint64_t(usec_as_uint64_t(us) + millis * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_delta(usec_t later, usec_t earlier)
|
||||||
|
{
|
||||||
|
return usec_from_uint64_t(later.v - earlier.v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline double
|
||||||
|
us2ms_f(usec_t us)
|
||||||
|
{
|
||||||
|
return (double)usec_as_uint64_t(us) / 1000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_from_timeval(const struct timeval *tv)
|
||||||
|
{
|
||||||
|
return usec_from_uint64_t(tv->tv_sec * 1000000 + tv->tv_usec);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_from_timespec(const struct timespec *tp)
|
||||||
|
{
|
||||||
|
return usec_from_uint64_t(tp->tv_sec * 1000000 + tp->tv_nsec / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_from_now(void)
|
||||||
|
{
|
||||||
|
struct timespec ts = { 0, 0 };
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
|
||||||
|
return usec_from_timespec(&ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct timeval
|
||||||
|
usec_to_timeval(usec_t time)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
uint64_t time_us = usec_as_uint64_t(time);
|
||||||
|
uint64_t one_sec_us = usec_as_uint64_t(usec_from_millis(1000));
|
||||||
|
|
||||||
|
tv.tv_sec = time_us / one_sec_us;
|
||||||
|
tv.tv_usec = time_us % one_sec_us;
|
||||||
|
|
||||||
|
return tv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct timespec
|
||||||
|
usec_to_timespec(usec_t time)
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
uint64_t time_us = usec_as_uint64_t(time);
|
||||||
|
uint64_t one_sec_us = usec_as_uint64_t(usec_from_millis(1000));
|
||||||
|
|
||||||
|
ts.tv_sec = time_us / one_sec_us;
|
||||||
|
ts.tv_nsec = (time_us % one_sec_us) * 1000;
|
||||||
|
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_add(usec_t a, usec_t b)
|
||||||
|
{
|
||||||
|
return usec_from_uint64_t(usec_as_uint64_t(a) + usec_as_uint64_t(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_sub(usec_t a, usec_t b)
|
||||||
|
{
|
||||||
|
return usec_from_uint64_t(usec_as_uint64_t(a) - usec_as_uint64_t(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_div(usec_t a, uint64_t b)
|
||||||
|
{
|
||||||
|
return usec_from_uint64_t(usec_as_uint64_t(a) / b);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline usec_t
|
||||||
|
usec_mul(usec_t a, double b)
|
||||||
|
{
|
||||||
|
return usec_from_uint64_t(usec_as_uint64_t(a) * b);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
usec_is_zero(usec_t a)
|
||||||
|
{
|
||||||
|
return usec_as_uint64_t(a) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
msleep(unsigned int ms)
|
msleep(unsigned int ms)
|
||||||
|
|
@ -40,94 +182,18 @@ msleep(unsigned int ms)
|
||||||
usleep(ms * 1000);
|
usleep(ms * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 uint32_t
|
|
||||||
ms2s(uint64_t ms)
|
|
||||||
{
|
|
||||||
return ms / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t
|
|
||||||
s2us(uint64_t s)
|
|
||||||
{
|
|
||||||
return ms2us(s * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t
|
|
||||||
h2us(uint64_t h)
|
|
||||||
{
|
|
||||||
return s2us(h * 3600);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t
|
|
||||||
us2ms(uint64_t us)
|
|
||||||
{
|
|
||||||
return (uint32_t)(us / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t
|
|
||||||
us2s(uint64_t us)
|
|
||||||
{
|
|
||||||
return ms2s(us2ms(us));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline double
|
|
||||||
us2ms_f(uint64_t us)
|
|
||||||
{
|
|
||||||
return (double)us / 1000.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t
|
|
||||||
tv2us(const struct timeval *tv)
|
|
||||||
{
|
|
||||||
return s2us(tv->tv_sec) + tv->tv_usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t
|
|
||||||
tp2us(const struct timespec *tp)
|
|
||||||
{
|
|
||||||
return s2us(tp->tv_sec) + ns2us(tp->tv_nsec);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 int
|
static inline int
|
||||||
now_in_us(uint64_t *us)
|
now_in_us(usec_t *us)
|
||||||
{
|
{
|
||||||
struct timespec ts = { 0, 0 };
|
struct timespec ts = { 0, 0 };
|
||||||
|
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
|
||||||
*us = 0;
|
*us = usec_from_uint64_t(0);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
*us = s2us(ts.tv_sec) + ns2us(ts.tv_nsec);
|
*us = usec_from_timespec(&ts);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,7 +206,7 @@ struct human_time {
|
||||||
* Converts a time delta in µs to a human-readable time like "2h" or "4d"
|
* Converts a time delta in µs to a human-readable time like "2h" or "4d"
|
||||||
*/
|
*/
|
||||||
static inline struct human_time
|
static inline struct human_time
|
||||||
to_human_time(uint64_t us)
|
to_human_time(usec_t us)
|
||||||
{
|
{
|
||||||
struct human_time t;
|
struct human_time t;
|
||||||
struct c {
|
struct c {
|
||||||
|
|
@ -151,7 +217,7 @@ to_human_time(uint64_t us)
|
||||||
{ "us", 1, 5000 }, { "ms", 1000, 5000 }, { "s", 1000, 120 },
|
{ "us", 1, 5000 }, { "ms", 1000, 5000 }, { "s", 1000, 120 },
|
||||||
{ "min", 60, 120 }, { "h", 60, 48 }, { "d", 24, ~0 },
|
{ "min", 60, 120 }, { "h", 60, 48 }, { "d", 24, ~0 },
|
||||||
};
|
};
|
||||||
uint64_t value = us;
|
uint64_t value = usec_as_uint64_t(us);
|
||||||
|
|
||||||
ARRAY_FOR_EACH(conversion, c) {
|
ARRAY_FOR_EACH(conversion, c) {
|
||||||
value = value / c->change_from_previous;
|
value = value / c->change_from_previous;
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,8 @@ struct litest_runner_test {
|
||||||
int timerfd;
|
int timerfd;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint64_t start_millis;
|
usec_t start_usec;
|
||||||
uint64_t end_millis;
|
usec_t end_usec;
|
||||||
} times;
|
} times;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ struct litest_runner {
|
||||||
struct {
|
struct {
|
||||||
time_t start;
|
time_t start;
|
||||||
time_t end;
|
time_t end;
|
||||||
uint64_t start_millis;
|
usec_t start_usec;
|
||||||
} times;
|
} times;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -442,9 +442,9 @@ litest_runner_test_collect_child(struct litest_runner_test *t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t now = 0;
|
usec_t now = usec_from_uint64_t(0);
|
||||||
now_in_us(&now);
|
now_in_us(&now);
|
||||||
t->times.end_millis = us2ms(now);
|
t->times.end_usec = now;
|
||||||
|
|
||||||
if (RUNNING_ON_VALGRIND) {
|
if (RUNNING_ON_VALGRIND) {
|
||||||
_autofree_ char *filename = valgrind_logfile(t->pid);
|
_autofree_ char *filename = valgrind_logfile(t->pid);
|
||||||
|
|
@ -628,9 +628,9 @@ litest_runner_run_test(struct litest_runner *runner, struct litest_runner_test *
|
||||||
|
|
||||||
t->result = LITEST_SYSTEM_ERROR;
|
t->result = LITEST_SYSTEM_ERROR;
|
||||||
|
|
||||||
uint64_t now = 0;
|
usec_t now = usec_from_uint64_t(0);
|
||||||
now_in_us(&now);
|
now_in_us(&now);
|
||||||
t->times.start_millis = us2ms(now);
|
t->times.start_usec = now;
|
||||||
|
|
||||||
if (runner->max_forks == 0) {
|
if (runner->max_forks == 0) {
|
||||||
if (use_jmpbuf && setjmp(jmpbuf) == 0) {
|
if (use_jmpbuf && setjmp(jmpbuf) == 0) {
|
||||||
|
|
@ -772,12 +772,14 @@ litest_runner_log_test_result(struct litest_runner *runner,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usec_t delta = usec_delta(t->times.end_usec, t->times.start_usec);
|
||||||
|
usec_t total_delta = usec_delta(t->times.end_usec, runner->times.start_usec);
|
||||||
fprintf(runner->fp,
|
fprintf(runner->fp,
|
||||||
" duration: %" PRIu64 " # (ms), total test run time: %02" PRIu32
|
" duration: %d # (ms), total test run time: %02" PRIu32
|
||||||
":%02" PRIu32 "\n",
|
":%02" PRIu32 "\n",
|
||||||
t->times.end_millis - t->times.start_millis,
|
usec_to_millis(delta),
|
||||||
(ms2s(t->times.end_millis - runner->times.start_millis)) / 60,
|
usec_to_minutes(total_delta),
|
||||||
(ms2s(t->times.end_millis - runner->times.start_millis)) % 60);
|
usec_to_seconds(total_delta) % 60);
|
||||||
|
|
||||||
status = litest_runner_result_as_str(t->result);
|
status = litest_runner_result_as_str(t->result);
|
||||||
fprintf(runner->fp,
|
fprintf(runner->fp,
|
||||||
|
|
@ -921,9 +923,9 @@ litest_runner_check_finished_tests(struct litest_runner *runner)
|
||||||
if (r == -EAGAIN)
|
if (r == -EAGAIN)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uint64_t now = 0;
|
usec_t now = usec_from_uint64_t(0);
|
||||||
now_in_us(&now);
|
now_in_us(&now);
|
||||||
running->times.end_millis = us2ms(now);
|
running->times.end_usec = now;
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
litest_runner_test_update_errno(running, -r);
|
litest_runner_test_update_errno(running, -r);
|
||||||
|
|
@ -985,10 +987,10 @@ litest_runner_run_tests(struct litest_runner *runner)
|
||||||
|
|
||||||
setup_sighandler(SIGINT);
|
setup_sighandler(SIGINT);
|
||||||
|
|
||||||
uint64_t now = 0;
|
usec_t now = usec_from_uint64_t(0);
|
||||||
now_in_us(&now);
|
now_in_us(&now);
|
||||||
|
|
||||||
runner->times.start_millis = us2ms(now);
|
runner->times.start_usec = now;
|
||||||
runner->times.start = time(NULL);
|
runner->times.start = time(NULL);
|
||||||
ltime = localtime(&runner->times.start);
|
ltime = localtime(&runner->times.start);
|
||||||
strftime(timestamp, sizeof(timestamp), "%FT%H:%M", ltime);
|
strftime(timestamp, sizeof(timestamp), "%FT%H:%M", ltime);
|
||||||
|
|
|
||||||
|
|
@ -3513,9 +3513,9 @@ _litest_wait_for_event_of_type(struct libinput *li, const char *func, int lineno
|
||||||
fds.revents = 0;
|
fds.revents = 0;
|
||||||
|
|
||||||
const int timeout = 2000;
|
const int timeout = 2000;
|
||||||
uint64_t expiry = 0;
|
usec_t expiry = usec_from_uint64_t(0);
|
||||||
int rc = now_in_us(&expiry);
|
int rc = now_in_us(&expiry);
|
||||||
expiry += ms2us(timeout);
|
expiry = usec_add_millis(expiry, timeout);
|
||||||
litest_assert_errno_success(rc);
|
litest_assert_errno_success(rc);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
@ -3530,9 +3530,9 @@ _litest_wait_for_event_of_type(struct libinput *li, const char *func, int lineno
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == LIBINPUT_EVENT_NONE) {
|
if (type == LIBINPUT_EVENT_NONE) {
|
||||||
uint64_t now;
|
usec_t now;
|
||||||
now_in_us(&now);
|
now_in_us(&now);
|
||||||
if (now > expiry) {
|
if (usec_cmp(now, expiry) > 0) {
|
||||||
_litest_abort_msg(
|
_litest_abort_msg(
|
||||||
NULL,
|
NULL,
|
||||||
lineno,
|
lineno,
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ START_TEST(lua_test_libinput_now)
|
||||||
LIBINPUT_PLUGIN_SYSTEM_FLAG_NONE);
|
LIBINPUT_PLUGIN_SYSTEM_FLAG_NONE);
|
||||||
litest_drain_events(li);
|
litest_drain_events(li);
|
||||||
|
|
||||||
uint64_t test_now;
|
usec_t test_now;
|
||||||
int rc = now_in_us(&test_now);
|
int rc = now_in_us(&test_now);
|
||||||
litest_assert_neg_errno_success(rc);
|
litest_assert_neg_errno_success(rc);
|
||||||
|
|
||||||
|
|
@ -290,10 +290,12 @@ START_TEST(lua_test_libinput_now)
|
||||||
|
|
||||||
uint64_t plugin_now = strtoull(tokens[1], NULL, 10);
|
uint64_t plugin_now = strtoull(tokens[1], NULL, 10);
|
||||||
|
|
||||||
litest_assert_int_le(plugin_now, test_now);
|
litest_assert_int_le(plugin_now, usec_as_uint64_t(test_now));
|
||||||
/* Even a slow test runner hopefully doesn't take >300ms to get to the
|
/* Even a slow test runner hopefully doesn't take >300ms to get to the
|
||||||
* log print */
|
* log print */
|
||||||
litest_assert_int_gt(plugin_now, test_now - ms2us(300));
|
litest_assert_int_gt(
|
||||||
|
plugin_now,
|
||||||
|
usec_as_uint64_t(usec_sub(test_now, usec_from_millis(300))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
@ -308,12 +310,12 @@ START_TEST(lua_test_libinput_timer)
|
||||||
_autofree_ char *timeout =
|
_autofree_ char *timeout =
|
||||||
strdup_printf("%s%" PRIu64,
|
strdup_printf("%s%" PRIu64,
|
||||||
streq(mode, "absolute") ? "libinput:now() + " : "",
|
streq(mode, "absolute") ? "libinput:now() + " : "",
|
||||||
ms2us(100));
|
usec_as_uint64_t(usec_from_millis(100)));
|
||||||
_autofree_ char *reschedule_timeout =
|
_autofree_ char *reschedule_timeout =
|
||||||
strdup_printf("libinput:timer_set_%s(%s%" PRIu64 ")\n",
|
strdup_printf("libinput:timer_set_%s(%s%" PRIu64 ")\n",
|
||||||
mode,
|
mode,
|
||||||
streq(mode, "absolute") ? "t + " : "",
|
streq(mode, "absolute") ? "t + " : "",
|
||||||
ms2us(100));
|
usec_as_uint64_t(usec_from_millis(100)));
|
||||||
_autofree_ char *lua = strdup_printf(
|
_autofree_ char *lua = strdup_printf(
|
||||||
"libinput:register({1})\n"
|
"libinput:register({1})\n"
|
||||||
"libinput:connect(\"timer-expired\",\n"
|
"libinput:connect(\"timer-expired\",\n"
|
||||||
|
|
@ -343,7 +345,7 @@ START_TEST(lua_test_libinput_timer)
|
||||||
msleep(100);
|
msleep(100);
|
||||||
libinput_dispatch(li);
|
libinput_dispatch(li);
|
||||||
|
|
||||||
uint64_t test_now;
|
usec_t test_now;
|
||||||
int rc = now_in_us(&test_now);
|
int rc = now_in_us(&test_now);
|
||||||
litest_assert_neg_errno_success(rc);
|
litest_assert_neg_errno_success(rc);
|
||||||
|
|
||||||
|
|
@ -358,10 +360,13 @@ START_TEST(lua_test_libinput_timer)
|
||||||
litest_assert_int_eq(nelem, 2U);
|
litest_assert_int_eq(nelem, 2U);
|
||||||
|
|
||||||
uint64_t plugin_now = strtoull(tokens[1], NULL, 10);
|
uint64_t plugin_now = strtoull(tokens[1], NULL, 10);
|
||||||
litest_assert_int_le(plugin_now, test_now);
|
litest_assert_int_le(plugin_now, usec_as_uint64_t(test_now));
|
||||||
/* Even a slow test runner hopefully doesn't take >300ms between
|
/* Even a slow test runner hopefully doesn't take >300ms between
|
||||||
* dispatch and now_in_us */
|
* dispatch and now_in_us */
|
||||||
litest_assert_int_gt(plugin_now, test_now - ms2us(300));
|
litest_assert_int_gt(
|
||||||
|
plugin_now,
|
||||||
|
usec_as_uint64_t(
|
||||||
|
usec_sub(test_now, usec_from_millis(300))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!reschedule) {
|
if (!reschedule) {
|
||||||
|
|
@ -547,7 +552,7 @@ START_TEST(lua_frame_handler)
|
||||||
_destroy_(litest_device) *device = litest_add_device(li, LITEST_MOUSE);
|
_destroy_(litest_device) *device = litest_add_device(li, LITEST_MOUSE);
|
||||||
litest_drain_events(li);
|
litest_drain_events(li);
|
||||||
|
|
||||||
uint64_t before, after;
|
usec_t before, after;
|
||||||
now_in_us(&before);
|
now_in_us(&before);
|
||||||
msleep(1);
|
msleep(1);
|
||||||
litest_button_click_debounced(device, li, BTN_LEFT, 1);
|
litest_button_click_debounced(device, li, BTN_LEFT, 1);
|
||||||
|
|
@ -580,8 +585,8 @@ START_TEST(lua_frame_handler)
|
||||||
char *strtime = split[nelems - 1];
|
char *strtime = split[nelems - 1];
|
||||||
uint64_t timestamp = 0;
|
uint64_t timestamp = 0;
|
||||||
litest_assert(safe_atou64(strtime, ×tamp));
|
litest_assert(safe_atou64(strtime, ×tamp));
|
||||||
litest_assert_int_gt(timestamp, before);
|
litest_assert_int_gt(timestamp, usec_as_uint64_t(before));
|
||||||
litest_assert_int_lt(timestamp, after);
|
litest_assert_int_lt(timestamp, usec_as_uint64_t(after));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
START_TEST(auto_test)
|
START_TEST(auto_test)
|
||||||
{
|
{
|
||||||
/* This one is just a compile test */
|
/* This one is just a compile test */
|
||||||
auto tv = us2tv(0);
|
auto tv = usec_to_timeval(usec_from_uint64_t(0));
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
litest_assert_int_eq(tv.tv_sec, 0);
|
litest_assert_int_eq(tv.tv_sec, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -605,7 +605,7 @@ START_TEST(ratelimit_helpers)
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
/* 10 attempts every 1000ms */
|
/* 10 attempts every 1000ms */
|
||||||
ratelimit_init(&rl, ms2us(1000), 10);
|
ratelimit_init(&rl, usec_from_millis(1000), 10);
|
||||||
|
|
||||||
for (j = 0; j < 3; ++j) {
|
for (j = 0; j < 3; ++j) {
|
||||||
/* a burst of 9 attempts must succeed */
|
/* a burst of 9 attempts must succeed */
|
||||||
|
|
@ -1165,12 +1165,125 @@ END_TEST
|
||||||
|
|
||||||
START_TEST(time_conversion)
|
START_TEST(time_conversion)
|
||||||
{
|
{
|
||||||
litest_assert_int_eq(us(10), 10U);
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_uint64_t(0)), 0U);
|
||||||
litest_assert_int_eq(ns2us(10000), 10U);
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_uint64_t(12345)), 12345U);
|
||||||
litest_assert_int_eq(ms2us(10), 10000U);
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_uint64_t(999999)), 999999U);
|
||||||
litest_assert_int_eq(s2us(1), 1000000U);
|
|
||||||
litest_assert_int_eq(h2us(2), s2us(2 * 60 * 60));
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_millis(0)), 0U);
|
||||||
litest_assert_int_eq(us2ms(10000), 10U);
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_millis(1)), 1000U);
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_millis(10)), 10000U);
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_millis(1000)), 1000000U);
|
||||||
|
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_seconds(0)), 0U);
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_seconds(1)), 1000000U);
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_seconds(10)), 10000000U);
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_seconds(60)), 60000000U);
|
||||||
|
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_hours(0)), 0ULL);
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_hours(1)), 3600000000ULL);
|
||||||
|
|
||||||
|
{
|
||||||
|
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_timeval(&tv)), 0U);
|
||||||
|
|
||||||
|
tv.tv_sec = 1;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_timeval(&tv)),
|
||||||
|
1000000U);
|
||||||
|
|
||||||
|
tv.tv_sec = 1;
|
||||||
|
tv.tv_usec = 234567;
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_timeval(&tv)),
|
||||||
|
1234567U);
|
||||||
|
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 999999;
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_timeval(&tv)), 999999U);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_timespec(&ts)), 0U);
|
||||||
|
|
||||||
|
ts.tv_sec = 1;
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_timespec(&ts)),
|
||||||
|
1000000U);
|
||||||
|
|
||||||
|
ts.tv_sec = 1;
|
||||||
|
ts.tv_nsec = 234567000;
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_timespec(&ts)),
|
||||||
|
1234567U);
|
||||||
|
|
||||||
|
ts.tv_sec = 0;
|
||||||
|
ts.tv_nsec = 999999000;
|
||||||
|
litest_assert_int_eq(usec_as_uint64_t(usec_from_timespec(&ts)),
|
||||||
|
999999U);
|
||||||
|
}
|
||||||
|
|
||||||
|
litest_assert_int_eq(usec_to_millis(usec_from_uint64_t(0)), 0U);
|
||||||
|
litest_assert_int_eq(usec_to_millis(usec_from_uint64_t(1000)), 1U);
|
||||||
|
litest_assert_int_eq(usec_to_millis(usec_from_uint64_t(10000)), 10U);
|
||||||
|
litest_assert_int_eq(usec_to_millis(usec_from_uint64_t(123456)), 123U);
|
||||||
|
litest_assert_int_eq(usec_to_millis(usec_from_uint64_t(999)), 0U);
|
||||||
|
|
||||||
|
litest_assert_int_eq(usec_to_seconds(usec_from_uint64_t(0)), 0U);
|
||||||
|
litest_assert_int_eq(usec_to_seconds(usec_from_uint64_t(1000000)), 1U);
|
||||||
|
litest_assert_int_eq(usec_to_seconds(usec_from_uint64_t(5000000)), 5U);
|
||||||
|
litest_assert_int_eq(usec_to_seconds(usec_from_uint64_t(60000000)), 60U);
|
||||||
|
litest_assert_int_eq(usec_to_seconds(usec_from_uint64_t(999999)), 0U);
|
||||||
|
|
||||||
|
litest_assert_int_eq(usec_to_minutes(usec_from_uint64_t(0)), 0U);
|
||||||
|
litest_assert_int_eq(usec_to_minutes(usec_from_uint64_t(60000000)), 1U);
|
||||||
|
litest_assert_int_eq(usec_to_minutes(usec_from_uint64_t(120000000)), 2U);
|
||||||
|
litest_assert_int_eq(usec_to_minutes(usec_from_uint64_t(3600000000)), 60U);
|
||||||
|
litest_assert_int_eq(usec_to_minutes(usec_from_uint64_t(59999999)), 0U);
|
||||||
|
|
||||||
|
litest_assert_int_eq(usec_to_hours(usec_from_uint64_t(0)), 0U);
|
||||||
|
litest_assert_int_eq(usec_to_hours(usec_from_uint64_t(3600000000)), 1U);
|
||||||
|
litest_assert_int_eq(usec_to_hours(usec_from_uint64_t(7200000000)), 2U);
|
||||||
|
litest_assert_int_eq(usec_to_hours(usec_from_uint64_t(86400000000)), 24U);
|
||||||
|
litest_assert_int_eq(usec_to_hours(usec_from_uint64_t(3599999999)), 0U);
|
||||||
|
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
tv = usec_to_timeval(usec_from_uint64_t(0));
|
||||||
|
litest_assert_int_eq(tv.tv_sec, 0);
|
||||||
|
litest_assert_int_eq(tv.tv_usec, 0);
|
||||||
|
|
||||||
|
tv = usec_to_timeval(usec_from_uint64_t(1000000));
|
||||||
|
litest_assert_int_eq(tv.tv_sec, 1);
|
||||||
|
litest_assert_int_eq(tv.tv_usec, 0);
|
||||||
|
|
||||||
|
tv = usec_to_timeval(usec_from_uint64_t(1234567));
|
||||||
|
litest_assert_int_eq(tv.tv_sec, 1);
|
||||||
|
litest_assert_int_eq(tv.tv_usec, 234567);
|
||||||
|
|
||||||
|
tv = usec_to_timeval(usec_from_uint64_t(999999));
|
||||||
|
litest_assert_int_eq(tv.tv_sec, 0);
|
||||||
|
litest_assert_int_eq(tv.tv_usec, 999999);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
ts = usec_to_timespec(usec_from_uint64_t(0));
|
||||||
|
litest_assert_int_eq(ts.tv_sec, 0);
|
||||||
|
litest_assert_int_eq(ts.tv_nsec, 0);
|
||||||
|
|
||||||
|
ts = usec_to_timespec(usec_from_uint64_t(1000000));
|
||||||
|
litest_assert_int_eq(ts.tv_sec, 1);
|
||||||
|
litest_assert_int_eq(ts.tv_nsec, 0);
|
||||||
|
|
||||||
|
ts = usec_to_timespec(usec_from_uint64_t(1234567));
|
||||||
|
litest_assert_int_eq(ts.tv_sec, 1);
|
||||||
|
litest_assert_int_eq(ts.tv_nsec, 234567000);
|
||||||
|
|
||||||
|
ts = usec_to_timespec(usec_from_uint64_t(999999));
|
||||||
|
litest_assert_int_eq(ts.tv_sec, 0);
|
||||||
|
litest_assert_int_eq(ts.tv_nsec, 999999000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
@ -1178,23 +1291,23 @@ START_TEST(human_time)
|
||||||
{
|
{
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
struct ht_tests {
|
struct ht_tests {
|
||||||
uint64_t interval;
|
usec_t interval;
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
const char *unit;
|
const char *unit;
|
||||||
} tests[] = {
|
} tests[] = {
|
||||||
{ 0, 0, "us" },
|
{ usec_from_uint64_t(0), 0, "us" },
|
||||||
{ 123, 123, "us" },
|
{ usec_from_uint64_t(123), 123, "us" },
|
||||||
{ ms2us(5), 5, "ms" },
|
{ usec_from_millis(5), 5, "ms" },
|
||||||
{ ms2us(100), 100, "ms" },
|
{ usec_from_millis(100), 100, "ms" },
|
||||||
{ s2us(5), 5, "s" },
|
{ usec_from_seconds(5), 5, "s" },
|
||||||
{ s2us(100), 100, "s" },
|
{ usec_from_seconds(100), 100, "s" },
|
||||||
{ s2us(120), 2, "min" },
|
{ usec_from_seconds(120), 2, "min" },
|
||||||
{ 5 * s2us(60), 5, "min" },
|
{ usec_mul(usec_from_seconds(60), 5), 5, "min" },
|
||||||
{ 120 * s2us(60), 2, "h" },
|
{ usec_mul(usec_from_seconds(60), 120), 2, "h" },
|
||||||
{ 5 * 60 * s2us(60), 5, "h" },
|
{ usec_mul(usec_from_seconds(60), 5 * 60), 5, "h" },
|
||||||
{ 48 * 60 * s2us(60), 2, "d" },
|
{ usec_mul(usec_from_seconds(60), 48 * 60), 2, "d" },
|
||||||
{ 1000 * 24 * 60 * s2us(60), 1000, "d" },
|
{ usec_mul(usec_from_seconds(60), 1000 * 24 * 60), 1000, "d" },
|
||||||
{ 0, 0, NULL },
|
{ usec_from_uint64_t(0), 0, NULL },
|
||||||
};
|
};
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
for (int i = 0; tests[i].unit != NULL; i++) {
|
for (int i = 0; tests[i].unit != NULL; i++) {
|
||||||
|
|
@ -3006,7 +3119,8 @@ START_TEST(evdev_frames)
|
||||||
litest_assert_int_eq(evdev_frame_get_count(frame), 2U);
|
litest_assert_int_eq(evdev_frame_get_count(frame), 2U);
|
||||||
|
|
||||||
/* We never appended a timestamp */
|
/* We never appended a timestamp */
|
||||||
litest_assert_int_eq(evdev_frame_get_time(frame), 0U);
|
litest_assert(usec_cmp(evdev_frame_get_time(frame),
|
||||||
|
usec_from_uint64_t(0)) == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
struct evdev_event events[] = {
|
struct evdev_event events[] = {
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ struct record_context {
|
||||||
int timeout;
|
int timeout;
|
||||||
bool show_keycodes;
|
bool show_keycodes;
|
||||||
|
|
||||||
uint64_t offset;
|
usec_t offset;
|
||||||
|
|
||||||
/* The first device to be added */
|
/* The first device to be added */
|
||||||
struct record_device *first_device;
|
struct record_device *first_device;
|
||||||
|
|
@ -222,10 +222,11 @@ iprintf(FILE *fp, enum indent indent, const char *format, ...)
|
||||||
assert(rc != -1 && (unsigned int)rc > indent);
|
assert(rc != -1 && (unsigned int)rc > indent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t
|
static usec_t
|
||||||
time_offset(struct record_context *ctx, uint64_t time)
|
time_offset(struct record_context *ctx, usec_t time)
|
||||||
{
|
{
|
||||||
return ctx->offset ? time - ctx->offset : 0;
|
return !usec_is_zero(ctx->offset) ? usec_sub(time, ctx->offset)
|
||||||
|
: usec_from_uint64_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -234,7 +235,7 @@ print_evdev_event(struct record_device *dev, struct input_event *ev)
|
||||||
const char *tname, *cname;
|
const char *tname, *cname;
|
||||||
bool was_modified = false;
|
bool was_modified = false;
|
||||||
char desc[1024];
|
char desc[1024];
|
||||||
uint64_t time = input_event_time(ev) - dev->ctx->offset;
|
usec_t time = usec_sub(input_event_time(ev), dev->ctx->offset);
|
||||||
|
|
||||||
input_event_set_time(ev, time);
|
input_event_set_time(ev, time);
|
||||||
|
|
||||||
|
|
@ -252,19 +253,17 @@ print_evdev_event(struct record_device *dev, struct input_event *ev)
|
||||||
cname,
|
cname,
|
||||||
ev->value);
|
ev->value);
|
||||||
} else if (ev->type == EV_SYN) {
|
} else if (ev->type == EV_SYN) {
|
||||||
static unsigned long last_ms = 0;
|
static usec_t last_time = { 0 };
|
||||||
unsigned long time, dt;
|
|
||||||
|
|
||||||
time = us2ms(input_event_time(ev));
|
usec_t time = input_event_time(ev);
|
||||||
dt = time - last_ms;
|
usec_t dt = usec_delta(time, last_time);
|
||||||
last_ms = time;
|
|
||||||
|
|
||||||
snprintf(desc,
|
snprintf(desc,
|
||||||
sizeof(desc),
|
sizeof(desc),
|
||||||
"------------ %s (%d) ---------- %+ldms",
|
"------------ %s (%d) ---------- %+dms",
|
||||||
cname,
|
cname,
|
||||||
ev->value,
|
ev->value,
|
||||||
dt);
|
usec_to_millis(dt));
|
||||||
} else if (ev->type == EV_ABS) {
|
} else if (ev->type == EV_ABS) {
|
||||||
int oldval = 0;
|
int oldval = 0;
|
||||||
enum { DELTA, SLOT_DELTA, NO_DELTA } want = DELTA;
|
enum { DELTA, SLOT_DELTA, NO_DELTA } want = DELTA;
|
||||||
|
|
@ -378,9 +377,8 @@ handle_evdev_frame(struct record_device *d)
|
||||||
iprintf(d->fp, I_EVENTTYPE, "- evdev:\n");
|
iprintf(d->fp, I_EVENTTYPE, "- evdev:\n");
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if (d->ctx->offset == 0) {
|
if (usec_is_zero(d->ctx->offset)) {
|
||||||
uint64_t time = input_event_time(&e);
|
d->ctx->offset = input_event_time(&e);
|
||||||
d->ctx->offset = time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_evdev_event(d, &e);
|
print_evdev_event(d, &e);
|
||||||
|
|
@ -445,7 +443,7 @@ print_key_event(struct record_device *dev, struct libinput_event *e)
|
||||||
struct libinput_event_keyboard *k = libinput_event_get_keyboard_event(e);
|
struct libinput_event_keyboard *k = libinput_event_get_keyboard_event(e);
|
||||||
enum libinput_key_state state;
|
enum libinput_key_state state;
|
||||||
uint32_t key;
|
uint32_t key;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
const char *type;
|
const char *type;
|
||||||
|
|
||||||
switch (libinput_event_get_type(e)) {
|
switch (libinput_event_get_type(e)) {
|
||||||
|
|
@ -456,7 +454,9 @@ print_key_event(struct record_device *dev, struct libinput_event *e)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_keyboard_get_time_usec(k));
|
time = time_offset(
|
||||||
|
dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_keyboard_get_time_usec(k)));
|
||||||
state = libinput_event_keyboard_get_key_state(k);
|
state = libinput_event_keyboard_get_key_state(k);
|
||||||
|
|
||||||
key = libinput_event_keyboard_get_key(k);
|
key = libinput_event_keyboard_get_key(k);
|
||||||
|
|
@ -465,9 +465,9 @@ print_key_event(struct record_device *dev, struct libinput_event *e)
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, key: %d, state: %s}\n",
|
"- {time: %d.%06ld, type: %s, key: %d, state: %s}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
key,
|
key,
|
||||||
state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
|
state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
|
||||||
|
|
@ -481,7 +481,7 @@ print_motion_event(struct record_device *dev, struct libinput_event *e)
|
||||||
y = libinput_event_pointer_get_dy(p);
|
y = libinput_event_pointer_get_dy(p);
|
||||||
double uax = libinput_event_pointer_get_dx_unaccelerated(p),
|
double uax = libinput_event_pointer_get_dx_unaccelerated(p),
|
||||||
uay = libinput_event_pointer_get_dy_unaccelerated(p);
|
uay = libinput_event_pointer_get_dy_unaccelerated(p);
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
const char *type;
|
const char *type;
|
||||||
|
|
||||||
switch (libinput_event_get_type(e)) {
|
switch (libinput_event_get_type(e)) {
|
||||||
|
|
@ -492,12 +492,13 @@ print_motion_event(struct record_device *dev, struct libinput_event *e)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_pointer_get_time_usec(p));
|
time = time_offset(dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_pointer_get_time_usec(p)));
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, delta: [%6.2f, %6.2f], unaccel: [%6.2f, %6.2f]}\n",
|
"- {time: %d.%06ld, type: %s, delta: [%6.2f, %6.2f], unaccel: [%6.2f, %6.2f]}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
|
@ -513,7 +514,7 @@ print_absmotion_event(struct record_device *dev, struct libinput_event *e)
|
||||||
y = libinput_event_pointer_get_absolute_y(p);
|
y = libinput_event_pointer_get_absolute_y(p);
|
||||||
double tx = libinput_event_pointer_get_absolute_x_transformed(p, 100),
|
double tx = libinput_event_pointer_get_absolute_x_transformed(p, 100),
|
||||||
ty = libinput_event_pointer_get_absolute_y_transformed(p, 100);
|
ty = libinput_event_pointer_get_absolute_y_transformed(p, 100);
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
const char *type;
|
const char *type;
|
||||||
|
|
||||||
switch (libinput_event_get_type(e)) {
|
switch (libinput_event_get_type(e)) {
|
||||||
|
|
@ -524,13 +525,14 @@ print_absmotion_event(struct record_device *dev, struct libinput_event *e)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_pointer_get_time_usec(p));
|
time = time_offset(dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_pointer_get_time_usec(p)));
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, point: [%6.2f, %6.2f], transformed: [%6.2f, %6.2f]}\n",
|
"- {time: %d.%06ld, type: %s, point: [%6.2f, %6.2f], transformed: [%6.2f, %6.2f]}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
|
@ -544,7 +546,7 @@ print_pointer_button_event(struct record_device *dev, struct libinput_event *e)
|
||||||
struct libinput_event_pointer *p = libinput_event_get_pointer_event(e);
|
struct libinput_event_pointer *p = libinput_event_get_pointer_event(e);
|
||||||
enum libinput_button_state state;
|
enum libinput_button_state state;
|
||||||
int button;
|
int button;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
const char *type;
|
const char *type;
|
||||||
|
|
||||||
switch (libinput_event_get_type(e)) {
|
switch (libinput_event_get_type(e)) {
|
||||||
|
|
@ -555,15 +557,16 @@ print_pointer_button_event(struct record_device *dev, struct libinput_event *e)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_pointer_get_time_usec(p));
|
time = time_offset(dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_pointer_get_time_usec(p)));
|
||||||
button = libinput_event_pointer_get_button(p);
|
button = libinput_event_pointer_get_button(p);
|
||||||
state = libinput_event_pointer_get_button_state(p);
|
state = libinput_event_pointer_get_button_state(p);
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, button: %d, state: %s, seat_count: %u}\n",
|
"- {time: %d.%06ld, type: %s, button: %d, state: %s, seat_count: %u}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
button,
|
button,
|
||||||
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
|
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
|
||||||
|
|
@ -574,7 +577,7 @@ static void
|
||||||
print_pointer_axis_event(struct record_device *dev, struct libinput_event *e)
|
print_pointer_axis_event(struct record_device *dev, struct libinput_event *e)
|
||||||
{
|
{
|
||||||
struct libinput_event_pointer *p = libinput_event_get_pointer_event(e);
|
struct libinput_event_pointer *p = libinput_event_get_pointer_event(e);
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
const char *type, *source;
|
const char *type, *source;
|
||||||
double h = 0, v = 0;
|
double h = 0, v = 0;
|
||||||
int hd = 0, vd = 0;
|
int hd = 0, vd = 0;
|
||||||
|
|
@ -587,7 +590,8 @@ print_pointer_axis_event(struct record_device *dev, struct libinput_event *e)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_pointer_get_time_usec(p));
|
time = time_offset(dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_pointer_get_time_usec(p)));
|
||||||
if (libinput_event_pointer_has_axis(p,
|
if (libinput_event_pointer_has_axis(p,
|
||||||
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
|
||||||
h = libinput_event_pointer_get_axis_value(
|
h = libinput_event_pointer_get_axis_value(
|
||||||
|
|
@ -625,9 +629,9 @@ print_pointer_axis_event(struct record_device *dev, struct libinput_event *e)
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, axes: [%2.2f, %2.2f], discrete: [%d, %d], source: %s}\n",
|
"- {time: %d.%06ld, type: %s, axes: [%2.2f, %2.2f], discrete: [%d, %d], source: %s}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
h,
|
h,
|
||||||
v,
|
v,
|
||||||
|
|
@ -644,7 +648,7 @@ print_touch_event(struct record_device *dev, struct libinput_event *e)
|
||||||
const char *type;
|
const char *type;
|
||||||
double x, y;
|
double x, y;
|
||||||
double tx, ty;
|
double tx, ty;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
int32_t slot, seat_slot;
|
int32_t slot, seat_slot;
|
||||||
|
|
||||||
switch (etype) {
|
switch (etype) {
|
||||||
|
|
@ -667,7 +671,8 @@ print_touch_event(struct record_device *dev, struct libinput_event *e)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_touch_get_time_usec(t));
|
time = time_offset(dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_touch_get_time_usec(t)));
|
||||||
|
|
||||||
if (etype != LIBINPUT_EVENT_TOUCH_FRAME) {
|
if (etype != LIBINPUT_EVENT_TOUCH_FRAME) {
|
||||||
slot = libinput_event_touch_get_slot(t);
|
slot = libinput_event_touch_get_slot(t);
|
||||||
|
|
@ -679,8 +684,8 @@ print_touch_event(struct record_device *dev, struct libinput_event *e)
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s}\n",
|
"- {time: %ld.%06ld, type: %s}\n",
|
||||||
(long)(time / (int)1e6),
|
(long)(usec_as_uint64_t(time) / (int)1e6),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type);
|
type);
|
||||||
break;
|
break;
|
||||||
case LIBINPUT_EVENT_TOUCH_DOWN:
|
case LIBINPUT_EVENT_TOUCH_DOWN:
|
||||||
|
|
@ -691,10 +696,10 @@ print_touch_event(struct record_device *dev, struct libinput_event *e)
|
||||||
ty = libinput_event_touch_get_y_transformed(t, 100);
|
ty = libinput_event_touch_get_y_transformed(t, 100);
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, slot: %d, seat_slot: %d, "
|
"- {time: %d.%06ld, type: %s, slot: %d, seat_slot: %d, "
|
||||||
"point: [%6.2f, %6.2f], transformed: [%6.2f, %6.2f]}\n",
|
"point: [%6.2f, %6.2f], transformed: [%6.2f, %6.2f]}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
slot,
|
slot,
|
||||||
seat_slot,
|
seat_slot,
|
||||||
|
|
@ -707,9 +712,9 @@ print_touch_event(struct record_device *dev, struct libinput_event *e)
|
||||||
case LIBINPUT_EVENT_TOUCH_CANCEL:
|
case LIBINPUT_EVENT_TOUCH_CANCEL:
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, slot: %d, seat_slot: %d}\n",
|
"- {time: %d.%06ld, type: %s, slot: %d, seat_slot: %d}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
slot,
|
slot,
|
||||||
seat_slot);
|
seat_slot);
|
||||||
|
|
@ -725,7 +730,7 @@ print_gesture_event(struct record_device *dev, struct libinput_event *e)
|
||||||
enum libinput_event_type etype = libinput_event_get_type(e);
|
enum libinput_event_type etype = libinput_event_get_type(e);
|
||||||
struct libinput_event_gesture *g = libinput_event_get_gesture_event(e);
|
struct libinput_event_gesture *g = libinput_event_get_gesture_event(e);
|
||||||
const char *type;
|
const char *type;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
|
|
||||||
switch (etype) {
|
switch (etype) {
|
||||||
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
||||||
|
|
@ -750,7 +755,8 @@ print_gesture_event(struct record_device *dev, struct libinput_event *e)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_gesture_get_time_usec(g));
|
time = time_offset(dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_gesture_get_time_usec(g)));
|
||||||
|
|
||||||
switch (etype) {
|
switch (etype) {
|
||||||
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
||||||
|
|
@ -761,8 +767,8 @@ print_gesture_event(struct record_device *dev, struct libinput_event *e)
|
||||||
"- {time: %ld.%06ld, type: %s, nfingers: %d, "
|
"- {time: %ld.%06ld, type: %s, nfingers: %d, "
|
||||||
"delta: [%6.2f, %6.2f], unaccel: [%6.2f, %6.2f], "
|
"delta: [%6.2f, %6.2f], unaccel: [%6.2f, %6.2f], "
|
||||||
"angle_delta: %6.2f, scale: %6.2f}\n",
|
"angle_delta: %6.2f, scale: %6.2f}\n",
|
||||||
(long)(time / (int)1e6),
|
(long)(usec_as_uint64_t(time) / (int)1e6),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
libinput_event_gesture_get_finger_count(g),
|
libinput_event_gesture_get_finger_count(g),
|
||||||
libinput_event_gesture_get_dx(g),
|
libinput_event_gesture_get_dx(g),
|
||||||
|
|
@ -777,10 +783,10 @@ print_gesture_event(struct record_device *dev, struct libinput_event *e)
|
||||||
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
|
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, nfingers: %d, "
|
"- {time: %d.%06ld, type: %s, nfingers: %d, "
|
||||||
"delta: [%6.2f, %6.2f], unaccel: [%6.2f, %6.2f]}\n",
|
"delta: [%6.2f, %6.2f], unaccel: [%6.2f, %6.2f]}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
libinput_event_gesture_get_finger_count(g),
|
libinput_event_gesture_get_finger_count(g),
|
||||||
libinput_event_gesture_get_dx(g),
|
libinput_event_gesture_get_dx(g),
|
||||||
|
|
@ -877,7 +883,7 @@ print_tablet_tool_proximity_event(struct record_device *dev, struct libinput_eve
|
||||||
{
|
{
|
||||||
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(e);
|
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(e);
|
||||||
struct libinput_tablet_tool *tool = libinput_event_tablet_tool_get_tool(t);
|
struct libinput_tablet_tool *tool = libinput_event_tablet_tool_get_tool(t);
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
const char *type, *tool_type;
|
const char *type, *tool_type;
|
||||||
char caps[10] = { 0 };
|
char caps[10] = { 0 };
|
||||||
enum libinput_tablet_tool_proximity_state prox;
|
enum libinput_tablet_tool_proximity_state prox;
|
||||||
|
|
@ -919,7 +925,9 @@ print_tablet_tool_proximity_event(struct record_device *dev, struct libinput_eve
|
||||||
}
|
}
|
||||||
|
|
||||||
prox = libinput_event_tablet_tool_get_proximity_state(t);
|
prox = libinput_event_tablet_tool_get_proximity_state(t);
|
||||||
time = time_offset(dev->ctx, libinput_event_tablet_tool_get_time_usec(t));
|
time = time_offset(
|
||||||
|
dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_tablet_tool_get_time_usec(t)));
|
||||||
_autofree_ char *axes = buffer_tablet_axes(t);
|
_autofree_ char *axes = buffer_tablet_axes(t);
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
|
|
@ -939,10 +947,10 @@ print_tablet_tool_proximity_event(struct record_device *dev, struct libinput_eve
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, proximity: %s, tool-type: %s, serial: %" PRIu64
|
"- {time: %d.%06ld, type: %s, proximity: %s, tool-type: %s, serial: %" PRIu64
|
||||||
", axes: %s, %s}\n",
|
", axes: %s, %s}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
prox ? "in" : "out",
|
prox ? "in" : "out",
|
||||||
tool_type,
|
tool_type,
|
||||||
|
|
@ -955,7 +963,7 @@ static void
|
||||||
print_tablet_tool_button_event(struct record_device *dev, struct libinput_event *e)
|
print_tablet_tool_button_event(struct record_device *dev, struct libinput_event *e)
|
||||||
{
|
{
|
||||||
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(e);
|
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(e);
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
const char *type;
|
const char *type;
|
||||||
uint32_t button;
|
uint32_t button;
|
||||||
enum libinput_button_state state;
|
enum libinput_button_state state;
|
||||||
|
|
@ -970,13 +978,15 @@ print_tablet_tool_button_event(struct record_device *dev, struct libinput_event
|
||||||
|
|
||||||
button = libinput_event_tablet_tool_get_button(t);
|
button = libinput_event_tablet_tool_get_button(t);
|
||||||
state = libinput_event_tablet_tool_get_button_state(t);
|
state = libinput_event_tablet_tool_get_button_state(t);
|
||||||
time = time_offset(dev->ctx, libinput_event_tablet_tool_get_time_usec(t));
|
time = time_offset(
|
||||||
|
dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_tablet_tool_get_time_usec(t)));
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, button: %d, state: %s}\n",
|
"- {time: %d.%06ld, type: %s, button: %d, state: %s}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
button,
|
button,
|
||||||
state ? "pressed" : "released");
|
state ? "pressed" : "released");
|
||||||
|
|
@ -986,7 +996,7 @@ static void
|
||||||
print_tablet_tool_event(struct record_device *dev, struct libinput_event *e)
|
print_tablet_tool_event(struct record_device *dev, struct libinput_event *e)
|
||||||
{
|
{
|
||||||
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(e);
|
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(e);
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
const char *type;
|
const char *type;
|
||||||
enum libinput_tablet_tool_tip_state tip;
|
enum libinput_tablet_tool_tip_state tip;
|
||||||
char btn_buffer[30] = { 0 };
|
char btn_buffer[30] = { 0 };
|
||||||
|
|
@ -1019,14 +1029,16 @@ print_tablet_tool_event(struct record_device *dev, struct libinput_event *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
tip = libinput_event_tablet_tool_get_tip_state(t);
|
tip = libinput_event_tablet_tool_get_tip_state(t);
|
||||||
time = time_offset(dev->ctx, libinput_event_tablet_tool_get_time_usec(t));
|
time = time_offset(
|
||||||
|
dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_tablet_tool_get_time_usec(t)));
|
||||||
_autofree_ char *axes = buffer_tablet_axes(t);
|
_autofree_ char *axes = buffer_tablet_axes(t);
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s%s, tip: %s, %s}\n",
|
"- {time: %d.%06ld, type: %s%s, tip: %s, %s}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
btn_buffer, /* may be empty string */
|
btn_buffer, /* may be empty string */
|
||||||
tip ? "down" : "up",
|
tip ? "down" : "up",
|
||||||
|
|
@ -1041,7 +1053,7 @@ print_tablet_pad_button_event(struct record_device *dev, struct libinput_event *
|
||||||
enum libinput_button_state state;
|
enum libinput_button_state state;
|
||||||
unsigned int button, mode;
|
unsigned int button, mode;
|
||||||
const char *type;
|
const char *type;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
|
|
||||||
switch (libinput_event_get_type(e)) {
|
switch (libinput_event_get_type(e)) {
|
||||||
case LIBINPUT_EVENT_TABLET_PAD_BUTTON:
|
case LIBINPUT_EVENT_TABLET_PAD_BUTTON:
|
||||||
|
|
@ -1051,7 +1063,9 @@ print_tablet_pad_button_event(struct record_device *dev, struct libinput_event *
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_tablet_pad_get_time_usec(p));
|
time = time_offset(
|
||||||
|
dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_tablet_pad_get_time_usec(p)));
|
||||||
button = libinput_event_tablet_pad_get_button_number(p),
|
button = libinput_event_tablet_pad_get_button_number(p),
|
||||||
state = libinput_event_tablet_pad_get_button_state(p);
|
state = libinput_event_tablet_pad_get_button_state(p);
|
||||||
mode = libinput_event_tablet_pad_get_mode(p);
|
mode = libinput_event_tablet_pad_get_mode(p);
|
||||||
|
|
@ -1059,9 +1073,9 @@ print_tablet_pad_button_event(struct record_device *dev, struct libinput_event *
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, button: %d, state: %s, mode: %d, is-toggle: %s}\n",
|
"- {time: %d.%06ld, type: %s, button: %d, state: %s, mode: %d, is-toggle: %s}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
button,
|
button,
|
||||||
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
|
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
|
||||||
|
|
@ -1077,7 +1091,7 @@ print_tablet_pad_ringstrip_event(struct record_device *dev, struct libinput_even
|
||||||
const char *source = NULL;
|
const char *source = NULL;
|
||||||
unsigned int mode, number;
|
unsigned int mode, number;
|
||||||
const char *type;
|
const char *type;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
double pos;
|
double pos;
|
||||||
|
|
||||||
switch (libinput_event_get_type(e)) {
|
switch (libinput_event_get_type(e)) {
|
||||||
|
|
@ -1113,14 +1127,16 @@ print_tablet_pad_ringstrip_event(struct record_device *dev, struct libinput_even
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_tablet_pad_get_time_usec(p));
|
time = time_offset(
|
||||||
|
dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_tablet_pad_get_time_usec(p)));
|
||||||
mode = libinput_event_tablet_pad_get_mode(p);
|
mode = libinput_event_tablet_pad_get_mode(p);
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, number: %d, position: %.2f, source: %s, mode: %d}\n",
|
"- {time: %d.%06ld, type: %s, number: %d, position: %.2f, source: %s, mode: %d}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
number,
|
number,
|
||||||
pos,
|
pos,
|
||||||
|
|
@ -1135,7 +1151,7 @@ print_switch_event(struct record_device *dev, struct libinput_event *e)
|
||||||
enum libinput_switch_state state;
|
enum libinput_switch_state state;
|
||||||
uint32_t sw;
|
uint32_t sw;
|
||||||
const char *type;
|
const char *type;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
|
|
||||||
switch (libinput_event_get_type(e)) {
|
switch (libinput_event_get_type(e)) {
|
||||||
case LIBINPUT_EVENT_SWITCH_TOGGLE:
|
case LIBINPUT_EVENT_SWITCH_TOGGLE:
|
||||||
|
|
@ -1145,15 +1161,16 @@ print_switch_event(struct record_device *dev, struct libinput_event *e)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
time = time_offset(dev->ctx, libinput_event_switch_get_time_usec(s));
|
time = time_offset(dev->ctx,
|
||||||
|
usec_from_uint64_t(libinput_event_switch_get_time_usec(s)));
|
||||||
sw = libinput_event_switch_get_switch(s);
|
sw = libinput_event_switch_get_switch(s);
|
||||||
state = libinput_event_switch_get_switch_state(s);
|
state = libinput_event_switch_get_switch_state(s);
|
||||||
|
|
||||||
iprintf(dev->fp,
|
iprintf(dev->fp,
|
||||||
I_EVENT,
|
I_EVENT,
|
||||||
"- {time: %ld.%06ld, type: %s, switch: %d, state: %s}\n",
|
"- {time: %d.%06ld, type: %s, switch: %d, state: %s}\n",
|
||||||
(long)(time / (int)1e6),
|
usec_to_seconds(time),
|
||||||
(long)(time % (int)1e6),
|
(long)(usec_as_uint64_t(time) % (int)1e6),
|
||||||
type,
|
type,
|
||||||
sw,
|
sw,
|
||||||
state == LIBINPUT_SWITCH_STATE_ON ? "on" : "off");
|
state == LIBINPUT_SWITCH_STATE_ON ? "on" : "off");
|
||||||
|
|
@ -1231,7 +1248,7 @@ handle_hidraw(struct hidraw *hidraw)
|
||||||
unsigned char report[4096];
|
unsigned char report[4096];
|
||||||
const char *sep = "";
|
const char *sep = "";
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
uint64_t time;
|
usec_t time;
|
||||||
|
|
||||||
int rc = read(hidraw->fd, report, sizeof(report));
|
int rc = read(hidraw->fd, report, sizeof(report));
|
||||||
if (rc <= 0)
|
if (rc <= 0)
|
||||||
|
|
@ -1239,23 +1256,28 @@ handle_hidraw(struct hidraw *hidraw)
|
||||||
|
|
||||||
/* hidraw doesn't give us a timestamps, we have to make them up */
|
/* hidraw doesn't give us a timestamps, we have to make them up */
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
time = s2us(ts.tv_sec) + ns2us(ts.tv_nsec);
|
time = usec_from_timespec(&ts);
|
||||||
|
|
||||||
/* The first evdev event is guaranteed to have an event time earlier
|
/* The first evdev event is guaranteed to have an event time earlier
|
||||||
than now, so we don't set the offset here, we rely on the evdev
|
than now, so we don't set the offset here, we rely on the evdev
|
||||||
events to do so. This potentially leaves us with multiple hidraw
|
events to do so. This potentially leaves us with multiple hidraw
|
||||||
events at timestap 0 but it's too niche to worry about. */
|
events at timestap 0 but it's too niche to worry about. */
|
||||||
if (d->ctx->offset == 0)
|
if (usec_is_zero(d->ctx->offset))
|
||||||
time = 0;
|
time = usec_from_uint64_t(0);
|
||||||
else
|
else
|
||||||
time = time_offset(d->ctx, time);
|
time = time_offset(d->ctx, time);
|
||||||
|
|
||||||
iprintf(d->fp, I_EVENTTYPE, "- hid:\n");
|
{
|
||||||
iprintf(d->fp,
|
iprintf(d->fp, I_EVENTTYPE, "- hid:\n");
|
||||||
I_EVENT,
|
uint64_t time_sec = usec_to_seconds(time);
|
||||||
"time: [%3" PRIu64 ", %6" PRIu64 "]\n",
|
uint64_t time_usec =
|
||||||
time / s2us(1),
|
usec_as_uint64_t(time) % usec_as_uint64_t(usec_from_seconds(1));
|
||||||
time % s2us(1));
|
iprintf(d->fp,
|
||||||
|
I_EVENT,
|
||||||
|
"time: [%3" PRIu64 ", %6" PRIu64 "]\n",
|
||||||
|
time_sec,
|
||||||
|
time_usec);
|
||||||
|
}
|
||||||
iprintf(d->fp, I_EVENT, "%s: [", hidraw->name);
|
iprintf(d->fp, I_EVENT, "%s: [", hidraw->name);
|
||||||
|
|
||||||
for (int byte = 0; byte < rc; byte++) {
|
for (int byte = 0; byte < rc; byte++) {
|
||||||
|
|
@ -2233,7 +2255,7 @@ mainloop(struct record_context *ctx)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
ctx->offset = s2us(ts.tv_sec) + ns2us(ts.tv_nsec);
|
ctx->offset = usec_from_timespec(&ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ print_ptraccel_deltas(struct motion_filter *filter, double step)
|
||||||
{
|
{
|
||||||
struct device_float_coords motion;
|
struct device_float_coords motion;
|
||||||
struct normalized_coords accel;
|
struct normalized_coords accel;
|
||||||
uint64_t time = 0;
|
usec_t time = usec_from_uint64_t(0);
|
||||||
double i;
|
double i;
|
||||||
|
|
||||||
printf("# gnuplot:\n");
|
printf("# gnuplot:\n");
|
||||||
|
|
@ -54,7 +54,8 @@ print_ptraccel_deltas(struct motion_filter *filter, double step)
|
||||||
for (i = 0.0; i < 15.0; i += step) { // NOLINT: security.FloatLoopCounter
|
for (i = 0.0; i < 15.0; i += step) { // NOLINT: security.FloatLoopCounter
|
||||||
motion.x = i;
|
motion.x = i;
|
||||||
motion.y = 0;
|
motion.y = 0;
|
||||||
time += us(12500); /* pretend 80Hz data */
|
time = usec_add(time,
|
||||||
|
usec_from_uint64_t(12500)); /* pretend 80Hz data */
|
||||||
|
|
||||||
accel = filter_dispatch(filter, &motion, NULL, time);
|
accel = filter_dispatch(filter, &motion, NULL, time);
|
||||||
|
|
||||||
|
|
@ -70,7 +71,7 @@ print_ptraccel_movement(struct motion_filter *filter,
|
||||||
{
|
{
|
||||||
struct device_float_coords motion;
|
struct device_float_coords motion;
|
||||||
struct normalized_coords accel;
|
struct normalized_coords accel;
|
||||||
uint64_t time = 0;
|
usec_t time = usec_from_uint64_t(0);
|
||||||
double dx;
|
double dx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
@ -98,7 +99,8 @@ print_ptraccel_movement(struct motion_filter *filter,
|
||||||
for (i = 0; i < nevents; i++) {
|
for (i = 0; i < nevents; i++) {
|
||||||
motion.x = dx;
|
motion.x = dx;
|
||||||
motion.y = 0;
|
motion.y = 0;
|
||||||
time += us(12500); /* pretend 80Hz data */
|
time = usec_add(time,
|
||||||
|
usec_from_uint64_t(12500)); /* pretend 80Hz data */
|
||||||
|
|
||||||
accel = filter_dispatch(filter, &motion, NULL, time);
|
accel = filter_dispatch(filter, &motion, NULL, time);
|
||||||
|
|
||||||
|
|
@ -114,7 +116,7 @@ print_ptraccel_sequence(struct motion_filter *filter, int nevents, double *delta
|
||||||
{
|
{
|
||||||
struct device_float_coords motion;
|
struct device_float_coords motion;
|
||||||
struct normalized_coords accel;
|
struct normalized_coords accel;
|
||||||
uint64_t time = 0;
|
usec_t time = usec_from_uint64_t(0);
|
||||||
double *dx;
|
double *dx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
@ -131,7 +133,8 @@ print_ptraccel_sequence(struct motion_filter *filter, int nevents, double *delta
|
||||||
for (i = 0; i < nevents; i++, dx++) {
|
for (i = 0; i < nevents; i++, dx++) {
|
||||||
motion.x = *dx;
|
motion.x = *dx;
|
||||||
motion.y = 0;
|
motion.y = 0;
|
||||||
time += us(12500); /* pretend 80Hz data */
|
time = usec_add(time,
|
||||||
|
usec_from_uint64_t(12500)); /* pretend 80Hz data */
|
||||||
|
|
||||||
accel = filter_dispatch(filter, &motion, NULL, time);
|
accel = filter_dispatch(filter, &motion, NULL, time);
|
||||||
|
|
||||||
|
|
@ -162,7 +165,8 @@ print_accel_func(struct motion_filter *filter, accel_profile_func_t profile, int
|
||||||
mmps += 1) {
|
mmps += 1) {
|
||||||
double units_per_us = mmps_to_upus(mmps, dpi);
|
double units_per_us = mmps_to_upus(mmps, dpi);
|
||||||
double units_per_ms = units_per_us * 1000.0;
|
double units_per_ms = units_per_us * 1000.0;
|
||||||
double result = profile(filter, NULL, units_per_us, 0 /* time */);
|
double result =
|
||||||
|
profile(filter, NULL, units_per_us, usec_from_uint64_t(0));
|
||||||
printf("%.8f\t%.4f\t%.8f\t%.8f\n",
|
printf("%.8f\t%.4f\t%.8f\t%.8f\n",
|
||||||
mmps,
|
mmps,
|
||||||
result,
|
result,
|
||||||
|
|
@ -357,10 +361,11 @@ main(int argc, char **argv)
|
||||||
use_averaging);
|
use_averaging);
|
||||||
profile = pointer_accel_profile_linear_low_dpi;
|
profile = pointer_accel_profile_linear_low_dpi;
|
||||||
} else if (streq(filter_type, "touchpad")) {
|
} else if (streq(filter_type, "touchpad")) {
|
||||||
filter = create_pointer_accelerator_filter_touchpad(dpi,
|
filter = create_pointer_accelerator_filter_touchpad(
|
||||||
0,
|
dpi,
|
||||||
0,
|
usec_from_uint64_t(0),
|
||||||
use_averaging);
|
usec_from_uint64_t(0),
|
||||||
|
use_averaging);
|
||||||
profile = touchpad_accel_profile_linear;
|
profile = touchpad_accel_profile_linear;
|
||||||
} else if (streq(filter_type, "x230")) {
|
} else if (streq(filter_type, "x230")) {
|
||||||
filter = create_pointer_accelerator_filter_lenovo_x230(dpi,
|
filter = create_pointer_accelerator_filter_lenovo_x230(dpi,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue