Run clang-format over the code

This uses the .clang-format file in the follow-up commit, but committed
prior to that to ease review of said file and various integrations.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
This commit is contained in:
Peter Hutterer 2025-07-01 16:30:11 +10:00
parent 490084569d
commit 2a1095924b
235 changed files with 10428 additions and 11450 deletions

View file

@ -26,6 +26,7 @@
#pragma once
#include <unistd.h>
#include "util-strings.h"
/**

View file

@ -28,9 +28,10 @@
#include <mtdev-plumbing.h>
#include "evdev-fallback.h"
#include "util-input-event.h"
#include "evdev-fallback.h"
static void
fallback_keyboard_notify_key(struct fallback_dispatch *dispatch,
struct evdev_device *device,
@ -89,9 +90,8 @@ fallback_interface_get_switch_state(struct evdev_dispatch *evdev_dispatch,
abort();
}
return dispatch->tablet_mode.sw.state ?
LIBINPUT_SWITCH_STATE_ON :
LIBINPUT_SWITCH_STATE_OFF;
return dispatch->tablet_mode.sw.state ? LIBINPUT_SWITCH_STATE_ON
: LIBINPUT_SWITCH_STATE_OFF;
}
static inline bool
@ -102,7 +102,7 @@ post_button_scroll(struct evdev_device *device,
if (device->scroll.method != LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)
return false;
switch(device->scroll.button_scroll_state) {
switch (device->scroll.button_scroll_state) {
case BUTTONSCROLL_IDLE:
return false;
case BUTTONSCROLL_BUTTON_DOWN:
@ -114,17 +114,17 @@ post_button_scroll(struct evdev_device *device,
case BUTTONSCROLL_READY:
device->scroll.button_scroll_state = BUTTONSCROLL_SCROLLING;
_fallthrough_;
case BUTTONSCROLL_SCROLLING:
{
case BUTTONSCROLL_SCROLLING: {
const struct normalized_coords normalized =
filter_dispatch_scroll(device->pointer.filter,
&raw,
device,
time);
evdev_post_scroll(device, time,
filter_dispatch_scroll(device->pointer.filter,
&raw,
device,
time);
evdev_post_scroll(device,
time,
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
&normalized);
}
}
return true;
}
@ -191,13 +191,9 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
if (device->pointer.filter) {
/* Apply pointer acceleration. */
accel = filter_dispatch(device->pointer.filter,
&raw,
device,
time);
accel = filter_dispatch(device->pointer.filter, &raw, device, time);
} else {
evdev_log_bug_libinput(device,
"accel filter missing\n");
evdev_log_bug_libinput(device, "accel filter missing\n");
accel.x = accel.y = 0;
}
@ -228,10 +224,10 @@ fallback_flush_wheels(struct fallback_dispatch *dispatch,
.y = dispatch->wheel.lo_res.y * -1,
};
const struct normalized_coords normalized =
filter_dispatch_scroll(device->pointer.filter,
&raw,
device,
time);
filter_dispatch_scroll(device->pointer.filter,
&raw,
device,
time);
evdev_post_scroll(device,
time,
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
@ -248,13 +244,13 @@ fallback_flush_wheels(struct fallback_dispatch *dispatch,
int value = dispatch->wheel.hi_res.y;
v120.y = -1 * value;
wheel_degrees.y = -1 * value/120.0 * device->scroll.wheel_click_angle.y;
evdev_notify_axis_wheel(
device,
time,
bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
&wheel_degrees,
&v120);
wheel_degrees.y =
-1 * value / 120.0 * device->scroll.wheel_click_angle.y;
evdev_notify_axis_wheel(device,
time,
bit(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
&wheel_degrees,
&v120);
dispatch->wheel.hi_res.y = 0;
}
@ -276,13 +272,12 @@ fallback_flush_wheels(struct fallback_dispatch *dispatch,
int value = dispatch->wheel.hi_res.x;
v120.x = value;
wheel_degrees.x = value/120.0 * device->scroll.wheel_click_angle.x;
evdev_notify_axis_wheel(
device,
time,
bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
&wheel_degrees,
&v120);
wheel_degrees.x = value / 120.0 * device->scroll.wheel_click_angle.x;
evdev_notify_axis_wheel(device,
time,
bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
&wheel_degrees,
&v120);
dispatch->wheel.hi_res.x = 0;
}
@ -335,8 +330,9 @@ fallback_flush_mt_down(struct fallback_dispatch *dispatch,
slot = &dispatch->mt.slots[slot_idx];
if (slot->seat_slot != -1) {
evdev_log_bug_kernel(device,
"driver sent multiple touch down for the same slot");
evdev_log_bug_kernel(
device,
"driver sent multiple touch down for the same slot");
return false;
}
@ -351,8 +347,7 @@ fallback_flush_mt_down(struct fallback_dispatch *dispatch,
slot->hysteresis_center = point;
evdev_transform_absolute(device, &point);
touch_notify_touch_down(base, time, slot_idx, seat_slot,
&point);
touch_notify_touch_down(base, time, slot_idx, seat_slot, &point);
return true;
}
@ -382,8 +377,7 @@ fallback_flush_mt_motion(struct fallback_dispatch *dispatch,
return false;
evdev_transform_absolute(device, &point);
touch_notify_touch_motion(base, time, slot_idx, seat_slot,
&point);
touch_notify_touch_motion(base, time, slot_idx, seat_slot, &point);
return true;
}
@ -458,8 +452,9 @@ fallback_flush_st_down(struct fallback_dispatch *dispatch,
return false;
if (dispatch->abs.seat_slot != -1) {
evdev_log_bug_kernel(device,
"driver sent multiple touch down for the same slot");
evdev_log_bug_kernel(
device,
"driver sent multiple touch down for the same slot");
return false;
}
@ -554,17 +549,18 @@ fallback_flush_st_cancel(struct fallback_dispatch *dispatch,
static void
fallback_process_touch_button(struct fallback_dispatch *dispatch,
struct evdev_device *device,
uint64_t time, int value)
uint64_t time,
int value)
{
dispatch->pending_event |= (value) ?
EVDEV_ABSOLUTE_TOUCH_DOWN :
EVDEV_ABSOLUTE_TOUCH_UP;
dispatch->pending_event |=
(value) ? EVDEV_ABSOLUTE_TOUCH_DOWN : EVDEV_ABSOLUTE_TOUCH_UP;
}
static inline void
fallback_process_key(struct fallback_dispatch *dispatch,
struct evdev_device *device,
struct evdev_event *e, uint64_t time)
struct evdev_event *e,
uint64_t time)
{
/* ignore kernel key repeat */
if (e->value == 2)
@ -572,10 +568,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
if (evdev_usage_eq(e->usage, EVDEV_BTN_TOUCH)) {
if (!device->is_mt)
fallback_process_touch_button(dispatch,
device,
time,
e->value);
fallback_process_touch_button(dispatch, device, time, e->value);
return;
}
@ -600,8 +593,8 @@ fallback_process_key(struct fallback_dispatch *dispatch,
device,
time,
e->usage,
e->value ? LIBINPUT_KEY_STATE_PRESSED :
LIBINPUT_KEY_STATE_RELEASED);
e->value ? LIBINPUT_KEY_STATE_PRESSED
: LIBINPUT_KEY_STATE_RELEASED);
}
}
@ -617,9 +610,9 @@ fallback_process_touch(struct fallback_dispatch *dispatch,
case EVDEV_ABS_MT_SLOT:
if ((size_t)e->value >= dispatch->mt.slots_len) {
evdev_log_bug_libinput(device,
"exceeded slot count (%d of max %zd)\n",
e->value,
dispatch->mt.slots_len);
"exceeded slot count (%d of max %zd)\n",
e->value,
dispatch->mt.slots_len);
e->value = dispatch->mt.slots_len - 1;
}
dispatch->mt.slot = e->value;
@ -710,9 +703,7 @@ fallback_process_absolute_motion(struct fallback_dispatch *dispatch,
}
static void
fallback_lid_keyboard_event(uint64_t time,
struct libinput_event *event,
void *data)
fallback_lid_keyboard_event(uint64_t time, struct libinput_event *event, void *data)
{
struct fallback_dispatch *dispatch = fallback_dispatch(data);
@ -759,11 +750,10 @@ fallback_lid_toggle_keyboard_listener(struct fallback_dispatch *dispatch,
libinput_device_remove_event_listener(&kbd->listener);
if (is_closed) {
libinput_device_add_event_listener(
&kbd->device->base,
&kbd->listener,
fallback_lid_keyboard_event,
dispatch);
libinput_device_add_event_listener(&kbd->device->base,
&kbd->listener,
fallback_lid_keyboard_event,
dispatch);
} else {
libinput_device_init_event_listener(&kbd->listener);
}
@ -779,9 +769,7 @@ fallback_lid_toggle_keyboard_listeners(struct fallback_dispatch *dispatch,
if (!kbd->device)
continue;
fallback_lid_toggle_keyboard_listener(dispatch,
kbd,
is_closed);
fallback_lid_toggle_keyboard_listener(dispatch, kbd, is_closed);
}
}
@ -836,9 +824,10 @@ fallback_reject_relative(struct evdev_device *device,
case EVDEV_REL_X:
case EVDEV_REL_Y:
if ((device->seat_caps & EVDEV_DEVICE_POINTER) == 0) {
evdev_log_bug_libinput_ratelimit(device,
&device->nonpointer_rel_limit,
"REL_X/Y from a non-pointer device\n");
evdev_log_bug_libinput_ratelimit(
device,
&device->nonpointer_rel_limit,
"REL_X/Y from a non-pointer device\n");
return true;
}
break;
@ -849,15 +838,13 @@ fallback_reject_relative(struct evdev_device *device,
}
static void
fallback_rotate_wheel(struct fallback_dispatch *dispatch,
struct evdev_event *e)
fallback_rotate_wheel(struct fallback_dispatch *dispatch, struct evdev_event *e)
{
/* Special case: if we're upside down (-ish),
* swap the direction of the wheels so that user-down
* means scroll down. This isn't done for any other angle
* since it's not clear what the heuristics should be.*/
if (dispatch->rotation.angle >= 160.0 &&
dispatch->rotation.angle <= 220.0) {
if (dispatch->rotation.angle >= 160.0 && dispatch->rotation.angle <= 220.0) {
e->value *= -1;
}
}
@ -865,7 +852,8 @@ fallback_rotate_wheel(struct fallback_dispatch *dispatch,
static inline void
fallback_process_relative(struct fallback_dispatch *dispatch,
struct evdev_device *device,
struct evdev_event *e, uint64_t time)
struct evdev_event *e,
uint64_t time)
{
if (fallback_reject_relative(device, e, time))
return;
@ -915,7 +903,7 @@ fallback_process_absolute(struct fallback_dispatch *dispatch,
static inline bool
fallback_any_button_down(struct fallback_dispatch *dispatch,
struct evdev_device *device)
struct evdev_device *device)
{
for (evdev_usage_t usage = evdev_usage_from(EVDEV_BTN_LEFT);
evdev_usage_lt(usage, EVDEV_BTN_JOYSTICK);
@ -930,8 +918,7 @@ fallback_any_button_down(struct fallback_dispatch *dispatch,
}
static inline bool
fallback_arbitrate_touch(struct fallback_dispatch *dispatch,
struct mt_slot *slot)
fallback_arbitrate_touch(struct fallback_dispatch *dispatch, struct mt_slot *slot)
{
bool discard = false;
struct device_coords point = slot->point;
@ -975,8 +962,7 @@ fallback_flush_mt_events(struct fallback_dispatch *dispatch,
} else if (slot->palm_state == PALM_NONE) {
switch (slot->state) {
case SLOT_STATE_BEGIN:
if (!fallback_arbitrate_touch(dispatch,
slot)) {
if (!fallback_arbitrate_touch(dispatch, slot)) {
sent = fallback_flush_mt_down(dispatch,
device,
i,
@ -990,10 +976,7 @@ fallback_flush_mt_events(struct fallback_dispatch *dispatch,
time);
break;
case SLOT_STATE_END:
sent = fallback_flush_mt_up(dispatch,
device,
i,
time);
sent = fallback_flush_mt_up(dispatch, device, i, time);
break;
case SLOT_STATE_NONE:
break;
@ -1038,14 +1021,10 @@ fallback_handle_state(struct fallback_dispatch *dispatch,
need_touch_frame = true;
} else if (dispatch->pending_event & EVDEV_ABSOLUTE_MOTION) {
if (device->seat_caps & EVDEV_DEVICE_TOUCH) {
if (fallback_flush_st_motion(dispatch,
device,
time))
if (fallback_flush_st_motion(dispatch, device, time))
need_touch_frame = true;
} else if (device->seat_caps & EVDEV_DEVICE_POINTER) {
fallback_flush_absolute_motion(dispatch,
device,
time);
fallback_flush_absolute_motion(dispatch, device, time);
}
}
@ -1056,9 +1035,7 @@ fallback_handle_state(struct fallback_dispatch *dispatch,
/* Multitouch devices */
if (dispatch->pending_event & EVDEV_ABSOLUTE_MT)
need_touch_frame = fallback_flush_mt_events(dispatch,
device,
time);
need_touch_frame = fallback_flush_mt_events(dispatch, device, time);
if (need_touch_frame)
touch_notify_frame(&device->base, time);
@ -1075,16 +1052,16 @@ fallback_handle_state(struct fallback_dispatch *dispatch,
if (evdev_usage_is_button(usage)) {
enum libinput_button_state state =
hw_is_key_down(dispatch, usage) ?
LIBINPUT_BUTTON_STATE_PRESSED :
LIBINPUT_BUTTON_STATE_RELEASED;
evdev_usage_t button = evdev_to_left_handed(device, usage);
hw_is_key_down(dispatch, usage)
? LIBINPUT_BUTTON_STATE_PRESSED
: LIBINPUT_BUTTON_STATE_RELEASED;
evdev_usage_t button =
evdev_to_left_handed(device, usage);
fallback_notify_physical_button(dispatch,
device,
time,
button,
state);
}
}
@ -1105,7 +1082,8 @@ fallback_interface_process(struct evdev_dispatch *evdev_dispatch,
if (dispatch->arbitration.in_arbitration) {
if (!warned) {
evdev_log_debug(device, "dropping events due to touch arbitration\n");
evdev_log_debug(device,
"dropping events due to touch arbitration\n");
warned = true;
}
return;
@ -1146,9 +1124,7 @@ cancel_touches(struct fallback_dispatch *dispatch,
point = dispatch->abs.point;
evdev_transform_absolute(device, &point);
if (!rect || point_in_rect(&point, rect))
need_frame = fallback_flush_st_cancel(dispatch,
device,
time);
need_frame = fallback_flush_st_cancel(dispatch, device, time);
for (idx = 0; idx < dispatch->mt.slots_len; idx++) {
struct mt_slot *slot = &dispatch->mt.slots[idx];
@ -1199,11 +1175,10 @@ release_pressed_keys(struct fallback_dispatch *dispatch,
* get_key_down_count(). We must not map this to left-handed
* again, see #881.
*/
evdev_pointer_notify_button(
device,
time,
usage,
LIBINPUT_BUTTON_STATE_RELEASED);
evdev_pointer_notify_button(device,
time,
usage,
LIBINPUT_BUTTON_STATE_RELEASED);
}
count = get_key_down_count(device, usage);
@ -1253,9 +1228,7 @@ fallback_interface_remove(struct evdev_dispatch *evdev_dispatch)
libinput_device_remove_event_listener(&dispatch->tablet_mode.other.listener);
list_for_each_safe(kbd,
&dispatch->lid.paired_keyboard_list,
link) {
list_for_each_safe(kbd, &dispatch->lid.paired_keyboard_list, link) {
evdev_paired_keyboard_destroy(kbd);
}
}
@ -1270,9 +1243,8 @@ fallback_interface_sync_initial_state(struct evdev_device *device,
if (device->tags & EVDEV_TAG_LID_SWITCH) {
struct libevdev *evdev = device->evdev;
dispatch->lid.is_closed = libevdev_get_event_value(evdev,
EV_SW,
SW_LID);
dispatch->lid.is_closed =
libevdev_get_event_value(evdev, EV_SW, SW_LID);
dispatch->lid.is_closed_client_state = false;
/* For the initial state sync, we depend on whether the lid switch
@ -1299,8 +1271,8 @@ fallback_interface_sync_initial_state(struct evdev_device *device,
static void
fallback_interface_update_rect(struct evdev_dispatch *evdev_dispatch,
struct evdev_device *device,
const struct phys_rect *phys_rect,
uint64_t time)
const struct phys_rect *phys_rect,
uint64_t time)
{
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
struct device_coord_rect rect;
@ -1322,7 +1294,7 @@ fallback_interface_toggle_touch(struct evdev_dispatch *evdev_dispatch,
uint64_t time)
{
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
struct device_coord_rect rect = {0};
struct device_coord_rect rect = { 0 };
const char *state = NULL;
if (which == dispatch->arbitration.state)
@ -1378,8 +1350,7 @@ static void
fallback_lid_pair_keyboard(struct evdev_device *lid_switch,
struct evdev_device *keyboard)
{
struct fallback_dispatch *dispatch =
fallback_dispatch(lid_switch->dispatch);
struct fallback_dispatch *dispatch = fallback_dispatch(lid_switch->dispatch);
struct evdev_paired_keyboard *kbd;
size_t count = 0;
@ -1417,8 +1388,7 @@ fallback_lid_pair_keyboard(struct evdev_device *lid_switch,
}
static void
fallback_resume(struct fallback_dispatch *dispatch,
struct evdev_device *device)
fallback_resume(struct fallback_dispatch *dispatch, struct evdev_device *device)
{
if (dispatch->base.sendevents.current_mode ==
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED)
@ -1428,8 +1398,7 @@ fallback_resume(struct fallback_dispatch *dispatch,
}
static void
fallback_suspend(struct fallback_dispatch *dispatch,
struct evdev_device *device)
fallback_suspend(struct fallback_dispatch *dispatch, struct evdev_device *device)
{
evdev_device_suspend(device);
}
@ -1447,8 +1416,7 @@ fallback_tablet_mode_switch_event(uint64_t time,
return;
swev = libinput_event_get_switch_event(event);
if (libinput_event_switch_get_switch(swev) !=
LIBINPUT_SWITCH_TABLET_MODE)
if (libinput_event_switch_get_switch(swev) != LIBINPUT_SWITCH_TABLET_MODE)
return;
switch (libinput_event_switch_get_switch_state(swev)) {
@ -1467,23 +1435,21 @@ static void
fallback_pair_tablet_mode(struct evdev_device *keyboard,
struct evdev_device *tablet_mode_switch)
{
struct fallback_dispatch *dispatch =
fallback_dispatch(keyboard->dispatch);
struct fallback_dispatch *dispatch = fallback_dispatch(keyboard->dispatch);
if ((keyboard->tags & EVDEV_TAG_EXTERNAL_KEYBOARD))
if (keyboard->tags & EVDEV_TAG_EXTERNAL_KEYBOARD)
return;
if ((keyboard->tags & EVDEV_TAG_TRACKPOINT)) {
if (keyboard->tags & EVDEV_TAG_TRACKPOINT) {
if (keyboard->tags & EVDEV_TAG_EXTERNAL_MOUSE)
return;
/* This filters out all internal keyboard-like devices (Video
* Switch) */
/* This filters out all internal keyboard-like devices (Video
* Switch) */
} else if ((keyboard->tags & EVDEV_TAG_INTERNAL_KEYBOARD) == 0) {
return;
}
if (evdev_device_has_model_quirk(keyboard,
QUIRK_MODEL_TABLET_MODE_NO_SUSPEND))
if (evdev_device_has_model_quirk(keyboard, QUIRK_MODEL_TABLET_MODE_NO_SUSPEND))
return;
if ((tablet_mode_switch->tags & EVDEV_TAG_TABLET_MODE_SWITCH) == 0)
@ -1498,14 +1464,14 @@ fallback_pair_tablet_mode(struct evdev_device *keyboard,
tablet_mode_switch->devname);
libinput_device_add_event_listener(&tablet_mode_switch->base,
&dispatch->tablet_mode.other.listener,
fallback_tablet_mode_switch_event,
dispatch);
&dispatch->tablet_mode.other.listener,
fallback_tablet_mode_switch_event,
dispatch);
dispatch->tablet_mode.other.sw_device = tablet_mode_switch;
if (evdev_device_switch_get_state(tablet_mode_switch,
LIBINPUT_SWITCH_TABLET_MODE)
== LIBINPUT_SWITCH_STATE_ON) {
LIBINPUT_SWITCH_TABLET_MODE) ==
LIBINPUT_SWITCH_STATE_ON) {
evdev_log_debug(keyboard, "tablet-mode: suspending device\n");
fallback_suspend(dispatch, keyboard);
}
@ -1523,13 +1489,10 @@ static void
fallback_interface_device_removed(struct evdev_device *device,
struct evdev_device *removed_device)
{
struct fallback_dispatch *dispatch =
fallback_dispatch(device->dispatch);
struct fallback_dispatch *dispatch = fallback_dispatch(device->dispatch);
struct evdev_paired_keyboard *kbd;
list_for_each_safe(kbd,
&dispatch->lid.paired_keyboard_list,
link) {
list_for_each_safe(kbd, &dispatch->lid.paired_keyboard_list, link) {
if (!kbd->device)
continue;
@ -1541,9 +1504,9 @@ fallback_interface_device_removed(struct evdev_device *device,
if (removed_device == dispatch->tablet_mode.other.sw_device) {
libinput_device_remove_event_listener(
&dispatch->tablet_mode.other.listener);
&dispatch->tablet_mode.other.listener);
libinput_device_init_event_listener(
&dispatch->tablet_mode.other.listener);
&dispatch->tablet_mode.other.listener);
dispatch->tablet_mode.other.sw_device = NULL;
}
}
@ -1556,7 +1519,7 @@ static struct evdev_dispatch_interface fallback_interface = {
.device_added = fallback_interface_device_added,
.device_removed = fallback_interface_device_removed,
.device_suspended = fallback_interface_device_removed, /* treat as remove */
.device_resumed = fallback_interface_device_added, /* treat as add */
.device_resumed = fallback_interface_device_added, /* treat as add */
.post_added = fallback_interface_sync_initial_state,
.touch_arbitration_toggle = fallback_interface_toggle_touch,
.touch_arbitration_update_rect = fallback_interface_update_rect,
@ -1605,7 +1568,7 @@ fallback_rotation_config_is_available(struct libinput_device *device)
static enum libinput_config_status
fallback_rotation_config_set_angle(struct libinput_device *libinput_device,
unsigned int degrees_cw)
unsigned int degrees_cw)
{
struct evdev_device *device = evdev_device(libinput_device);
struct fallback_dispatch *dispatch = fallback_dispatch(device->dispatch);
@ -1632,8 +1595,7 @@ fallback_rotation_config_get_default_angle(struct libinput_device *device)
}
static void
fallback_init_rotation(struct fallback_dispatch *dispatch,
struct evdev_device *device)
fallback_init_rotation(struct fallback_dispatch *dispatch, struct evdev_device *device)
{
if (device->tags & EVDEV_TAG_TRACKPOINT)
return;
@ -1641,7 +1603,8 @@ fallback_init_rotation(struct fallback_dispatch *dispatch,
dispatch->rotation.config.is_available = fallback_rotation_config_is_available;
dispatch->rotation.config.set_angle = fallback_rotation_config_set_angle;
dispatch->rotation.config.get_angle = fallback_rotation_config_get_angle;
dispatch->rotation.config.get_default_angle = fallback_rotation_config_get_default_angle;
dispatch->rotation.config.get_default_angle =
fallback_rotation_config_get_default_angle;
matrix_init_identity(&dispatch->rotation.matrix);
device->base.config.rotation = &dispatch->rotation.config;
}
@ -1659,7 +1622,7 @@ fallback_dispatch_init_slots(struct fallback_dispatch *dispatch,
if (evdev_is_fake_mt_device(device) ||
!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ||
!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y))
return 0;
return 0;
/* We only handle the slotted Protocol B in libinput.
Devices with ABS_MT_POSITION_* but not ABS_MT_SLOT
@ -1686,24 +1649,21 @@ fallback_dispatch_init_slots(struct fallback_dispatch *dispatch,
if (evdev_need_mtdev(device))
continue;
slots[slot].point.x = libevdev_get_slot_value(evdev,
slot,
ABS_MT_POSITION_X);
slots[slot].point.y = libevdev_get_slot_value(evdev,
slot,
ABS_MT_POSITION_Y);
slots[slot].point.x =
libevdev_get_slot_value(evdev, slot, ABS_MT_POSITION_X);
slots[slot].point.y =
libevdev_get_slot_value(evdev, slot, ABS_MT_POSITION_Y);
}
dispatch->mt.slots = slots;
dispatch->mt.slots_len = num_slots;
dispatch->mt.slot = active_slot;
dispatch->mt.has_palm = libevdev_has_event_code(evdev,
EV_ABS,
ABS_MT_TOOL_TYPE);
dispatch->mt.has_palm =
libevdev_has_event_code(evdev, EV_ABS, ABS_MT_TOOL_TYPE);
if (device->abs.absinfo_x->fuzz || device->abs.absinfo_y->fuzz) {
dispatch->mt.want_hysteresis = true;
dispatch->mt.hysteresis_margin.x = device->abs.absinfo_x->fuzz/2;
dispatch->mt.hysteresis_margin.y = device->abs.absinfo_y->fuzz/2;
dispatch->mt.hysteresis_margin.x = device->abs.absinfo_x->fuzz / 2;
dispatch->mt.hysteresis_margin.y = device->abs.absinfo_y->fuzz / 2;
}
return 0;
@ -1745,9 +1705,7 @@ fallback_dispatch_init_switch(struct fallback_dispatch *dispatch,
}
if (device->tags & EVDEV_TAG_TABLET_MODE_SWITCH) {
val = libevdev_get_event_value(device->evdev,
EV_SW,
SW_TABLET_MODE);
val = libevdev_get_event_value(device->evdev, EV_SW, SW_TABLET_MODE);
dispatch->tablet_mode.sw.state = val;
}
@ -1773,8 +1731,8 @@ fallback_init_arbitration(struct fallback_dispatch *dispatch,
snprintf(timer_name,
sizeof(timer_name),
"%s arbitration",
evdev_device_get_sysname(device));
"%s arbitration",
evdev_device_get_sysname(device));
libinput_timer_init(&dispatch->arbitration.arbitration_timer,
evdev_libinput_context(device),
timer_name,
@ -1806,12 +1764,10 @@ fallback_dispatch_create(struct libinput_device *libinput_device)
fallback_dispatch_init_switch(dispatch, device);
if (device->left_handed.want_enabled)
evdev_init_left_handed(device,
fallback_change_to_left_handed);
evdev_init_left_handed(device, fallback_change_to_left_handed);
if (evdev_usage_enum(device->scroll.want_button))
evdev_init_button_scroll(device,
fallback_change_scroll_method);
evdev_init_button_scroll(device, fallback_change_scroll_method);
if (device->scroll.natural_scrolling_enabled)
evdev_init_natural_scroll(device);
@ -1827,15 +1783,12 @@ fallback_dispatch_create(struct libinput_device *libinput_device)
* option */
if (libevdev_has_event_code(device->evdev, EV_KEY, BTN_LEFT) &&
libevdev_has_event_code(device->evdev, EV_KEY, BTN_RIGHT)) {
bool has_middle = libevdev_has_event_code(device->evdev,
EV_KEY,
BTN_MIDDLE);
bool has_middle =
libevdev_has_event_code(device->evdev, EV_KEY, BTN_MIDDLE);
bool want_config = has_middle;
bool enable_by_default = !has_middle;
evdev_init_middlebutton(device,
enable_by_default,
want_config);
evdev_init_middlebutton(device, enable_by_default, want_config);
}
fallback_init_arbitration(dispatch, device);

View file

@ -29,9 +29,10 @@
#ifndef EVDEV_FALLBACK_H
#define EVDEV_FALLBACK_H
#include "evdev.h"
#include "util-input-event.h"
#include "evdev.h"
enum debounce_state {
DEBOUNCE_STATE_IS_UP = 100,
DEBOUNCE_STATE_IS_DOWN,
@ -156,7 +157,7 @@ struct fallback_dispatch {
} arbitration;
};
static inline struct fallback_dispatch*
static inline struct fallback_dispatch *
fallback_dispatch(struct evdev_dispatch *dispatch)
{
evdev_verify_dispatch_type(dispatch, DISPATCH_FALLBACK);
@ -180,14 +181,14 @@ hw_key_has_changed(struct fallback_dispatch *dispatch, evdev_usage_t usage)
unsigned int code = evdev_usage_code(usage);
return long_bit_is_set(dispatch->hw_key_mask, code) !=
long_bit_is_set(dispatch->last_hw_key_mask, code);
long_bit_is_set(dispatch->last_hw_key_mask, code);
}
static inline void
hw_key_update_last_state(struct fallback_dispatch *dispatch)
{
static_assert(sizeof(dispatch->hw_key_mask) ==
sizeof(dispatch->last_hw_key_mask),
sizeof(dispatch->last_hw_key_mask),
"Mismatching key mask size");
memcpy(dispatch->last_hw_key_mask,
@ -211,8 +212,8 @@ get_key_down_count(struct evdev_device *device, evdev_usage_t usage)
return device->key_count[code];
}
void fallback_debounce_handle_state(struct fallback_dispatch *dispatch,
uint64_t time);
void
fallback_debounce_handle_state(struct fallback_dispatch *dispatch, uint64_t time);
void
fallback_notify_physical_button(struct fallback_dispatch *dispatch,
struct evdev_device *device,

View file

@ -26,12 +26,12 @@
#include "config.h"
#include "util-mem.h"
#include "util-input-event.h"
#include "util-newtype.h"
#include <stdbool.h>
#include <linux/input.h>
#include <stdbool.h>
#include "util-input-event.h"
#include "util-mem.h"
#include "util-newtype.h"
#define _evbit(t_, c_) ((t_) << 16 | (c_))
@ -48,7 +48,7 @@ enum evdev_usage {
EVDEV_SYN_REPORT = _evbit(EV_SYN, SYN_REPORT),
EVDEV_KEY_RESERVED = _evbit(EV_KEY, KEY_RESERVED),
EVDEV_KEY_ESC= _evbit(EV_KEY, KEY_ESC),
EVDEV_KEY_ESC = _evbit(EV_KEY, KEY_ESC),
EVDEV_KEY_MICMUTE = _evbit(EV_KEY, KEY_MICMUTE),
EVDEV_KEY_OK = _evbit(EV_KEY, KEY_OK),
EVDEV_KEY_LIGHTS_TOGGLE = _evbit(EV_KEY, KEY_LIGHTS_TOGGLE),
@ -196,7 +196,8 @@ evdev_usage_type_name(evdev_usage_t usage)
static inline evdev_usage_t
evdev_usage_next(evdev_usage_t usage)
{
return evdev_usage_from_code(evdev_usage_type(usage), evdev_usage_code(usage) + 1);
return evdev_usage_from_code(evdev_usage_type(usage),
evdev_usage_code(usage) + 1);
}
/**
@ -286,7 +287,7 @@ static inline struct input_event
evdev_event_to_input_event(const struct evdev_event *e, uint64_t time)
{
struct timeval tv = us2tv(time);
return (struct input_event) {
return (struct input_event){
.type = evdev_event_type(e),
.code = evdev_event_code(e),
.value = e->value,
@ -300,7 +301,7 @@ evdev_event_from_input_event(const struct input_event *e, uint64_t *time)
{
if (time)
*time = input_event_time(e);
return (struct evdev_event) {
return (struct evdev_event){
.usage = evdev_usage_from_code(e->type, e->code),
.value = e->value,
};
@ -399,7 +400,8 @@ evdev_frame_reset(struct evdev_frame *frame)
static inline struct evdev_frame *
evdev_frame_new(size_t max_size)
{
struct evdev_frame *frame = zalloc(max_size * sizeof(sizeof(*frame->events)) + sizeof(*frame));
struct evdev_frame *frame =
zalloc(max_size * sizeof(sizeof(*frame->events)) + sizeof(*frame));
frame->refcount = 1;
frame->max_size = max_size;
@ -412,7 +414,8 @@ static inline struct evdev_frame *
evdev_frame_new_on_stack(size_t max_size)
{
assert(max_size <= 64);
struct evdev_frame *frame = alloca(max_size * sizeof(*frame->events) + sizeof(*frame));
struct evdev_frame *frame =
alloca(max_size * sizeof(*frame->events) + sizeof(*frame));
frame->refcount = 1;
frame->max_size = max_size;
@ -464,7 +467,9 @@ evdev_frame_append(struct evdev_frame *frame,
if (frame->count + nevents > frame->max_size)
return -ENOMEM;
memcpy(frame->events + frame->count - 1, events, nevents * sizeof(*events));
memcpy(frame->events + frame->count - 1,
events,
nevents * sizeof(*events));
frame->count += nevents;
}

View file

@ -42,7 +42,7 @@
* as-is.
*/
static inline const char*
static inline const char *
middlebutton_state_to_str(enum evdev_middlebutton_state state)
{
switch (state) {
@ -61,7 +61,7 @@ middlebutton_state_to_str(enum evdev_middlebutton_state state)
return NULL;
}
static inline const char*
static inline const char *
middlebutton_event_to_str(enum evdev_middlebutton_event event)
{
switch (event) {
@ -90,8 +90,7 @@ middlebutton_state_error(struct evdev_device *device,
static void
middlebutton_timer_set(struct evdev_device *device, uint64_t now)
{
libinput_timer_set(&device->middlebutton.timer,
now + MIDDLEBUTTON_TIMEOUT);
libinput_timer_set(&device->middlebutton.timer, now + MIDDLEBUTTON_TIMEOUT);
}
static void
@ -132,10 +131,7 @@ middlebutton_post_event(struct evdev_device *device,
evdev_usage_t button,
enum libinput_button_state state)
{
evdev_pointer_notify_button(device,
now,
button,
state);
evdev_pointer_notify_button(device, now, button, state);
}
static int
@ -174,18 +170,18 @@ evdev_middlebutton_ldown_handle_event(struct evdev_device *device,
middlebutton_state_error(device, event);
break;
case MIDDLEBUTTON_EVENT_R_DOWN:
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_MIDDLE),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_set_state(device, MIDDLEBUTTON_MIDDLE, time);
break;
case MIDDLEBUTTON_EVENT_OTHER:
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_LEFT),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_set_state(device,
MIDDLEBUTTON_PASSTHROUGH,
time);
middlebutton_set_state(device, MIDDLEBUTTON_PASSTHROUGH, time);
return 0;
case MIDDLEBUTTON_EVENT_R_UP:
middlebutton_state_error(device, event);
@ -195,7 +191,8 @@ evdev_middlebutton_ldown_handle_event(struct evdev_device *device,
device->middlebutton.first_event_time,
evdev_usage_from(EVDEV_BTN_LEFT),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_LEFT),
LIBINPUT_BUTTON_STATE_RELEASED);
middlebutton_set_state(device, MIDDLEBUTTON_IDLE, time);
@ -205,9 +202,7 @@ evdev_middlebutton_ldown_handle_event(struct evdev_device *device,
device->middlebutton.first_event_time,
evdev_usage_from(EVDEV_BTN_LEFT),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_set_state(device,
MIDDLEBUTTON_PASSTHROUGH,
time);
middlebutton_set_state(device, MIDDLEBUTTON_PASSTHROUGH, time);
break;
case MIDDLEBUTTON_EVENT_ALL_UP:
middlebutton_state_error(device, event);
@ -224,7 +219,8 @@ evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
{
switch (event) {
case MIDDLEBUTTON_EVENT_L_DOWN:
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_MIDDLE),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_set_state(device, MIDDLEBUTTON_MIDDLE, time);
@ -237,16 +233,15 @@ evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
device->middlebutton.first_event_time,
evdev_usage_from(EVDEV_BTN_RIGHT),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_set_state(device,
MIDDLEBUTTON_PASSTHROUGH,
time);
middlebutton_set_state(device, MIDDLEBUTTON_PASSTHROUGH, time);
return 0;
case MIDDLEBUTTON_EVENT_R_UP:
middlebutton_post_event(device,
device->middlebutton.first_event_time,
evdev_usage_from(EVDEV_BTN_RIGHT),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_RIGHT),
LIBINPUT_BUTTON_STATE_RELEASED);
middlebutton_set_state(device, MIDDLEBUTTON_IDLE, time);
@ -259,9 +254,7 @@ evdev_middlebutton_rdown_handle_event(struct evdev_device *device,
device->middlebutton.first_event_time,
evdev_usage_from(EVDEV_BTN_RIGHT),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_set_state(device,
MIDDLEBUTTON_PASSTHROUGH,
time);
middlebutton_set_state(device, MIDDLEBUTTON_PASSTHROUGH, time);
break;
case MIDDLEBUTTON_EVENT_ALL_UP:
middlebutton_state_error(device, event);
@ -282,26 +275,25 @@ evdev_middlebutton_middle_handle_event(struct evdev_device *device,
middlebutton_state_error(device, event);
break;
case MIDDLEBUTTON_EVENT_OTHER:
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_MIDDLE),
LIBINPUT_BUTTON_STATE_RELEASED);
middlebutton_set_state(device, MIDDLEBUTTON_IGNORE_LR, time);
return 0;
case MIDDLEBUTTON_EVENT_R_UP:
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_MIDDLE),
LIBINPUT_BUTTON_STATE_RELEASED);
middlebutton_set_state(device,
MIDDLEBUTTON_LEFT_UP_PENDING,
time);
middlebutton_set_state(device, MIDDLEBUTTON_LEFT_UP_PENDING, time);
break;
case MIDDLEBUTTON_EVENT_L_UP:
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_MIDDLE),
LIBINPUT_BUTTON_STATE_RELEASED);
middlebutton_set_state(device,
MIDDLEBUTTON_RIGHT_UP_PENDING,
time);
middlebutton_set_state(device, MIDDLEBUTTON_RIGHT_UP_PENDING, time);
break;
case MIDDLEBUTTON_EVENT_TIMEOUT:
middlebutton_state_error(device, event);
@ -324,7 +316,8 @@ evdev_middlebutton_lup_pending_handle_event(struct evdev_device *device,
middlebutton_state_error(device, event);
break;
case MIDDLEBUTTON_EVENT_R_DOWN:
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_MIDDLE),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_set_state(device, MIDDLEBUTTON_MIDDLE, time);
@ -356,7 +349,8 @@ evdev_middlebutton_rup_pending_handle_event(struct evdev_device *device,
{
switch (event) {
case MIDDLEBUTTON_EVENT_L_DOWN:
middlebutton_post_event(device, time,
middlebutton_post_event(device,
time,
evdev_usage_from(EVDEV_BTN_MIDDLE),
LIBINPUT_BUTTON_STATE_PRESSED);
middlebutton_set_state(device, MIDDLEBUTTON_MIDDLE, time);
@ -451,9 +445,7 @@ evdev_middlebutton_ignore_l_handle_event(struct evdev_device *device,
case MIDDLEBUTTON_EVENT_R_UP:
return 0;
case MIDDLEBUTTON_EVENT_L_UP:
middlebutton_set_state(device,
MIDDLEBUTTON_PASSTHROUGH,
time);
middlebutton_set_state(device, MIDDLEBUTTON_PASSTHROUGH, time);
break;
case MIDDLEBUTTON_EVENT_TIMEOUT:
case MIDDLEBUTTON_EVENT_ALL_UP:
@ -477,9 +469,7 @@ evdev_middlebutton_ignore_r_handle_event(struct evdev_device *device,
case MIDDLEBUTTON_EVENT_OTHER:
return 0;
case MIDDLEBUTTON_EVENT_R_UP:
middlebutton_set_state(device,
MIDDLEBUTTON_PASSTHROUGH,
time);
middlebutton_set_state(device, MIDDLEBUTTON_PASSTHROUGH, time);
break;
case MIDDLEBUTTON_EVENT_L_UP:
return 0;
@ -515,34 +505,22 @@ evdev_middlebutton_handle_event(struct evdev_device *device,
rc = evdev_middlebutton_middle_handle_event(device, time, event);
break;
case MIDDLEBUTTON_LEFT_UP_PENDING:
rc = evdev_middlebutton_lup_pending_handle_event(device,
time,
event);
rc = evdev_middlebutton_lup_pending_handle_event(device, time, event);
break;
case MIDDLEBUTTON_RIGHT_UP_PENDING:
rc = evdev_middlebutton_rup_pending_handle_event(device,
time,
event);
rc = evdev_middlebutton_rup_pending_handle_event(device, time, event);
break;
case MIDDLEBUTTON_PASSTHROUGH:
rc = evdev_middlebutton_passthrough_handle_event(device,
time,
event);
rc = evdev_middlebutton_passthrough_handle_event(device, time, event);
break;
case MIDDLEBUTTON_IGNORE_LR:
rc = evdev_middlebutton_ignore_lr_handle_event(device,
time,
event);
rc = evdev_middlebutton_ignore_lr_handle_event(device, time, event);
break;
case MIDDLEBUTTON_IGNORE_L:
rc = evdev_middlebutton_ignore_l_handle_event(device,
time,
event);
rc = evdev_middlebutton_ignore_l_handle_event(device, time, event);
break;
case MIDDLEBUTTON_IGNORE_R:
rc = evdev_middlebutton_ignore_r_handle_event(device,
time,
event);
rc = evdev_middlebutton_ignore_r_handle_event(device, time, event);
break;
default:
evdev_log_bug_libinput(device,
@ -564,8 +542,7 @@ evdev_middlebutton_handle_event(struct evdev_device *device,
static inline void
evdev_middlebutton_apply_config(struct evdev_device *device)
{
if (device->middlebutton.want_enabled ==
device->middlebutton.enabled)
if (device->middlebutton.want_enabled == device->middlebutton.enabled)
return;
if (device->middlebutton.button_mask != 0)
@ -679,9 +656,9 @@ evdev_middlebutton_get(struct libinput_device *device)
{
struct evdev_device *evdev = evdev_device(device);
return evdev->middlebutton.want_enabled ?
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED :
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
return evdev->middlebutton.want_enabled
? LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED
: LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
}
enum libinput_config_middle_emulation_state
@ -689,15 +666,13 @@ evdev_middlebutton_get_default(struct libinput_device *device)
{
struct evdev_device *evdev = evdev_device(device);
return evdev->middlebutton.enabled_default ?
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED :
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
return evdev->middlebutton.enabled_default
? LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED
: LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
}
void
evdev_init_middlebutton(struct evdev_device *device,
bool enable,
bool want_config)
evdev_init_middlebutton(struct evdev_device *device, bool enable, bool want_config)
{
char timer_name[64];

View file

@ -26,10 +26,11 @@
#include <limits.h>
#include <math.h>
#include <string.h>
#include "linux/input.h"
#include "util-input-event.h"
#include "evdev-mt-touchpad.h"
#include "linux/input.h"
#define DEFAULT_BUTTON_ENTER_TIMEOUT ms2us(100)
#define DEFAULT_BUTTON_LEAVE_TIMEOUT ms2us(300)
@ -43,10 +44,10 @@
* The state machine only affects the soft button area code.
*/
static inline const char*
static inline const char *
button_state_to_str(enum button_state state)
{
switch(state) {
switch (state) {
CASE_RETURN_STRING(BUTTON_STATE_NONE);
CASE_RETURN_STRING(BUTTON_STATE_AREA);
CASE_RETURN_STRING(BUTTON_STATE_BOTTOM);
@ -58,10 +59,10 @@ button_state_to_str(enum button_state state)
return NULL;
}
static inline const char*
static inline const char *
button_event_to_str(enum button_event event)
{
switch(event) {
switch (event) {
CASE_RETURN_STRING(BUTTON_EVENT_IN_BOTTOM_R);
CASE_RETURN_STRING(BUTTON_EVENT_IN_BOTTOM_M);
CASE_RETURN_STRING(BUTTON_EVENT_IN_BOTTOM_L);
@ -78,23 +79,20 @@ button_event_to_str(enum button_event event)
}
static inline bool
is_inside_bottom_button_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
is_inside_bottom_button_area(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return t->point.y >= tp->buttons.bottom_area.top_edge;
}
static inline bool
is_inside_bottom_right_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
is_inside_bottom_right_area(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return is_inside_bottom_button_area(tp, t) &&
t->point.x > tp->buttons.bottom_area.rightbutton_left_edge;
}
static inline bool
is_inside_bottom_middle_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
is_inside_bottom_middle_area(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return is_inside_bottom_button_area(tp, t) &&
!is_inside_bottom_right_area(tp, t) &&
@ -102,23 +100,20 @@ is_inside_bottom_middle_area(const struct tp_dispatch *tp,
}
static inline bool
is_inside_top_button_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
is_inside_top_button_area(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return t->point.y <= tp->buttons.top_area.bottom_edge;
}
static inline bool
is_inside_top_right_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
is_inside_top_right_area(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return is_inside_top_button_area(tp, t) &&
t->point.x > tp->buttons.top_area.rightbutton_left_edge;
}
static inline bool
is_inside_top_middle_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
is_inside_top_middle_area(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return is_inside_top_button_area(tp, t) &&
t->point.x >= tp->buttons.top_area.leftbutton_right_edge &&
@ -126,21 +121,15 @@ is_inside_top_middle_area(const struct tp_dispatch *tp,
}
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, uint64_t time)
{
libinput_timer_set(&t->button.timer,
time + DEFAULT_BUTTON_ENTER_TIMEOUT);
libinput_timer_set(&t->button.timer, time + DEFAULT_BUTTON_ENTER_TIMEOUT);
}
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, uint64_t time)
{
libinput_timer_set(&t->button.timer,
time + DEFAULT_BUTTON_LEAVE_TIMEOUT);
libinput_timer_set(&t->button.timer, time + DEFAULT_BUTTON_LEAVE_TIMEOUT);
}
/*
@ -252,8 +241,7 @@ tp_button_release_other_bottom_touches(struct tp_dispatch *tp,
tp_for_each_touch(tp, t) {
uint64_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;
if (other_start_time > t->button.initial_time)
@ -279,11 +267,7 @@ tp_button_bottom_handle_event(struct tp_dispatch *tp,
case BUTTON_EVENT_IN_BOTTOM_M:
case BUTTON_EVENT_IN_BOTTOM_L:
if (event != t->button.current)
tp_button_set_state(tp,
t,
BUTTON_STATE_BOTTOM,
event,
time);
tp_button_set_state(tp, t, BUTTON_STATE_BOTTOM, event, time);
break;
case BUTTON_EVENT_IN_TOP_R:
case BUTTON_EVENT_IN_TOP_M:
@ -296,8 +280,7 @@ tp_button_bottom_handle_event(struct tp_dispatch *tp,
* simultaneously with this finger, release those fingers
* because they're part of a gesture.
*/
tp_button_release_other_bottom_touches(tp,
t->button.initial_time);
tp_button_release_other_bottom_touches(tp, t->button.initial_time);
break;
case BUTTON_EVENT_UP:
tp_button_set_state(tp, t, BUTTON_STATE_NONE, event, time);
@ -325,11 +308,7 @@ tp_button_top_handle_event(struct tp_dispatch *tp,
case BUTTON_EVENT_IN_TOP_M:
case BUTTON_EVENT_IN_TOP_L:
if (event != t->button.current)
tp_button_set_state(tp,
t,
BUTTON_STATE_TOP_NEW,
event,
time);
tp_button_set_state(tp, t, BUTTON_STATE_TOP_NEW, event, time);
break;
case BUTTON_EVENT_IN_AREA:
tp_button_set_state(tp, t, BUTTON_STATE_TOP_TO_IGNORE, event, time);
@ -350,7 +329,7 @@ tp_button_top_new_handle_event(struct tp_dispatch *tp,
enum button_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case BUTTON_EVENT_IN_BOTTOM_R:
case BUTTON_EVENT_IN_BOTTOM_M:
case BUTTON_EVENT_IN_BOTTOM_L:
@ -360,11 +339,7 @@ tp_button_top_new_handle_event(struct tp_dispatch *tp,
case BUTTON_EVENT_IN_TOP_M:
case BUTTON_EVENT_IN_TOP_L:
if (event != t->button.current)
tp_button_set_state(tp,
t,
BUTTON_STATE_TOP_NEW,
event,
time);
tp_button_set_state(tp, t, BUTTON_STATE_TOP_NEW, event, time);
break;
case BUTTON_EVENT_IN_AREA:
tp_button_set_state(tp, t, BUTTON_STATE_AREA, event, time);
@ -389,22 +364,14 @@ tp_button_top_to_ignore_handle_event(struct tp_dispatch *tp,
enum button_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case BUTTON_EVENT_IN_TOP_R:
case BUTTON_EVENT_IN_TOP_M:
case BUTTON_EVENT_IN_TOP_L:
if (event == t->button.current)
tp_button_set_state(tp,
t,
BUTTON_STATE_TOP,
event,
time);
tp_button_set_state(tp, t, BUTTON_STATE_TOP, event, time);
else
tp_button_set_state(tp,
t,
BUTTON_STATE_TOP_NEW,
event,
time);
tp_button_set_state(tp, t, BUTTON_STATE_TOP_NEW, event, time);
break;
case BUTTON_EVENT_IN_BOTTOM_R:
case BUTTON_EVENT_IN_BOTTOM_M:
@ -459,7 +426,7 @@ tp_button_handle_event(struct tp_dispatch *tp,
{
enum button_state current = t->button.state;
switch(t->button.state) {
switch (t->button.state) {
case BUTTON_STATE_NONE:
tp_button_none_handle_event(tp, t, event, time);
break;
@ -484,12 +451,13 @@ tp_button_handle_event(struct tp_dispatch *tp,
}
if (current != t->button.state)
evdev_log_debug(tp->device,
"button state: touch %d from %-20s event %-24s to %-20s\n",
t->index,
button_state_to_str(current),
button_event_to_str(event),
button_state_to_str(t->button.state));
evdev_log_debug(
tp->device,
"button state: touch %d from %-20s event %-24s to %-20s\n",
t->index,
button_state_to_str(current),
button_event_to_str(event),
button_state_to_str(t->button.state));
}
static inline void
@ -523,8 +491,7 @@ tp_button_check_for_movement(struct tp_dispatch *tp, struct tp_touch *t)
if (vector_length > 5.0 /* mm */) {
t->button.has_moved = true;
tp_button_release_other_bottom_touches(tp,
t->button.initial_time);
tp_button_release_other_bottom_touches(tp, t->button.initial_time);
}
}
@ -588,9 +555,7 @@ tp_button_handle_timeout(uint64_t now, void *data)
}
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, uint64_t time)
{
uint32_t mask = bit(evdev_usage_enum(e->usage) - EVDEV_BTN_LEFT);
@ -612,8 +577,7 @@ tp_process_button(struct tp_dispatch *tp,
}
void
tp_release_all_buttons(struct tp_dispatch *tp,
uint64_t time)
tp_release_all_buttons(struct tp_dispatch *tp, uint64_t time)
{
if (tp->buttons.state) {
tp->buttons.state = 0;
@ -622,8 +586,7 @@ tp_release_all_buttons(struct tp_dispatch *tp,
}
static void
tp_init_softbuttons(struct tp_dispatch *tp,
struct evdev_device *device)
tp_init_softbuttons(struct tp_dispatch *tp, struct evdev_device *device)
{
double width, height;
struct device_coords edges;
@ -658,13 +621,12 @@ tp_init_softbuttons(struct tp_dispatch *tp,
* On touchpads with visible markings we reduce the size of the
* middle button since users have a visual guide.
*/
if (evdev_device_has_model_quirk(device,
QUIRK_MODEL_TOUCHPAD_VISIBLE_MARKER)) {
mm.x = width/2 - 5; /* 10mm wide */
if (evdev_device_has_model_quirk(device, QUIRK_MODEL_TOUCHPAD_VISIBLE_MARKER)) {
mm.x = width / 2 - 5; /* 10mm wide */
edges = evdev_device_mm_to_units(device, &mm);
mb_le = edges.x;
mm.x = width/2 + 5; /* 10mm wide */
mm.x = width / 2 + 5; /* 10mm wide */
edges = evdev_device_mm_to_units(device, &mm);
mb_re = edges.x;
} else {
@ -717,7 +679,7 @@ static inline uint32_t
tp_button_config_click_get_methods(struct libinput_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;
uint32_t methods = LIBINPUT_CONFIG_CLICK_METHOD_NONE;
if (tp->buttons.is_clickpad) {
@ -762,7 +724,7 @@ tp_button_config_click_set_method(struct libinput_device *device,
enum libinput_config_click_method method)
{
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;
tp->buttons.click_method = method;
tp_switch_click_method(tp);
@ -774,7 +736,7 @@ static enum libinput_config_click_method
tp_button_config_click_get_method(struct libinput_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;
return tp->buttons.click_method;
}
@ -805,7 +767,7 @@ static enum libinput_config_click_method
tp_button_config_click_get_default_method(struct libinput_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;
return tp_click_get_default_method(tp);
}
@ -813,19 +775,16 @@ tp_button_config_click_get_default_method(struct libinput_device *device)
void
tp_clickpad_middlebutton_apply_config(struct evdev_device *device)
{
struct tp_dispatch *tp = (struct tp_dispatch*)device->dispatch;
struct tp_dispatch *tp = (struct tp_dispatch *)device->dispatch;
if (!tp->buttons.is_clickpad ||
tp->buttons.state != 0)
if (!tp->buttons.is_clickpad || tp->buttons.state != 0)
return;
if (device->middlebutton.want_enabled ==
device->middlebutton.enabled)
if (device->middlebutton.want_enabled == device->middlebutton.enabled)
return;
device->middlebutton.enabled = device->middlebutton.want_enabled;
if (tp->buttons.click_method ==
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)
if (tp->buttons.click_method == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)
tp_init_softbuttons(tp, device);
}
@ -837,7 +796,7 @@ tp_clickpad_middlebutton_is_available(struct libinput_device *device)
static enum libinput_config_status
tp_clickpad_middlebutton_set(struct libinput_device *device,
enum libinput_config_middle_emulation_state enable)
enum libinput_config_middle_emulation_state enable)
{
struct evdev_device *evdev = evdev_device(device);
@ -885,11 +844,9 @@ tp_init_clickpad_middlebutton_emulation(struct tp_dispatch *tp,
}
static inline void
tp_init_middlebutton_emulation(struct tp_dispatch *tp,
struct evdev_device *device)
tp_init_middlebutton_emulation(struct tp_dispatch *tp, struct evdev_device *device)
{
bool enable_by_default,
want_config_option;
bool enable_by_default, want_config_option;
/* On clickpads we provide the config option but disable by default.
When enabled, the middle software button disappears */
@ -913,9 +870,7 @@ tp_init_middlebutton_emulation(struct tp_dispatch *tp,
} else
return;
evdev_init_middlebutton(tp->device,
enable_by_default,
want_config_option);
evdev_init_middlebutton(tp->device, enable_by_default, want_config_option);
}
static bool
@ -937,22 +892,22 @@ tp_guess_clickpad(const struct tp_dispatch *tp, struct evdev_device *device)
*/
if (!is_clickpad && has_left && !has_right &&
(tp->device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON) == 0) {
evdev_log_bug_kernel(device,
"missing right button, assuming it is a clickpad.\n");
evdev_log_bug_kernel(
device,
"missing right button, assuming it is a clickpad.\n");
is_clickpad = true;
}
if (has_middle || has_right) {
if (is_clickpad)
evdev_log_bug_kernel(device,
"clickpad advertising right button. "
"See %s/clickpad-with-right-button.html for details\n",
HTTP_DOC_LINK);
} else if (has_left &&
!is_clickpad &&
evdev_log_bug_kernel(
device,
"clickpad advertising right button. "
"See %s/clickpad-with-right-button.html for details\n",
HTTP_DOC_LINK);
} else if (has_left && !is_clickpad &&
libevdev_get_id_vendor(device->evdev) != VENDOR_ID_APPLE) {
evdev_log_bug_kernel(device,
"non clickpad without right button?\n");
evdev_log_bug_kernel(device, "non clickpad without right button?\n");
}
return is_clickpad;
@ -1004,8 +959,7 @@ tp_button_config_get_default_clickfinger_map(struct libinput_device *device)
}
void
tp_init_buttons(struct tp_dispatch *tp,
struct evdev_device *device)
tp_init_buttons(struct tp_dispatch *tp, struct evdev_device *device)
{
struct tp_touch *t;
const struct input_absinfo *absinfo_x, *absinfo_y;
@ -1013,23 +967,27 @@ tp_init_buttons(struct tp_dispatch *tp,
tp->buttons.is_clickpad = tp_guess_clickpad(tp, device);
tp->buttons.has_topbuttons = libevdev_has_property(device->evdev,
INPUT_PROP_TOPBUTTONPAD);
tp->buttons.has_topbuttons =
libevdev_has_property(device->evdev, INPUT_PROP_TOPBUTTONPAD);
absinfo_x = device->abs.absinfo_x;
absinfo_y = device->abs.absinfo_y;
/* pinned-finger motion threshold, see tp_unpin_finger. */
tp->buttons.motion_dist.x_scale_coeff = 1.0/absinfo_x->resolution;
tp->buttons.motion_dist.y_scale_coeff = 1.0/absinfo_y->resolution;
tp->buttons.motion_dist.x_scale_coeff = 1.0 / absinfo_x->resolution;
tp->buttons.motion_dist.y_scale_coeff = 1.0 / absinfo_y->resolution;
tp->buttons.config_method.get_methods = tp_button_config_click_get_methods;
tp->buttons.config_method.set_method = tp_button_config_click_set_method;
tp->buttons.config_method.get_method = tp_button_config_click_get_method;
tp->buttons.config_method.get_default_method = tp_button_config_click_get_default_method;
tp->buttons.config_method.set_clickfinger_map = tp_button_config_set_clickfinger_map;
tp->buttons.config_method.get_clickfinger_map = tp_button_config_get_clickfinger_map;
tp->buttons.config_method.get_default_clickfinger_map = tp_button_config_get_default_clickfinger_map;
tp->buttons.config_method.get_default_method =
tp_button_config_click_get_default_method;
tp->buttons.config_method.set_clickfinger_map =
tp_button_config_set_clickfinger_map;
tp->buttons.config_method.get_clickfinger_map =
tp_button_config_get_clickfinger_map;
tp->buttons.config_method.get_default_clickfinger_map =
tp_button_config_get_default_clickfinger_map;
tp->device->base.config.click_method = &tp->buttons.config_method;
@ -1057,7 +1015,8 @@ tp_init_buttons(struct tp_dispatch *tp,
libinput_timer_init(&t->button.timer,
tp_libinput_context(tp),
timer_name,
tp_button_handle_timeout, t);
tp_button_handle_timeout,
t);
}
}
@ -1151,12 +1110,11 @@ tp_clickfinger_within_distance(struct tp_dispatch *tp,
* and the other one isn't
*/
if (tp->device->abs.dimensions.y/yres < 50)
if (tp->device->abs.dimensions.y / yres < 50)
goto out;
bottom_threshold = tp->device->abs.absinfo_y->maximum - 20 * yres;
if ((t1->point.y > bottom_threshold) !=
(t2->point.y > bottom_threshold))
if ((t1->point.y > bottom_threshold) != (t2->point.y > bottom_threshold))
within_distance = 0;
out:
@ -1169,8 +1127,7 @@ tp_clickfinger_set_button(struct tp_dispatch *tp)
uint32_t button;
unsigned int nfingers = 0;
struct tp_touch *t;
struct tp_touch *first = NULL,
*second = NULL;
struct tp_touch *first = NULL, *second = NULL;
uint32_t button_map[2][3] = {
{ EVDEV_BTN_LEFT, EVDEV_BTN_RIGHT, EVDEV_BTN_MIDDLE },
{ EVDEV_BTN_LEFT, EVDEV_BTN_MIDDLE, EVDEV_BTN_RIGHT },
@ -1211,7 +1168,7 @@ out:
case 1:
case 2:
case 3:
button = button_map[tp->buttons.map][nfingers-1];
button = button_map[tp->buttons.map][nfingers - 1];
break;
default:
button = 0;
@ -1231,7 +1188,8 @@ tp_notify_clickpadbutton(struct tp_dispatch *tp,
/* If we've a trackpoint, send top buttons through the trackpoint */
if (tp->buttons.trackpoint) {
if (is_topbutton) {
struct evdev_dispatch *dispatch = tp->buttons.trackpoint->dispatch;
struct evdev_dispatch *dispatch =
tp->buttons.trackpoint->dispatch;
int value = (state == LIBINPUT_BUTTON_STATE_PRESSED) ? 1 : 0;
struct evdev_event event = {
.usage = button,
@ -1337,15 +1295,15 @@ tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
}
}
if (area == 0 &&
tp->buttons.click_method != LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) {
if (area == 0 && tp->buttons.click_method !=
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) {
/* No touches, wait for a touch before processing */
tp->buttons.click_pending = true;
return 0;
}
if ((tp->device->middlebutton.enabled || is_top) &&
(area & LEFT) && (area & RIGHT)) {
if ((tp->device->middlebutton.enabled || is_top) && (area & LEFT) &&
(area & RIGHT)) {
button = evdev_usage_from(EVDEV_BTN_MIDDLE);
} else if (area & MIDDLE) {
button = evdev_usage_from(EVDEV_BTN_MIDDLE);
@ -1378,11 +1336,7 @@ tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
tp->buttons.click_pending = false;
if (evdev_usage_ne(button, 0))
return tp_notify_clickpadbutton(tp,
time,
button,
is_top,
state);
return tp_notify_clickpadbutton(tp, time, button, is_top, state);
return 0;
}
@ -1397,8 +1351,7 @@ tp_post_button_events(struct tp_dispatch *tp, uint64_t time)
}
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)
{
return t->button.state == BUTTON_STATE_AREA || t->button.has_moved;
}
@ -1407,6 +1360,5 @@ bool
tp_button_is_inside_softbutton_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
{
return is_inside_top_button_area(tp, t) ||
is_inside_bottom_button_area(tp, t);
return is_inside_top_button_area(tp, t) || is_inside_bottom_button_area(tp, t);
}

View file

@ -43,7 +43,7 @@ enum scroll_event {
SCROLL_EVENT_POSTED,
};
static inline const char*
static inline const char *
edge_state_to_str(enum tp_edge_scroll_touch_state state)
{
@ -56,7 +56,7 @@ edge_state_to_str(enum tp_edge_scroll_touch_state state)
return NULL;
}
static inline const char*
static inline const char *
edge_event_to_str(enum scroll_event event)
{
switch (event) {
@ -87,21 +87,17 @@ tp_touch_get_edge(const struct tp_dispatch *tp, const struct tp_touch *t)
}
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, uint64_t time)
{
const int DEFAULT_SCROLL_LOCK_TIMEOUT = ms2us(300);
/* if we use software buttons, we disable timeout-based
* edge scrolling. A finger resting on the button areas is
* likely there to trigger a button event.
*/
if (tp->buttons.click_method ==
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)
if (tp->buttons.click_method == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)
return;
libinput_timer_set(&t->scroll.timer,
time + DEFAULT_SCROLL_LOCK_TIMEOUT);
libinput_timer_set(&t->scroll.timer, time + DEFAULT_SCROLL_LOCK_TIMEOUT);
}
static void
@ -155,10 +151,11 @@ tp_edge_scroll_handle_none(struct tp_dispatch *tp,
case SCROLL_EVENT_RELEASE:
case SCROLL_EVENT_TIMEOUT:
case SCROLL_EVENT_POSTED:
evdev_log_bug_libinput(tp->device,
"edge-scroll: touch %d: unexpected scroll event %d in none state\n",
t->index,
event);
evdev_log_bug_libinput(
tp->device,
"edge-scroll: touch %d: unexpected scroll event %d in none state\n",
t->index,
event);
break;
}
}
@ -171,10 +168,11 @@ tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp,
{
switch (event) {
case SCROLL_EVENT_TOUCH:
evdev_log_bug_libinput(tp->device,
"edge-scroll: touch %d: unexpected scroll event %d in edge new state\n",
t->index,
event);
evdev_log_bug_libinput(
tp->device,
"edge-scroll: touch %d: unexpected scroll event %d in edge new state\n",
t->index,
event);
break;
case SCROLL_EVENT_MOTION:
t->scroll.edge &= tp_touch_get_edge(tp, t);
@ -185,17 +183,11 @@ tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp,
time);
break;
case SCROLL_EVENT_RELEASE:
tp_edge_scroll_set_state(tp,
t,
EDGE_SCROLL_TOUCH_STATE_NONE,
time);
tp_edge_scroll_set_state(tp, t, EDGE_SCROLL_TOUCH_STATE_NONE, time);
break;
case SCROLL_EVENT_TIMEOUT:
case SCROLL_EVENT_POSTED:
tp_edge_scroll_set_state(tp,
t,
EDGE_SCROLL_TOUCH_STATE_EDGE,
time);
tp_edge_scroll_set_state(tp, t, EDGE_SCROLL_TOUCH_STATE_EDGE, time);
break;
}
}
@ -209,10 +201,11 @@ tp_edge_scroll_handle_edge(struct tp_dispatch *tp,
switch (event) {
case SCROLL_EVENT_TOUCH:
case SCROLL_EVENT_TIMEOUT:
evdev_log_bug_libinput(tp->device,
"edge-scroll: touch %d: unexpected scroll event %d in edge state\n",
t->index,
event);
evdev_log_bug_libinput(
tp->device,
"edge-scroll: touch %d: unexpected scroll event %d in edge state\n",
t->index,
event);
break;
case SCROLL_EVENT_MOTION:
/* If started at the bottom right, decide in which dir to scroll */
@ -226,10 +219,7 @@ tp_edge_scroll_handle_edge(struct tp_dispatch *tp,
}
break;
case SCROLL_EVENT_RELEASE:
tp_edge_scroll_set_state(tp,
t,
EDGE_SCROLL_TOUCH_STATE_NONE,
time);
tp_edge_scroll_set_state(tp, t, EDGE_SCROLL_TOUCH_STATE_NONE, time);
break;
case SCROLL_EVENT_POSTED:
break;
@ -247,16 +237,13 @@ tp_edge_scroll_handle_area(struct tp_dispatch *tp,
case SCROLL_EVENT_TIMEOUT:
case SCROLL_EVENT_POSTED:
evdev_log_bug_libinput(tp->device,
"unexpected scroll event %d in area state\n",
event);
"unexpected scroll event %d in area state\n",
event);
break;
case SCROLL_EVENT_MOTION:
break;
case SCROLL_EVENT_RELEASE:
tp_edge_scroll_set_state(tp,
t,
EDGE_SCROLL_TOUCH_STATE_NONE,
time);
tp_edge_scroll_set_state(tp, t, EDGE_SCROLL_TOUCH_STATE_NONE, time);
break;
}
}
@ -319,7 +306,7 @@ tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device)
when software buttons were a thing, e.g. Lenovo *20 series)
*/
if (!tp->buttons.is_clickpad)
want_horiz_scroll = (height >= 40);
want_horiz_scroll = (height >= 40);
/* 7mm edge size */
mm.x = width - 7;
@ -345,7 +332,8 @@ tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device)
libinput_timer_init(&t->scroll.timer,
tp_libinput_context(tp),
timer_name,
tp_edge_scroll_handle_timeout, t);
tp_edge_scroll_handle_timeout,
t);
}
}
@ -368,11 +356,9 @@ tp_edge_scroll_handle_state(struct tp_dispatch *tp, uint64_t time)
if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_EDGE) {
tp_for_each_touch(tp, t) {
if (t->state == TOUCH_BEGIN)
t->scroll.edge_state =
EDGE_SCROLL_TOUCH_STATE_AREA;
t->scroll.edge_state = EDGE_SCROLL_TOUCH_STATE_AREA;
else if (t->state == TOUCH_END)
t->scroll.edge_state =
EDGE_SCROLL_TOUCH_STATE_NONE;
t->scroll.edge_state = EDGE_SCROLL_TOUCH_STATE_NONE;
}
return;
}
@ -386,16 +372,10 @@ tp_edge_scroll_handle_state(struct tp_dispatch *tp, uint64_t time)
case TOUCH_HOVERING:
break;
case TOUCH_BEGIN:
tp_edge_scroll_handle_event(tp,
t,
SCROLL_EVENT_TOUCH,
time);
tp_edge_scroll_handle_event(tp, t, SCROLL_EVENT_TOUCH, time);
break;
case TOUCH_UPDATE:
tp_edge_scroll_handle_event(tp,
t,
SCROLL_EVENT_MOTION,
time);
tp_edge_scroll_handle_event(tp, t, SCROLL_EVENT_MOTION, time);
break;
case TOUCH_MAYBE_END:
/* This shouldn't happen we transfer to TOUCH_END
@ -406,10 +386,7 @@ tp_edge_scroll_handle_state(struct tp_dispatch *tp, uint64_t time)
t->state);
_fallthrough_;
case TOUCH_END:
tp_edge_scroll_handle_event(tp,
t,
SCROLL_EVENT_RELEASE,
time);
tp_edge_scroll_handle_event(tp, t, SCROLL_EVENT_RELEASE, time);
break;
}
}
@ -435,31 +412,30 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
continue;
/* only scroll with the finger in the previous edge */
if (t->scroll.edge &&
(tp_touch_get_edge(tp, t) & t->scroll.edge) == 0)
if (t->scroll.edge && (tp_touch_get_edge(tp, t) & t->scroll.edge) == 0)
continue;
switch (t->scroll.edge) {
case EDGE_NONE:
if (t->scroll.direction != -1) {
/* Send stop scroll event */
evdev_notify_axis_finger(device,
time,
bit(t->scroll.direction),
&zero);
t->scroll.direction = -1;
}
continue;
case EDGE_RIGHT:
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
delta = &normalized.y;
break;
case EDGE_BOTTOM:
axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
delta = &normalized.x;
break;
default: /* EDGE_RIGHT | EDGE_BOTTOM */
continue; /* Don't know direction yet, skip */
case EDGE_NONE:
if (t->scroll.direction != -1) {
/* Send stop scroll event */
evdev_notify_axis_finger(device,
time,
bit(t->scroll.direction),
&zero);
t->scroll.direction = -1;
}
continue;
case EDGE_RIGHT:
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
delta = &normalized.y;
break;
case EDGE_BOTTOM:
axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
delta = &normalized.x;
break;
default: /* EDGE_RIGHT | EDGE_BOTTOM */
continue; /* Don't know direction yet, skip */
}
raw = tp_get_delta(t);
@ -472,14 +448,14 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
case EDGE_SCROLL_TOUCH_STATE_NONE:
case EDGE_SCROLL_TOUCH_STATE_AREA:
evdev_log_bug_libinput(device,
"unexpected scroll state %d\n",
t->scroll.edge_state);
"unexpected scroll state %d\n",
t->scroll.edge_state);
break;
case EDGE_SCROLL_TOUCH_STATE_EDGE_NEW:
tmp = normalized;
normalized = tp_normalize_delta(tp,
device_delta(t->point,
t->scroll.initial));
normalized = tp_normalize_delta(
tp,
device_delta(t->point, t->scroll.initial));
if (fabs(*delta) < DEFAULT_SCROLL_THRESHOLD)
normalized = zero;
else
@ -492,9 +468,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
if (*delta == 0.0)
continue;
evdev_notify_axis_finger(device, time,
bit(axis),
&normalized);
evdev_notify_axis_finger(device, time, bit(axis), &normalized);
t->scroll.direction = axis;
tp_edge_scroll_handle_event(tp, t, SCROLL_EVENT_POSTED, time);
@ -526,8 +500,7 @@ tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time)
}
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)
{
return t->scroll.edge_state == EDGE_SCROLL_TOUCH_STATE_AREA;
}

View file

@ -68,7 +68,7 @@ enum gesture_event {
* Any changes in this file must be represented in the diagram.
*/
static inline const char*
static inline const char *
gesture_state_to_str(enum tp_gesture_state state)
{
switch (state) {
@ -90,10 +90,10 @@ gesture_state_to_str(enum tp_gesture_state state)
return NULL;
}
static inline const char*
static inline const char *
gesture_event_to_str(enum gesture_event event)
{
switch(event) {
switch (event) {
CASE_RETURN_STRING(GESTURE_EVENT_RESET);
CASE_RETURN_STRING(GESTURE_EVENT_END);
CASE_RETURN_STRING(GESTURE_EVENT_CANCEL);
@ -117,7 +117,7 @@ tp_get_touches_delta(struct tp_dispatch *tp, bool average)
{
struct tp_touch *t;
unsigned int i, nactive = 0;
struct device_float_coords delta = {0.0, 0.0};
struct device_float_coords delta = { 0.0, 0.0 };
for (i = 0; i < tp->num_slots; i++) {
t = &tp->touches[i];
@ -149,7 +149,7 @@ tp_get_touches_delta(struct tp_dispatch *tp, bool average)
static void
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.v = false;
tp->scroll.duration.h = 0;
@ -214,10 +214,7 @@ tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
struct device_float_coords unaccel;
unaccel = tp_scale_to_xaxis(tp, raw);
pointer_notify_motion(&tp->device->base,
time,
&delta,
&unaccel);
pointer_notify_motion(&tp->device->base, time, &delta, &unaccel);
}
}
@ -262,10 +259,8 @@ tp_gesture_same_directions(int dir1, int dir2)
* The ((dira & 0x80) && (dirb & 0x01)) checks are to check for bit 0
* and 7 being set as they also represent neighboring directions.
*/
return ((dir1 | (dir1 >> 1)) & dir2) ||
((dir2 | (dir2 >> 1)) & dir1) ||
((dir1 & 0x80) && (dir2 & 0x01)) ||
((dir2 & 0x80) && (dir1 & 0x01));
return ((dir1 | (dir1 >> 1)) & dir2) || ((dir2 | (dir2 >> 1)) & dir1) ||
((dir1 & 0x80) && (dir2 & 0x01)) || ((dir2 & 0x80) && (dir1 & 0x01));
}
static struct phys_coords
@ -347,16 +342,15 @@ tp_gesture_set_scroll_buildup(struct tp_dispatch *tp)
static void
tp_gesture_apply_scroll_constraints(struct tp_dispatch *tp,
struct device_float_coords *raw,
struct normalized_coords *delta,
uint64_t time)
struct device_float_coords *raw,
struct normalized_coords *delta,
uint64_t time)
{
uint64_t tdelta = 0;
struct phys_coords delta_mm, vector;
double vector_decay, vector_length, slope;
const uint64_t ACTIVE_THRESHOLD = ms2us(100),
INACTIVE_THRESHOLD = ms2us(50),
const uint64_t ACTIVE_THRESHOLD = ms2us(100), INACTIVE_THRESHOLD = ms2us(50),
EVENT_TIMEOUT = ms2us(100);
/* Both axes active == true means free scrolling is enabled */
@ -380,12 +374,9 @@ tp_gesture_apply_scroll_constraints(struct tp_dispatch *tp,
*/
if (tdelta > 0) {
double recent, later;
recent = ((EVENT_TIMEOUT / 2.0) - tdelta) /
(EVENT_TIMEOUT / 2.0);
later = (EVENT_TIMEOUT - tdelta) /
(EVENT_TIMEOUT * 2.0);
vector_decay = tdelta <= (0.33 * EVENT_TIMEOUT) ?
recent : later;
recent = ((EVENT_TIMEOUT / 2.0) - tdelta) / (EVENT_TIMEOUT / 2.0);
later = (EVENT_TIMEOUT - tdelta) / (EVENT_TIMEOUT * 2.0);
vector_decay = tdelta <= (0.33 * EVENT_TIMEOUT) ? recent : later;
} else {
vector_decay = 0.0;
}
@ -426,7 +417,7 @@ tp_gesture_apply_scroll_constraints(struct tp_dispatch *tp,
tp->scroll.duration.h = 0;
}
}
if (slope < DEGREE_60 && vector_length > MIN_VECTOR) {
if (slope < DEGREE_60 && vector_length > MIN_VECTOR) {
tp->scroll.duration.h += tdelta;
if (tp->scroll.duration.h > ACTIVE_THRESHOLD)
tp->scroll.duration.h = ACTIVE_THRESHOLD;
@ -489,8 +480,7 @@ tp_gesture_is_quick_hold(struct tp_dispatch *tp)
* make the hold to stop kinetic scrolling user interaction feel more
* natural.
*/
return (tp->gesture.finger_count == 1) ||
(tp->gesture.finger_count == 2);
return (tp->gesture.finger_count == 1) || (tp->gesture.finger_count == 2);
}
static bool
@ -537,9 +527,8 @@ tp_gesture_set_hold_timer(struct tp_dispatch *tp, uint64_t time)
return;
if (tp_gesture_use_hold_timer(tp)) {
timeout = tp_gesture_is_quick_hold(tp) ?
QUICK_GESTURE_HOLD_TIMEOUT :
DEFAULT_GESTURE_HOLD_TIMEOUT;
timeout = tp_gesture_is_quick_hold(tp) ? QUICK_GESTURE_HOLD_TIMEOUT
: DEFAULT_GESTURE_HOLD_TIMEOUT;
libinput_timer_set(&tp->gesture.hold_timer, time + timeout);
}
@ -550,7 +539,7 @@ tp_gesture_handle_event_on_state_none(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL:
@ -561,7 +550,8 @@ tp_gesture_handle_event_on_state_none(struct tp_dispatch *tp,
* 3fg pinch/hold. Those are niche enough to not worry about
* for now.
*/
if (!tp->tap.enabled && tp->drag_3fg.nfingers == tp->gesture.finger_count) {
if (!tp->tap.enabled &&
tp->drag_3fg.nfingers == tp->gesture.finger_count) {
tp->gesture.state = GESTURE_STATE_3FG_DRAG_START;
} else {
tp_gesture_set_hold_timer(tp, time);
@ -593,7 +583,7 @@ tp_gesture_handle_event_on_state_unknown(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL:
@ -605,7 +595,8 @@ tp_gesture_handle_event_on_state_unknown(struct tp_dispatch *tp,
case GESTURE_EVENT_HOLD_TIMEOUT:
case GESTURE_EVENT_TAP_TIMEOUT:
tp->gesture.state = GESTURE_STATE_HOLD;
gesture_notify_hold_begin(&tp->device->base, time,
gesture_notify_hold_begin(&tp->device->base,
time,
tp->gesture.finger_count);
break;
case GESTURE_EVENT_POINTER_MOTION_START:
@ -645,15 +636,17 @@ tp_gesture_handle_event_on_state_hold(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
log_gesture_bug(tp, event);
break;
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL: {
bool cancelled = event == GESTURE_EVENT_CANCEL;
gesture_notify_hold_end(&tp->device->base, time,
tp->gesture.finger_count, cancelled);
gesture_notify_hold_end(&tp->device->base,
time,
tp->gesture.finger_count,
cancelled);
libinput_timer_cancel(&tp->gesture.hold_timer);
tp->gesture.state = GESTURE_STATE_NONE;
break;
@ -701,15 +694,17 @@ tp_gesture_handle_event_on_state_hold_and_motion(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
log_gesture_bug(tp, event);
break;
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL: {
bool cancelled = event == GESTURE_EVENT_CANCEL;
gesture_notify_hold_end(&tp->device->base, time,
tp->gesture.finger_count, cancelled);
gesture_notify_hold_end(&tp->device->base,
time,
tp->gesture.finger_count,
cancelled);
libinput_timer_cancel(&tp->gesture.hold_timer);
tp->gesture.state = GESTURE_STATE_NONE;
break;
@ -744,7 +739,7 @@ tp_gesture_handle_event_on_state_pointer_motion(struct tp_dispatch *tp,
struct phys_coords first_moved;
double first_mm;
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL:
@ -762,8 +757,9 @@ tp_gesture_handle_event_on_state_pointer_motion(struct tp_dispatch *tp,
if (first_mm < HOLD_AND_MOTION_THRESHOLD) {
tp->gesture.state = GESTURE_STATE_HOLD_AND_MOTION;
gesture_notify_hold_begin(&tp->device->base, time,
tp->gesture.finger_count);
gesture_notify_hold_begin(&tp->device->base,
time,
tp->gesture.finger_count);
}
break;
case GESTURE_EVENT_FINGER_SWITCH_TIMEOUT:
@ -785,7 +781,7 @@ tp_gesture_handle_event_on_state_scroll_start(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL:
@ -818,7 +814,7 @@ tp_gesture_handle_event_on_state_scroll(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL:
@ -853,7 +849,7 @@ tp_gesture_handle_event_on_state_pinch_start(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL:
@ -881,14 +877,15 @@ tp_gesture_handle_event_on_state_pinch(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
log_gesture_bug(tp, event);
break;
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL: {
bool cancelled = event == GESTURE_EVENT_CANCEL;
gesture_notify_pinch_end(&tp->device->base, time,
gesture_notify_pinch_end(&tp->device->base,
time,
tp->gesture.finger_count,
tp->gesture.prev_scale,
cancelled);
@ -919,7 +916,7 @@ tp_gesture_handle_event_on_state_swipe_start(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL:
@ -948,7 +945,7 @@ tp_gesture_handle_event_on_state_swipe(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
log_gesture_bug(tp, event);
break;
@ -986,7 +983,7 @@ tp_gesture_handle_event_on_state_3fg_drag_start(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
case GESTURE_EVENT_END:
case GESTURE_EVENT_CANCEL:
@ -1022,7 +1019,7 @@ tp_gesture_handle_event_on_state_3fg_drag(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
log_gesture_bug(tp, event);
break;
@ -1043,9 +1040,9 @@ tp_gesture_handle_event_on_state_3fg_drag(struct tp_dispatch *tp,
case GESTURE_EVENT_FINGER_SWITCH_TIMEOUT:
if (tp->gesture.finger_count_pending < 2) {
evdev_pointer_notify_button(tp->device,
tp->gesture.drag_3fg_release_time,
evdev_usage_from(EVDEV_BTN_LEFT),
LIBINPUT_BUTTON_STATE_RELEASED);
tp->gesture.drag_3fg_release_time,
evdev_usage_from(EVDEV_BTN_LEFT),
LIBINPUT_BUTTON_STATE_RELEASED);
tp->gesture.state = GESTURE_STATE_NONE;
}
break;
@ -1070,7 +1067,7 @@ tp_gesture_handle_event_on_state_3fg_drag_released(struct tp_dispatch *tp,
enum gesture_event event,
uint64_t time)
{
switch(event) {
switch (event) {
case GESTURE_EVENT_RESET:
log_gesture_bug(tp, event);
break;
@ -1128,15 +1125,13 @@ tp_gesture_handle_event_on_state_3fg_drag_released(struct tp_dispatch *tp,
}
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, uint64_t time)
{
enum tp_gesture_state oldstate;
oldstate = tp->gesture.state;
switch(tp->gesture.state) {
switch (tp->gesture.state) {
case GESTURE_STATE_NONE:
tp_gesture_handle_event_on_state_none(tp, event, time);
break;
@ -1224,8 +1219,7 @@ static void
tp_gesture_detect_motion_gestures(struct tp_dispatch *tp, uint64_t time)
{
struct tp_touch *first = tp->gesture.touches[0],
*second = tp->gesture.touches[1],
*thumb;
*second = tp->gesture.touches[1], *thumb;
uint32_t dir1, dir2;
struct device_coords delta;
struct phys_coords first_moved, second_moved, distance_mm;
@ -1243,8 +1237,7 @@ tp_gesture_detect_motion_gestures(struct tp_dispatch *tp, uint64_t time)
is_hold_and_motion = (first_mm < HOLD_AND_MOTION_THRESHOLD);
if (tp->gesture.state == GESTURE_STATE_HOLD &&
is_hold_and_motion) {
if (tp->gesture.state == GESTURE_STATE_HOLD && is_hold_and_motion) {
tp_gesture_handle_event(tp,
GESTURE_EVENT_HOLD_AND_MOTION_START,
time);
@ -1255,9 +1248,7 @@ tp_gesture_detect_motion_gestures(struct tp_dispatch *tp, uint64_t time)
is_hold_and_motion)
return;
tp_gesture_handle_event(tp,
GESTURE_EVENT_POINTER_MOTION_START,
time);
tp_gesture_handle_event(tp, GESTURE_EVENT_POINTER_MOTION_START, time);
return;
}
@ -1289,8 +1280,7 @@ tp_gesture_detect_motion_gestures(struct tp_dispatch *tp, uint64_t time)
/* If both touches are within 7mm vertically and 40mm horizontally
* 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)) {
if (tp->gesture.finger_count == 2)
tp_gesture_handle_event(tp, GESTURE_EVENT_SCROLL_START, time);
@ -1304,8 +1294,8 @@ tp_gesture_detect_motion_gestures(struct tp_dispatch *tp, uint64_t time)
/* If 3fg dragging touches are within a 60x10mm box, start
* dragging immediately */
if (tp->gesture.finger_count == tp->drag_3fg.nfingers &&
distance_mm.x < 60.0 && distance_mm.y < 10.0) {
if (tp->gesture.finger_count == tp->drag_3fg.nfingers && distance_mm.x < 60.0 &&
distance_mm.y < 10.0) {
tp_gesture_handle_event(tp, GESTURE_EVENT_3FG_DRAG_START, time);
return;
}
@ -1353,10 +1343,8 @@ tp_gesture_detect_motion_gestures(struct tp_dispatch *tp, uint64_t time)
/* If more than 2 fingers are involved, and the thumb moves
* while the fingers stay still, assume a pinch if eligible.
*/
if (finger_mm < min_move &&
tp->gesture.finger_count > 2 &&
tp->gesture.enabled &&
tp->thumb.pinch_eligible) {
if (finger_mm < min_move && tp->gesture.finger_count > 2 &&
tp->gesture.enabled && tp->thumb.pinch_eligible) {
tp_gesture_handle_event(tp, GESTURE_EVENT_PINCH_START, time);
return;
}
@ -1447,9 +1435,7 @@ tp_gesture_handle_state_none(struct tp_dispatch *tp, uint64_t time)
first->gesture.initial = first->point;
tp->gesture.touches[0] = first;
tp_gesture_handle_event(tp,
GESTURE_EVENT_FINGER_DETECTED,
time);
tp_gesture_handle_event(tp, GESTURE_EVENT_FINGER_DETECTED, time);
return;
}
@ -1487,7 +1473,6 @@ tp_gesture_handle_state_none(struct tp_dispatch *tp, uint64_t time)
if (first == second)
return;
}
tp->gesture.initial_time = time;
@ -1500,7 +1485,8 @@ tp_gesture_handle_state_none(struct tp_dispatch *tp, uint64_t time)
}
static void
tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time,
tp_gesture_handle_state_unknown(struct tp_dispatch *tp,
uint64_t time,
bool ignore_motion)
{
if (!ignore_motion)
@ -1508,8 +1494,7 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time,
}
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, uint64_t time, bool ignore_motion)
{
if (!ignore_motion)
tp_gesture_detect_motion_gestures(tp, time);
@ -1605,10 +1590,12 @@ tp_gesture_handle_state_swipe_start(struct tp_dispatch *tp, uint64_t time)
if (!normalized_is_zero(delta) || !device_float_is_zero(raw)) {
const struct normalized_coords zero = { 0.0, 0.0 };
gesture_notify_swipe(&tp->device->base, time,
gesture_notify_swipe(&tp->device->base,
time,
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
tp->gesture.finger_count,
&zero, &zero);
&zero,
&zero);
tp->gesture.state = GESTURE_STATE_SWIPE;
}
}
@ -1624,10 +1611,12 @@ tp_gesture_handle_state_swipe(struct tp_dispatch *tp, uint64_t time)
if (!normalized_is_zero(delta) || !device_float_is_zero(raw)) {
unaccel = tp_filter_motion_unaccelerated(tp, &raw, time);
gesture_notify_swipe(&tp->device->base, time,
gesture_notify_swipe(&tp->device->base,
time,
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
tp->gesture.finger_count,
&delta, &unaccel);
&delta,
&unaccel);
}
}
@ -1659,10 +1648,14 @@ tp_gesture_handle_state_pinch_start(struct tp_dispatch *tp, uint64_t time)
scale == tp->gesture.prev_scale && angle_delta == 0.0)
return;
gesture_notify_pinch(&tp->device->base, time,
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
tp->gesture.finger_count,
&zero, &zero, 1.0, 0.0);
gesture_notify_pinch(&tp->device->base,
time,
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
tp->gesture.finger_count,
&zero,
&zero,
1.0,
0.0);
tp->gesture.prev_scale = scale;
tp->gesture.state = GESTURE_STATE_PINCH;
@ -1696,10 +1689,14 @@ tp_gesture_handle_state_pinch(struct tp_dispatch *tp, uint64_t time)
return;
unaccel = tp_filter_motion_unaccelerated(tp, &fdelta, time);
gesture_notify_pinch(&tp->device->base, time,
gesture_notify_pinch(&tp->device->base,
time,
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
tp->gesture.finger_count,
&delta, &unaccel, scale, angle_delta);
&delta,
&unaccel,
scale,
angle_delta);
tp->gesture.prev_scale = scale;
}
@ -1731,11 +1728,10 @@ tp_gesture_handle_state_3fg_drag_released(struct tp_dispatch *tp,
}
static void
tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time,
bool ignore_motion)
tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time, bool ignore_motion)
{
enum tp_gesture_state oldstate = tp->gesture.state;
enum tp_gesture_state transitions[16] = {0};
enum tp_gesture_state transitions[16] = { 0 };
enum tp_gesture_state *transition_state = transitions;
#define REMEMBER_TRANSITION(_ts, _state) { \
@ -1809,10 +1805,12 @@ tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time,
if (oldstate != tp->gesture.state) {
_autostrvfree_ char **states = NULL;
states = strv_append_strdup(states, gesture_state_to_str(oldstate));
for (enum tp_gesture_state *s = transitions + 1; s < transition_state; s++) {
for (enum tp_gesture_state *s = transitions + 1; s < transition_state;
s++) {
states = strv_append_strdup(states, gesture_state_to_str(*s));
}
states = strv_append_strdup(states, gesture_state_to_str(tp->gesture.state));
states = strv_append_strdup(states,
gesture_state_to_str(tp->gesture.state));
_autofree_ char *str = strv_join(states, "");
evdev_log_debug(tp->device,
"gesture: [%dfg] state %s\n",
@ -1841,8 +1839,7 @@ tp_gesture_thumb_moved(struct tp_dispatch *tp)
}
void
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time,
bool ignore_motion)
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time, bool ignore_motion)
{
if (tp->gesture.finger_count == 0)
return;
@ -1851,9 +1848,8 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time,
* physical button is down, don't allow gestures unless the button
* is held down by a *thumb*, specifically.
*/
if (tp_tap_dragging(tp) ||
(tp->buttons.is_clickpad && tp->buttons.state &&
tp->thumb.state == THUMB_STATE_FINGER)) {
if (tp_tap_dragging(tp) || (tp->buttons.is_clickpad && tp->buttons.state &&
tp->thumb.state == THUMB_STATE_FINGER)) {
if (tp->gesture.state != GESTURE_STATE_POINTER_MOTION) {
tp_gesture_cancel(tp, time);
tp_gesture_handle_event(tp,
@ -1885,9 +1881,7 @@ tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_2FG)
return;
evdev_stop_scroll(tp->device,
time,
LIBINPUT_POINTER_AXIS_SOURCE_FINGER);
evdev_stop_scroll(tp->device, time, LIBINPUT_POINTER_AXIS_SOURCE_FINGER);
}
static void
@ -2018,7 +2012,7 @@ tp_gesture_update_finger_state(struct tp_dispatch *tp, uint64_t time)
tp_gesture_stop(tp, time);
tp->gesture.finger_count = 0;
tp->gesture.finger_count_pending = 0;
/* Immediately switch to new mode to avoid initial latency */
/* Immediately switch to new mode to avoid initial latency */
} else if (!tp_gesture_debounce_finger_changes(tp)) {
tp->gesture.finger_count = active_touches;
tp->gesture.finger_count_pending = 0;
@ -2027,18 +2021,16 @@ tp_gesture_update_finger_state(struct tp_dispatch *tp, uint64_t time)
*/
if (tp->gesture.state == GESTURE_STATE_UNKNOWN ||
tp->gesture.state == GESTURE_STATE_POINTER_MOTION) {
tp_gesture_handle_event(tp,
GESTURE_EVENT_RESET,
time);
tp_gesture_handle_event(tp, GESTURE_EVENT_RESET, time);
}
/* Else debounce finger changes */
/* Else debounce finger changes */
} else if (active_touches != tp->gesture.finger_count_pending) {
tp->gesture.finger_count_pending = active_touches;
libinput_timer_set(&tp->gesture.finger_count_switch_timer,
time + DEFAULT_GESTURE_SWITCH_TIMEOUT);
}
} else {
tp->gesture.finger_count_pending = 0;
tp->gesture.finger_count_pending = 0;
}
}
@ -2069,8 +2061,8 @@ tp_gesture_is_hold_enabled(struct libinput_device *device)
struct evdev_dispatch *dispatch = evdev_device(device)->dispatch;
struct tp_dispatch *tp = tp_dispatch(dispatch);
return tp->gesture.hold_enabled ? LIBINPUT_CONFIG_HOLD_ENABLED :
LIBINPUT_CONFIG_HOLD_DISABLED;
return tp->gesture.hold_enabled ? LIBINPUT_CONFIG_HOLD_ENABLED
: LIBINPUT_CONFIG_HOLD_DISABLED;
}
static enum libinput_config_hold_state
@ -2079,9 +2071,8 @@ tp_gesture_get_hold_default(struct libinput_device *device)
struct evdev_dispatch *dispatch = evdev_device(device)->dispatch;
struct tp_dispatch *tp = tp_dispatch(dispatch);
return tp_gesture_are_gestures_enabled(tp) ?
LIBINPUT_CONFIG_HOLD_ENABLED :
LIBINPUT_CONFIG_HOLD_DISABLED;
return tp_gesture_are_gestures_enabled(tp) ? LIBINPUT_CONFIG_HOLD_ENABLED
: LIBINPUT_CONFIG_HOLD_DISABLED;
}
static int
@ -2169,7 +2160,9 @@ tp_3fg_drag_apply_config(struct evdev_device *device)
tp->drag_3fg.nfingers = tp->drag_3fg.want_nfingers;
evdev_log_debug(device, "touchpad-3fg-drag: drag is now for %zd fingers\n", tp->drag_3fg.nfingers);
evdev_log_debug(device,
"touchpad-3fg-drag: drag is now for %zd fingers\n",
tp->drag_3fg.nfingers);
}
void
@ -2216,7 +2209,8 @@ tp_init_gesture(struct tp_dispatch *tp)
libinput_timer_init(&tp->gesture.finger_count_switch_timer,
tp_libinput_context(tp),
timer_name,
tp_gesture_finger_count_switch_timeout, tp);
tp_gesture_finger_count_switch_timeout,
tp);
snprintf(timer_name,
sizeof(timer_name),
@ -2225,7 +2219,8 @@ tp_init_gesture(struct tp_dispatch *tp)
libinput_timer_init(&tp->gesture.hold_timer,
tp_libinput_context(tp),
timer_name,
tp_gesture_hold_timeout, tp);
tp_gesture_hold_timeout,
tp);
snprintf(timer_name,
sizeof(timer_name),
"%s drag_3fg",
@ -2233,7 +2228,8 @@ tp_init_gesture(struct tp_dispatch *tp)
libinput_timer_init(&tp->gesture.drag_3fg_timer,
tp_libinput_context(tp),
timer_name,
tp_gesture_3fg_drag_timeout, tp);
tp_gesture_3fg_drag_timeout,
tp);
}
void

View file

@ -55,10 +55,10 @@ enum tap_event {
* Any changes in this file must be represented in the diagram.
*/
static inline const char*
static inline const char *
tap_state_to_str(enum tp_tap_state state)
{
switch(state) {
switch (state) {
CASE_RETURN_STRING(TAP_STATE_IDLE);
CASE_RETURN_STRING(TAP_STATE_HOLD);
CASE_RETURN_STRING(TAP_STATE_TOUCH);
@ -92,10 +92,10 @@ tap_state_to_str(enum tp_tap_state state)
return NULL;
}
static inline const char*
static inline const char *
tap_event_to_str(enum tap_event event)
{
switch(event) {
switch (event) {
CASE_RETURN_STRING(TAP_EVENT_TOUCH);
CASE_RETURN_STRING(TAP_EVENT_MOTION);
CASE_RETURN_STRING(TAP_EVENT_RELEASE);
@ -116,7 +116,6 @@ log_tap_bug(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event)
t->index,
tap_event_to_str(event),
tap_state_to_str(tp->tap.state));
}
static void
@ -158,20 +157,18 @@ tp_tap_set_timer(struct tp_dispatch *tp, uint64_t time)
}
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, uint64_t time, int nfingers_tapped)
{
libinput_timer_set(&tp->tap.timer,
time + DEFAULT_DRAG_TIMEOUT_PERIOD_BASE +
(nfingers_tapped *
DEFAULT_DRAG_TIMEOUT_PERIOD_PERFINGER));
libinput_timer_set(
&tp->tap.timer,
time + DEFAULT_DRAG_TIMEOUT_PERIOD_BASE +
(nfingers_tapped * DEFAULT_DRAG_TIMEOUT_PERIOD_PERFINGER));
}
static void
tp_tap_set_draglock_timer(struct tp_dispatch *tp, uint64_t time)
{
libinput_timer_set(&tp->tap.timer,
time + DEFAULT_DRAGLOCK_TIMEOUT_PERIOD);
libinput_timer_set(&tp->tap.timer, time + DEFAULT_DRAGLOCK_TIMEOUT_PERIOD);
}
static void
@ -191,7 +188,8 @@ tp_tap_move_to_dead(struct tp_dispatch *tp, struct tp_touch *t)
static void
tp_tap_idle_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
case TAP_EVENT_TOUCH:
@ -223,7 +221,8 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp,
static void
tp_tap_touch_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
@ -242,10 +241,7 @@ tp_tap_touch_handle_event(struct tp_dispatch *tp,
tp->tap.saved_release_time = time;
tp_tap_set_drag_timer(tp, time, 1);
} else {
tp_tap_notify(tp,
time,
1,
LIBINPUT_BUTTON_STATE_RELEASED);
tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED);
tp->tap.state = TAP_STATE_IDLE;
}
break;
@ -279,7 +275,8 @@ tp_tap_touch_handle_event(struct tp_dispatch *tp,
static void
tp_tap_hold_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
@ -316,7 +313,8 @@ tp_tap_hold_handle_event(struct tp_dispatch *tp,
static void
tp_tap_tapped_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time,
enum tap_event event,
uint64_t time,
int nfingers_tapped)
{
switch (event) {
@ -364,7 +362,8 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp,
static void
tp_tap_touch2_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
@ -401,7 +400,8 @@ tp_tap_touch2_handle_event(struct tp_dispatch *tp,
static void
tp_tap_touch2_hold_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
@ -435,7 +435,8 @@ tp_tap_touch2_hold_handle_event(struct tp_dispatch *tp,
static void
tp_tap_touch2_release_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
@ -503,7 +504,8 @@ tp_tap_touch2_release_handle_event(struct tp_dispatch *tp,
static void
tp_tap_touch3_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
@ -540,7 +542,8 @@ tp_tap_touch3_handle_event(struct tp_dispatch *tp,
static void
tp_tap_touch3_hold_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
@ -572,7 +575,8 @@ tp_tap_touch3_hold_handle_event(struct tp_dispatch *tp,
static void
tp_tap_touch3_release_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
@ -639,7 +643,8 @@ tp_tap_touch3_release_handle_event(struct tp_dispatch *tp,
static void
tp_tap_touch3_release2_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time)
enum tap_event event,
uint64_t time)
{
switch (event) {
@ -736,7 +741,8 @@ tp_tap_touch3_release2_handle_event(struct tp_dispatch *tp,
static void
tp_tap_dragging_or_doubletap_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time,
enum tap_event event,
uint64_t time,
int nfingers_tapped)
{
switch (event) {
@ -801,7 +807,8 @@ tp_tap_dragging_or_doubletap_handle_event(struct tp_dispatch *tp,
static void
tp_tap_dragging_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time,
enum tap_event event,
uint64_t time,
int nfingers_tapped)
{
@ -825,7 +832,8 @@ tp_tap_dragging_handle_event(struct tp_dispatch *tp,
};
assert(nfingers_tapped >= 1 && nfingers_tapped <= 3);
tp->tap.state = dest[nfingers_tapped - 1];
if (tp->tap.drag_lock == LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_TIMEOUT)
if (tp->tap.drag_lock ==
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_TIMEOUT)
tp_tap_set_draglock_timer(tp, time);
} else {
tp_tap_notify(tp,
@ -863,7 +871,8 @@ tp_tap_dragging_handle_event(struct tp_dispatch *tp,
static void
tp_tap_dragging_wait_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time,
enum tap_event event,
uint64_t time,
int nfingers_tapped)
{
@ -909,7 +918,8 @@ tp_tap_dragging_wait_handle_event(struct tp_dispatch *tp,
static void
tp_tap_dragging_tap_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time,
enum tap_event event,
uint64_t time,
int nfingers_tapped)
{
@ -968,7 +978,8 @@ tp_tap_dragging_tap_handle_event(struct tp_dispatch *tp,
static void
tp_tap_dragging2_handle_event(struct tp_dispatch *tp,
struct tp_touch *t,
enum tap_event event, uint64_t time,
enum tap_event event,
uint64_t time,
int nfingers_tapped)
{
@ -1055,7 +1066,7 @@ tp_tap_handle_event(struct tp_dispatch *tp,
current = tp->tap.state;
switch(tp->tap.state) {
switch (tp->tap.state) {
case TAP_STATE_IDLE:
tp_tap_idle_handle_event(tp, t, event, time);
break;
@ -1096,16 +1107,13 @@ tp_tap_handle_event(struct tp_dispatch *tp,
tp_tap_touch3_release2_handle_event(tp, t, event, time);
break;
case TAP_STATE_1FGTAP_DRAGGING_OR_DOUBLETAP:
tp_tap_dragging_or_doubletap_handle_event(tp, t, event, time,
1);
tp_tap_dragging_or_doubletap_handle_event(tp, t, event, time, 1);
break;
case TAP_STATE_2FGTAP_DRAGGING_OR_DOUBLETAP:
tp_tap_dragging_or_doubletap_handle_event(tp, t, event, time,
2);
tp_tap_dragging_or_doubletap_handle_event(tp, t, event, time, 2);
break;
case TAP_STATE_3FGTAP_DRAGGING_OR_DOUBLETAP:
tp_tap_dragging_or_doubletap_handle_event(tp, t, event, time,
3);
tp_tap_dragging_or_doubletap_handle_event(tp, t, event, time, 3);
break;
case TAP_STATE_1FGTAP_DRAGGING:
tp_tap_dragging_handle_event(tp, t, event, time, 1);
@ -1153,17 +1161,16 @@ tp_tap_handle_event(struct tp_dispatch *tp,
if (current != tp->tap.state)
evdev_log_debug(tp->device,
"tap: touch %d (%s), tap state %s → %s → %s\n",
t ? (int)t->index : -1,
t ? touch_state_to_str(t->state) : "",
tap_state_to_str(current),
tap_event_to_str(event),
tap_state_to_str(tp->tap.state));
"tap: touch %d (%s), tap state %s → %s → %s\n",
t ? (int)t->index : -1,
t ? touch_state_to_str(t->state) : "",
tap_state_to_str(current),
tap_event_to_str(event),
tap_state_to_str(tp->tap.state));
}
static bool
tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp,
struct tp_touch *t)
tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp, struct tp_touch *t)
{
struct phys_coords mm =
tp_phys_delta(tp, device_delta(t->point, t->tap.initial));
@ -1217,8 +1224,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
if (!t->dirty || t->state == TOUCH_NONE)
continue;
if (tp->buttons.is_clickpad &&
tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
if (tp->buttons.is_clickpad && tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
t->tap.state = TAP_TOUCH_STATE_DEAD;
/* If a touch was considered thumb for tapping once, we
@ -1232,10 +1238,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
*/
if (t->tap.is_palm) {
if (t->state == TOUCH_END)
tp_tap_handle_event(tp,
t,
TAP_EVENT_PALM_UP,
time);
tp_tap_handle_event(tp, t, TAP_EVENT_PALM_UP, time);
continue;
}
@ -1271,8 +1274,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
tp_tap_handle_event(tp, t, TAP_EVENT_RELEASE, time);
}
t->tap.state = TAP_TOUCH_STATE_IDLE;
} else if (tp->tap.state != TAP_STATE_IDLE &&
tp_thumb_ignored(tp, t)) {
} else if (tp->tap.state != TAP_STATE_IDLE && tp_thumb_ignored(tp, t)) {
tp_tap_handle_event(tp, t, TAP_EVENT_THUMB, time);
} else if (tp->tap.state != TAP_STATE_IDLE &&
tp_tap_exceeds_motion_threshold(tp, t)) {
@ -1313,7 +1315,6 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
default:
break;
}
assert(tp->tap.nfingers_down <= tp->nfingers_down);
@ -1348,8 +1349,7 @@ tp_tap_handle_timeout(uint64_t time, void *data)
tp_tap_handle_event(tp, NULL, TAP_EVENT_TIMEOUT, time);
tp_for_each_touch(tp, t) {
if (t->state == TOUCH_NONE ||
t->tap.state == TAP_TOUCH_STATE_IDLE)
if (t->state == TOUCH_NONE || t->tap.state == TAP_TOUCH_STATE_IDLE)
continue;
t->tap.state = TAP_TOUCH_STATE_DEAD;
@ -1357,7 +1357,10 @@ tp_tap_handle_timeout(uint64_t time, void *data)
}
static void
tp_tap_enabled_update(struct tp_dispatch *tp, bool suspended, bool enabled, uint64_t time)
tp_tap_enabled_update(struct tp_dispatch *tp,
bool suspended,
bool enabled,
uint64_t time)
{
bool was_enabled = tp_tap_enabled(tp);
@ -1402,8 +1405,9 @@ tp_tap_config_set_enabled(struct libinput_device *device,
struct evdev_dispatch *dispatch = evdev_device(device)->dispatch;
struct tp_dispatch *tp = tp_dispatch(dispatch);
tp_tap_enabled_update(tp, tp->tap.suspended,
(enabled == LIBINPUT_CONFIG_TAP_ENABLED),
tp_tap_enabled_update(tp,
tp->tap.suspended,
enabled == LIBINPUT_CONFIG_TAP_ENABLED,
libinput_now(device->seat->libinput));
return LIBINPUT_CONFIG_STATUS_SUCCESS;
@ -1415,8 +1419,8 @@ tp_tap_config_is_enabled(struct libinput_device *device)
struct evdev_dispatch *dispatch = evdev_device(device)->dispatch;
struct tp_dispatch *tp = tp_dispatch(dispatch);
return tp->tap.enabled ? LIBINPUT_CONFIG_TAP_ENABLED :
LIBINPUT_CONFIG_TAP_DISABLED;
return tp->tap.enabled ? LIBINPUT_CONFIG_TAP_ENABLED
: LIBINPUT_CONFIG_TAP_DISABLED;
}
static enum libinput_config_tap_state
@ -1562,10 +1566,12 @@ tp_init_tap(struct tp_dispatch *tp)
tp->tap.config.get_default_map = tp_tap_config_get_default_map;
tp->tap.config.set_drag_enabled = tp_tap_config_set_drag_enabled;
tp->tap.config.get_drag_enabled = tp_tap_config_get_drag_enabled;
tp->tap.config.get_default_drag_enabled = tp_tap_config_get_default_drag_enabled;
tp->tap.config.get_default_drag_enabled =
tp_tap_config_get_default_drag_enabled;
tp->tap.config.set_draglock_enabled = tp_tap_config_set_draglock_enabled;
tp->tap.config.get_draglock_enabled = tp_tap_config_get_draglock_enabled;
tp->tap.config.get_default_draglock_enabled = tp_tap_config_get_default_draglock_enabled;
tp->tap.config.get_default_draglock_enabled =
tp_tap_config_get_default_draglock_enabled;
tp->device->base.config.tap = &tp->tap.config;
tp->tap.state = TAP_STATE_IDLE;
@ -1582,7 +1588,8 @@ tp_init_tap(struct tp_dispatch *tp)
libinput_timer_init(&tp->tap.timer,
tp_libinput_context(tp),
timer_name,
tp_tap_handle_timeout, tp);
tp_tap_handle_timeout,
tp);
}
void

View file

@ -23,6 +23,7 @@
*/
#include "config.h"
#include "evdev-mt-touchpad.h"
/* distance between fingers to assume it is not a scroll */
@ -30,10 +31,10 @@
#define SCROLL_MM_Y 25
#define THUMB_TIMEOUT ms2us(100)
static inline const char*
static inline const char *
thumb_state_to_str(enum tp_thumb_state state)
{
switch(state){
switch (state) {
CASE_RETURN_STRING(THUMB_STATE_FINGER);
CASE_RETURN_STRING(THUMB_STATE_JAILED);
CASE_RETURN_STRING(THUMB_STATE_PINCH);
@ -82,28 +83,23 @@ tp_thumb_lift(struct tp_dispatch *tp)
}
static bool
tp_thumb_in_exclusion_area(const struct tp_dispatch *tp,
const struct tp_touch *t)
tp_thumb_in_exclusion_area(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return (t->point.y > tp->thumb.lower_thumb_line &&
tp->scroll.method != LIBINPUT_CONFIG_SCROLL_EDGE);
}
static bool
tp_thumb_detect_pressure_size(const struct tp_dispatch *tp,
const struct tp_touch *t)
tp_thumb_detect_pressure_size(const struct tp_dispatch *tp, const struct tp_touch *t)
{
bool is_thumb = false;
if (tp->thumb.use_pressure &&
t->pressure > tp->thumb.pressure_threshold &&
if (tp->thumb.use_pressure && t->pressure > tp->thumb.pressure_threshold &&
tp_thumb_in_exclusion_area(tp, t)) {
is_thumb = true;
}
if (tp->thumb.use_size &&
(t->major > tp->thumb.size_threshold) &&
if (tp->thumb.use_size && (t->major > tp->thumb.size_threshold) &&
(t->minor < (tp->thumb.size_threshold * 0.6))) {
is_thumb = true;
}
@ -119,7 +115,7 @@ tp_thumb_needs_jail(const struct tp_dispatch *tp, const struct tp_touch *t)
return false;
if (!tp_thumb_in_exclusion_area(tp, t) &&
(tp->thumb.use_size || tp->thumb.use_pressure) &&
(tp->thumb.use_size || tp->thumb.use_pressure) &&
!tp_thumb_detect_pressure_size(tp, t))
return false;
@ -132,8 +128,7 @@ tp_thumb_needs_jail(const struct tp_dispatch *tp, const struct tp_touch *t)
bool
tp_thumb_ignored(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return (tp->thumb.detect_thumbs &&
tp->thumb.index == t->index &&
return (tp->thumb.detect_thumbs && tp->thumb.index == t->index &&
(tp->thumb.state == THUMB_STATE_JAILED ||
tp->thumb.state == THUMB_STATE_PINCH ||
tp->thumb.state == THUMB_STATE_SUPPRESSED ||
@ -142,22 +137,18 @@ tp_thumb_ignored(const struct tp_dispatch *tp, const struct tp_touch *t)
}
bool
tp_thumb_ignored_for_tap(const struct tp_dispatch *tp,
const struct tp_touch *t)
tp_thumb_ignored_for_tap(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return (tp->thumb.detect_thumbs &&
tp->thumb.index == t->index &&
return (tp->thumb.detect_thumbs && tp->thumb.index == t->index &&
(tp->thumb.state == THUMB_STATE_PINCH ||
tp->thumb.state == THUMB_STATE_SUPPRESSED ||
tp->thumb.state == THUMB_STATE_DEAD));
}
bool
tp_thumb_ignored_for_gesture(const struct tp_dispatch *tp,
const struct tp_touch *t)
tp_thumb_ignored_for_gesture(const struct tp_dispatch *tp, const struct tp_touch *t)
{
return (tp->thumb.detect_thumbs &&
tp->thumb.index == t->index &&
return (tp->thumb.detect_thumbs && tp->thumb.index == t->index &&
(tp->thumb.state == THUMB_STATE_JAILED ||
tp->thumb.state == THUMB_STATE_SUPPRESSED ||
tp->thumb.state == THUMB_STATE_REVIVED_JAILED ||
@ -167,10 +158,9 @@ tp_thumb_ignored_for_gesture(const struct tp_dispatch *tp,
void
tp_thumb_suppress(struct tp_dispatch *tp, struct tp_touch *t)
{
if(tp->thumb.state == THUMB_STATE_FINGER ||
tp->thumb.state == THUMB_STATE_JAILED ||
tp->thumb.state == THUMB_STATE_PINCH ||
tp->thumb.index != t->index) {
if (tp->thumb.state == THUMB_STATE_FINGER ||
tp->thumb.state == THUMB_STATE_JAILED ||
tp->thumb.state == THUMB_STATE_PINCH || tp->thumb.index != t->index) {
tp_thumb_set_state(tp, t, THUMB_STATE_SUPPRESSED);
return;
}
@ -181,9 +171,8 @@ tp_thumb_suppress(struct tp_dispatch *tp, struct tp_touch *t)
static void
tp_thumb_pinch(struct tp_dispatch *tp, struct tp_touch *t)
{
if(tp->thumb.state == THUMB_STATE_FINGER ||
tp->thumb.state == THUMB_STATE_JAILED ||
tp->thumb.index != t->index)
if (tp->thumb.state == THUMB_STATE_FINGER ||
tp->thumb.state == THUMB_STATE_JAILED || tp->thumb.index != t->index)
tp_thumb_set_state(tp, t, THUMB_STATE_PINCH);
else if (tp->thumb.state != THUMB_STATE_PINCH)
tp_thumb_suppress(tp, t);
@ -192,21 +181,19 @@ tp_thumb_pinch(struct tp_dispatch *tp, struct tp_touch *t)
static void
tp_thumb_revive(struct tp_dispatch *tp, struct tp_touch *t)
{
if((tp->thumb.state != THUMB_STATE_SUPPRESSED &&
tp->thumb.state != THUMB_STATE_PINCH) ||
(tp->thumb.index != t->index))
if ((tp->thumb.state != THUMB_STATE_SUPPRESSED &&
tp->thumb.state != THUMB_STATE_PINCH) ||
(tp->thumb.index != t->index))
return;
if(tp_thumb_needs_jail(tp, t))
if (tp_thumb_needs_jail(tp, t))
tp_thumb_set_state(tp, t, THUMB_STATE_REVIVED_JAILED);
else
tp_thumb_set_state(tp, t, THUMB_STATE_REVIVED);
}
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, uint64_t time)
{
if (!tp->thumb.detect_thumbs)
return;
@ -214,11 +201,10 @@ tp_thumb_update_touch(struct tp_dispatch *tp,
/* Once any active touch exceeds the speed threshold, don't
* try to detect pinches until all touches lift.
*/
if (t->speed.exceeded_count >= 10 &&
tp->thumb.pinch_eligible &&
if (t->speed.exceeded_count >= 10 && tp->thumb.pinch_eligible &&
tp->gesture.state == GESTURE_STATE_NONE) {
tp->thumb.pinch_eligible = false;
if(tp->thumb.state == THUMB_STATE_PINCH) {
if (tp->thumb.state == THUMB_STATE_PINCH) {
struct tp_touch *thumb;
tp_for_each_touch(tp, thumb) {
if (thumb->index != tp->thumb.index)
@ -258,8 +244,7 @@ tp_thumb_update_touch(struct tp_dispatch *tp,
/* If a touch breaks the speed threshold, or leaves the thumb area
* (upper or lower, depending on HW detection), it "escapes" jail.
*/
if (tp->thumb.state == THUMB_STATE_JAILED &&
!(tp_thumb_needs_jail(tp, t)))
if (tp->thumb.state == THUMB_STATE_JAILED && !(tp_thumb_needs_jail(tp, t)))
tp_thumb_set_state(tp, t, THUMB_STATE_FINGER);
if (tp->thumb.state == THUMB_STATE_REVIVED_JAILED &&
!(tp_thumb_needs_jail(tp, t)))
@ -270,10 +255,7 @@ void
tp_thumb_update_multifinger(struct tp_dispatch *tp)
{
struct tp_touch *t;
struct tp_touch *first = NULL,
*second = NULL,
*newest = NULL,
*oldest = NULL;
struct tp_touch *first = NULL, *second = NULL, *newest = NULL, *oldest = NULL;
struct device_coords distance;
struct phys_coords mm;
@ -283,15 +265,14 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp)
* count overall, and the newest and oldest touches.
*/
tp_for_each_touch(tp, t) {
if (t->state == TOUCH_NONE ||
t->state == TOUCH_HOVERING)
if (t->state == TOUCH_NONE || t->state == TOUCH_HOVERING)
continue;
if (t->state == TOUCH_BEGIN)
newest = t;
speed_exceeded_count = max(speed_exceeded_count,
t->speed.exceeded_count);
speed_exceeded_count =
max(speed_exceeded_count, t->speed.exceeded_count);
if (!oldest || t->initial_time < oldest->initial_time) {
oldest = t;
@ -308,7 +289,7 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp)
continue;
}
if (!second || t->point.y > second->point.y ) {
if (!second || t->point.y > second->point.y) {
second = t;
}
}
@ -325,9 +306,7 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp)
* 2-finger scroll. Also account for a thumb dropping onto the touchpad
* while scrolling or swiping.
*/
if (newest &&
tp->thumb.state == THUMB_STATE_FINGER &&
tp->nfingers_down >= 2 &&
if (newest && tp->thumb.state == THUMB_STATE_FINGER && tp->nfingers_down >= 2 &&
speed_exceeded_count > 5 &&
(tp->scroll.method != LIBINPUT_CONFIG_SCROLL_2FG ||
(mm.x > SCROLL_MM_X || mm.y > SCROLL_MM_Y))) {
@ -358,8 +337,7 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp)
* the behavior of the other touches.)
*/
if (newest &&
(newest->initial_time - oldest->initial_time) < THUMB_TIMEOUT &&
if (newest && (newest->initial_time - oldest->initial_time) < THUMB_TIMEOUT &&
first->point.y < tp->thumb.lower_thumb_line) {
tp_thumb_lift(tp);
return;
@ -368,7 +346,7 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp)
/* If we're past the THUMB_TIMEOUT, and the touches are relatively far
* apart, then the new touch is unlikely to be a tap or clickfinger.
* Proceed with pre-1.14.901 thumb detection.
*/
*/
if (mm.y > SCROLL_MM_Y) {
if (tp->thumb.pinch_eligible)
@ -427,9 +405,7 @@ tp_init_thumb(struct tp_dispatch *tp)
}
if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_MT_TOUCH_MAJOR)) {
if (quirks_get_uint32(q,
QUIRK_ATTR_THUMB_SIZE_THRESHOLD,
&threshold)) {
if (quirks_get_uint32(q, QUIRK_ATTR_THUMB_SIZE_THRESHOLD, &threshold)) {
tp->thumb.use_size = true;
tp->thumb.size_threshold = threshold;
}
@ -443,7 +419,7 @@ tp_init_thumb(struct tp_dispatch *tp)
tp->thumb.use_size ? ", size" : "");
}
struct tp_touch*
struct tp_touch *
tp_thumb_get_touch(struct tp_dispatch *tp)
{
struct tp_touch *thumb;

File diff suppressed because it is too large Load diff

View file

@ -36,12 +36,12 @@
#define TP_MM_TO_DPI_NORMALIZED(mm) (DEFAULT_MOUSE_DPI/25.4 * mm)
enum touchpad_event {
TOUCHPAD_EVENT_NONE = 0,
TOUCHPAD_EVENT_MOTION = bit(0),
TOUCHPAD_EVENT_BUTTON_PRESS = bit(1),
TOUCHPAD_EVENT_BUTTON_RELEASE = bit(2),
TOUCHPAD_EVENT_OTHERAXIS = bit(3),
TOUCHPAD_EVENT_TIMESTAMP = bit(4),
TOUCHPAD_EVENT_NONE = 0,
TOUCHPAD_EVENT_MOTION = bit(0),
TOUCHPAD_EVENT_BUTTON_PRESS = bit(1),
TOUCHPAD_EVENT_BUTTON_RELEASE = bit(2),
TOUCHPAD_EVENT_OTHERAXIS = bit(3),
TOUCHPAD_EVENT_TIMESTAMP = bit(4),
};
enum touch_state {
@ -56,7 +56,7 @@ enum touch_state {
static inline const char *
touch_state_to_str(enum touch_state state)
{
switch(state) {
switch (state) {
CASE_RETURN_STRING(TOUCH_NONE);
CASE_RETURN_STRING(TOUCH_HOVERING);
CASE_RETURN_STRING(TOUCH_BEGIN);
@ -135,16 +135,16 @@ enum tp_tap_state {
};
enum tp_tap_touch_state {
TAP_TOUCH_STATE_IDLE = 16, /**< not in touch */
TAP_TOUCH_STATE_TOUCH, /**< touching, may tap */
TAP_TOUCH_STATE_DEAD, /**< exceeded motion/timeout */
TAP_TOUCH_STATE_IDLE = 16, /**< not in touch */
TAP_TOUCH_STATE_TOUCH, /**< touching, may tap */
TAP_TOUCH_STATE_DEAD, /**< exceeded motion/timeout */
};
/* For edge scrolling, so we only care about right and bottom */
enum tp_edge {
EDGE_NONE = 0,
EDGE_RIGHT = bit(0),
EDGE_BOTTOM = bit(1),
EDGE_NONE = 0,
EDGE_RIGHT = bit(0),
EDGE_BOTTOM = bit(1),
};
enum tp_edge_scroll_touch_state {
@ -191,7 +191,7 @@ struct tp_touch {
struct tp_dispatch *tp;
unsigned int index;
enum touch_state state;
bool has_ended; /* TRACKING_ID == -1 */
bool has_ended; /* TRACKING_ID == -1 */
bool dirty;
struct device_coords point;
uint64_t initial_time;
@ -267,7 +267,7 @@ struct tp_touch {
struct {
enum touch_palm_state state;
struct device_coords first; /* first coordinates if is_palm == true */
uint64_t time; /* first timestamp if is_palm == true */
uint64_t time; /* first timestamp if is_palm == true */
} palm;
struct {
@ -281,19 +281,19 @@ struct tp_touch {
};
enum suspend_trigger {
SUSPEND_NO_FLAG = 0x0,
SUSPEND_EXTERNAL_MOUSE = 0x1,
SUSPEND_SENDEVENTS = 0x2,
SUSPEND_LID = 0x4,
SUSPEND_TABLET_MODE = 0x8,
SUSPEND_NO_FLAG = 0x0,
SUSPEND_EXTERNAL_MOUSE = 0x1,
SUSPEND_SENDEVENTS = 0x2,
SUSPEND_LID = 0x4,
SUSPEND_TABLET_MODE = 0x8,
};
struct tp_dispatch {
struct evdev_dispatch base;
struct evdev_device *device;
unsigned int nfingers_down; /* number of fingers down */
unsigned int old_nfingers_down; /* previous no fingers down */
unsigned int slot; /* current slot */
unsigned int nfingers_down; /* number of fingers down */
unsigned int old_nfingers_down; /* previous no fingers down */
unsigned int slot; /* current slot */
bool has_mt;
bool semi_mt;
@ -305,10 +305,10 @@ struct tp_dispatch {
struct libinput_timer arbitration_timer;
} arbitration;
unsigned int nactive_slots; /* number of active slots */
unsigned int num_slots; /* number of slots */
unsigned int ntouches; /* no slots inc. fakes */
struct tp_touch *touches; /* len == ntouches */
unsigned int nactive_slots; /* number of active slots */
unsigned int num_slots; /* number of slots */
unsigned int ntouches; /* no slots inc. fakes */
struct tp_touch *touches; /* len == ntouches */
/* bit 0: BTN_TOUCH
* bit 1: BTN_TOOL_FINGER
* bit 2: BTN_TOOL_DOUBLETAP
@ -331,7 +331,7 @@ struct tp_dispatch {
/* If touch size (either axis) goes above high -> touch down,
if touch size (either axis) goes below low -> touch up */
struct {
struct {
bool use_touch_size;
int high;
int low;
@ -374,31 +374,31 @@ struct tp_dispatch {
} gesture;
struct {
bool is_clickpad; /* true for clickpads */
bool is_clickpad; /* true for clickpads */
bool has_topbuttons;
bool use_clickfinger; /* number of fingers decides button number */
bool use_clickfinger; /* number of fingers decides button number */
bool click_pending;
uint32_t state;
uint32_t old_state;
struct {
double x_scale_coeff;
double y_scale_coeff;
} motion_dist; /* for pinned touches */
evdev_usage_t active; /* currently active button, for release event */
bool active_is_topbutton; /* is active a top button? */
} motion_dist; /* for pinned touches */
evdev_usage_t active; /* currently active button, for release event */
bool active_is_topbutton; /* is active a top button? */
/* Only used for clickpads. The software button areas are
* always 2 horizontal stripes across the touchpad.
* The buttons are split according to the edge settings.
*/
struct {
int32_t top_edge; /* in device coordinates */
int32_t rightbutton_left_edge; /* in device coordinates */
int32_t top_edge; /* in device coordinates */
int32_t rightbutton_left_edge; /* in device coordinates */
int32_t middlebutton_left_edge; /* in device coordinates */
} bottom_area;
struct {
int32_t bottom_edge; /* in device coordinates */
int32_t bottom_edge; /* in device coordinates */
int32_t rightbutton_left_edge; /* in device coordinates */
int32_t leftbutton_right_edge; /* in device coordinates */
} top_area;
@ -415,8 +415,8 @@ struct tp_dispatch {
struct {
struct libinput_device_config_scroll_method config_method;
enum libinput_config_scroll_method method;
int32_t right_edge; /* in device coordinates */
int32_t bottom_edge; /* in device coordinates */
int32_t right_edge; /* in device coordinates */
int32_t bottom_edge; /* in device coordinates */
struct {
bool h, v;
} active;
@ -436,8 +436,7 @@ struct tp_dispatch {
struct libinput_timer timer;
enum tp_tap_state state;
uint32_t buttons_pressed;
uint64_t saved_press_time,
saved_release_time;
uint64_t saved_press_time, saved_release_time;
enum libinput_config_tap_button_map map;
enum libinput_config_tap_button_map want_map;
@ -445,7 +444,8 @@ struct tp_dispatch {
bool drag_enabled;
enum libinput_config_drag_lock_state drag_lock;
unsigned int nfingers_down; /* number of fingers down for tapping (excl. thumb/palm) */
unsigned int nfingers_down; /* number of fingers down for tapping (excl.
thumb/palm) */
} tap;
struct {
@ -458,9 +458,9 @@ struct tp_dispatch {
struct libinput_device_config_dwtp config;
bool dwtp_enabled;
int32_t right_edge; /* in device coordinates */
int32_t left_edge; /* in device coordinates */
int32_t upper_edge; /* in device coordinates */
int32_t right_edge; /* in device coordinates */
int32_t left_edge; /* in device coordinates */
int32_t upper_edge; /* in device coordinates */
bool trackpoint_active;
struct libinput_event_listener trackpoint_listener;
@ -554,7 +554,7 @@ struct tp_dispatch {
} left_handed;
};
static inline struct tp_dispatch*
static inline struct tp_dispatch *
tp_dispatch(struct evdev_dispatch *dispatch)
{
evdev_verify_dispatch_type(dispatch, DISPATCH_TOUCHPAD);
@ -565,15 +565,14 @@ tp_dispatch(struct evdev_dispatch *dispatch)
#define tp_for_each_touch(_tp, _t) \
for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
static inline struct libinput*
static inline struct libinput *
tp_libinput_context(const struct tp_dispatch *tp)
{
return evdev_libinput_context(tp->device);
}
static inline struct normalized_coords
tp_normalize_delta(const struct tp_dispatch *tp,
struct device_float_coords delta)
tp_normalize_delta(const struct tp_dispatch *tp, struct device_float_coords delta)
{
struct normalized_coords normalized;
@ -584,8 +583,7 @@ tp_normalize_delta(const struct tp_dispatch *tp,
}
static inline struct phys_coords
tp_phys_delta(const struct tp_dispatch *tp,
struct device_float_coords delta)
tp_phys_delta(const struct tp_dispatch *tp, struct device_float_coords delta)
{
struct phys_coords mm;
@ -600,8 +598,7 @@ tp_phys_delta(const struct tp_dispatch *tp,
* x-axis' resolution.
*/
static inline struct device_float_coords
tp_scale_to_xaxis(const struct tp_dispatch *tp,
struct device_float_coords delta)
tp_scale_to_xaxis(const struct tp_dispatch *tp, struct device_float_coords delta)
{
struct device_float_coords raw;
@ -633,8 +630,7 @@ bool
tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t);
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
tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time);
@ -663,13 +659,10 @@ void
tp_remove_buttons(struct tp_dispatch *tp);
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, uint64_t time);
void
tp_release_all_buttons(struct tp_dispatch *tp,
uint64_t time);
tp_release_all_buttons(struct tp_dispatch *tp, uint64_t time);
int
tp_post_button_events(struct tp_dispatch *tp, uint64_t time);
@ -678,16 +671,14 @@ void
tp_button_handle_state(struct tp_dispatch *tp, uint64_t time);
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);
bool
tp_button_is_inside_softbutton_area(const struct tp_dispatch *tp,
const struct tp_touch *t);
void
tp_release_all_taps(struct tp_dispatch *tp,
uint64_t now);
tp_release_all_taps(struct tp_dispatch *tp, uint64_t now);
void
tp_tap_suspend(struct tp_dispatch *tp, uint64_t time);
@ -717,8 +708,7 @@ void
tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time);
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);
uint32_t
tp_touch_get_edge(const struct tp_dispatch *tp, const struct tp_touch *t);
@ -742,8 +732,7 @@ void
tp_gesture_update_finger_state(struct tp_dispatch *tp, uint64_t time);
void
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time,
bool ignore_motion);
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time, bool ignore_motion);
void
tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time);
@ -764,16 +753,13 @@ bool
tp_thumb_ignored_for_gesture(const struct tp_dispatch *tp, const struct tp_touch *t);
bool
tp_thumb_ignored_for_tap(const struct tp_dispatch *tp,
const struct tp_touch *t);
tp_thumb_ignored_for_tap(const struct tp_dispatch *tp, const struct tp_touch *t);
void
tp_thumb_suppress(struct tp_dispatch *tp, struct tp_touch *t);
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, uint64_t time);
void
tp_detect_thumb_while_moving(struct tp_dispatch *tp);
@ -784,7 +770,7 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp);
void
tp_init_thumb(struct tp_dispatch *tp);
struct tp_touch*
struct tp_touch *
tp_thumb_get_touch(struct tp_dispatch *tp);
void

View file

@ -23,14 +23,14 @@
#include "config.h"
#include "util-mem.h"
#include <mtdev-plumbing.h>
#include "evdev.h"
#include "evdev-plugin.h"
#include "util-mem.h"
_unused_
static inline void
#include "evdev-plugin.h"
#include "evdev.h"
_unused_ static inline void
evdev_print_event(struct evdev_device *device,
const struct evdev_event *e,
uint64_t time_in_us)
@ -48,39 +48,38 @@ evdev_print_event(struct evdev_device *device,
switch (evdev_usage_enum(e->usage)) {
case EVDEV_SYN_REPORT:
evdev_log_debug(device,
"%u.%03u ----------------- EV_SYN ----------------- +%ums\n",
time / 1000,
time % 1000,
time - last_time);
evdev_log_debug(
device,
"%u.%03u ----------------- EV_SYN ----------------- +%ums\n",
time / 1000,
time % 1000,
time - last_time);
last_time = time;
break;
case EVDEV_MSC_SERIAL:
evdev_log_debug(device,
"%u.%03u %-16s %-16s %#010x\n",
time / 1000,
time % 1000,
evdev_event_get_type_name(e),
evdev_event_get_code_name(e),
e->value);
"%u.%03u %-16s %-16s %#010x\n",
time / 1000,
time % 1000,
evdev_event_get_type_name(e),
evdev_event_get_code_name(e),
e->value);
break;
default:
evdev_log_debug(device,
"%u.%03u %-16s %-20s %4d\n",
time / 1000,
time % 1000,
evdev_event_get_type_name(e),
evdev_event_get_code_name(e),
e->value);
"%u.%03u %-16s %-20s %4d\n",
time / 1000,
time % 1000,
evdev_event_get_type_name(e),
evdev_event_get_code_name(e),
e->value);
break;
}
}
static inline void
evdev_process_event(struct evdev_device *device,
struct evdev_event *e,
uint64_t time)
evdev_process_event(struct evdev_device *device, struct evdev_event *e, uint64_t time)
{
struct evdev_dispatch *dispatch = device->dispatch;
@ -95,8 +94,8 @@ evdev_process_event(struct evdev_device *device,
static inline void
evdev_device_dispatch_frame(struct libinput_plugin *plugin,
struct libinput_device *libinput_device,
struct evdev_frame *frame)
struct libinput_device *libinput_device,
struct evdev_frame *frame)
{
struct evdev_device *device = evdev_device(libinput_device);
uint64_t time = evdev_frame_get_time(frame);
@ -117,7 +116,8 @@ evdev_device_dispatch_frame(struct libinput_plugin *plugin,
mtdev_get_event(device->mtdev, &e);
uint64_t time;
struct evdev_event ev = evdev_event_from_input_event(&e, &time);
struct evdev_event ev =
evdev_event_from_input_event(&e, &time);
evdev_process_event(device, &ev, time);
}
}
@ -149,8 +149,6 @@ static const struct libinput_plugin_interface interface = {
void
libinput_evdev_dispatch_plugin(struct libinput *libinput)
{
_unref_(libinput_plugin) *p = libinput_plugin_new(libinput,
"evdev",
&interface,
NULL);
_unref_(libinput_plugin) *p =
libinput_plugin_new(libinput, "evdev", &interface, NULL);
}

View file

@ -25,8 +25,8 @@
#include "config.h"
#include "libinput.h"
#include "libinput-plugin.h"
#include "libinput.h"
void
libinput_evdev_dispatch_plugin(struct libinput *libinput);

View file

@ -23,8 +23,8 @@
#include "config.h"
#include <limits.h>
#include <fcntl.h>
#include <limits.h>
#include "evdev-tablet-pad.h"
@ -68,7 +68,7 @@ struct pad_mode_led {
};
static inline void
pad_mode_toggle_button_destroy(struct pad_mode_toggle_button* button)
pad_mode_toggle_button_destroy(struct pad_mode_toggle_button *button)
{
list_remove(&button->link);
free(button);
@ -77,7 +77,7 @@ pad_mode_toggle_button_destroy(struct pad_mode_toggle_button* button)
static inline int
pad_led_group_get_mode(struct pad_led_group *group)
{
char buf[4] = {0};
char buf[4] = { 0 };
int rc;
unsigned int brightness;
struct pad_mode_led *led;
@ -106,8 +106,7 @@ pad_led_group_get_mode(struct pad_led_group *group)
}
static inline void
pad_led_destroy(struct libinput *libinput,
struct pad_mode_led *led)
pad_led_destroy(struct libinput *libinput, struct pad_mode_led *led)
{
list_remove(&led->link);
if (led->brightness_fd != -1)
@ -130,12 +129,7 @@ pad_led_new(struct libinput *libinput, const char *prefix, int group, int mode)
/* /sys/devices/..../input1235/input1235::wacom-0.1/brightness,
* where 0 and 1 are group and mode index. */
rc = snprintf(path,
sizeof(path),
"%s%d.%d/brightness",
prefix,
group,
mode);
rc = snprintf(path, sizeof(path), "%s%d.%d/brightness", prefix, group, mode);
if (rc == -1)
goto error;
@ -174,9 +168,7 @@ pad_led_group_destroy(struct libinput_tablet_pad_mode_group *g)
}
static struct pad_led_group *
pad_group_new(struct pad_dispatch *pad,
unsigned int group_index,
int num_modes)
pad_group_new(struct pad_dispatch *pad, unsigned int group_index, int num_modes)
{
struct pad_led_group *group;
@ -258,8 +250,9 @@ pad_led_get_sysfs_base_path(struct evdev_device *device,
/* For testing purposes only allow for a base path set through a
* udev rule. We still expect the normal directory hierarchy inside */
test_path = udev_device_get_property_value(udev_device,
"LIBINPUT_TEST_TABLET_PAD_SYSFS_PATH");
test_path =
udev_device_get_property_value(udev_device,
"LIBINPUT_TEST_TABLET_PAD_SYSFS_PATH");
if (test_path) {
rc = snprintf(path_out, path_out_sz, "%s", test_path);
return rc != -1;
@ -342,17 +335,17 @@ out:
}
static int
pad_fetch_group_index(struct pad_dispatch *pad,
WacomDevice *wacom,
int button_index)
pad_fetch_group_index(struct pad_dispatch *pad, WacomDevice *wacom, int button_index)
{
char btn = 'A' + button_index;
WacomButtonFlags flags = libwacom_get_button_flag(wacom, btn);
int led_group = libwacom_get_button_led_group(wacom, btn);
if ((flags & WACOM_BUTTON_MODESWITCH) == 0) {
evdev_log_bug_libinput(pad->device,
"Cannot fetch group index for non-mode toggle button %c\n", btn);
evdev_log_bug_libinput(
pad->device,
"Cannot fetch group index for non-mode toggle button %c\n",
btn);
return -1;
}
@ -395,7 +388,7 @@ pad_fetch_group_index(struct pad_dispatch *pad,
#endif
}
return group_index;
return group_index;
}
static inline int
@ -416,7 +409,7 @@ pad_find_button_group(struct pad_dispatch *pad,
continue;
if ((flags & WACOM_BUTTON_DIRECTION) ==
(button_flags & WACOM_BUTTON_DIRECTION))
(button_flags & WACOM_BUTTON_DIRECTION))
return pad_fetch_group_index(pad, wacom, i);
}
@ -428,11 +421,16 @@ pad_button_target_mode(WacomDevice *wacom, char button)
{
#ifdef HAVE_LIBWACOM_BUTTON_MODESWITCH_MODE
switch (libwacom_get_button_modeswitch_mode(wacom, button)) {
case WACOM_MODE_SWITCH_NEXT: return MODE_NEXT;
case WACOM_MODE_SWITCH_0: return MODE_0;
case WACOM_MODE_SWITCH_1: return MODE_1;
case WACOM_MODE_SWITCH_2: return MODE_2;
case WACOM_MODE_SWITCH_3: return MODE_3;
case WACOM_MODE_SWITCH_NEXT:
return MODE_NEXT;
case WACOM_MODE_SWITCH_0:
return MODE_0;
case WACOM_MODE_SWITCH_1:
return MODE_1;
case WACOM_MODE_SWITCH_2:
return MODE_2;
case WACOM_MODE_SWITCH_3:
return MODE_3;
}
#endif
return MODE_NEXT;
@ -460,9 +458,10 @@ pad_init_leds_from_libwacom(struct pad_dispatch *pad,
if ((flags & WACOM_BUTTON_MODESWITCH) == 0)
continue;
enum pad_toggle_button_target_mode target_mode = pad_button_target_mode(wacom, btn);
enum pad_toggle_button_target_mode target_mode =
pad_button_target_mode(wacom, btn);
int group_index = pad_fetch_group_index(pad, wacom, b);
int group_index = pad_fetch_group_index(pad, wacom, b);
switch (flags & WACOM_BUTTON_MODESWITCH) {
case WACOM_BUTTON_RING_MODESWITCH:
nmodes = libwacom_get_ring_num_modes(wacom);
@ -492,22 +491,36 @@ pad_init_leds_from_libwacom(struct pad_dispatch *pad,
break;
#endif
default:
evdev_log_error(pad->device,
"unable to init pad mode group: button %c has multiple modeswitch flags 0x%x\n",
btn, flags);
evdev_log_error(
pad->device,
"unable to init pad mode group: button %c has multiple modeswitch flags 0x%x\n",
btn,
flags);
goto out;
}
have_status_led = libwacom_get_button_led_group(wacom, btn) >= 0;
if (nmodes > 1) {
struct libinput_tablet_pad_mode_group *group = pad_get_mode_group(pad, group_index);
struct libinput_tablet_pad_mode_group *group =
pad_get_mode_group(pad, group_index);
if (!group) {
rc = pad_add_mode_group(pad, device, group_index, nmodes, b, target_mode,
ring_mask, strip_mask, dial_mask,
rc = pad_add_mode_group(pad,
device,
group_index,
nmodes,
b,
target_mode,
ring_mask,
strip_mask,
dial_mask,
have_status_led);
} else {
struct pad_led_group *led_group = (struct pad_led_group *)group;
/* Multiple toggle buttons (Wacom MobileStudio Pro 16) */
rc = pad_led_group_add_toggle_button(led_group, b, target_mode);
struct pad_led_group *led_group =
(struct pad_led_group *)group;
/* Multiple toggle buttons (Wacom MobileStudio Pro 16)
*/
rc = pad_led_group_add_toggle_button(led_group,
b,
target_mode);
if (rc < 0)
goto out;
}
@ -525,7 +538,7 @@ pad_init_leds_from_libwacom(struct pad_dispatch *pad,
char btn = 'A' + b;
WacomButtonFlags flags = libwacom_get_button_flag(wacom, btn);
if ((flags & WACOM_BUTTON_MODESWITCH))
if (flags & WACOM_BUTTON_MODESWITCH)
continue;
int group_index = pad_find_button_group(pad, wacom, b, flags);
@ -537,12 +550,14 @@ pad_init_leds_from_libwacom(struct pad_dispatch *pad,
goto out;
}
struct libinput_tablet_pad_mode_group *group = pad_get_mode_group(pad, group_index);
struct libinput_tablet_pad_mode_group *group =
pad_get_mode_group(pad, group_index);
if (!group) {
evdev_log_bug_libinput(pad->device,
"Failed to find group %d for button %i\n",
group_index,
b);
evdev_log_bug_libinput(
pad->device,
"Failed to find group %d for button %i\n",
group_index,
b);
rc = -EINVAL;
goto out;
}
@ -589,9 +604,7 @@ pad_init_fallback_group(struct pad_dispatch *pad)
}
int
pad_init_leds(struct pad_dispatch *pad,
struct evdev_device *device,
WacomDevice *wacom)
pad_init_leds(struct pad_dispatch *pad, struct evdev_device *device, WacomDevice *wacom)
{
int rc = 1;
@ -628,7 +641,7 @@ pad_button_update_mode(struct libinput_tablet_pad_mode_group *g,
unsigned int button_index,
enum libinput_button_state state)
{
struct pad_led_group *group = (struct pad_led_group*)g;
struct pad_led_group *group = (struct pad_led_group *)g;
int rc = -ENODEV;
if (state != LIBINPUT_BUTTON_STATE_PRESSED)
@ -660,7 +673,7 @@ pad_button_update_mode(struct libinput_tablet_pad_mode_group *g,
int
evdev_device_tablet_pad_get_num_mode_groups(struct evdev_device *device)
{
struct pad_dispatch *pad = (struct pad_dispatch*)device->dispatch;
struct pad_dispatch *pad = (struct pad_dispatch *)device->dispatch;
struct libinput_tablet_pad_mode_group *group;
int num_groups = 0;
@ -674,16 +687,14 @@ evdev_device_tablet_pad_get_num_mode_groups(struct evdev_device *device)
}
struct libinput_tablet_pad_mode_group *
evdev_device_tablet_pad_get_mode_group(struct evdev_device *device,
unsigned int index)
evdev_device_tablet_pad_get_mode_group(struct evdev_device *device, unsigned int index)
{
struct pad_dispatch *pad = (struct pad_dispatch*)device->dispatch;
struct pad_dispatch *pad = (struct pad_dispatch *)device->dispatch;
if (!(device->seat_caps & EVDEV_DEVICE_TABLET_PAD))
return NULL;
if (index >=
(unsigned int)evdev_device_tablet_pad_get_num_mode_groups(device))
if (index >= (unsigned int)evdev_device_tablet_pad_get_num_mode_groups(device))
return NULL;
return pad_get_mode_group(pad, index);

View file

@ -22,24 +22,25 @@
*/
#include "config.h"
#include "evdev-tablet-pad.h"
#include "util-input-event.h"
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include "util-input-event.h"
#include "evdev-tablet-pad.h"
#if HAVE_LIBWACOM
#include <libwacom/libwacom.h>
#endif
#define pad_set_status(pad_,s_) (pad_)->status |= (s_)
#define pad_unset_status(pad_,s_) (pad_)->status &= ~(s_)
#define pad_has_status(pad_,s_) (!!((pad_)->status & (s_)))
#define pad_set_status(pad_, s_) (pad_)->status |= (s_)
#define pad_unset_status(pad_, s_) (pad_)->status &= ~(s_)
#define pad_has_status(pad_, s_) (!!((pad_)->status & (s_)))
static void
pad_get_buttons_pressed(struct pad_dispatch *pad,
struct button_state *buttons)
pad_get_buttons_pressed(struct pad_dispatch *pad, struct button_state *buttons)
{
struct button_state *state = &pad->button_state;
struct button_state *prev_state = &pad->prev_button_state;
@ -50,8 +51,7 @@ pad_get_buttons_pressed(struct pad_dispatch *pad,
}
static void
pad_get_buttons_released(struct pad_dispatch *pad,
struct button_state *buttons)
pad_get_buttons_released(struct pad_dispatch *pad, struct button_state *buttons)
{
struct button_state *state = &pad->button_state;
struct button_state *prev_state = &pad->prev_button_state;
@ -62,8 +62,7 @@ pad_get_buttons_released(struct pad_dispatch *pad,
}
static inline bool
pad_button_is_down(const struct pad_dispatch *pad,
uint32_t button)
pad_button_is_down(const struct pad_dispatch *pad, uint32_t button)
{
return bit_is_set(pad->button_state.bits, button);
}
@ -82,9 +81,7 @@ pad_any_button_down(const struct pad_dispatch *pad)
}
static inline void
pad_button_set_down(struct pad_dispatch *pad,
evdev_usage_t button,
bool is_down)
pad_button_set_down(struct pad_dispatch *pad, evdev_usage_t button, bool is_down)
{
struct button_state *state = &pad->button_state;
unsigned int code = evdev_usage_code(button);
@ -148,10 +145,11 @@ pad_update_changed_axis(struct pad_dispatch *pad,
const struct evdev_event *e)
{
if (pad->changed_axes & axis) {
evdev_log_bug_kernel_ratelimit(pad->device,
&pad->duplicate_abs_limit,
"Multiple EV_ABS %s events in the same SYN_REPORT\n",
evdev_event_get_code_name(e));
evdev_log_bug_kernel_ratelimit(
pad->device,
&pad->duplicate_abs_limit,
"Multiple EV_ABS %s events in the same SYN_REPORT\n",
evdev_event_get_code_name(e));
/* Special heuristics probably good enough:
* if we get multiple EV_ABS in the same SYN_REPORT
@ -179,10 +177,18 @@ pad_process_absolute(struct pad_dispatch *pad,
enum pad_axes axis = PAD_AXIS_NONE;
switch (evdev_usage_enum(e->usage)) {
case EVDEV_ABS_WHEEL: axis = PAD_AXIS_RING1; break;
case EVDEV_ABS_THROTTLE: axis = PAD_AXIS_RING2; break;
case EVDEV_ABS_RX: axis = PAD_AXIS_STRIP1; break;
case EVDEV_ABS_RY: axis = PAD_AXIS_STRIP2; break;
case EVDEV_ABS_WHEEL:
axis = PAD_AXIS_RING1;
break;
case EVDEV_ABS_THROTTLE:
axis = PAD_AXIS_RING2;
break;
case EVDEV_ABS_RX:
axis = PAD_AXIS_STRIP1;
break;
case EVDEV_ABS_RY:
axis = PAD_AXIS_STRIP2;
break;
case EVDEV_ABS_MISC:
/* The wacom driver always sends a 0 axis event on finger
up, but we also get an ABS_MISC 15 on touch down and
@ -234,8 +240,7 @@ normalize_wacom_strip(const struct input_absinfo *absinfo)
/* strip axes don't use a proper value, they just shift the bit left
* for each position. 0 isn't a real value either, it's only sent on
* finger release */
double min = 0,
max = log2(absinfo->maximum);
double min = 0, max = log2(absinfo->maximum);
double range = max - min;
double value = (log2(absinfo->value) - min) / range;
@ -293,8 +298,7 @@ pad_handle_strip(struct pad_dispatch *pad,
}
static inline struct libinput_tablet_pad_mode_group *
pad_dial_get_mode_group(struct pad_dispatch *pad,
unsigned int dial)
pad_dial_get_mode_group(struct pad_dispatch *pad, unsigned int dial)
{
struct libinput_tablet_pad_mode_group *group;
@ -309,8 +313,7 @@ pad_dial_get_mode_group(struct pad_dispatch *pad,
}
static inline struct libinput_tablet_pad_mode_group *
pad_ring_get_mode_group(struct pad_dispatch *pad,
unsigned int ring)
pad_ring_get_mode_group(struct pad_dispatch *pad, unsigned int ring)
{
struct libinput_tablet_pad_mode_group *group;
@ -325,8 +328,7 @@ pad_ring_get_mode_group(struct pad_dispatch *pad,
}
static inline struct libinput_tablet_pad_mode_group *
pad_strip_get_mode_group(struct pad_dispatch *pad,
unsigned int strip)
pad_strip_get_mode_group(struct pad_dispatch *pad, unsigned int strip)
{
struct libinput_tablet_pad_mode_group *group;
@ -360,20 +362,12 @@ pad_check_notify_axes(struct pad_dispatch *pad,
* so we can't set a source */
if (pad->changed_axes & PAD_AXIS_DIAL1) {
group = pad_dial_get_mode_group(pad, 0);
tablet_pad_notify_dial(base,
time,
0,
pad->dials.dial1,
group);
tablet_pad_notify_dial(base, time, 0, pad->dials.dial1, group);
}
if (pad->changed_axes & PAD_AXIS_DIAL2) {
group = pad_dial_get_mode_group(pad, 1);
tablet_pad_notify_dial(base,
time,
1,
pad->dials.dial2,
group);
tablet_pad_notify_dial(base, time, 1, pad->dials.dial2, group);
}
if (pad->changed_axes & PAD_AXIS_RING1) {
@ -452,8 +446,7 @@ pad_process_key(struct pad_dispatch *pad,
}
static inline struct libinput_tablet_pad_mode_group *
pad_button_get_mode_group(struct pad_dispatch *pad,
unsigned int button)
pad_button_get_mode_group(struct pad_dispatch *pad, unsigned int button)
{
struct libinput_tablet_pad_mode_group *group;
@ -503,11 +496,12 @@ pad_notify_button_mask(struct pad_dispatch *pad,
group = pad_button_get_mode_group(pad, button);
pad_button_update_mode(group, button, state);
tablet_pad_notify_button(base,
time,
pad_button_from_uint32_t(button),
state,
group);
tablet_pad_notify_button(
base,
time,
pad_button_from_uint32_t(button),
state,
group);
} else if (map_is_key(map)) {
uint32_t key = map_value(map);
@ -541,7 +535,7 @@ pad_notify_buttons(struct pad_dispatch *pad,
static void
pad_change_to_left_handed(struct evdev_device *device)
{
struct pad_dispatch *pad = (struct pad_dispatch*)device->dispatch;
struct pad_dispatch *pad = (struct pad_dispatch *)device->dispatch;
if (device->left_handed.enabled == device->left_handed.want_enabled)
return;
@ -553,9 +547,7 @@ pad_change_to_left_handed(struct evdev_device *device)
}
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, uint64_t time)
{
if (pad_has_status(pad, PAD_AXES_UPDATED)) {
pad_check_notify_axes(pad, device, time);
@ -563,27 +555,19 @@ pad_flush(struct pad_dispatch *pad,
}
if (pad_has_status(pad, PAD_BUTTONS_RELEASED)) {
pad_notify_buttons(pad,
device,
time,
LIBINPUT_BUTTON_STATE_RELEASED);
pad_notify_buttons(pad, device, time, LIBINPUT_BUTTON_STATE_RELEASED);
pad_unset_status(pad, PAD_BUTTONS_RELEASED);
pad_change_to_left_handed(device);
}
if (pad_has_status(pad, PAD_BUTTONS_PRESSED)) {
pad_notify_buttons(pad,
device,
time,
LIBINPUT_BUTTON_STATE_PRESSED);
pad_notify_buttons(pad, device, time, LIBINPUT_BUTTON_STATE_PRESSED);
pad_unset_status(pad, PAD_BUTTONS_PRESSED);
}
/* Update state */
memcpy(&pad->prev_button_state,
&pad->button_state,
sizeof(pad->button_state));
memcpy(&pad->prev_button_state, &pad->button_state, sizeof(pad->button_state));
pad->dials.dial1 = 0;
pad->dials.dial2 = 0;
}
@ -624,8 +608,7 @@ pad_process(struct evdev_dispatch *dispatch,
}
static void
pad_suspend(struct evdev_dispatch *dispatch,
struct evdev_device *device)
pad_suspend(struct evdev_dispatch *dispatch, struct evdev_device *device)
{
struct pad_dispatch *pad = pad_dispatch(dispatch);
struct libinput *libinput = pad_libinput_context(pad);
@ -693,8 +676,7 @@ pad_init_buttons_from_libwacom(struct pad_dispatch *pad,
}
static void
pad_init_buttons_from_kernel(struct pad_dispatch *pad,
struct evdev_device *device)
pad_init_buttons_from_kernel(struct pad_dispatch *pad, struct evdev_device *device)
{
unsigned int code;
int map = 0;
@ -759,8 +741,7 @@ pad_init_buttons(struct pad_dispatch *pad,
}
static void
pad_init_left_handed(struct evdev_device *device,
WacomDevice *wacom)
pad_init_left_handed(struct evdev_device *device, WacomDevice *wacom)
{
bool has_left_handed = true;
@ -768,8 +749,7 @@ pad_init_left_handed(struct evdev_device *device,
has_left_handed = !wacom || libwacom_is_reversible(wacom);
#endif
if (has_left_handed)
evdev_init_left_handed(device,
pad_change_to_left_handed);
evdev_init_left_handed(device, pad_change_to_left_handed);
}
static int
@ -788,17 +768,19 @@ pad_init(struct pad_dispatch *pad, struct evdev_device *device)
evdev_device_get_sysname(device));
wacom = libwacom_new_from_path(db, event_path, WFALLBACK_NONE, NULL);
if (!wacom) {
wacom = libwacom_new_from_usbid(db,
evdev_device_get_id_vendor(device),
evdev_device_get_id_product(device),
NULL);
wacom = libwacom_new_from_usbid(
db,
evdev_device_get_id_vendor(device),
evdev_device_get_id_product(device),
NULL);
}
if (!wacom) {
evdev_log_info(device,
"device \"%s\" (%04x:%04x) is not known to libwacom\n",
evdev_device_get_name(device),
evdev_device_get_id_vendor(device),
evdev_device_get_id_product(device));
evdev_log_info(
device,
"device \"%s\" (%04x:%04x) is not known to libwacom\n",
evdev_device_get_name(device),
evdev_device_get_id_vendor(device),
evdev_device_get_id_product(device));
}
}
#endif
@ -809,14 +791,16 @@ pad_init(struct pad_dispatch *pad, struct evdev_device *device)
pad->status = PAD_NONE;
pad->changed_axes = PAD_AXIS_NONE;
/* 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 */
pad->dials.has_hires_dial = libevdev_has_event_code(device->evdev, EV_REL, REL_WHEEL_HI_RES) ||
libevdev_has_event_code(device->evdev, EV_REL, REL_HWHEEL_HI_RES);
pad->dials.has_hires_dial =
libevdev_has_event_code(device->evdev, EV_REL, REL_WHEEL_HI_RES) ||
libevdev_has_event_code(device->evdev, EV_REL, REL_HWHEEL_HI_RES);
if (libevdev_has_event_code(device->evdev, EV_REL, REL_WHEEL) &&
libevdev_has_event_code(device->evdev, EV_REL, REL_DIAL)) {
log_bug_libinput(li, "Unsupported combination REL_DIAL and REL_WHEEL\n");
log_bug_libinput(li,
"Unsupported combination REL_DIAL and REL_WHEEL\n");
}
pad_init_buttons(pad, device, wacom);
@ -865,7 +849,7 @@ evdev_device_tablet_pad_has_key(struct evdev_device *device, uint32_t code)
int
evdev_device_tablet_pad_get_num_buttons(struct evdev_device *device)
{
struct pad_dispatch *pad = (struct pad_dispatch*)device->dispatch;
struct pad_dispatch *pad = (struct pad_dispatch *)device->dispatch;
if (!(device->seat_caps & EVDEV_DEVICE_TABLET_PAD))
return -1;
@ -884,9 +868,7 @@ evdev_device_tablet_pad_get_num_dials(struct evdev_device *device)
if (libevdev_has_event_code(device->evdev, EV_REL, REL_WHEEL) ||
libevdev_has_event_code(device->evdev, EV_REL, REL_DIAL)) {
ndials++;
if (libevdev_has_event_code(device->evdev,
EV_REL,
REL_HWHEEL))
if (libevdev_has_event_code(device->evdev, EV_REL, REL_HWHEEL))
ndials++;
}
@ -903,9 +885,7 @@ evdev_device_tablet_pad_get_num_rings(struct evdev_device *device)
if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_WHEEL)) {
nrings++;
if (libevdev_has_event_code(device->evdev,
EV_ABS,
ABS_THROTTLE))
if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_THROTTLE))
nrings++;
}
@ -922,9 +902,7 @@ evdev_device_tablet_pad_get_num_strips(struct evdev_device *device)
if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_RX)) {
nstrips++;
if (libevdev_has_event_code(device->evdev,
EV_ABS,
ABS_RY))
if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_RY))
nstrips++;
}

View file

@ -27,26 +27,26 @@
#include "evdev.h"
#if !HAVE_LIBWACOM
typedef void * WacomDevice;
typedef void *WacomDevice;
#endif
#define LIBINPUT_BUTTONSET_AXIS_NONE 0
enum pad_status {
PAD_NONE = 0,
PAD_AXES_UPDATED = bit(0),
PAD_BUTTONS_PRESSED = bit(1),
PAD_BUTTONS_RELEASED = bit(2),
PAD_NONE = 0,
PAD_AXES_UPDATED = bit(0),
PAD_BUTTONS_PRESSED = bit(1),
PAD_BUTTONS_RELEASED = bit(2),
};
enum pad_axes {
PAD_AXIS_NONE = 0,
PAD_AXIS_RING1 = bit(0),
PAD_AXIS_RING2 = bit(1),
PAD_AXIS_STRIP1 = bit(2),
PAD_AXIS_STRIP2 = bit(3),
PAD_AXIS_DIAL1 = bit(4),
PAD_AXIS_DIAL2 = bit(5),
PAD_AXIS_NONE = 0,
PAD_AXIS_RING1 = bit(0),
PAD_AXIS_RING2 = bit(1),
PAD_AXIS_STRIP1 = bit(2),
PAD_AXIS_STRIP2 = bit(3),
PAD_AXIS_DIAL1 = bit(4),
PAD_AXIS_DIAL2 = bit(5),
};
struct button_state {
@ -92,7 +92,7 @@ struct pad_dispatch {
struct ratelimit duplicate_abs_limit;
};
static inline struct pad_dispatch*
static inline struct pad_dispatch *
pad_dispatch(struct evdev_dispatch *dispatch)
{
evdev_verify_dispatch_type(dispatch, DISPATCH_TABLET_PAD);

File diff suppressed because it is too large Load diff

View file

@ -28,7 +28,7 @@
#include "evdev.h"
#if !HAVE_LIBWACOM
typedef void * WacomDevice;
typedef void *WacomDevice;
#endif
#define LIBINPUT_TABLET_TOOL_AXIS_NONE 0
@ -38,20 +38,20 @@ typedef void * WacomDevice;
#define TABLET_HISTORY_LENGTH 4
enum tablet_status {
TABLET_NONE = 0,
TABLET_AXES_UPDATED = bit(0),
TABLET_BUTTONS_PRESSED = bit(1),
TABLET_BUTTONS_DOWN = bit(2),
TABLET_BUTTONS_RELEASED = bit(3),
TABLET_TOOL_UPDATED = bit(4),
TABLET_TOOL_IN_CONTACT = bit(5),
TABLET_TOOL_LEAVING_PROXIMITY = bit(6),
TABLET_TOOL_OUT_OF_PROXIMITY = bit(7),
TABLET_TOOL_ENTERING_PROXIMITY = bit(8),
TABLET_TOOL_ENTERING_CONTACT = bit(9),
TABLET_TOOL_LEAVING_CONTACT = bit(10),
TABLET_TOOL_OUT_OF_RANGE = bit(11),
TABLET_TOOL_OUTSIDE_AREA = bit(12),
TABLET_NONE = 0,
TABLET_AXES_UPDATED = bit(0),
TABLET_BUTTONS_PRESSED = bit(1),
TABLET_BUTTONS_DOWN = bit(2),
TABLET_BUTTONS_RELEASED = bit(3),
TABLET_TOOL_UPDATED = bit(4),
TABLET_TOOL_IN_CONTACT = bit(5),
TABLET_TOOL_LEAVING_PROXIMITY = bit(6),
TABLET_TOOL_OUT_OF_PROXIMITY = bit(7),
TABLET_TOOL_ENTERING_PROXIMITY = bit(8),
TABLET_TOOL_ENTERING_CONTACT = bit(9),
TABLET_TOOL_LEAVING_CONTACT = bit(10),
TABLET_TOOL_OUT_OF_RANGE = bit(11),
TABLET_TOOL_OUTSIDE_AREA = bit(12),
};
struct button_state {
@ -118,7 +118,7 @@ struct tablet_dispatch {
} rotation;
};
static inline struct tablet_dispatch*
static inline struct tablet_dispatch *
tablet_dispatch(struct evdev_dispatch *dispatch)
{
evdev_verify_dispatch_type(dispatch, DISPATCH_TABLET);
@ -216,13 +216,27 @@ tablet_tool_to_evcode(enum libinput_tablet_tool_type type)
int code;
switch (type) {
case LIBINPUT_TABLET_TOOL_TYPE_PEN: code = BTN_TOOL_PEN; break;
case LIBINPUT_TABLET_TOOL_TYPE_ERASER: code = BTN_TOOL_RUBBER; break;
case LIBINPUT_TABLET_TOOL_TYPE_BRUSH: code = BTN_TOOL_BRUSH; break;
case LIBINPUT_TABLET_TOOL_TYPE_PENCIL: code = BTN_TOOL_PENCIL; break;
case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH: code = BTN_TOOL_AIRBRUSH; break;
case LIBINPUT_TABLET_TOOL_TYPE_MOUSE: code = BTN_TOOL_MOUSE; break;
case LIBINPUT_TABLET_TOOL_TYPE_LENS: code = BTN_TOOL_LENS; break;
case LIBINPUT_TABLET_TOOL_TYPE_PEN:
code = BTN_TOOL_PEN;
break;
case LIBINPUT_TABLET_TOOL_TYPE_ERASER:
code = BTN_TOOL_RUBBER;
break;
case LIBINPUT_TABLET_TOOL_TYPE_BRUSH:
code = BTN_TOOL_BRUSH;
break;
case LIBINPUT_TABLET_TOOL_TYPE_PENCIL:
code = BTN_TOOL_PENCIL;
break;
case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH:
code = BTN_TOOL_AIRBRUSH;
break;
case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
code = BTN_TOOL_MOUSE;
break;
case LIBINPUT_TABLET_TOOL_TYPE_LENS:
code = BTN_TOOL_LENS;
break;
default:
abort();
}
@ -236,13 +250,27 @@ tablet_tool_type_to_string(enum libinput_tablet_tool_type type)
const char *str;
switch (type) {
case LIBINPUT_TABLET_TOOL_TYPE_PEN: str = "pen"; break;
case LIBINPUT_TABLET_TOOL_TYPE_ERASER: str = "eraser"; break;
case LIBINPUT_TABLET_TOOL_TYPE_BRUSH: str = "brush"; break;
case LIBINPUT_TABLET_TOOL_TYPE_PENCIL: str = "pencil"; break;
case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH: str = "airbrush"; break;
case LIBINPUT_TABLET_TOOL_TYPE_MOUSE: str = "mouse"; break;
case LIBINPUT_TABLET_TOOL_TYPE_LENS: str = "lens"; break;
case LIBINPUT_TABLET_TOOL_TYPE_PEN:
str = "pen";
break;
case LIBINPUT_TABLET_TOOL_TYPE_ERASER:
str = "eraser";
break;
case LIBINPUT_TABLET_TOOL_TYPE_BRUSH:
str = "brush";
break;
case LIBINPUT_TABLET_TOOL_TYPE_PENCIL:
str = "pencil";
break;
case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH:
str = "airbrush";
break;
case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
str = "mouse";
break;
case LIBINPUT_TABLET_TOOL_TYPE_LENS:
str = "lens";
break;
default:
abort();
}

View file

@ -22,6 +22,7 @@
*/
#include "config.h"
#include "evdev.h"
enum totem_slot_state {
@ -59,7 +60,7 @@ struct totem_dispatch {
enum evdev_arbitration_state arbitration_state;
};
static inline struct totem_dispatch*
static inline struct totem_dispatch *
totem_dispatch(struct evdev_dispatch *totem)
{
evdev_verify_dispatch_type(totem, DISPATCH_TOTEM);
@ -81,7 +82,7 @@ totem_new_tool(struct totem_dispatch *totem)
tool = zalloc(sizeof *tool);
*tool = (struct libinput_tablet_tool) {
*tool = (struct libinput_tablet_tool){
.type = LIBINPUT_TABLET_TOOL_TYPE_TOTEM,
.serial = 0,
.tool_id = 0,
@ -146,30 +147,32 @@ totem_set_touch_device_enabled(struct totem_dispatch *totem,
dispatch = touch_device->dispatch;
if (enable_touch_device) {
if (dispatch->interface->touch_arbitration_toggle)
dispatch->interface->touch_arbitration_toggle(dispatch,
touch_device,
state,
rect,
time);
if (dispatch->interface->touch_arbitration_toggle)
dispatch->interface->touch_arbitration_toggle(dispatch,
touch_device,
state,
rect,
time);
} else {
switch (totem->arbitration_state) {
case ARBITRATION_IGNORE_ALL:
abort();
case ARBITRATION_NOT_ACTIVE:
if (dispatch->interface->touch_arbitration_toggle)
dispatch->interface->touch_arbitration_toggle(dispatch,
touch_device,
state,
rect,
time);
dispatch->interface->touch_arbitration_toggle(
dispatch,
touch_device,
state,
rect,
time);
break;
case ARBITRATION_IGNORE_RECT:
if (dispatch->interface->touch_arbitration_update_rect)
dispatch->interface->touch_arbitration_update_rect(dispatch,
touch_device,
rect,
time);
dispatch->interface->touch_arbitration_update_rect(
dispatch,
touch_device,
rect,
time);
break;
}
}
@ -232,16 +235,13 @@ totem_process_abs(struct totem_dispatch *totem,
set_bit(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_Y);
break;
case EVDEV_ABS_MT_TOUCH_MAJOR:
set_bit(slot->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR);
set_bit(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR);
break;
case EVDEV_ABS_MT_TOUCH_MINOR:
set_bit(slot->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR);
set_bit(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR);
break;
case EVDEV_ABS_MT_ORIENTATION:
set_bit(slot->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
set_bit(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
break;
case EVDEV_ABS_MT_TOOL_TYPE:
if (e->value != MT_TOOL_DIAL) {
@ -266,8 +266,8 @@ totem_slot_fetch_axes(struct totem_dispatch *totem,
uint64_t time)
{
struct evdev_device *device = totem->device;
const char tmp[sizeof(slot->changed_axes)] = {0};
struct tablet_axes axes = {0};
const char tmp[sizeof(slot->changed_axes)] = { 0 };
struct tablet_axes axes = { 0 };
struct device_float_coords delta;
bool rc = false;
@ -286,8 +286,7 @@ totem_slot_fetch_axes(struct totem_dispatch *totem,
ABS_MT_POSITION_Y);
}
if (bit_is_set(slot->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z)) {
if (bit_is_set(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z)) {
int angle = libevdev_get_slot_value(device->evdev,
slot->index,
ABS_MT_ORIENTATION);
@ -295,10 +294,8 @@ totem_slot_fetch_axes(struct totem_dispatch *totem,
slot->axes.rotation = (360 - angle) % 360;
}
if (bit_is_set(slot->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR) ||
bit_is_set(slot->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR)) {
if (bit_is_set(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR) ||
bit_is_set(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR)) {
int major, minor;
unsigned int rmajor, rminor;
@ -310,8 +307,8 @@ totem_slot_fetch_axes(struct totem_dispatch *totem,
ABS_MT_TOUCH_MINOR);
rmajor = libevdev_get_abs_resolution(device->evdev, ABS_MT_TOUCH_MAJOR);
rminor = libevdev_get_abs_resolution(device->evdev, ABS_MT_TOUCH_MINOR);
slot->axes.size.major = (double)major/rmajor;
slot->axes.size.minor = (double)minor/rminor;
slot->axes.size.major = (double)major / rmajor;
slot->axes.size.minor = (double)minor / rminor;
}
axes.point = slot->axes.point;
@ -326,42 +323,34 @@ totem_slot_fetch_axes(struct totem_dispatch *totem,
out:
*axes_out = axes;
return rc;
}
static void
totem_slot_mark_all_axes_changed(struct totem_dispatch *totem,
struct totem_slot *slot,
struct libinput_tablet_tool *tool)
struct totem_slot *slot,
struct libinput_tablet_tool *tool)
{
static_assert(sizeof(slot->changed_axes) ==
sizeof(tool->axis_caps),
static_assert(sizeof(slot->changed_axes) == sizeof(tool->axis_caps),
"Mismatching array sizes");
memcpy(slot->changed_axes,
tool->axis_caps,
sizeof(slot->changed_axes));
memcpy(slot->changed_axes, tool->axis_caps, sizeof(slot->changed_axes));
}
static inline void
totem_slot_reset_changed_axes(struct totem_dispatch *totem,
struct totem_slot *slot)
totem_slot_reset_changed_axes(struct totem_dispatch *totem, struct totem_slot *slot)
{
memset(slot->changed_axes, 0, sizeof(slot->changed_axes));
}
static inline void
slot_axes_initialize(struct totem_dispatch *totem,
struct totem_slot *slot)
slot_axes_initialize(struct totem_dispatch *totem, struct totem_slot *slot)
{
struct evdev_device *device = totem->device;
slot->axes.point.x = libevdev_get_slot_value(device->evdev,
slot->index,
ABS_MT_POSITION_X);
slot->axes.point.y = libevdev_get_slot_value(device->evdev,
slot->index,
ABS_MT_POSITION_Y);
slot->axes.point.x =
libevdev_get_slot_value(device->evdev, slot->index, ABS_MT_POSITION_X);
slot->axes.point.y =
libevdev_get_slot_value(device->evdev, slot->index, ABS_MT_POSITION_Y);
slot->last_point.x = slot->axes.point.x;
slot->last_point.y = slot->axes.point.y;
}
@ -466,7 +455,7 @@ totem_handle_slot_state(struct totem_dispatch *totem,
totem->button_state_previous = totem->button_state_now;
}
switch(slot->state) {
switch (slot->state) {
case SLOT_STATE_BEGIN:
case SLOT_STATE_UPDATE:
break;
@ -487,8 +476,8 @@ totem_handle_slot_state(struct totem_dispatch *totem,
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT,
slot->changed_axes,
&axes,
device->abs.absinfo_x,
device->abs.absinfo_y);
device->abs.absinfo_x,
device->abs.absinfo_y);
slot->state = SLOT_STATE_NONE;
break;
@ -504,17 +493,14 @@ totem_handle_slot_state(struct totem_dispatch *totem,
}
static enum totem_slot_state
totem_handle_state(struct totem_dispatch *totem,
uint64_t time)
totem_handle_state(struct totem_dispatch *totem, uint64_t time)
{
enum totem_slot_state global_state = SLOT_STATE_NONE;
for (size_t i = 0; i < totem->nslots; i++) {
enum totem_slot_state s;
s = totem_handle_slot_state(totem,
&totem->slots[i],
time);
s = totem_handle_slot_state(totem, &totem->slots[i], time);
/* If one slot is active, the totem is active */
if (s != SLOT_STATE_NONE)
@ -535,7 +521,7 @@ totem_interface_process(struct evdev_dispatch *dispatch,
bool enable_touch;
uint16_t type = evdev_event_type(e);
switch(type) {
switch (type) {
case EV_ABS:
totem_process_abs(totem, device, e, time);
break;
@ -548,9 +534,7 @@ totem_interface_process(struct evdev_dispatch *dispatch,
case EV_SYN:
global_state = totem_handle_state(totem, time);
enable_touch = (global_state == SLOT_STATE_NONE);
totem_set_touch_device_enabled(totem,
enable_touch,
time);
totem_set_touch_device_enabled(totem, enable_touch, time);
break;
default:
evdev_log_error(device,
@ -562,8 +546,7 @@ totem_interface_process(struct evdev_dispatch *dispatch,
}
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);
uint64_t now = libinput_now(evdev_libinput_context(device));
@ -616,8 +599,8 @@ totem_interface_suspend(struct evdev_dispatch *dispatch,
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT,
slot->changed_axes,
&axes,
device->abs.absinfo_x,
device->abs.absinfo_y);
device->abs.absinfo_x,
device->abs.absinfo_y);
}
totem_set_touch_device_enabled(totem, true, now);
}
@ -639,10 +622,10 @@ totem_interface_device_added(struct evdev_device *device,
struct libinput_device_group *g1, *g2;
if ((evdev_device_get_id_vendor(added_device) !=
evdev_device_get_id_vendor(device)) ||
evdev_device_get_id_vendor(device)) ||
(evdev_device_get_id_product(added_device) !=
evdev_device_get_id_product(device)))
return;
return;
/* virtual devices don't have device groups, so check for that
libinput replay */
@ -652,14 +635,17 @@ totem_interface_device_added(struct evdev_device *device,
return;
if (totem->touch_device != NULL) {
evdev_log_bug_libinput(device,
"already has a paired touch device, ignoring (%s)\n",
added_device->devname);
evdev_log_bug_libinput(
device,
"already has a paired touch device, ignoring (%s)\n",
added_device->devname);
return;
}
totem->touch_device = added_device;
evdev_log_info(device, "%s: is the totem touch device\n", added_device->devname);
evdev_log_info(device,
"%s: is the totem touch device\n",
added_device->devname);
}
static void
@ -671,7 +657,8 @@ totem_interface_device_removed(struct evdev_device *device,
if (totem->touch_device != removed_device)
return;
totem_set_touch_device_enabled(totem, true,
totem_set_touch_device_enabled(totem,
true,
libinput_now(evdev_libinput_context(device)));
totem->touch_device = NULL;
}
@ -689,9 +676,8 @@ totem_interface_initial_proximity(struct evdev_device *device,
struct tablet_axes axes;
int tracking_id;
tracking_id = libevdev_get_slot_value(device->evdev,
i,
ABS_MT_TRACKING_ID);
tracking_id =
libevdev_get_slot_value(device->evdev, i, ABS_MT_TRACKING_ID);
if (tracking_id == -1)
continue;
@ -705,8 +691,8 @@ totem_interface_initial_proximity(struct evdev_device *device,
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN,
slot->changed_axes,
&axes,
device->abs.absinfo_x,
device->abs.absinfo_y);
device->abs.absinfo_x,
device->abs.absinfo_y);
totem_slot_reset_changed_axes(totem, slot);
tablet_notify_tip(&device->base,
now,
@ -731,7 +717,7 @@ static struct evdev_dispatch_interface totem_interface = {
.device_added = totem_interface_device_added,
.device_removed = totem_interface_device_removed,
.device_suspended = totem_interface_device_removed, /* treat as remove */
.device_resumed = totem_interface_device_added, /* treat as add */
.device_resumed = totem_interface_device_added, /* treat as add */
.post_added = totem_interface_initial_proximity,
.touch_arbitration_toggle = NULL,
.touch_arbitration_update_rect = NULL,
@ -746,10 +732,11 @@ totem_reject_device(struct evdev_device *device)
double w, h;
has_xy = libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) &&
libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y);
libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y);
has_slot = libevdev_has_event_code(evdev, EV_ABS, ABS_MT_SLOT);
has_tool_dial = libevdev_has_event_code(evdev, EV_ABS, ABS_MT_TOOL_TYPE) &&
libevdev_get_abs_maximum(evdev, ABS_MT_TOOL_TYPE) >= MT_TOOL_DIAL;
has_tool_dial =
libevdev_has_event_code(evdev, EV_ABS, ABS_MT_TOOL_TYPE) &&
libevdev_get_abs_maximum(evdev, ABS_MT_TOOL_TYPE) >= MT_TOOL_DIAL;
has_size = evdev_device_get_size(device, &w, &h) == 0;
has_touch_size =
libevdev_get_abs_resolution(device->evdev, ABS_MT_TOUCH_MAJOR) > 0 ||
@ -777,7 +764,7 @@ totem_accel_config_get_profiles(struct libinput_device *libinput_device)
static enum libinput_config_status
totem_accel_config_set_profile(struct libinput_device *libinput_device,
enum libinput_config_accel_profile profile)
enum libinput_config_accel_profile profile)
{
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
}
@ -804,8 +791,7 @@ totem_init_accel(struct totem_dispatch *totem, struct evdev_device *device)
y = device->abs.absinfo_y;
/* same filter as the tablet */
filter = create_pointer_accelerator_filter_tablet(x->resolution,
y->resolution);
filter = create_pointer_accelerator_filter_tablet(x->resolution, y->resolution);
if (!filter)
return -1;
@ -816,7 +802,8 @@ totem_init_accel(struct totem_dispatch *totem, struct evdev_device *device)
device->pointer.config.get_profiles = totem_accel_config_get_profiles;
device->pointer.config.set_profile = totem_accel_config_set_profile;
device->pointer.config.get_profile = totem_accel_config_get_profile;
device->pointer.config.get_default_profile = totem_accel_config_get_default_profile;
device->pointer.config.get_default_profile =
totem_accel_config_get_default_profile;
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -28,56 +28,57 @@
#include "config.h"
#include <stdbool.h>
#include <stdarg.h>
#include "linux/input.h"
#include <libevdev/libevdev.h>
#include <stdarg.h>
#include <stdbool.h>
#include "libinput-private.h"
#include "timer.h"
#include "filter.h"
#include "quirks.h"
#include "evdev-frame.h"
#include "util-input-event.h"
#include "evdev-frame.h"
#include "filter.h"
#include "libinput-private.h"
#include "linux/input.h"
#include "quirks.h"
#include "timer.h"
/* The fake resolution value for abs devices without resolution */
#define EVDEV_FAKE_RESOLUTION 1
enum evdev_event_type {
EVDEV_NONE = 0,
EVDEV_ABSOLUTE_TOUCH_DOWN = bit(0),
EVDEV_ABSOLUTE_MOTION = bit(1),
EVDEV_ABSOLUTE_TOUCH_UP = bit(2),
EVDEV_ABSOLUTE_MT = bit(3),
EVDEV_KEY = bit(4),
EVDEV_RELATIVE_MOTION = bit(5),
EVDEV_BUTTON = bit(6),
EVDEV_NONE = 0,
EVDEV_ABSOLUTE_TOUCH_DOWN = bit(0),
EVDEV_ABSOLUTE_MOTION = bit(1),
EVDEV_ABSOLUTE_TOUCH_UP = bit(2),
EVDEV_ABSOLUTE_MT = bit(3),
EVDEV_KEY = bit(4),
EVDEV_RELATIVE_MOTION = bit(5),
EVDEV_BUTTON = bit(6),
};
enum evdev_device_seat_capability {
EVDEV_DEVICE_NO_CAPABILITIES = 0,
EVDEV_DEVICE_POINTER = bit(0),
EVDEV_DEVICE_KEYBOARD = bit(1),
EVDEV_DEVICE_TOUCH = bit(2),
EVDEV_DEVICE_TABLET = bit(3),
EVDEV_DEVICE_TABLET_PAD = bit(4),
EVDEV_DEVICE_GESTURE = bit(5),
EVDEV_DEVICE_SWITCH = bit(6),
EVDEV_DEVICE_NO_CAPABILITIES = 0,
EVDEV_DEVICE_POINTER = bit(0),
EVDEV_DEVICE_KEYBOARD = bit(1),
EVDEV_DEVICE_TOUCH = bit(2),
EVDEV_DEVICE_TABLET = bit(3),
EVDEV_DEVICE_TABLET_PAD = bit(4),
EVDEV_DEVICE_GESTURE = bit(5),
EVDEV_DEVICE_SWITCH = bit(6),
};
enum evdev_device_tags {
EVDEV_TAG_NONE = 0,
EVDEV_TAG_EXTERNAL_MOUSE = bit(0),
EVDEV_TAG_INTERNAL_TOUCHPAD = bit(1),
EVDEV_TAG_EXTERNAL_TOUCHPAD = bit(2),
EVDEV_TAG_TRACKPOINT = bit(3),
EVDEV_TAG_KEYBOARD = bit(4),
EVDEV_TAG_LID_SWITCH = bit(5),
EVDEV_TAG_INTERNAL_KEYBOARD = bit(6),
EVDEV_TAG_EXTERNAL_KEYBOARD = bit(7),
EVDEV_TAG_TABLET_MODE_SWITCH = bit(8),
EVDEV_TAG_TABLET_TOUCHPAD = bit(9),
EVDEV_TAG_VIRTUAL = bit(10),
EVDEV_TAG_NONE = 0,
EVDEV_TAG_EXTERNAL_MOUSE = bit(0),
EVDEV_TAG_INTERNAL_TOUCHPAD = bit(1),
EVDEV_TAG_EXTERNAL_TOUCHPAD = bit(2),
EVDEV_TAG_TRACKPOINT = bit(3),
EVDEV_TAG_KEYBOARD = bit(4),
EVDEV_TAG_LID_SWITCH = bit(5),
EVDEV_TAG_INTERNAL_KEYBOARD = bit(6),
EVDEV_TAG_EXTERNAL_KEYBOARD = bit(7),
EVDEV_TAG_TABLET_MODE_SWITCH = bit(8),
EVDEV_TAG_TABLET_TOUCHPAD = bit(9),
EVDEV_TAG_VIRTUAL = bit(10),
};
enum evdev_middlebutton_state {
@ -110,24 +111,24 @@ enum evdev_middlebutton_event {
*/
enum evdev_device_model {
EVDEV_MODEL_DEFAULT = 0,
EVDEV_MODEL_WACOM_TOUCHPAD = bit(1),
EVDEV_MODEL_SYNAPTICS_SERIAL_TOUCHPAD = bit(2),
EVDEV_MODEL_ALPS_SERIAL_TOUCHPAD = bit(3),
EVDEV_MODEL_LENOVO_T450_TOUCHPAD = bit(4),
EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON = bit(5),
EVDEV_MODEL_LENOVO_SCROLLPOINT = bit(6),
EVDEV_MODEL_WACOM_TOUCHPAD = bit(1),
EVDEV_MODEL_SYNAPTICS_SERIAL_TOUCHPAD = bit(2),
EVDEV_MODEL_ALPS_SERIAL_TOUCHPAD = bit(3),
EVDEV_MODEL_LENOVO_T450_TOUCHPAD = bit(4),
EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON = bit(5),
EVDEV_MODEL_LENOVO_SCROLLPOINT = bit(6),
/* udev tags, not true quirks */
EVDEV_MODEL_TEST_DEVICE = bit(20),
EVDEV_MODEL_TRACKBALL = bit(21),
EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81 = bit(22),
EVDEV_MODEL_TEST_DEVICE = bit(20),
EVDEV_MODEL_TRACKBALL = bit(21),
EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81 = bit(22),
};
enum evdev_button_scroll_state {
BUTTONSCROLL_IDLE,
BUTTONSCROLL_BUTTON_DOWN, /* button is down */
BUTTONSCROLL_READY, /* ready for scroll events */
BUTTONSCROLL_SCROLLING, /* have sent scroll events */
BUTTONSCROLL_BUTTON_DOWN, /* button is down */
BUTTONSCROLL_READY, /* ready for scroll events */
BUTTONSCROLL_SCROLLING, /* have sent scroll events */
};
enum evdev_button_scroll_lock_state {
@ -181,12 +182,15 @@ struct evdev_device {
enum evdev_device_tags tags;
bool is_mt;
bool is_suspended;
int dpi; /* HW resolution */
int dpi; /* HW resolution */
double trackpoint_multiplier; /* trackpoint constant multiplier */
bool use_velocity_averaging; /* whether averaging should be applied on velocity calculation */
bool use_velocity_averaging; /* whether averaging should be applied on velocity
calculation */
struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */
struct ratelimit delay_warning_limit; /* ratelimit for delayd processing logging */
struct ratelimit nonpointer_rel_limit; /* ratelimit for REL_* events from non-pointer devices */
struct ratelimit
delay_warning_limit; /* ratelimit for delayd processing logging */
struct ratelimit nonpointer_rel_limit; /* ratelimit for REL_* events from
non-pointer devices */
uint32_t model_flags;
struct mtdev *mtdev;
@ -196,8 +200,9 @@ struct evdev_device {
int apply_calibration;
struct matrix calibration;
struct matrix default_calibration; /* from LIBINPUT_CALIBRATION_MATRIX */
struct matrix usermatrix; /* as supplied by the caller */
struct matrix
default_calibration; /* from LIBINPUT_CALIBRATION_MATRIX */
struct matrix usermatrix; /* as supplied by the caller */
struct device_coords dimensions;
@ -295,8 +300,7 @@ struct evdev_dispatch_interface {
uint64_t time);
/* Device is being suspended */
void (*suspend)(struct evdev_dispatch *dispatch,
struct evdev_device *device);
void (*suspend)(struct evdev_dispatch *dispatch, struct evdev_device *device);
/* Device is being removed (may be NULL) */
void (*remove)(struct evdev_dispatch *dispatch);
@ -343,9 +347,8 @@ struct evdev_dispatch_interface {
uint64_t now);
/* Return the state of the given switch */
enum libinput_switch_state
(*get_switch_state)(struct evdev_dispatch *dispatch,
enum libinput_switch which);
enum libinput_switch_state (*get_switch_state)(struct evdev_dispatch *dispatch,
enum libinput_switch which);
void (*left_handed_toggle)(struct evdev_dispatch *dispatch,
struct evdev_device *device,
@ -379,8 +382,7 @@ evdev_verify_dispatch_type(struct evdev_dispatch *dispatch,
}
struct evdev_device *
evdev_device_create(struct libinput_seat *seat,
struct udev_device *device);
evdev_device_create(struct libinput_seat *seat, struct udev_device *device);
static inline struct libinput *
evdev_libinput_context(const struct evdev_device *device)
@ -389,8 +391,7 @@ evdev_libinput_context(const struct evdev_device *device)
}
static inline bool
evdev_device_has_model_quirk(struct evdev_device *device,
enum quirk model_quirk)
evdev_device_has_model_quirk(struct evdev_device *device, enum quirk model_quirk)
{
assert(quirk_get_name(model_quirk) != NULL);
@ -404,16 +405,14 @@ evdev_device_has_model_quirk(struct evdev_device *device,
}
void
evdev_transform_absolute(struct evdev_device *device,
struct device_coords *point);
evdev_transform_absolute(struct evdev_device *device, struct device_coords *point);
void
evdev_transform_relative(struct evdev_device *device,
struct device_coords *point);
evdev_transform_relative(struct evdev_device *device, struct device_coords *point);
void
evdev_init_calibration(struct evdev_device *device,
struct libinput_device_config_calibration *calibration);
struct libinput_device_config_calibration *calibration);
void
evdev_read_calibration_prop(struct evdev_device *device);
@ -425,8 +424,7 @@ enum switch_reliability
evdev_read_switch_reliability_prop(struct evdev_device *device);
void
evdev_init_sendevents(struct evdev_device *device,
struct evdev_dispatch *dispatch);
evdev_init_sendevents(struct evdev_device *device, struct evdev_dispatch *dispatch);
void
evdev_device_init_pointer_acceleration(struct evdev_device *device,
@ -490,17 +488,14 @@ void
evdev_device_set_default_calibration(struct evdev_device *device,
const float calibration[6]);
void
evdev_device_calibrate(struct evdev_device *device,
const float calibration[6]);
evdev_device_calibrate(struct evdev_device *device, const float calibration[6]);
bool
evdev_device_has_capability(struct evdev_device *device,
enum libinput_device_capability capability);
int
evdev_device_get_size(const struct evdev_device *device,
double *w,
double *h);
evdev_device_get_size(const struct evdev_device *device, double *w, double *h);
int
evdev_device_has_button(struct evdev_device *device, uint32_t code);
@ -512,12 +507,10 @@ int
evdev_device_get_touch_count(struct evdev_device *device);
int
evdev_device_has_switch(struct evdev_device *device,
enum libinput_switch sw);
evdev_device_has_switch(struct evdev_device *device, enum libinput_switch sw);
int
evdev_device_tablet_pad_has_key(struct evdev_device *device,
uint32_t code);
evdev_device_tablet_pad_has_key(struct evdev_device *device, uint32_t code);
int
evdev_device_tablet_pad_get_num_buttons(struct evdev_device *device);
@ -535,22 +528,16 @@ int
evdev_device_tablet_pad_get_num_mode_groups(struct evdev_device *device);
struct libinput_tablet_pad_mode_group *
evdev_device_tablet_pad_get_mode_group(struct evdev_device *device,
unsigned int index);
evdev_device_tablet_pad_get_mode_group(struct evdev_device *device, unsigned int index);
enum libinput_switch_state
evdev_device_switch_get_state(struct evdev_device *device,
enum libinput_switch sw);
evdev_device_switch_get_state(struct evdev_device *device, enum libinput_switch sw);
double
evdev_device_transform_x(struct evdev_device *device,
double x,
uint32_t width);
evdev_device_transform_x(struct evdev_device *device, double x, uint32_t width);
double
evdev_device_transform_y(struct evdev_device *device,
double y,
uint32_t height);
evdev_device_transform_y(struct evdev_device *device, double y, uint32_t height);
void
evdev_device_suspend(struct evdev_device *device);
@ -582,8 +569,7 @@ evdev_init_button_scroll(struct evdev_device *device,
void (*change_scroll_method)(struct evdev_device *));
void
evdev_set_button_scroll_lock_enabled(struct evdev_device *device,
bool enabled);
evdev_set_button_scroll_lock_enabled(struct evdev_device *device, bool enabled);
int
evdev_update_key_down_count(struct evdev_device *device,
@ -604,9 +590,9 @@ evdev_notify_axis_wheel(struct evdev_device *device,
const struct wheel_v120 *v120_in);
void
evdev_notify_axis_finger(struct evdev_device *device,
uint64_t time,
uint32_t axes,
const struct normalized_coords *delta_in);
uint64_t time,
uint32_t axes,
const struct normalized_coords *delta_in);
void
evdev_notify_axis_continous(struct evdev_device *device,
uint64_t time,
@ -637,9 +623,7 @@ evdev_middlebutton_filter_button(struct evdev_device *device,
enum libinput_button_state state);
void
evdev_init_middlebutton(struct evdev_device *device,
bool enabled,
bool want_config);
evdev_init_middlebutton(struct evdev_device *device, bool enabled, bool want_config);
enum libinput_config_middle_emulation_state
evdev_middlebutton_get(struct libinput_device *device);
@ -666,8 +650,7 @@ evdev_init_left_handed(struct evdev_device *device,
void (*change_to_left_handed)(struct evdev_device *));
static inline evdev_usage_t
evdev_to_left_handed(struct evdev_device *device,
evdev_usage_t button)
evdev_to_left_handed(struct evdev_device *device, evdev_usage_t button)
{
if (device->left_handed.enabled) {
if (evdev_usage_eq(button, EVDEV_BTN_LEFT))
@ -731,8 +714,8 @@ evdev_hysteresis(const struct device_coords *in,
* the ratio of finger_distance to margin_distance:
* dx²/a² + dy²/b² = normalized_finger_distance²
*/
normalized_finger_distance = sqrt((double)dx2 / (a * a) +
(double)dy2 / (b * b));
normalized_finger_distance =
sqrt((double)dx2 / (a * a) + (double)dy2 / (b * b));
/* Which means anything less than 1 is within the elliptical margin */
if (normalized_finger_distance < 1.0)
@ -749,9 +732,8 @@ evdev_hysteresis(const struct device_coords *in,
if (dx) {
double gradient = (double)dy / dx;
lag_x = margin_distance / sqrt(gradient * gradient + 1);
lag_y = sqrt((margin_distance + lag_x) *
(margin_distance - lag_x));
} else { /* Infinite gradient */
lag_y = sqrt((margin_distance + lag_x) * (margin_distance - lag_x));
} else { /* Infinite gradient */
lag_x = 0.0;
lag_y = margin_distance;
}
@ -784,8 +766,9 @@ evdev_log_msg(struct evdev_device *device,
sizeof(buf),
"%-7s - %s%s%s",
evdev_device_get_sysname(device),
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? device->log_prefix_name : "",
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? ": " : "",
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? device->log_prefix_name
: "",
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? ": " : "",
format);
va_start(args, format);
@ -794,7 +777,6 @@ evdev_log_msg(struct evdev_device *device,
log_msg_va(evdev_libinput_context(device), priority, buf, args);
#pragma GCC diagnostic pop
va_end(args);
}
LIBINPUT_ATTRIBUTE_PRINTF(4, 5)
@ -822,8 +804,9 @@ evdev_log_msg_ratelimit(struct evdev_device *device,
sizeof(buf),
"%-7s - %s%s%s",
evdev_device_get_sysname(device),
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? device->log_prefix_name : "",
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? ": " : "",
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? device->log_prefix_name
: "",
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? ": " : "",
format);
va_start(args, format);
@ -842,7 +825,6 @@ evdev_log_msg_ratelimit(struct evdev_device *device,
ratelimit->burst,
ht.value,
ht.unit);
}
}
@ -870,14 +852,13 @@ evdev_log_msg_ratelimit(struct evdev_device *device,
* Convert the pair of delta coordinates in device space to mm.
*/
static inline struct phys_coords
evdev_device_unit_delta_to_mm(const struct evdev_device* device,
evdev_device_unit_delta_to_mm(const struct evdev_device *device,
const struct device_coords *units)
{
struct phys_coords mm = { 0, 0 };
struct phys_coords mm = { 0, 0 };
const struct input_absinfo *absx, *absy;
if (device->abs.absinfo_x == NULL ||
device->abs.absinfo_y == NULL) {
if (device->abs.absinfo_x == NULL || device->abs.absinfo_y == NULL) {
log_bug_libinput(evdev_libinput_context(device),
"%s: is not an abs device\n",
device->devname);
@ -887,8 +868,8 @@ evdev_device_unit_delta_to_mm(const struct evdev_device* device,
absx = device->abs.absinfo_x;
absy = device->abs.absinfo_y;
mm.x = 1.0 * units->x/absx->resolution;
mm.y = 1.0 * units->y/absy->resolution;
mm.x = 1.0 * units->x / absx->resolution;
mm.y = 1.0 * units->y / absy->resolution;
return mm;
}
@ -898,14 +879,13 @@ evdev_device_unit_delta_to_mm(const struct evdev_device* device,
* axis min into account, i.e. a unit of min is equivalent to 0 mm.
*/
static inline struct phys_coords
evdev_device_units_to_mm(const struct evdev_device* device,
evdev_device_units_to_mm(const struct evdev_device *device,
const struct device_coords *units)
{
struct phys_coords mm = { 0, 0 };
struct phys_coords mm = { 0, 0 };
const struct input_absinfo *absx, *absy;
if (device->abs.absinfo_x == NULL ||
device->abs.absinfo_y == NULL) {
if (device->abs.absinfo_x == NULL || device->abs.absinfo_y == NULL) {
log_bug_libinput(evdev_libinput_context(device),
"%s: is not an abs device\n",
device->devname);
@ -915,8 +895,8 @@ evdev_device_units_to_mm(const struct evdev_device* device,
absx = device->abs.absinfo_x;
absy = device->abs.absinfo_y;
mm.x = (units->x - absx->minimum)/absx->resolution;
mm.y = (units->y - absy->minimum)/absy->resolution;
mm.x = (units->x - absx->minimum) / absx->resolution;
mm.y = (units->y - absy->minimum) / absy->resolution;
return mm;
}
@ -929,11 +909,10 @@ static inline struct device_coords
evdev_device_mm_to_units(const struct evdev_device *device,
const struct phys_coords *mm)
{
struct device_coords units = { 0, 0 };
struct device_coords units = { 0, 0 };
const struct input_absinfo *absx, *absy;
if (device->abs.absinfo_x == NULL ||
device->abs.absinfo_y == NULL) {
if (device->abs.absinfo_x == NULL || device->abs.absinfo_y == NULL) {
log_bug_libinput(evdev_libinput_context(device),
"%s: is not an abs device\n",
device->devname);
@ -950,14 +929,12 @@ evdev_device_mm_to_units(const struct evdev_device *device,
}
static inline struct device_coord_rect
evdev_phys_rect_to_units(const struct evdev_device *device,
const struct phys_rect *mm)
evdev_phys_rect_to_units(const struct evdev_device *device, const struct phys_rect *mm)
{
struct device_coord_rect units = {0};
struct device_coord_rect units = { 0 };
const struct input_absinfo *absx, *absy;
if (device->abs.absinfo_x == NULL ||
device->abs.absinfo_y == NULL) {
if (device->abs.absinfo_x == NULL || device->abs.absinfo_y == NULL) {
log_bug_libinput(evdev_libinput_context(device),
"%s: is not an abs device\n",
device->devname);
@ -992,9 +969,7 @@ evdev_device_init_abs_range_warnings(struct evdev_device *device)
device->abs.warning_range.max.y = y->maximum + 0.05 * height;
/* 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, s2us(3000), 1);
}
static inline void
@ -1020,12 +995,16 @@ evdev_device_check_abs_axis_range(struct evdev_device *device,
}
if (value < min || value > max) {
log_info_ratelimit(evdev_libinput_context(device),
&device->abs.warning_range.range_warn_limit,
"Axis %#x value %d is outside expected range [%d, %d]\n"
"See %s/absolute-coordinate-ranges.html for details\n",
evdev_usage_enum(usage), value, min, max,
HTTP_DOC_LINK);
log_info_ratelimit(
evdev_libinput_context(device),
&device->abs.warning_range.range_warn_limit,
"Axis %#x value %d is outside expected range [%d, %d]\n"
"See %s/absolute-coordinate-ranges.html for details\n",
evdev_usage_enum(usage),
value,
min,
max,
HTTP_DOC_LINK);
}
}

View file

@ -22,12 +22,12 @@
#include "config.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "filter.h"
#include "filter-private.h"
#include "filter.h"
#define MOTION_TIMEOUT ms2us(1000)
#define FIRST_MOTION_TIME_INTERVAL ms2us(7) /* random but good enough interval for very first event */
@ -55,7 +55,8 @@ create_custom_accel_function(double step, const double *points, size_t npoints)
return NULL;
}
struct custom_accel_function *cf = zalloc(sizeof(*cf) + npoints * sizeof(*points));
struct custom_accel_function *cf =
zalloc(sizeof(*cf) + npoints * sizeof(*points));
cf->last_time = 0;
cf->step = step;
cf->npoints = npoints;
@ -121,8 +122,7 @@ custom_accel_function_calculate_speed(struct custom_accel_function *cf,
}
static double
custom_accel_function_profile(struct custom_accel_function *cf,
double speed_in)
custom_accel_function_profile(struct custom_accel_function *cf, double speed_in)
{
size_t npoints = cf->npoints;
double step = cf->step;
@ -249,9 +249,7 @@ custom_accelerator_filter(enum libinput_config_accel_type accel_type,
}
static void
custom_accelerator_restart(struct motion_filter *filter,
void *data,
uint64_t time)
custom_accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
{
/* noop, this function has no effect in the custom interface */
}
@ -259,8 +257,7 @@ custom_accelerator_restart(struct motion_filter *filter,
static void
custom_accelerator_destroy(struct motion_filter *filter)
{
struct custom_accelerator *f =
(struct custom_accelerator *)filter;
struct custom_accelerator *f = (struct custom_accelerator *)filter;
/* destroy all custom movement functions */
custom_accel_function_destroy(f->funcs.fallback);
@ -270,8 +267,7 @@ custom_accelerator_destroy(struct motion_filter *filter)
}
static bool
custom_accelerator_set_speed(struct motion_filter *filter,
double speed_adjustment)
custom_accelerator_set_speed(struct motion_filter *filter, double speed_adjustment)
{
assert(speed_adjustment >= -1.0 && speed_adjustment <= 1.0);
@ -284,17 +280,15 @@ static bool
custom_accelerator_set_accel_config(struct motion_filter *filter,
struct libinput_config_accel *config)
{
struct custom_accelerator *f =
(struct custom_accelerator *)filter;
struct custom_accelerator *f = (struct custom_accelerator *)filter;
struct custom_accel_function *fallback = NULL,
*motion = NULL,
*scroll = NULL;
struct custom_accel_function *fallback = NULL, *motion = NULL, *scroll = NULL;
if (config->custom.fallback) {
fallback = create_custom_accel_function(config->custom.fallback->step,
config->custom.fallback->points,
config->custom.fallback->npoints);
fallback =
create_custom_accel_function(config->custom.fallback->step,
config->custom.fallback->points,
config->custom.fallback->npoints);
if (!fallback)
goto out;
}
@ -364,9 +358,7 @@ custom_accel_profile_motion(struct motion_filter *filter,
double speed_in,
uint64_t time)
{
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_MOTION,
filter,
speed_in);
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_MOTION, filter, speed_in);
}
static struct normalized_coords
@ -387,9 +379,7 @@ custom_accel_profile_scroll(struct motion_filter *filter,
double speed_in,
uint64_t time)
{
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_SCROLL,
filter,
speed_in);
return custom_accelerator_profile(LIBINPUT_ACCEL_TYPE_SCROLL, filter, speed_in);
}
static struct normalized_coords
@ -423,7 +413,7 @@ create_custom_accelerator_filter(void)
/* the unit function by default, speed in = speed out,
i.e. no acceleration */
const double default_step = 1.0;
const double default_points[2] = {0.0, 1.0};
const double default_points[2] = { 0.0, 1.0 };
/* initialize default acceleration, used as fallback */
f->funcs.fallback = create_custom_accel_function(default_step,

View file

@ -26,13 +26,13 @@
#include "config.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
struct pointer_accelerator_flat {
struct motion_filter base;
@ -44,7 +44,8 @@ struct pointer_accelerator_flat {
static struct normalized_coords
accelerator_filter_flat(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct pointer_accelerator_flat *accel_filter =
(struct pointer_accelerator_flat *)filter;
@ -63,7 +64,8 @@ accelerator_filter_flat(struct motion_filter *filter,
static struct normalized_coords
accelerator_filter_noop_flat(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
/* We map the unaccelerated flat filter to have the same behavior as
* the "accelerated" flat filter.
@ -80,8 +82,7 @@ accelerator_filter_noop_flat(struct motion_filter *filter,
}
static bool
accelerator_set_speed_flat(struct motion_filter *filter,
double speed_adjustment)
accelerator_set_speed_flat(struct motion_filter *filter, double speed_adjustment)
{
struct pointer_accelerator_flat *accel_filter =
(struct pointer_accelerator_flat *)filter;
@ -103,7 +104,7 @@ static void
accelerator_destroy_flat(struct motion_filter *filter)
{
struct pointer_accelerator_flat *accel =
(struct pointer_accelerator_flat *) filter;
(struct pointer_accelerator_flat *)filter;
free(accel);
}

View file

@ -26,13 +26,13 @@
#include "config.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
/*
* Default parameters for pointer acceleration profiles.
@ -48,14 +48,14 @@ struct pointer_accelerator_low_dpi {
accel_profile_func_t profile;
double velocity; /* units/us */
double last_velocity; /* units/us */
double velocity; /* units/us */
double last_velocity; /* units/us */
struct pointer_trackers trackers;
double threshold; /* units/us */
double accel; /* unitless factor */
double incline; /* incline of the function */
double threshold; /* units/us */
double accel; /* unitless factor */
double incline; /* incline of the function */
int dpi;
};
@ -79,10 +79,10 @@ pointer_accel_profile_linear_low_dpi(struct motion_filter *filter,
struct pointer_accelerator_low_dpi *accel_filter =
(struct pointer_accelerator_low_dpi *)filter;
double max_accel = accel_filter->accel; /* unitless factor */
double max_accel = accel_filter->accel; /* unitless factor */
double threshold = accel_filter->threshold; /* units/us */
const double incline = accel_filter->incline;
double dpi_factor = accel_filter->dpi/(double)DEFAULT_MOUSE_DPI;
double dpi_factor = accel_filter->dpi / (double)DEFAULT_MOUSE_DPI;
double factor; /* unitless */
/* dpi_factor is always < 1.0, increase max_accel, reduce
@ -128,16 +128,15 @@ calculate_acceleration_factor(struct pointer_accelerator_low_dpi *accel,
static struct normalized_coords
accelerator_filter_low_dpi(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct pointer_accelerator_low_dpi *accel =
(struct pointer_accelerator_low_dpi *) filter;
(struct pointer_accelerator_low_dpi *)filter;
/* Accelerate for device units and return device units */
double accel_factor = calculate_acceleration_factor(accel,
unaccelerated,
data,
time);
double accel_factor =
calculate_acceleration_factor(accel, unaccelerated, data, time);
const struct normalized_coords normalized = {
.x = accel_factor * unaccelerated->x,
.y = accel_factor * unaccelerated->y,
@ -148,7 +147,8 @@ accelerator_filter_low_dpi(struct motion_filter *filter,
static struct normalized_coords
accelerator_filter_noop(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
const struct normalized_coords normalized = {
.x = unaccelerated->x,
@ -158,12 +158,10 @@ accelerator_filter_noop(struct motion_filter *filter,
}
static void
accelerator_restart(struct motion_filter *filter,
void *data,
uint64_t time)
accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
{
struct pointer_accelerator_low_dpi *accel =
(struct pointer_accelerator_low_dpi *) filter;
(struct pointer_accelerator_low_dpi *)filter;
trackers_reset(&accel->trackers, time);
}
@ -172,15 +170,14 @@ static void
accelerator_destroy(struct motion_filter *filter)
{
struct pointer_accelerator_low_dpi *accel =
(struct pointer_accelerator_low_dpi *) filter;
(struct pointer_accelerator_low_dpi *)filter;
trackers_free(&accel->trackers);
free(accel);
}
static bool
accelerator_set_speed(struct motion_filter *filter,
double speed_adjustment)
accelerator_set_speed(struct motion_filter *filter, double speed_adjustment)
{
struct pointer_accelerator_low_dpi *accel_filter =
(struct pointer_accelerator_low_dpi *)filter;
@ -191,8 +188,7 @@ accelerator_set_speed(struct motion_filter *filter,
don't read more into them other than "they mostly worked ok" */
/* delay when accel kicks in */
accel_filter->threshold = DEFAULT_THRESHOLD -
v_ms2us(0.25) * speed_adjustment;
accel_filter->threshold = DEFAULT_THRESHOLD - v_ms2us(0.25) * speed_adjustment;
if (accel_filter->threshold < MINIMUM_THRESHOLD)
accel_filter->threshold = MINIMUM_THRESHOLD;

View file

@ -26,13 +26,13 @@
#include "config.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
/*
* Default parameters for pointer acceleration profiles.
@ -48,14 +48,14 @@ struct pointer_accelerator {
accel_profile_func_t profile;
double velocity; /* units/us */
double last_velocity; /* units/us */
double velocity; /* units/us */
double last_velocity; /* units/us */
struct pointer_trackers trackers;
double threshold; /* 1000dpi units/us */
double accel; /* unitless factor */
double incline; /* incline of the function */
double threshold; /* 1000dpi units/us */
double accel; /* unitless factor */
double incline; /* incline of the function */
int dpi;
};
@ -88,12 +88,13 @@ calculate_acceleration_factor(struct pointer_accelerator *accel,
trackers_feed(&accel->trackers, &unaccel, time);
velocity = trackers_velocity(&accel->trackers, time);
/* This will call into our pointer_accel_profile_linear() profile func */
accel_factor = calculate_acceleration_simpsons(&accel->base,
accel->profile,
data,
velocity, /* normalized coords */
accel->last_velocity, /* normalized coords */
time);
accel_factor = calculate_acceleration_simpsons(
&accel->base,
accel->profile,
data,
velocity, /* normalized coords */
accel->last_velocity, /* normalized coords */
time);
accel->last_velocity = velocity;
return accel_factor;
@ -102,18 +103,16 @@ calculate_acceleration_factor(struct pointer_accelerator *accel,
static struct normalized_coords
accelerator_filter_linear(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct pointer_accelerator *accel =
(struct pointer_accelerator *) filter;
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
/* Accelerate for normalized units and return normalized units */
const struct normalized_coords normalized = normalize_for_dpi(unaccelerated,
accel->dpi);
double accel_factor = calculate_acceleration_factor(accel,
&normalized,
data,
time);
const struct normalized_coords normalized =
normalize_for_dpi(unaccelerated, accel->dpi);
double accel_factor =
calculate_acceleration_factor(accel, &normalized, data, time);
struct normalized_coords accelerated = {
.x = normalized.x * accel_factor,
.y = normalized.y * accel_factor,
@ -136,21 +135,18 @@ accelerator_filter_linear(struct motion_filter *filter,
static struct normalized_coords
accelerator_filter_noop(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct pointer_accelerator *accel =
(struct pointer_accelerator *) filter;
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
return normalize_for_dpi(unaccelerated, accel->dpi);
}
static void
accelerator_restart(struct motion_filter *filter,
void *data,
uint64_t time)
accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
{
struct pointer_accelerator *accel =
(struct pointer_accelerator *) filter;
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
trackers_reset(&accel->trackers, time);
}
@ -158,19 +154,16 @@ accelerator_restart(struct motion_filter *filter,
static void
accelerator_destroy(struct motion_filter *filter)
{
struct pointer_accelerator *accel =
(struct pointer_accelerator *) filter;
struct pointer_accelerator *accel = (struct pointer_accelerator *)filter;
trackers_free(&accel->trackers);
free(accel);
}
static bool
accelerator_set_speed(struct motion_filter *filter,
double speed_adjustment)
accelerator_set_speed(struct motion_filter *filter, double speed_adjustment)
{
struct pointer_accelerator *accel_filter =
(struct pointer_accelerator *)filter;
struct pointer_accelerator *accel_filter = (struct pointer_accelerator *)filter;
assert(speed_adjustment >= -1.0 && speed_adjustment <= 1.0);
@ -178,8 +171,7 @@ accelerator_set_speed(struct motion_filter *filter,
don't read more into them other than "they mostly worked ok" */
/* delay when accel kicks in */
accel_filter->threshold = DEFAULT_THRESHOLD -
v_ms2us(0.25) * speed_adjustment;
accel_filter->threshold = DEFAULT_THRESHOLD - v_ms2us(0.25) * speed_adjustment;
if (accel_filter->threshold < MINIMUM_THRESHOLD)
accel_filter->threshold = MINIMUM_THRESHOLD;
@ -199,9 +191,8 @@ pointer_accel_profile_linear(struct motion_filter *filter,
double speed_in, /* in normalized units */
uint64_t time)
{
struct pointer_accelerator *accel_filter =
(struct pointer_accelerator *)filter;
const double max_accel = accel_filter->accel; /* unitless factor */
struct pointer_accelerator *accel_filter = (struct pointer_accelerator *)filter;
const double max_accel = accel_filter->accel; /* unitless factor */
const double threshold = accel_filter->threshold; /* 1000dpi units/us */
const double incline = accel_filter->incline;
double factor; /* unitless */
@ -223,7 +214,7 @@ pointer_accel_profile_linear(struct motion_filter *filter,
The two inclines are linear functions in the form
y = ax + b
where y is speed_out
x is speed_in
x is speed_in
a is the incline of acceleration
b is minimum acceleration factor
@ -242,21 +233,21 @@ pointer_accel_profile_linear(struct motion_filter *filter,
*/
if (v_us2ms(speed_in) < 0.07) {
factor = 10 * v_us2ms(speed_in) + 0.3;
/* up to the threshold, we keep factor 1, i.e. 1:1 movement */
/* up to the threshold, we keep factor 1, i.e. 1:1 movement */
} else if (speed_in < threshold) {
factor = 1;
} else {
/* Acceleration function above the threshold:
y = ax' + b
where T is threshold
x is speed_in
x' is speed
and
y(T) == 1
hence 1 = ax' + 1
=> x' := (x - T)
*/
/* Acceleration function above the threshold:
y = ax' + b
where T is threshold
x is speed_in
x' is speed
and
y(T) == 1
hence 1 = ax' + 1
=> x' := (x - T)
*/
factor = incline * v_us2ms(speed_in - threshold) + 1;
}

View file

@ -31,23 +31,23 @@
struct motion_filter_interface {
enum libinput_config_accel_profile type;
struct normalized_coords (*filter)(
struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time);
struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data,
uint64_t time);
struct normalized_coords (*filter_constant)(
struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time);
struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data,
uint64_t time);
struct normalized_coords (*filter_scroll)(
struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time);
void (*restart)(struct motion_filter *filter,
void *data,
uint64_t time);
struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data,
uint64_t time);
void (*restart)(struct motion_filter *filter, void *data, uint64_t time);
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,
struct libinput_config_accel *accel_config);
};
@ -59,7 +59,7 @@ struct motion_filter {
struct pointer_tracker {
struct device_float_coords delta; /* delta to most recent event */
uint64_t time; /* us */
uint64_t time; /* us */
uint32_t dir;
};
@ -93,12 +93,13 @@ struct pointer_trackers {
struct pointer_delta_smoothener *smoothener;
};
void trackers_init(struct pointer_trackers *trackers, int ntrackers);
void trackers_free(struct pointer_trackers *trackers);
void
trackers_init(struct pointer_trackers *trackers, int ntrackers);
void
trackers_free(struct pointer_trackers *trackers);
void
trackers_reset(struct pointer_trackers *trackers,
uint64_t time);
trackers_reset(struct pointer_trackers *trackers, uint64_t time);
void
trackers_feed(struct pointer_trackers *trackers,
const struct device_float_coords *delta,
@ -135,7 +136,7 @@ v_us2s(double units_per_us)
static inline double
v_ms2us(double units_per_ms)
{
return units_per_ms/1000.0;
return units_per_ms / 1000.0;
}
static inline struct normalized_coords
@ -143,8 +144,8 @@ normalize_for_dpi(const struct device_float_coords *coords, int dpi)
{
struct normalized_coords norm;
norm.x = coords->x * DEFAULT_MOUSE_DPI/dpi;
norm.y = coords->y * DEFAULT_MOUSE_DPI/dpi;
norm.x = coords->x * DEFAULT_MOUSE_DPI / dpi;
norm.y = coords->y * DEFAULT_MOUSE_DPI / dpi;
return norm;
}

View file

@ -26,21 +26,21 @@
#include "config.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
struct tablet_accelerator_flat {
struct motion_filter base;
double factor;
int xres, yres;
double xres_scale, /* 1000dpi : tablet res */
yres_scale; /* 1000dpi : tablet res */
double xres_scale, /* 1000dpi : tablet res */
yres_scale; /* 1000dpi : tablet res */
};
static inline struct normalized_coords
@ -81,25 +81,26 @@ tablet_accelerator_filter_flat_pen(struct tablet_accelerator_flat *filter,
* is almost identical to the tablet mapped to screen in absolute
* mode. Tested on a Intuos5, other tablets may vary.
*/
const double DPI_CONVERSION = 96.0/25.4 * 2.5; /* unitless factor */
struct normalized_coords mm;
const double DPI_CONVERSION = 96.0 / 25.4 * 2.5; /* unitless factor */
struct normalized_coords mm;
mm.x = 1.0 * units->x/filter->xres;
mm.y = 1.0 * units->y/filter->yres;
accelerated.x = mm.x * filter->factor * DPI_CONVERSION;
accelerated.y = mm.y * filter->factor * DPI_CONVERSION;
mm.x = 1.0 * units->x / filter->xres;
mm.y = 1.0 * units->y / filter->yres;
accelerated.x = mm.x * filter->factor * DPI_CONVERSION;
accelerated.y = mm.y * filter->factor * DPI_CONVERSION;
return accelerated;
return accelerated;
}
static struct normalized_coords
tablet_accelerator_filter_flat(struct motion_filter *filter,
const struct device_float_coords *units,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct tablet_accelerator_flat *accel_filter =
(struct tablet_accelerator_flat *)filter;
struct libinput_tablet_tool *tool = (struct libinput_tablet_tool*)data;
struct libinput_tablet_tool *tool = (struct libinput_tablet_tool *)data;
enum libinput_tablet_tool_type type;
struct normalized_coords accel;
@ -108,12 +109,10 @@ tablet_accelerator_filter_flat(struct motion_filter *filter,
switch (type) {
case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
case LIBINPUT_TABLET_TOOL_TYPE_LENS:
accel = tablet_accelerator_filter_flat_mouse(accel_filter,
units);
accel = tablet_accelerator_filter_flat_mouse(accel_filter, units);
break;
default:
accel = tablet_accelerator_filter_flat_pen(accel_filter,
units);
accel = tablet_accelerator_filter_flat_pen(accel_filter, units);
break;
}
@ -121,8 +120,7 @@ tablet_accelerator_filter_flat(struct motion_filter *filter,
}
static bool
tablet_accelerator_set_speed(struct motion_filter *filter,
double speed_adjustment)
tablet_accelerator_set_speed(struct motion_filter *filter, double speed_adjustment)
{
struct tablet_accelerator_flat *accel_filter =
(struct tablet_accelerator_flat *)filter;
@ -162,8 +160,8 @@ create_tablet_filter_flat(int xres, int yres)
filter->factor = 1.0;
filter->xres = xres;
filter->yres = yres;
filter->xres_scale = DEFAULT_MOUSE_DPI/(25.4 * xres);
filter->yres_scale = DEFAULT_MOUSE_DPI/(25.4 * yres);
filter->xres_scale = DEFAULT_MOUSE_DPI / (25.4 * xres);
filter->yres_scale = DEFAULT_MOUSE_DPI / (25.4 * yres);
return filter;
}

View file

@ -26,13 +26,13 @@
#include "config.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
#define TP_MAGIC_SLOWDOWN_FLAT 0.2968
@ -46,7 +46,8 @@ struct touchpad_accelerator_flat {
static struct normalized_coords
accelerator_filter_touchpad_flat(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct touchpad_accelerator_flat *accel =
(struct touchpad_accelerator_flat *)filter;
@ -66,7 +67,8 @@ accelerator_filter_touchpad_flat(struct motion_filter *filter,
static struct normalized_coords
accelerator_filter_noop_touchpad_flat(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
/* We map the unaccelerated flat filter to have the same behavior as
* the "accelerated" flat filter.
@ -101,7 +103,7 @@ static void
accelerator_destroy_touchpad_flat(struct motion_filter *filter)
{
struct touchpad_accelerator_flat *accel =
(struct touchpad_accelerator_flat *) filter;
(struct touchpad_accelerator_flat *)filter;
free(accel);
}

View file

@ -26,12 +26,12 @@
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdlib.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
/* Trackpoint acceleration for the Lenovo x230. DO NOT TOUCH.
* This code is only invoked on the X230 and is quite flimsy,
@ -62,14 +62,14 @@ struct pointer_accelerator_x230 {
accel_profile_func_t profile;
double velocity; /* units/us */
double last_velocity; /* units/us */
double velocity; /* units/us */
double last_velocity; /* units/us */
struct pointer_trackers trackers;
double threshold; /* units/us */
double accel; /* unitless factor */
double incline; /* incline of the function */
double threshold; /* units/us */
double accel; /* unitless factor */
double incline; /* incline of the function */
int dpi;
};
@ -86,7 +86,9 @@ struct pointer_accelerator_x230 {
*/
static double
acceleration_profile(struct pointer_accelerator_x230 *accel,
void *data, double velocity, uint64_t time)
void *data,
double velocity,
uint64_t time)
{
return accel->profile(&accel->base, data, velocity, time);
}
@ -116,10 +118,9 @@ calculate_acceleration(struct pointer_accelerator_x230 *accel,
* the previous motion and the most recent. */
factor = acceleration_profile(accel, data, velocity, time);
factor += acceleration_profile(accel, data, last_velocity, time);
factor += 4.0 *
acceleration_profile(accel, data,
(last_velocity + velocity) / 2,
time);
factor +=
4.0 *
acceleration_profile(accel, data, (last_velocity + velocity) / 2, time);
factor = factor / 6.0;
@ -129,10 +130,11 @@ calculate_acceleration(struct pointer_accelerator_x230 *accel,
static struct normalized_coords
accelerator_filter_x230(struct motion_filter *filter,
const struct device_float_coords *raw,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct pointer_accelerator_x230 *accel =
(struct pointer_accelerator_x230 *) filter;
(struct pointer_accelerator_x230 *)filter;
double accel_factor; /* unitless factor */
struct normalized_coords accelerated;
struct device_float_coords delta_normalized;
@ -168,13 +170,13 @@ accelerator_filter_x230(struct motion_filter *filter,
static struct normalized_coords
accelerator_filter_constant_x230(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct pointer_accelerator_x230 *accel =
(struct pointer_accelerator_x230 *) filter;
(struct pointer_accelerator_x230 *)filter;
struct normalized_coords normalized;
const double factor =
X230_MAGIC_SLOWDOWN/X230_TP_MAGIC_LOW_RES_FACTOR;
const double factor = X230_MAGIC_SLOWDOWN / X230_TP_MAGIC_LOW_RES_FACTOR;
normalized = normalize_for_dpi(unaccelerated, accel->dpi);
normalized.x = factor * normalized.x;
@ -184,12 +186,10 @@ accelerator_filter_constant_x230(struct motion_filter *filter,
}
static void
accelerator_restart_x230(struct motion_filter *filter,
void *data,
uint64_t time)
accelerator_restart_x230(struct motion_filter *filter, void *data, uint64_t time)
{
struct pointer_accelerator_x230 *accel =
(struct pointer_accelerator_x230 *) filter;
(struct pointer_accelerator_x230 *)filter;
unsigned int offset;
struct pointer_tracker *tracker;
@ -210,15 +210,14 @@ static void
accelerator_destroy_x230(struct motion_filter *filter)
{
struct pointer_accelerator_x230 *accel =
(struct pointer_accelerator_x230 *) filter;
(struct pointer_accelerator_x230 *)filter;
free(accel->trackers.trackers);
free(accel);
}
static bool
accelerator_set_speed_x230(struct motion_filter *filter,
double speed_adjustment)
accelerator_set_speed_x230(struct motion_filter *filter, double speed_adjustment)
{
struct pointer_accelerator_x230 *accel_filter =
(struct pointer_accelerator_x230 *)filter;
@ -229,8 +228,7 @@ accelerator_set_speed_x230(struct motion_filter *filter,
don't read more into them other than "they mostly worked ok" */
/* delay when accel kicks in */
accel_filter->threshold = DEFAULT_THRESHOLD -
v_ms2us(0.25) * speed_adjustment;
accel_filter->threshold = DEFAULT_THRESHOLD - v_ms2us(0.25) * speed_adjustment;
if (accel_filter->threshold < MINIMUM_THRESHOLD)
accel_filter->threshold = MINIMUM_THRESHOLD;
@ -246,9 +244,9 @@ accelerator_set_speed_x230(struct motion_filter *filter,
double
touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
void *data,
double speed_in, /* 1000dpi-units/µs */
uint64_t time)
void *data,
double speed_in, /* 1000dpi-units/µs */
uint64_t time)
{
/* Those touchpads presents an actual lower resolution that what is
* advertised. We see some jumps from the cursor due to the big steps
@ -262,9 +260,9 @@ touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
double f1, f2; /* unitless */
const double max_accel = accel_filter->accel *
X230_TP_MAGIC_LOW_RES_FACTOR; /* unitless factor */
const double threshold = accel_filter->threshold /
X230_TP_MAGIC_LOW_RES_FACTOR; /* units/us */
X230_TP_MAGIC_LOW_RES_FACTOR; /* unitless factor */
const double threshold =
accel_filter->threshold / X230_TP_MAGIC_LOW_RES_FACTOR; /* units/us */
const double incline = accel_filter->incline * X230_TP_MAGIC_LOW_RES_FACTOR;
/* Note: the magic values in this function are obtained by
@ -311,7 +309,7 @@ create_pointer_accelerator_filter_lenovo_x230(int dpi, bool use_velocity_averagi
filter->threshold = X230_THRESHOLD;
filter->accel = X230_ACCELERATION; /* unitless factor */
filter->incline = X230_INCLINE; /* incline of the acceleration function */
filter->incline = X230_INCLINE; /* incline of the acceleration function */
filter->dpi = dpi;
return &filter->base;

View file

@ -26,13 +26,13 @@
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
/* Once normalized, touchpads see the same acceleration as mice. that is
* technically correct but subjectively wrong, we expect a touchpad to be a
@ -45,17 +45,17 @@ struct touchpad_accelerator {
accel_profile_func_t profile;
double velocity; /* units/us */
double last_velocity; /* units/us */
double velocity; /* units/us */
double last_velocity; /* units/us */
struct pointer_trackers trackers;
double threshold; /* mm/s */
double accel; /* unitless factor */
double threshold; /* mm/s */
double accel; /* unitless factor */
int dpi;
double speed_factor; /* factor based on speed setting */
double speed_factor; /* factor based on speed setting */
};
/**
@ -93,17 +93,15 @@ calculate_acceleration_factor(struct touchpad_accelerator *accel,
static struct normalized_coords
accelerator_filter_touchpad(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct touchpad_accelerator *accel =
(struct touchpad_accelerator *) filter;
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
/* Accelerate for device units, normalize afterwards */
double accel_factor = calculate_acceleration_factor(accel,
unaccelerated,
data,
time);
const struct device_float_coords accelerated = {
double accel_factor =
calculate_acceleration_factor(accel, unaccelerated, data, time);
const struct device_float_coords accelerated = {
.x = unaccelerated->x * accel_factor,
.y = unaccelerated->y * accel_factor,
};
@ -126,8 +124,7 @@ speed_factor(double s)
}
static bool
touchpad_accelerator_set_speed(struct motion_filter *filter,
double speed_adjustment)
touchpad_accelerator_set_speed(struct motion_filter *filter, double speed_adjustment)
{
struct touchpad_accelerator *accel_filter =
(struct touchpad_accelerator *)filter;
@ -143,10 +140,10 @@ touchpad_accelerator_set_speed(struct motion_filter *filter,
static struct normalized_coords
touchpad_constant_filter(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct touchpad_accelerator *accel =
(struct touchpad_accelerator *)filter;
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
struct normalized_coords normalized;
/* We need to use the same baseline here as the accelerated code,
* otherwise our unaccelerated speed is different to the accelerated
@ -166,12 +163,9 @@ touchpad_constant_filter(struct motion_filter *filter,
}
static void
touchpad_accelerator_restart(struct motion_filter *filter,
void *data,
uint64_t time)
touchpad_accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
{
struct touchpad_accelerator *accel =
(struct touchpad_accelerator *) filter;
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
trackers_reset(&accel->trackers, time);
}
@ -179,8 +173,7 @@ touchpad_accelerator_restart(struct motion_filter *filter,
static void
touchpad_accelerator_destroy(struct motion_filter *filter)
{
struct touchpad_accelerator *accel =
(struct touchpad_accelerator *) filter;
struct touchpad_accelerator *accel = (struct touchpad_accelerator *)filter;
trackers_free(&accel->trackers);
free(accel);
@ -199,7 +192,7 @@ touchpad_accel_profile_linear(struct motion_filter *filter,
double factor; /* unitless */
/* Convert to mm/s because that's something one can understand */
speed_in = v_us2s(speed_in) * 25.4/accel_filter->dpi;
speed_in = v_us2s(speed_in) * 25.4 / accel_filter->dpi;
/*
Our acceleration function calculates a factor to accelerate input
@ -220,7 +213,7 @@ touchpad_accel_profile_linear(struct motion_filter *filter,
The first incline is a linear function in the form
y = ax + b
where y is speed_out
x is speed_in
x is speed_in
a is the incline of acceleration
b is minimum acceleration factor
for speeds up to the lower threshold, we decelerate, down to 30%
@ -248,26 +241,27 @@ touchpad_accel_profile_linear(struct motion_filter *filter,
if (speed_in < 7.0) {
factor = min(baseline, 0.1 * speed_in + 0.3);
/* up to the threshold, we keep factor 1, i.e. 1:1 movement */
/* up to the threshold, we keep factor 1, i.e. 1:1 movement */
} else if (speed_in < threshold) {
factor = baseline;
} else {
/* Acceleration function above the threshold is a curve up
to four times the threshold, because why not.
/* Acceleration function above the threshold is a curve up
to four times the threshold, because why not.
Don't assume anything about the specific numbers though, this was
all just trial and error by tweaking numbers here and there, then
the formula was optimized doing basic maths.
Don't assume anything about the specific numbers though, this was
all just trial and error by tweaking numbers here and there, then
the formula was optimized doing basic maths.
You could replace this with some other random formula that gives
the same numbers and it would be just as correct.
You could replace this with some other random formula that gives
the same numbers and it would be just as correct.
*/
*/
const double upper_threshold = threshold * 4.0;
speed_in = min(speed_in, upper_threshold);
factor = 0.0025 * (speed_in/threshold) * (speed_in - threshold) + baseline;
factor = 0.0025 * (speed_in / threshold) * (speed_in - threshold) +
baseline;
}
factor *= accel_filter->speed_factor;
@ -286,9 +280,9 @@ static const struct motion_filter_interface accelerator_interface_touchpad = {
struct motion_filter *
create_pointer_accelerator_filter_touchpad(int dpi,
uint64_t event_delta_smooth_threshold,
uint64_t event_delta_smooth_value,
bool use_velocity_averaging)
uint64_t event_delta_smooth_threshold,
uint64_t event_delta_smooth_value,
bool use_velocity_averaging)
{
struct touchpad_accelerator *filter;
@ -302,7 +296,9 @@ create_pointer_accelerator_filter_touchpad(int dpi,
filter->base.interface = &accelerator_interface_touchpad;
filter->profile = touchpad_accel_profile_linear;
filter->trackers.smoothener = pointer_delta_smoothener_create(event_delta_smooth_threshold, event_delta_smooth_value);
filter->trackers.smoothener =
pointer_delta_smoothener_create(event_delta_smooth_threshold,
event_delta_smooth_value);
return &filter->base;
}

View file

@ -26,13 +26,13 @@
#include "config.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
struct trackpoint_flat_accelerator {
struct motion_filter base;
@ -44,10 +44,11 @@ struct trackpoint_flat_accelerator {
static struct normalized_coords
trackpoint_flat_filter(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct trackpoint_flat_accelerator *accel_filter =
(struct trackpoint_flat_accelerator *) filter;
(struct trackpoint_flat_accelerator *)filter;
struct normalized_coords accelerated;
double factor = accel_filter->speed_factor;
@ -61,7 +62,8 @@ trackpoint_flat_filter(struct motion_filter *filter,
static struct normalized_coords
trackpoint_flat_filter_noop(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
/* We map the unaccelerated flat filter to have the same behavior as
* the "accelerated" flat filter.
@ -97,16 +99,14 @@ static inline double
speed_factor(double s)
{
s += 1; /* map to [0, 2] */
return 435837.2 + (0.04762636 - 435837.2)/(1 + pow(s/240.4549,
2.377168));
return 435837.2 + (0.04762636 - 435837.2) / (1 + pow(s / 240.4549, 2.377168));
}
static bool
trackpoint_flat_set_speed(struct motion_filter *filter,
double speed_adjustment)
trackpoint_flat_set_speed(struct motion_filter *filter, double speed_adjustment)
{
struct trackpoint_flat_accelerator *accel_filter =
(struct trackpoint_flat_accelerator *) filter;
(struct trackpoint_flat_accelerator *)filter;
assert(speed_adjustment >= -1.0 && speed_adjustment <= 1.0);
@ -120,7 +120,7 @@ static void
trackpoint_flat_destroy(struct motion_filter *filter)
{
struct trackpoint_flat_accelerator *accel_filter =
(struct trackpoint_flat_accelerator *) filter;
(struct trackpoint_flat_accelerator *)filter;
free(accel_filter);
}

View file

@ -26,14 +26,14 @@
#include "config.h"
#include <assert.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
struct trackpoint_accelerator {
struct motion_filter base;
@ -64,7 +64,7 @@ trackpoint_accel_profile(struct motion_filter *filter,
* 0.4 3
* 0.6 4
*/
factor = 10.06254 + (0.3 - 10.06254)/(1 + pow(velocity/0.9205459, 1.15363));
factor = 10.06254 + (0.3 - 10.06254) / (1 + pow(velocity / 0.9205459, 1.15363));
factor *= accel_filter->speed_factor;
return factor;
@ -73,7 +73,8 @@ trackpoint_accel_profile(struct motion_filter *filter,
static struct normalized_coords
trackpoint_accelerator_filter(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct trackpoint_accelerator *accel_filter =
(struct trackpoint_accelerator *)filter;
@ -98,7 +99,8 @@ trackpoint_accelerator_filter(struct motion_filter *filter,
static struct normalized_coords
trackpoint_accelerator_filter_noop(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
struct trackpoint_accelerator *accel_filter =
(struct trackpoint_accelerator *)filter;
@ -130,16 +132,14 @@ static inline double
speed_factor(double s)
{
s += 1; /* map to [0, 2] */
return 435837.2 + (0.04762636 - 435837.2)/(1 + pow(s/240.4549,
2.377168));
return 435837.2 + (0.04762636 - 435837.2) / (1 + pow(s / 240.4549, 2.377168));
}
static bool
trackpoint_accelerator_set_speed(struct motion_filter *filter,
double speed_adjustment)
trackpoint_accelerator_set_speed(struct motion_filter *filter, double speed_adjustment)
{
struct trackpoint_accelerator *accel_filter =
(struct trackpoint_accelerator*)filter;
(struct trackpoint_accelerator *)filter;
assert(speed_adjustment >= -1.0 && speed_adjustment <= 1.0);
@ -150,12 +150,9 @@ trackpoint_accelerator_set_speed(struct motion_filter *filter,
}
static void
trackpoint_accelerator_restart(struct motion_filter *filter,
void *data,
uint64_t time)
trackpoint_accelerator_restart(struct motion_filter *filter, void *data, uint64_t time)
{
struct trackpoint_accelerator *accel =
(struct trackpoint_accelerator *) filter;
struct trackpoint_accelerator *accel = (struct trackpoint_accelerator *)filter;
trackers_reset(&accel->trackers, time);
}
@ -181,7 +178,8 @@ static const struct motion_filter_interface accelerator_interface_trackpoint = {
};
struct motion_filter *
create_pointer_accelerator_filter_trackpoint(double multiplier, bool use_velocity_averaging)
create_pointer_accelerator_filter_trackpoint(double multiplier,
bool use_velocity_averaging)
{
struct trackpoint_accelerator *filter;
@ -208,7 +206,8 @@ create_pointer_accelerator_filter_trackpoint(double multiplier, bool use_velocit
trackers_init(&filter->trackers, use_velocity_averaging ? 16 : 2);
filter->base.interface = &accelerator_interface_trackpoint;
filter->trackers.smoothener = pointer_delta_smoothener_create(ms2us(10), ms2us(10));
filter->trackers.smoothener =
pointer_delta_smoothener_create(ms2us(10), ms2us(10));
return &filter->base;
}

View file

@ -26,21 +26,22 @@
#include "config.h"
#include <assert.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include "filter-private.h"
#include "filter.h"
#include "libinput-util.h"
#include "filter-private.h"
#define MOTION_TIMEOUT ms2us(1000)
struct normalized_coords
filter_dispatch(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
return filter->interface->filter(filter, unaccelerated, data, time);
}
@ -48,7 +49,8 @@ filter_dispatch(struct motion_filter *filter,
struct normalized_coords
filter_dispatch_constant(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
return filter->interface->filter_constant(filter, unaccelerated, data, time);
}
@ -56,14 +58,14 @@ filter_dispatch_constant(struct motion_filter *filter,
struct normalized_coords
filter_dispatch_scroll(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time)
void *data,
uint64_t time)
{
return filter->interface->filter_scroll(filter, unaccelerated, data, time);
}
void
filter_restart(struct motion_filter *filter,
void *data, uint64_t time)
filter_restart(struct motion_filter *filter, void *data, uint64_t time)
{
if (filter->interface->restart)
filter->interface->restart(filter, data, time);
@ -79,8 +81,7 @@ filter_destroy(struct motion_filter *filter)
}
bool
filter_set_speed(struct motion_filter *filter,
double speed_adjustment)
filter_set_speed(struct motion_filter *filter, double speed_adjustment)
{
return filter->interface->set_speed(filter, speed_adjustment);
}
@ -112,8 +113,7 @@ filter_set_accel_config(struct motion_filter *filter,
void
trackers_init(struct pointer_trackers *trackers, int ntrackers)
{
trackers->trackers = zalloc(ntrackers *
sizeof(*trackers->trackers));
trackers->trackers = zalloc(ntrackers * sizeof(*trackers->trackers));
trackers->ntrackers = ntrackers;
trackers->cur_tracker = 0;
trackers->smoothener = NULL;
@ -127,8 +127,7 @@ trackers_free(struct pointer_trackers *trackers)
}
void
trackers_reset(struct pointer_trackers *trackers,
uint64_t time)
trackers_reset(struct pointer_trackers *trackers, uint64_t time)
{
unsigned int offset;
struct pointer_tracker *tracker;
@ -173,9 +172,8 @@ trackers_feed(struct pointer_trackers *trackers,
struct pointer_tracker *
trackers_by_offset(struct pointer_trackers *trackers, unsigned int offset)
{
unsigned int index =
(trackers->cur_tracker + trackers->ntrackers - offset)
% trackers->ntrackers;
unsigned int index = (trackers->cur_tracker + trackers->ntrackers - offset) %
trackers->ntrackers;
return &trackers->trackers[index];
}
@ -232,7 +230,8 @@ trackers_velocity(struct pointer_trackers *trackers, uint64_t time)
/* Find least recent vector within a timelimit, maximum velocity diff
* and direction threshold. */
for (unsigned int offset = 1; offset < trackers->ntrackers; offset++) {
const struct pointer_tracker *tracker = trackers_by_offset(trackers, offset);
const struct pointer_tracker *tracker =
trackers_by_offset(trackers, offset);
/* Bug: time running backwards */
if (tracker->time > time)
@ -242,8 +241,8 @@ trackers_velocity(struct pointer_trackers *trackers, uint64_t time)
if (time - tracker->time > MOTION_TIMEOUT) {
if (offset == 1)
result = trackers_velocity_after_timeout(
tracker,
trackers->smoothener);
tracker,
trackers->smoothener);
break;
}
@ -306,9 +305,7 @@ calculate_acceleration_simpsons(struct motion_filter *filter,
* the previous motion and the most recent. */
factor = profile(filter, data, velocity, time);
factor += profile(filter, data, last_velocity, time);
factor += 4.0 * profile(filter, data,
(last_velocity + velocity) / 2,
time);
factor += 4.0 * profile(filter, data, (last_velocity + velocity) / 2, time);
factor = factor / 6.0;

View file

@ -59,7 +59,8 @@ struct motion_filter;
struct normalized_coords
filter_dispatch(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time);
void *data,
uint64_t time);
/**
* Apply constant motion filters, but no acceleration.
@ -80,7 +81,8 @@ filter_dispatch(struct motion_filter *filter,
struct normalized_coords
filter_dispatch_constant(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time);
void *data,
uint64_t time);
/**
* Apply a scroll filter.
@ -102,18 +104,17 @@ filter_dispatch_constant(struct motion_filter *filter,
struct normalized_coords
filter_dispatch_scroll(struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time);
void *data,
uint64_t time);
void
filter_restart(struct motion_filter *filter,
void *data, uint64_t time);
filter_restart(struct motion_filter *filter, void *data, uint64_t time);
void
filter_destroy(struct motion_filter *filter);
bool
filter_set_speed(struct motion_filter *filter,
double speed);
filter_set_speed(struct motion_filter *filter, double speed);
double
filter_get_speed(struct motion_filter *filter);
@ -127,7 +128,7 @@ typedef double (*accel_profile_func_t)(struct motion_filter *filter,
bool
filter_set_accel_config(struct motion_filter *filter,
struct libinput_config_accel *accel_config);
struct libinput_config_accel *accel_config);
/* Pointer acceleration types */
struct motion_filter *
@ -141,9 +142,9 @@ create_pointer_accelerator_filter_linear_low_dpi(int dpi, bool use_velocity_aver
struct motion_filter *
create_pointer_accelerator_filter_touchpad(int dpi,
uint64_t event_delta_smooth_threshold,
uint64_t event_delta_smooth_value,
bool use_velocity_averaging);
uint64_t event_delta_smooth_threshold,
uint64_t event_delta_smooth_value,
bool use_velocity_averaging);
struct motion_filter *
create_pointer_accelerator_filter_touchpad_flat(int dpi);
@ -152,7 +153,8 @@ struct motion_filter *
create_pointer_accelerator_filter_lenovo_x230(int dpi, bool use_velocity_averaging);
struct motion_filter *
create_pointer_accelerator_filter_trackpoint(double multiplier, bool use_velocity_averaging);
create_pointer_accelerator_filter_trackpoint(double multiplier,
bool use_velocity_averaging);
struct motion_filter *
create_pointer_accelerator_filter_trackpoint_flat(double multiplier);
@ -184,9 +186,9 @@ touchpad_accel_profile_linear(struct motion_filter *filter,
uint64_t time);
double
touchpad_lenovo_x230_accel_profile(struct motion_filter *filter,
void *data,
double speed_in,
uint64_t time);
void *data,
double speed_in,
uint64_t time);
double
trackpoint_accel_profile(struct motion_filter *filter,
void *data,

View file

@ -29,6 +29,7 @@
#include <stdbool.h>
#include "util-ratelimit.h"
#include "libinput.h"
#define log_debug(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__)
@ -46,25 +47,23 @@
#define log_bug_client_ratelimit(li_, r_, ...) log_msg_ratelimit((li_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__)
bool
log_is_logged(const struct libinput *libinput,
enum libinput_log_priority priority);
log_is_logged(const struct libinput *libinput, enum libinput_log_priority priority);
void
log_msg_ratelimit(struct libinput *libinput,
struct ratelimit *ratelimit,
enum libinput_log_priority priority,
const char *format, ...)
LIBINPUT_ATTRIBUTE_PRINTF(4, 5);
const char *format,
...) LIBINPUT_ATTRIBUTE_PRINTF(4, 5);
void
log_msg(struct libinput *libinput,
enum libinput_log_priority priority,
const char *format, ...)
LIBINPUT_ATTRIBUTE_PRINTF(3, 4);
const char *format,
...) LIBINPUT_ATTRIBUTE_PRINTF(3, 4);
void
log_msg_va(struct libinput *libinput,
enum libinput_log_priority priority,
const char *format,
va_list args)
LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
va_list args) LIBINPUT_ATTRIBUTE_PRINTF(3, 0);

View file

@ -30,13 +30,12 @@
#include "util-strings.h"
#include "evdev-frame.h"
#include "timer.h"
#include "quirks.h"
#include "libinput-log.h"
#include "libinput-util.h"
#include "libinput-plugin.h"
#include "libinput-plugin-button-debounce.h"
#include "libinput-plugin.h"
#include "libinput-util.h"
#include "quirks.h"
#include "timer.h"
/* Debounce cases to handle
P ... button press
@ -55,9 +54,9 @@
5) P--R-P-| R P normal, R filtered, P filtered, R normal
6) R--P-R-| P R normal, P filtered, R filtered, P normal
7) P--R--|
---P-| P normal, R filtered, P filtered
---P-| P normal, R filtered, P filtered
8) R--P--|
---R-| R normal, P filtered, R filtered
---R-| R normal, P filtered, R filtered
1, 2 are the normal click cases without debouncing taking effect
3, 4 are fast clicks where the second event is delivered with a delay
@ -100,7 +99,7 @@ enum debounce_state {
static inline const char *
debounce_state_to_str(enum debounce_state state)
{
switch(state) {
switch (state) {
CASE_RETURN_STRING(DEBOUNCE_STATE_IS_UP);
CASE_RETURN_STRING(DEBOUNCE_STATE_IS_DOWN);
CASE_RETURN_STRING(DEBOUNCE_STATE_IS_DOWN_WAITING);
@ -116,10 +115,10 @@ debounce_state_to_str(enum debounce_state state)
return NULL;
}
static inline const char*
static inline const char *
debounce_event_to_str(enum debounce_event event)
{
switch(event) {
switch (event) {
CASE_RETURN_STRING(DEBOUNCE_EVENT_PRESS);
CASE_RETURN_STRING(DEBOUNCE_EVENT_RELEASE);
CASE_RETURN_STRING(DEBOUNCE_EVENT_TIMEOUT);
@ -194,8 +193,7 @@ log_debounce_bug(struct plugin_device *device, enum debounce_event event)
}
static inline void
debounce_set_state(struct plugin_device *device,
enum debounce_state new_state)
debounce_set_state(struct plugin_device *device, enum debounce_state new_state)
{
assert(new_state >= DEBOUNCE_STATE_IS_UP &&
new_state <= DEBOUNCE_STATE_IS_DOWN_DELAYING);
@ -204,18 +202,15 @@ debounce_set_state(struct plugin_device *device,
}
static inline void
debounce_set_timer(struct plugin_device *device,
uint64_t time)
debounce_set_timer(struct plugin_device *device, uint64_t time)
{
const int DEBOUNCE_TIMEOUT_BOUNCE = ms2us(25);
libinput_plugin_timer_set(device->timer,
time + DEBOUNCE_TIMEOUT_BOUNCE);
libinput_plugin_timer_set(device->timer, time + DEBOUNCE_TIMEOUT_BOUNCE);
}
static inline void
debounce_set_timer_short(struct plugin_device *device,
uint64_t time)
debounce_set_timer_short(struct plugin_device *device, uint64_t time)
{
const int DEBOUNCE_TIMEOUT_SPURIOUS = ms2us(12);
@ -270,8 +265,8 @@ debounce_notify_button(struct plugin_device *device,
evdev_frame_set_time(frame, device->button_time);
libinput_plugin_prepend_evdev_frame(device->parent->plugin,
device->device,
frame);
device->device,
frame);
}
static void
@ -285,9 +280,7 @@ debounce_is_up_handle_event(struct plugin_device *device,
device->button_time = time;
debounce_set_timer(device, time);
debounce_set_state(device, DEBOUNCE_STATE_IS_DOWN_WAITING);
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_PRESSED);
debounce_notify_button(device, frame, LIBINPUT_BUTTON_STATE_PRESSED);
break;
case DEBOUNCE_EVENT_RELEASE:
case DEBOUNCE_EVENT_TIMEOUT:
@ -316,9 +309,11 @@ debounce_is_down_handle_event(struct plugin_device *device,
debounce_set_timer(device, time);
debounce_set_timer_short(device, time);
if (device->spurious_enabled) {
debounce_set_state(device, DEBOUNCE_STATE_IS_UP_DELAYING_SPURIOUS);
debounce_set_state(device,
DEBOUNCE_STATE_IS_UP_DELAYING_SPURIOUS);
} else {
debounce_set_state(device, DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS);
debounce_set_state(device,
DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS);
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_RELEASED);
@ -380,9 +375,7 @@ debounce_is_up_delaying_handle_event(struct plugin_device *device,
case DEBOUNCE_EVENT_TIMEOUT:
case DEBOUNCE_EVENT_OTHERBUTTON:
debounce_set_state(device, DEBOUNCE_STATE_IS_UP);
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_RELEASED);
debounce_notify_button(device, frame, LIBINPUT_BUTTON_STATE_RELEASED);
break;
}
}
@ -405,15 +398,11 @@ debounce_is_up_delaying_spurious_handle_event(struct plugin_device *device,
break;
case DEBOUNCE_EVENT_TIMEOUT_SHORT:
debounce_set_state(device, DEBOUNCE_STATE_IS_UP_WAITING);
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_RELEASED);
debounce_notify_button(device, frame, LIBINPUT_BUTTON_STATE_RELEASED);
break;
case DEBOUNCE_EVENT_OTHERBUTTON:
debounce_set_state(device, DEBOUNCE_STATE_IS_UP);
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_RELEASED);
debounce_notify_button(device, frame, LIBINPUT_BUTTON_STATE_RELEASED);
break;
}
}
@ -467,16 +456,12 @@ debounce_is_down_detecting_spurious_handle_event(struct plugin_device *device,
debounce_cancel_timer(device);
debounce_set_state(device, DEBOUNCE_STATE_IS_DOWN);
debounce_enable_spurious(device);
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_PRESSED);
debounce_notify_button(device, frame, LIBINPUT_BUTTON_STATE_PRESSED);
break;
case DEBOUNCE_EVENT_TIMEOUT:
case DEBOUNCE_EVENT_OTHERBUTTON:
debounce_set_state(device, DEBOUNCE_STATE_IS_DOWN);
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_PRESSED);
debounce_notify_button(device, frame, LIBINPUT_BUTTON_STATE_PRESSED);
break;
}
}
@ -526,9 +511,7 @@ debounce_is_down_delaying_handle_event(struct plugin_device *device,
case DEBOUNCE_EVENT_TIMEOUT:
case DEBOUNCE_EVENT_OTHERBUTTON:
debounce_set_state(device, DEBOUNCE_STATE_IS_DOWN);
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_PRESSED);
debounce_notify_button(device, frame, LIBINPUT_BUTTON_STATE_PRESSED);
break;
}
}
@ -542,15 +525,11 @@ debounce_disabled_handle_event(struct plugin_device *device,
switch (event) {
case DEBOUNCE_EVENT_PRESS:
device->button_time = time;
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_PRESSED);
debounce_notify_button(device, frame, LIBINPUT_BUTTON_STATE_PRESSED);
break;
case DEBOUNCE_EVENT_RELEASE:
device->button_time = time;
debounce_notify_button(device,
frame,
LIBINPUT_BUTTON_STATE_RELEASED);
debounce_notify_button(device, frame, LIBINPUT_BUTTON_STATE_RELEASED);
break;
case DEBOUNCE_EVENT_TIMEOUT_SHORT:
case DEBOUNCE_EVENT_TIMEOUT:
@ -574,7 +553,7 @@ debounce_handle_event(struct plugin_device *device,
debounce_cancel_timer_short(device);
}
switch(current) {
switch (current) {
case DEBOUNCE_STATE_IS_UP:
debounce_is_up_handle_event(device, event, frame, time);
break;
@ -588,13 +567,22 @@ debounce_handle_event(struct plugin_device *device,
debounce_is_up_delaying_handle_event(device, event, frame, time);
break;
case DEBOUNCE_STATE_IS_UP_DELAYING_SPURIOUS:
debounce_is_up_delaying_spurious_handle_event(device, event, frame, time);
debounce_is_up_delaying_spurious_handle_event(device,
event,
frame,
time);
break;
case DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS:
debounce_is_up_detecting_spurious_handle_event(device, event, frame, time);
debounce_is_up_detecting_spurious_handle_event(device,
event,
frame,
time);
break;
case DEBOUNCE_STATE_IS_DOWN_DETECTING_SPURIOUS:
debounce_is_down_detecting_spurious_handle_event(device, event, frame, time);
debounce_is_down_detecting_spurious_handle_event(device,
event,
frame,
time);
break;
case DEBOUNCE_STATE_IS_UP_WAITING:
debounce_is_up_waiting_handle_event(device, event, frame, time);
@ -625,14 +613,14 @@ debounce_plugin_handle_frame(struct plugin_device *device,
size_t nevents;
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
/* Strip out all button events from this frame (if any). Then
* append the button events to that stripped frame according
* to our state machine.
*
* We allow for a max of 16 buttons to be appended, if you press more
* than 16 buttons within the same frame good luck to you.
*/
_unref_(evdev_frame) *filtered_frame = evdev_frame_new(nevents + 16);
/* Strip out all button events from this frame (if any). Then
* append the button events to that stripped frame according
* to our state machine.
*
* We allow for a max of 16 buttons to be appended, if you press more
* than 16 buttons within the same frame good luck to you.
*/
_unref_(evdev_frame) *filtered_frame = evdev_frame_new(nevents + 16);
for (size_t i = 0; i < nevents; i++) {
struct evdev_event *e = &events[i];
if (!evdev_usage_is_button(e->usage)) {
@ -646,7 +634,7 @@ debounce_plugin_handle_frame(struct plugin_device *device,
* flush the state machine with otherbutton */
if (!flushed &&
(nchanged > 1 ||
evdev_usage_cmp(e->usage, device->button_usage) != 0)) {
evdev_usage_cmp(e->usage, device->button_usage) != 0)) {
debounce_handle_event(device,
DEBOUNCE_EVENT_OTHERBUTTON,
NULL,
@ -671,20 +659,17 @@ debounce_plugin_handle_frame(struct plugin_device *device,
if (!evdev_usage_is_button(e->usage))
continue;
if (flushed &&
device->state != DEBOUNCE_STATE_DISABLED) {
if (flushed && device->state != DEBOUNCE_STATE_DISABLED) {
debounce_set_state(device,
!is_down ?
DEBOUNCE_STATE_IS_DOWN :
DEBOUNCE_STATE_IS_UP);
!is_down ? DEBOUNCE_STATE_IS_DOWN
: DEBOUNCE_STATE_IS_UP);
flushed = false;
}
device->button_usage = e->usage;
debounce_handle_event(device,
is_down ?
DEBOUNCE_EVENT_PRESS :
DEBOUNCE_EVENT_RELEASE,
is_down ? DEBOUNCE_EVENT_PRESS
: DEBOUNCE_EVENT_RELEASE,
filtered_frame,
time);
@ -706,8 +691,8 @@ debounce_plugin_handle_frame(struct plugin_device *device,
static void
debounce_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
struct libinput_device *device,
struct evdev_frame *frame)
struct libinput_device *device,
struct evdev_frame *frame)
{
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
struct plugin_device *pd;
@ -755,9 +740,7 @@ debounce_plugin_device_added(struct libinput_plugin *libinput_plugin,
_unref_(quirks) *q = libinput_device_get_quirks(device);
bool result = false;
if (q &&
quirks_get_bool(q, QUIRK_MODEL_BOUNCING_KEYS, &result) &&
result) {
if (q && quirks_get_bool(q, QUIRK_MODEL_BOUNCING_KEYS, &result) && result) {
return;
}
@ -769,10 +752,10 @@ debounce_plugin_device_added(struct libinput_plugin *libinput_plugin,
pd->parent = plugin;
pd->state = DEBOUNCE_STATE_IS_UP;
_autofree_ char *timer1_name = strdup_printf("debounce-%s",
libinput_device_get_sysname(device));
_autofree_ char *timer2_name = strdup_printf("debounce-short-%s",
libinput_device_get_sysname(device));
_autofree_ char *timer1_name =
strdup_printf("debounce-%s", libinput_device_get_sysname(device));
_autofree_ char *timer2_name =
strdup_printf("debounce-short-%s", libinput_device_get_sysname(device));
pd->timer = libinput_plugin_timer_new(libinput_plugin,
timer1_name,
debounce_timeout,
@ -787,7 +770,7 @@ debounce_plugin_device_added(struct libinput_plugin *libinput_plugin,
static void
debounce_plugin_device_removed(struct libinput_plugin *libinput_plugin,
struct libinput_device *device)
struct libinput_device *device)
{
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
struct plugin_device *dev;
@ -815,9 +798,7 @@ libinput_debounce_plugin(struct libinput *libinput)
struct plugin_data *plugin = zalloc(sizeof(*plugin));
list_init(&plugin->devices);
_unref_(libinput_plugin) *p = libinput_plugin_new(libinput,
"button-debounce",
&interface,
plugin);
_unref_(libinput_plugin) *p =
libinput_plugin_new(libinput, "button-debounce", &interface, plugin);
plugin->plugin = p;
}

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "libinput.h"
#include "libinput-plugin.h"
#include "libinput.h"
void
libinput_debounce_plugin(struct libinput *libinput);

View file

@ -29,13 +29,12 @@
#include <libevdev/libevdev.h>
#include "evdev.h"
#include "evdev-fallback.h"
#include "evdev.h"
#include "libinput-log.h"
#include "libinput-util.h"
#include "libinput-plugin.h"
#include "libinput-plugin-mouse-wheel.h"
#include "libinput-plugin.h"
#include "libinput-util.h"
#define ACC_V120_THRESHOLD 60
#define WHEEL_SCROLL_TIMEOUT ms2us(500)
@ -83,7 +82,7 @@ struct plugin_data {
static inline const char *
wheel_state_to_str(enum wheel_state state)
{
switch(state) {
switch (state) {
CASE_RETURN_STRING(WHEEL_STATE_NONE);
CASE_RETURN_STRING(WHEEL_STATE_ACCUMULATING_SCROLL);
CASE_RETURN_STRING(WHEEL_STATE_SCROLLING);
@ -91,10 +90,10 @@ wheel_state_to_str(enum wheel_state state)
return NULL;
}
static inline const char*
static inline const char *
wheel_event_to_str(enum wheel_event event)
{
switch(event) {
switch (event) {
CASE_RETURN_STRING(WHEEL_EVENT_SCROLL_ACCUMULATED);
CASE_RETURN_STRING(WHEEL_EVENT_SCROLL);
CASE_RETURN_STRING(WHEEL_EVENT_SCROLL_TIMEOUT);
@ -118,8 +117,7 @@ wheel_set_scroll_timer(struct plugin_device *pd, uint64_t time)
if (!pd->scroll_timer)
return;
libinput_plugin_timer_set(pd->scroll_timer,
time + WHEEL_SCROLL_TIMEOUT);
libinput_plugin_timer_set(pd->scroll_timer, time + WHEEL_SCROLL_TIMEOUT);
}
static inline void
@ -138,10 +136,9 @@ wheel_handle_event_on_state_none(struct plugin_device *pd,
{
switch (event) {
case WHEEL_EVENT_SCROLL:
pd->state =
pd->ignore_small_hi_res_movements ?
WHEEL_STATE_ACCUMULATING_SCROLL :
WHEEL_STATE_SCROLLING;
pd->state = pd->ignore_small_hi_res_movements
? WHEEL_STATE_ACCUMULATING_SCROLL
: WHEEL_STATE_SCROLLING;
break;
case WHEEL_EVENT_SCROLL_DIR_CHANGED:
break;
@ -198,9 +195,7 @@ wheel_handle_event_on_state_scrolling(struct plugin_device *pd,
}
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, uint64_t time)
{
enum wheel_state oldstate = pd->state;
@ -209,9 +204,7 @@ wheel_handle_event(struct plugin_device *pd,
wheel_handle_event_on_state_none(pd, event, time);
break;
case WHEEL_STATE_ACCUMULATING_SCROLL:
wheel_handle_event_on_state_accumulating_scroll(pd,
event,
time);
wheel_handle_event_on_state_accumulating_scroll(pd, event, time);
break;
case WHEEL_STATE_SCROLLING:
wheel_handle_event_on_state_scrolling(pd, event, time);
@ -302,7 +295,6 @@ wheel_handle_state_none(struct plugin_device *pd,
struct evdev_frame *frame,
uint64_t time)
{
}
static void
@ -353,9 +345,7 @@ wheel_handle_direction_change(struct plugin_device *pd,
}
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, uint64_t time)
{
switch (evdev_usage_enum(e->usage)) {
case EVDEV_REL_WHEEL:
@ -384,18 +374,16 @@ wheel_process_relative(struct plugin_device *pd,
}
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, uint64_t time)
{
struct evdev_device *evdev = evdev_device(pd->device);
if (!pd->hi_res_event_received &&
(pd->lo_res.x != 0 || pd->lo_res.y != 0)) {
evdev_log_bug_kernel(evdev,
"device supports high-resolution scroll but only low-resolution events have been received.\n"
"See %s/incorrectly-enabled-hires.html for details\n",
HTTP_DOC_LINK);
if (!pd->hi_res_event_received && (pd->lo_res.x != 0 || pd->lo_res.y != 0)) {
evdev_log_bug_kernel(
evdev,
"device supports high-resolution scroll but only low-resolution events have been received.\n"
"See %s/incorrectly-enabled-hires.html for details\n",
HTTP_DOC_LINK);
pd->hi_res.x = pd->lo_res.x * 120;
pd->hi_res.y = pd->lo_res.y * 120;
}
@ -414,9 +402,7 @@ wheel_handle_state(struct plugin_device *pd,
}
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, uint64_t now, void *data)
{
struct plugin_device *pd = data;
@ -438,10 +424,11 @@ wheel_plugin_device_create(struct libinput_plugin *libinput_plugin,
pd->ignore_small_hi_res_movements = !evdev_device_is_virtual(evdev);
if (pd->ignore_small_hi_res_movements) {
pd->scroll_timer = libinput_plugin_timer_new(libinput_plugin,
libinput_device_get_sysname(device),
wheel_on_scroll_timer_timeout,
pd);
pd->scroll_timer =
libinput_plugin_timer_new(libinput_plugin,
libinput_device_get_sysname(device),
wheel_on_scroll_timer_timeout,
pd);
}
return pd;
@ -485,8 +472,8 @@ wheel_plugin_device_added(struct libinput_plugin *libinput_plugin,
libinput_plugin_enable_device_event_frame(libinput_plugin, device, true);
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
struct plugin_device *pd = wheel_plugin_device_create(libinput_plugin,
plugin, device);
struct plugin_device *pd =
wheel_plugin_device_create(libinput_plugin, plugin, device);
list_take_append(&plugin->devices, pd, link);
}
@ -506,9 +493,7 @@ wheel_plugin_device_removed(struct libinput_plugin *libinput_plugin,
}
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, uint64_t time)
{
size_t nevents;
struct evdev_event *events = evdev_frame_get_events(frame, &nevents);
@ -561,9 +546,7 @@ libinput_mouse_plugin_wheel(struct libinput *libinput)
struct plugin_data *plugin = zalloc(sizeof(*plugin));
list_init(&plugin->devices);
_unref_(libinput_plugin) *p = libinput_plugin_new(libinput,
"mouse-wheel",
&interface,
plugin);
_unref_(libinput_plugin) *p =
libinput_plugin_new(libinput, "mouse-wheel", &interface, plugin);
plugin->plugin = p;
}

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "libinput.h"
#include "libinput-plugin.h"
#include "libinput.h"
void
libinput_mouse_plugin_wheel(struct libinput *libinput);

View file

@ -25,13 +25,13 @@
#include "config.h"
#include <stdbool.h>
#include <libudev.h>
#include <libevdev/libevdev.h>
#include <libudev.h>
#include <stdbool.h>
#include "evdev-frame.h"
#include "util-list.h"
#include "evdev-frame.h"
#include "libinput.h"
struct libinput;
@ -63,7 +63,7 @@ libinput_plugin_system_run(struct libinput_plugin_system *system);
void
libinput_plugin_system_register_plugin(struct libinput_plugin_system *system,
struct libinput_plugin *plugin);
struct libinput_plugin *plugin);
void
libinput_plugin_system_unregister_plugin(struct libinput_plugin_system *system,
struct libinput_plugin *plugin);
@ -87,8 +87,9 @@ libinput_plugin_system_notify_device_ignored(struct libinput_plugin_system *syst
struct libinput_device *device);
void
libinput_plugin_system_notify_tablet_tool_configured(struct libinput_plugin_system *system,
struct libinput_tablet_tool *tool);
libinput_plugin_system_notify_tablet_tool_configured(
struct libinput_plugin_system *system,
struct libinput_tablet_tool *tool);
void
libinput_plugin_system_notify_evdev_frame(struct libinput_plugin_system *system,

View file

@ -30,11 +30,10 @@
#include "util-strings.h"
#include "evdev-frame.h"
#include "libinput-log.h"
#include "libinput-util.h"
#include "libinput-plugin.h"
#include "libinput-plugin-tablet-double-tool.h"
#include "libinput-plugin.h"
#include "libinput-util.h"
enum {
TOOL_PEN_DOWN,
@ -45,11 +44,11 @@ enum {
};
enum tool_filter {
SKIP_PEN = bit(1),
SKIP_ERASER = bit(2),
PEN_IN_PROX = bit(3),
PEN_OUT_OF_PROX = bit(4),
ERASER_IN_PROX = bit(5),
SKIP_PEN = bit(1),
SKIP_ERASER = bit(2),
PEN_IN_PROX = bit(3),
PEN_OUT_OF_PROX = bit(4),
ERASER_IN_PROX = bit(5),
ERASER_OUT_OF_PROX = bit(6),
};
@ -122,14 +121,14 @@ double_tool_plugin_filter_frame(struct libinput_plugin *plugin,
}
}
if (filter & (PEN_IN_PROX|PEN_OUT_OF_PROX)) {
if (filter & (PEN_IN_PROX | PEN_OUT_OF_PROX)) {
struct evdev_event event = {
.usage = evdev_usage_from(EVDEV_BTN_TOOL_PEN),
.value = (filter & PEN_IN_PROX) ? 1 : 0,
};
evdev_frame_append(frame_out, &event, 1);
}
if (filter & (ERASER_IN_PROX|ERASER_OUT_OF_PROX)) {
if (filter & (ERASER_IN_PROX | ERASER_OUT_OF_PROX)) {
struct evdev_event event = {
.usage = evdev_usage_from(EVDEV_BTN_TOOL_RUBBER),
.value = (filter & ERASER_IN_PROX) ? 1 : 0,
@ -187,10 +186,14 @@ double_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
#if EVENT_DEBUGGING
plugin_log_debug(libinput_plugin,
"device %s: tool state: pen:%s eraser:%s\n",
libinput_device_get_name(device->device),
pen_toggled ? (pen_is_down ? "" : "") : pen_is_down ? "|" : ".",
eraser_toggled ? (eraser_is_down ? "" : "") : eraser_is_down ? "|" : ".");
"device %s: tool state: pen:%s eraser:%s\n",
libinput_device_get_name(device->device),
pen_toggled ? (pen_is_down ? "" : "")
: pen_is_down ? "|"
: ".",
eraser_toggled ? (eraser_is_down ? "" : "")
: eraser_is_down ? "|"
: ".");
#endif
if (!bitmask_bit_is_set(device->tools_seen, TOOL_DOUBLE_TOOL)) {
@ -214,9 +217,10 @@ double_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
* a doubled-up tool, assume the device is sane and
* unregister this device */
if (bitmask_all(device->tools_seen, tool_mask)) {
plugin_log_debug(libinput_plugin,
"device %s: device is fine, unregistering device\n",
libinput_device_get_name(device->device));
plugin_log_debug(
libinput_plugin,
"device %s: device is fine, unregistering device\n",
libinput_device_get_name(device->device));
plugin_device_destroy(device);
return;
}
@ -227,9 +231,10 @@ double_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
if (eraser_is_down && pen_is_down) {
if (!pen_toggled) {
_unref_(evdev_frame) *pen_out_of_prox =
double_tool_plugin_filter_frame(libinput_plugin,
frame,
SKIP_ERASER|PEN_OUT_OF_PROX);
double_tool_plugin_filter_frame(
libinput_plugin,
frame,
SKIP_ERASER | PEN_OUT_OF_PROX);
libinput_plugin_prepend_evdev_frame(libinput_plugin,
device->device,
pen_out_of_prox);
@ -238,7 +243,8 @@ double_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
_unref_(evdev_frame) *eraser_in_prox =
double_tool_plugin_filter_frame(libinput_plugin,
frame,
SKIP_PEN|ERASER_IN_PROX);
SKIP_PEN |
ERASER_IN_PROX);
libinput_plugin_prepend_evdev_frame(libinput_plugin,
device->device,
@ -253,21 +259,23 @@ double_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
return;
} else if (!eraser_is_down) {
_unref_(evdev_frame) *eraser_out_of_prox =
double_tool_plugin_filter_frame(libinput_plugin,
frame,
SKIP_PEN|ERASER_OUT_OF_PROX);
double_tool_plugin_filter_frame(
libinput_plugin,
frame,
SKIP_PEN | ERASER_OUT_OF_PROX);
libinput_plugin_prepend_evdev_frame(libinput_plugin,
device->device,
eraser_out_of_prox);
/* Only revert back to the pen if the pen was actually toggled in this frame,
* otherwise it's just still set from before */
/* Only revert back to the pen if the pen was actually toggled
* in this frame, otherwise it's just still set from before */
if (pen_toggled && pen_is_down) {
_unref_(evdev_frame) *pen_in_prox =
double_tool_plugin_filter_frame(libinput_plugin,
frame,
SKIP_ERASER|PEN_IN_PROX);
double_tool_plugin_filter_frame(
libinput_plugin,
frame,
SKIP_ERASER | PEN_IN_PROX);
libinput_plugin_prepend_evdev_frame(libinput_plugin,
device->device,
pen_in_prox);
@ -289,7 +297,9 @@ double_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
if (device->ignore_pen) {
_unref_(evdev_frame) *frame_out =
double_tool_plugin_filter_frame(libinput_plugin, frame, SKIP_PEN);
double_tool_plugin_filter_frame(libinput_plugin,
frame,
SKIP_PEN);
size_t out_nevents;
evdev_frame_set(frame,
evdev_frame_get_events(frame_out, &out_nevents),
@ -297,7 +307,9 @@ double_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
bitmask_set_bit(&device->tools_seen, TOOL_DOUBLE_TOOL);
} else if (pen_is_down) {
_unref_(evdev_frame) *frame_out =
double_tool_plugin_filter_frame(libinput_plugin, frame, PEN_IN_PROX);
double_tool_plugin_filter_frame(libinput_plugin,
frame,
PEN_IN_PROX);
size_t out_nevents;
evdev_frame_set(frame,
evdev_frame_get_events(frame_out, &out_nevents),
@ -315,7 +327,9 @@ double_tool_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
list_for_each(pd, &plugin->devices, link) {
if (pd->device == device) {
double_tool_plugin_device_handle_frame(libinput_plugin, pd, frame);
double_tool_plugin_device_handle_frame(libinput_plugin,
pd,
frame);
break;
}
}

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "libinput.h"
#include "libinput-plugin.h"
#include "libinput.h"
void
libinput_tablet_plugin_double_tool(struct libinput *libinput);

View file

@ -30,11 +30,10 @@
#include "util-strings.h"
#include "evdev-frame.h"
#include "libinput-log.h"
#include "libinput-util.h"
#include "libinput-plugin.h"
#include "libinput-plugin-tablet-eraser-button.h"
#include "libinput-plugin.h"
#include "libinput-util.h"
static int ERASER_BUTTON_DELAY = 30 * 1000; /* µs */
@ -61,7 +60,7 @@ enum eraser_button_event {
static const char *
eraser_button_state_str(enum eraser_button_state state)
{
switch(state) {
switch (state) {
CASE_RETURN_STRING(ERASER_BUTTON_NEUTRAL);
CASE_RETURN_STRING(ERASER_BUTTON_PEN_PENDING_ERASER);
CASE_RETURN_STRING(ERASER_BUTTON_BUTTON_HELD_DOWN);
@ -73,7 +72,7 @@ eraser_button_state_str(enum eraser_button_state state)
static const char *
eraser_button_event_str(enum eraser_button_event event)
{
switch(event) {
switch (event) {
CASE_RETURN_STRING(ERASER_EVENT_PEN_ENTERING_PROX);
CASE_RETURN_STRING(ERASER_EVENT_PEN_LEAVING_PROX);
CASE_RETURN_STRING(ERASER_EVENT_ERASER_ENTERING_PROX);
@ -98,7 +97,6 @@ struct plugin_device {
evdev_usage_t button;
struct libinput_plugin_timer *timer;
enum eraser_button_state state;
};
struct plugin_data {
@ -140,8 +138,7 @@ plugin_destroy(struct libinput_plugin *libinput_plugin)
}
static void
eraser_button_set_state(struct plugin_device *device,
enum eraser_button_state to)
eraser_button_set_state(struct plugin_device *device, enum eraser_button_state to)
{
enum eraser_button_state *state = &device->state;
@ -161,8 +158,7 @@ eraser_button_cancel_timer(struct plugin_device *device)
}
static void
eraser_button_state_bug(struct plugin_device *device,
enum eraser_button_event event)
eraser_button_state_bug(struct plugin_device *device, enum eraser_button_event event)
{
plugin_log_bug(device->parent->plugin,
"Invalid eraser button event %s in state %s\n",
@ -171,15 +167,15 @@ eraser_button_state_bug(struct plugin_device *device,
}
enum tool_filter {
SKIP_PEN = bit(1),
SKIP_ERASER = bit(2),
PEN_IN_PROX = bit(3),
PEN_OUT_OF_PROX = bit(4),
ERASER_IN_PROX = bit(5),
SKIP_PEN = bit(1),
SKIP_ERASER = bit(2),
PEN_IN_PROX = bit(3),
PEN_OUT_OF_PROX = bit(4),
ERASER_IN_PROX = bit(5),
ERASER_OUT_OF_PROX = bit(6),
BUTTON_DOWN = bit(7),
BUTTON_UP = bit(8),
SKIP_BTN_TOUCH = bit(9),
BUTTON_DOWN = bit(7),
BUTTON_UP = bit(8),
SKIP_BTN_TOUCH = bit(9),
};
static void
@ -212,22 +208,22 @@ eraser_button_insert_frame(struct plugin_device *device,
}
}
if (filter & (PEN_IN_PROX|PEN_OUT_OF_PROX)) {
if (filter & (PEN_IN_PROX | PEN_OUT_OF_PROX)) {
struct evdev_event event = {
.usage = evdev_usage_from(EVDEV_BTN_TOOL_PEN),
.value = (filter & PEN_IN_PROX) ? 1 : 0,
};
evdev_frame_append(frame_out, &event, 1);
}
if (filter & (ERASER_IN_PROX|ERASER_OUT_OF_PROX)) {
if (filter & (ERASER_IN_PROX | ERASER_OUT_OF_PROX)) {
struct evdev_event event = {
.usage = evdev_usage_from(EVDEV_BTN_TOOL_RUBBER),
.value = (filter & ERASER_IN_PROX) ? 1 : 0,
};
evdev_frame_append(frame_out, &event, 1);
}
if (filter & (BUTTON_UP|BUTTON_DOWN)) {
assert (button != NULL);
if (filter & (BUTTON_UP | BUTTON_DOWN)) {
assert(button != NULL);
struct evdev_event event = {
.usage = *button,
.value = (filter & BUTTON_DOWN) ? 1 : 0,
@ -243,9 +239,9 @@ eraser_button_insert_frame(struct plugin_device *device,
static enum frame_filter_state
eraser_button_neutral_handle_event(struct plugin_device *device,
struct evdev_frame *frame,
enum eraser_button_event event,
uint64_t time)
struct evdev_frame *frame,
enum eraser_button_event event,
uint64_t time)
{
switch (event) {
case ERASER_EVENT_PEN_ENTERING_PROX:
@ -258,7 +254,7 @@ eraser_button_neutral_handle_event(struct plugin_device *device,
/* Change eraser prox in into pen prox in + button down */
eraser_button_insert_frame(device,
frame,
PEN_IN_PROX|SKIP_ERASER|BUTTON_DOWN,
PEN_IN_PROX | SKIP_ERASER | BUTTON_DOWN,
&device->button);
eraser_button_set_state(device, ERASER_BUTTON_BUTTON_HELD_DOWN);
return DISCARD;
@ -291,7 +287,7 @@ eraser_button_pending_eraser_handle_event(struct plugin_device *device,
eraser_button_cancel_timer(device);
eraser_button_insert_frame(device,
frame,
SKIP_ERASER|SKIP_PEN|BUTTON_DOWN,
SKIP_ERASER | SKIP_PEN | BUTTON_DOWN,
&device->button);
eraser_button_set_state(device, ERASER_BUTTON_BUTTON_HELD_DOWN);
return DISCARD;
@ -299,12 +295,12 @@ eraser_button_pending_eraser_handle_event(struct plugin_device *device,
eraser_button_state_bug(device, event);
break;
case ERASER_EVENT_TIMEOUT:
/* Pen went out of prox and we delayed expecting an eraser to
* come in prox. That didn't happen -> pen prox out */
eraser_button_set_state(device, ERASER_BUTTON_NEUTRAL);
eraser_button_insert_frame(device,
/* Pen went out of prox and we delayed expecting an eraser to
* come in prox. That didn't happen -> pen prox out */
eraser_button_set_state(device, ERASER_BUTTON_NEUTRAL);
eraser_button_insert_frame(device,
frame,
SKIP_ERASER|PEN_OUT_OF_PROX,
SKIP_ERASER | PEN_OUT_OF_PROX,
NULL);
break;
}
@ -330,11 +326,12 @@ eraser_button_button_held_handle_event(struct plugin_device *device,
case ERASER_EVENT_ERASER_LEAVING_PROX:
eraser_button_insert_frame(device,
device->last_frame,
SKIP_ERASER|SKIP_PEN|BUTTON_UP,
SKIP_ERASER | SKIP_PEN | BUTTON_UP,
&device->button);
eraser_button_set_state(device, ERASER_BUTTON_BUTTON_RELEASED);
eraser_button_set_timer(device, time);
return DISCARD; /* Discard the actual frame, it has garbage data anyway */
return DISCARD; /* Discard the actual frame, it has garbage data anyway
*/
case ERASER_EVENT_TIMEOUT:
/* Expected to be cancelled in previous state */
eraser_button_state_bug(device, event);
@ -353,10 +350,7 @@ eraser_button_button_released_handle_event(struct plugin_device *device,
switch (event) {
case ERASER_EVENT_PEN_ENTERING_PROX:
eraser_button_cancel_timer(device);
eraser_button_insert_frame(device,
frame,
SKIP_PEN|SKIP_ERASER,
NULL);
eraser_button_insert_frame(device, frame, SKIP_PEN | SKIP_ERASER, NULL);
eraser_button_set_state(device, ERASER_BUTTON_NEUTRAL);
return DISCARD;
case ERASER_EVENT_PEN_LEAVING_PROX:
@ -379,10 +373,7 @@ eraser_button_button_released_handle_event(struct plugin_device *device,
frame,
SKIP_PEN | SKIP_ERASER | BUTTON_UP,
&device->button);
eraser_button_insert_frame(device,
frame,
PEN_OUT_OF_PROX,
NULL);
eraser_button_insert_frame(device, frame, PEN_OUT_OF_PROX, NULL);
eraser_button_set_state(device, ERASER_BUTTON_NEUTRAL);
break;
}
@ -404,22 +395,31 @@ eraser_button_handle_state(struct plugin_device *device,
ret = eraser_button_neutral_handle_event(device, frame, event, time);
break;
case ERASER_BUTTON_PEN_PENDING_ERASER:
ret = eraser_button_pending_eraser_handle_event(device, frame, event, time);
ret = eraser_button_pending_eraser_handle_event(device,
frame,
event,
time);
break;
case ERASER_BUTTON_BUTTON_HELD_DOWN:
ret = eraser_button_button_held_handle_event(device, frame, event, time);
ret = eraser_button_button_held_handle_event(device,
frame,
event,
time);
break;
case ERASER_BUTTON_BUTTON_RELEASED:
ret = eraser_button_button_released_handle_event(device, frame, event, time);
ret = eraser_button_button_released_handle_event(device,
frame,
event,
time);
break;
}
if (state != device->state) {
plugin_log_debug(device->parent->plugin,
"eraser button: state %s -> %s -> %s\n",
eraser_button_state_str(state),
eraser_button_event_str(event),
eraser_button_state_str(device->state));
"eraser button: state %s -> %s -> %s\n",
eraser_button_state_str(state),
eraser_button_event_str(event),
eraser_button_state_str(device->state));
}
return ret;
}
@ -463,8 +463,12 @@ eraser_button_handle_frame(struct plugin_device *device,
bool eraser_in_prox = device->eraser_in_prox;
bool pen_in_prox = device->pen_in_prox;
enum eraser_button_event eraser_event = eraser_in_prox ? ERASER_EVENT_ERASER_ENTERING_PROX : ERASER_EVENT_ERASER_LEAVING_PROX;
enum eraser_button_event pen_event = pen_in_prox ? ERASER_EVENT_PEN_ENTERING_PROX : ERASER_EVENT_PEN_LEAVING_PROX;
enum eraser_button_event eraser_event =
eraser_in_prox ? ERASER_EVENT_ERASER_ENTERING_PROX
: ERASER_EVENT_ERASER_LEAVING_PROX;
enum eraser_button_event pen_event = pen_in_prox
? ERASER_EVENT_PEN_ENTERING_PROX
: ERASER_EVENT_PEN_LEAVING_PROX;
enum frame_filter_state ret = PROCESS;
@ -475,10 +479,16 @@ eraser_button_handle_frame(struct plugin_device *device,
if (eraser_toggled && pen_toggled) {
if (pen_in_prox) {
eraser_button_handle_state(device, frame, eraser_event, time);
ret = eraser_button_handle_state(device, frame, pen_event, time);
ret = eraser_button_handle_state(device,
frame,
pen_event,
time);
} else {
eraser_button_handle_state(device, frame, pen_event, time);
ret = eraser_button_handle_state(device, frame, eraser_event, time);
ret = eraser_button_handle_state(device,
frame,
eraser_event,
time);
}
} else if (eraser_toggled) {
ret = eraser_button_handle_state(device, frame, eraser_event, time);
@ -496,8 +506,8 @@ eraser_button_handle_frame(struct plugin_device *device,
static void
eraser_button_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
struct libinput_device *device,
struct evdev_frame *frame)
struct libinput_device *device,
struct evdev_frame *frame)
{
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
struct plugin_device *pd;
@ -517,13 +527,16 @@ eraser_button_timer_func(struct libinput_plugin *plugin, uint64_t now, void *d)
struct plugin_device *device = d;
if (!device->last_frame) {
plugin_log_bug(device->parent->plugin,
"Eraser button timer fired without a frame in state %s\n",
eraser_button_state_str(device->state)
);
plugin_log_bug(
device->parent->plugin,
"Eraser button timer fired without a frame in state %s\n",
eraser_button_state_str(device->state));
return;
}
eraser_button_handle_state(device, device->last_frame, ERASER_EVENT_TIMEOUT, now);
eraser_button_handle_state(device,
device->last_frame,
ERASER_EVENT_TIMEOUT,
now);
}
static void
@ -564,14 +577,15 @@ eraser_button_plugin_device_removed(struct libinput_plugin *libinput_plugin,
static void
eraser_button_plugin_tool_configured(struct libinput_plugin *libinput_plugin,
struct libinput_tablet_tool *tool)
struct libinput_tablet_tool *tool)
{
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
struct plugin_device *pd;
list_for_each(pd, &plugin->devices, link) {
/* FIXME: sigh, we need a separate list of tools? */
pd->mode = libinput_tablet_tool_config_eraser_button_get_mode(tool);
uint32_t button = libinput_tablet_tool_config_eraser_button_get_button(tool);
uint32_t button =
libinput_tablet_tool_config_eraser_button_get_button(tool);
pd->button = evdev_usage_from_code(EV_KEY, button);
}
@ -597,10 +611,8 @@ libinput_tablet_plugin_eraser_button(struct libinput *libinput)
_destroy_(plugin_data) *plugin = zalloc(sizeof(*plugin));
list_init(&plugin->devices);
_unref_(libinput_plugin) *p = libinput_plugin_new(libinput,
"tablet-eraser-button",
&interface,
NULL);
_unref_(libinput_plugin) *p =
libinput_plugin_new(libinput, "tablet-eraser-button", &interface, NULL);
plugin->plugin = p;
libinput_plugin_set_user_data(p, steal(&plugin));
}

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "libinput.h"
#include "libinput-plugin.h"
#include "libinput.h"
void
libinput_tablet_plugin_eraser_button(struct libinput *libinput);

View file

@ -28,12 +28,12 @@
#include "util-mem.h"
#include "util-strings.h"
#include "evdev-frame.h"
#include "evdev-frame.h"
#include "libinput-log.h"
#include "libinput-util.h"
#include "libinput-plugin.h"
#include "libinput-plugin-tablet-forced-tool.h"
#include "libinput-plugin.h"
#include "libinput-util.h"
/*
* Handling for tools that never set BTN_TOOL_PEN.
@ -114,7 +114,8 @@ forced_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
evdev_event_code(event) - BTN_TOOL_PEN);
} else {
bitmask_clear_bit(&device->tool_state,
evdev_event_code(event)- BTN_TOOL_PEN);
evdev_event_code(event) -
BTN_TOOL_PEN);
}
return; /* Nothing to do */
case EVDEV_ABS_X:
@ -126,12 +127,12 @@ forced_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
case EVDEV_ABS_TILT_Y:
case EVDEV_ABS_WHEEL: /* slider */
/* no early return here, the BTN_TOOL updates
* may come after the ABS_ events */
* may come after the ABS_ events */
axis_change = true;
break;
case EVDEV_REL_WHEEL:
/* no early return here, the BTN_TOOL updates
* may come after the REL_ events */
* may come after the REL_ events */
axis_change = true;
break;
default:
@ -142,13 +143,8 @@ forced_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
if (!axis_change)
return;
const bitmask_t all_tools = bitmask_from_bits(PEN,
RUBBER,
BRUSH,
PENCIL,
AIRBRUSH,
MOUSE,
LENS);
const bitmask_t all_tools =
bitmask_from_bits(PEN, RUBBER, BRUSH, PENCIL, AIRBRUSH, MOUSE, LENS);
if (bitmask_any(device->tool_state, all_tools))
return;
@ -160,7 +156,9 @@ forced_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
.usage = evdev_usage_from(EVDEV_BTN_TOOL_PEN),
.value = 1,
};
evdev_frame_append(frame, &prox, 1); /* libinput's event frame will have space */
evdev_frame_append(frame,
&prox,
1); /* libinput's event frame will have space */
}
static void
@ -173,7 +171,9 @@ forced_tool_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
list_for_each(pd, &plugin->devices, link) {
if (pd->device == device) {
forced_tool_plugin_device_handle_frame(libinput_plugin, pd, frame);
forced_tool_plugin_device_handle_frame(libinput_plugin,
pd,
frame);
break;
}
}

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "libinput.h"
#include "libinput-plugin.h"
#include "libinput.h"
void
libinput_tablet_plugin_forced_tool(struct libinput *libinput);

View file

@ -30,12 +30,11 @@
#include "util-strings.h"
#include "evdev-frame.h"
#include "timer.h"
#include "libinput-log.h"
#include "libinput-util.h"
#include "libinput-plugin.h"
#include "libinput-plugin-tablet-proximity-timer.h"
#include "libinput-plugin.h"
#include "libinput-util.h"
#include "timer.h"
/* The tablet sends events every ~2ms , 50ms should be plenty enough to
detect out-of-range.
@ -179,7 +178,8 @@ proximity_timer_plugin_device_handle_frame(struct libinput_plugin *libinput_plug
evdev_event_code(event) - BTN_STYLUS3);
else
bitmask_clear_bit(&device->button_state,
evdev_event_code(event) - BTN_STYLUS3);
evdev_event_code(event) -
BTN_STYLUS3);
break;
case EVDEV_BTN_TOOL_PEN:
pen_toggled = true;
@ -203,14 +203,14 @@ proximity_timer_plugin_device_handle_frame(struct libinput_plugin *libinput_plug
if (device->pen_state) {
proximity_timer_plugin_set_timer(device, time);
} else {
/* If we get a BTN_TOOL_PEN 0 it means the tablet will
* give us the right events after all and we can disable
* our timer-based proximity out.
*/
libinput_plugin_timer_cancel(device->prox_out_timer);
/* If we get a BTN_TOOL_PEN 0 it means the tablet will
* give us the right events after all and we can disable
* our timer-based proximity out.
*/
libinput_plugin_timer_cancel(device->prox_out_timer);
plugin_log_debug(libinput_plugin,
"%s: proximity out timer unloaded\n",
libinput_device_get_name(device->device));
"%s: proximity out timer unloaded\n",
libinput_device_get_name(device->device));
plugin_device_destroy(device);
return;
}
@ -222,7 +222,9 @@ proximity_timer_plugin_device_handle_frame(struct libinput_plugin *libinput_plug
plugin_log_debug(libinput_plugin,
"%s: forcing proximity in\n",
libinput_device_get_name(device->device));
evdev_frame_append(frame, &pen_in_event, 1); /* libinput's event frame will have space */
evdev_frame_append(frame,
&pen_in_event,
1); /* libinput's event frame will have space */
device->proximity_out_forced = false;
proximity_timer_plugin_set_timer(device, time);
}
@ -238,7 +240,9 @@ proximity_timer_plugin_evdev_frame(struct libinput_plugin *libinput_plugin,
list_for_each(pd, &plugin->devices, link) {
if (pd->device == device) {
proximity_timer_plugin_device_handle_frame(libinput_plugin, pd, frame);
proximity_timer_plugin_device_handle_frame(libinput_plugin,
pd,
frame);
break;
}
}
@ -257,17 +261,18 @@ proximity_timer_plugin_device_added(struct libinput_plugin *libinput_plugin,
struct plugin_device *pd = zalloc(sizeof(*pd));
pd->device = libinput_device_ref(device);
pd->parent = plugin;
pd->prox_out_timer = libinput_plugin_timer_new(libinput_plugin,
libinput_device_get_sysname(device),
tablet_proximity_out_quirk_timer_func,
pd);
pd->prox_out_timer =
libinput_plugin_timer_new(libinput_plugin,
libinput_device_get_sysname(device),
tablet_proximity_out_quirk_timer_func,
pd);
list_take_append(&plugin->devices, pd, link);
}
static void
proximity_timer_plugin_device_removed(struct libinput_plugin *libinput_plugin,
struct libinput_device *device)
struct libinput_device *device)
{
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
struct plugin_device *dev;

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "libinput.h"
#include "libinput-plugin.h"
#include "libinput.h"
void
libinput_tablet_plugin_proximity_timer(struct libinput *libinput);

View file

@ -28,22 +28,19 @@
#include "util-files.h"
#include "util-list.h"
#include "libinput-plugin.h"
#include "libinput-plugin-private.h"
#include "libinput-plugin-system.h"
#include "timer.h"
#include "libinput-util.h"
#include "libinput-private.h"
#include "evdev-plugin.h"
#include "libinput-plugin-button-debounce.h"
#include "libinput-plugin-mouse-wheel.h"
#include "libinput-plugin-private.h"
#include "libinput-plugin-system.h"
#include "libinput-plugin-tablet-double-tool.h"
#include "libinput-plugin-tablet-eraser-button.h"
#include "libinput-plugin-tablet-forced-tool.h"
#include "libinput-plugin-tablet-proximity-timer.h"
#include "evdev-plugin.h"
#include "libinput-plugin.h"
#include "libinput-private.h"
#include "libinput-util.h"
#include "timer.h"
struct libinput_plugin {
struct libinput *libinput;
@ -128,8 +125,7 @@ libinput_plugin_unregister(struct libinput_plugin *plugin)
plugin->registered = false;
libinput_plugin_system_unregister_plugin(&libinput->plugin_system,
plugin);
libinput_plugin_system_unregister_plugin(&libinput->plugin_system, plugin);
}
struct libinput_plugin *
@ -161,8 +157,7 @@ libinput_plugin_unref(struct libinput_plugin *plugin)
}
void
libinput_plugin_set_user_data(struct libinput_plugin *plugin,
void *user_data)
libinput_plugin_set_user_data(struct libinput_plugin *plugin, void *user_data)
{
plugin->user_data = user_data;
}
@ -199,7 +194,7 @@ libinput_plugin_enable_device_event_frame(struct libinput_plugin *plugin,
struct plugin_queued_event {
struct list link;
struct evdev_frame *frame; /* owns a ref */
struct evdev_frame *frame; /* owns a ref */
struct libinput_device *device; /* owns a ref */
};
@ -239,8 +234,7 @@ libinput_plugin_queue_evdev_frame(struct list *queue,
}
_unref_(evdev_frame) *clone = evdev_frame_clone(frame);
struct plugin_queued_event *event =
plugin_queued_event_new(clone, device);
struct plugin_queued_event *event = plugin_queued_event_new(clone, device);
list_take_append(queue, event, link);
}
@ -250,10 +244,10 @@ libinput_plugin_append_evdev_frame(struct libinput_plugin *plugin,
struct evdev_frame *frame)
{
libinput_plugin_queue_evdev_frame(plugin->event_queue.after,
__func__,
plugin,
device,
frame);
__func__,
plugin,
device,
frame);
}
void
@ -262,10 +256,10 @@ libinput_plugin_prepend_evdev_frame(struct libinput_plugin *plugin,
struct evdev_frame *frame)
{
libinput_plugin_queue_evdev_frame(plugin->event_queue.before,
__func__,
plugin,
device,
frame);
__func__,
plugin,
device,
frame);
}
void
@ -331,9 +325,7 @@ void
libinput_plugin_system_run(struct libinput_plugin_system *system)
{
struct libinput_plugin *plugin;
list_for_each_safe(plugin,
&system->plugins,
link) {
list_for_each_safe(plugin, &system->plugins, link) {
libinput_plugin_run(plugin);
}
}
@ -407,7 +399,7 @@ void
libinput_plugin_system_destroy(struct libinput_plugin_system *system)
{
struct libinput_plugin *plugin;
list_for_each_safe(plugin, &system->plugins, link) {
list_for_each_safe(plugin, &system->plugins, link) {
libinput_plugin_unregister(plugin);
}
@ -463,8 +455,9 @@ libinput_plugin_system_notify_device_ignored(struct libinput_plugin_system *syst
}
void
libinput_plugin_system_notify_tablet_tool_configured(struct libinput_plugin_system *system,
struct libinput_tablet_tool *tool)
libinput_plugin_system_notify_tablet_tool_configured(
struct libinput_plugin_system *system,
struct libinput_tablet_tool *tool)
{
struct libinput_plugin *plugin;
list_for_each_safe(plugin, &system->plugins, link) {
@ -495,18 +488,16 @@ libinput_plugin_process_frame(struct libinput_plugin *plugin,
list_chain(queued_events, &before_events);
if (!evdev_frame_is_empty(frame)) {
struct plugin_queued_event *event = plugin_queued_event_new(frame, device);
struct plugin_queued_event *event =
plugin_queued_event_new(frame, device);
list_take_append(queued_events, event, link);
}
list_chain(queued_events, &after_events);
}
_unused_
static inline void
print_frame(struct libinput *libinput,
struct evdev_frame *frame,
const char *prefix)
_unused_ static inline void
print_frame(struct libinput *libinput, struct evdev_frame *frame, const char *prefix)
{
static uint32_t offset = 0;
static uint32_t last_time = 0;
@ -527,12 +518,13 @@ print_frame(struct libinput *libinput,
switch (evdev_usage_enum(e->usage)) {
case EVDEV_SYN_REPORT:
log_debug(libinput,
"%s%u.%03u ----------------- EV_SYN ----------------- +%ums\n",
prefix,
time / 1000,
time % 1000,
time - last_time);
log_debug(
libinput,
"%s%u.%03u ----------------- EV_SYN ----------------- +%ums\n",
prefix,
time / 1000,
time % 1000,
time - last_time);
last_time = time;
break;
@ -611,16 +603,19 @@ plugin_system_notify_evdev_frame(struct libinput_plugin_system *system,
evdev_frame_set_time(event->frame, frame_time);
if (!bitmask_bit_is_set(device->plugin_frame_callbacks,
plugin->index)) {
plugin->index)) {
list_remove(&event->link);
list_append(&next_events, &event->link);
continue;
}
#ifdef EVENT_DEBUGGING
_autofree_ char *prefix = strdup_printf("plugin %-25s - %s:",
plugin->name,
libinput_device_get_name(event->device));
print_frame(libinput_device_get_context(device), event->frame, prefix);
_autofree_ char *prefix =
strdup_printf("plugin %-25s - %s:",
plugin->name,
libinput_device_get_name(event->device));
print_frame(libinput_device_get_context(device),
event->frame,
prefix);
#endif
libinput_plugin_process_frame(plugin,
@ -635,10 +630,13 @@ plugin_system_notify_evdev_frame(struct libinput_plugin_system *system,
list_chain(&queued_events, &next_events);
if (list_empty(&queued_events)) {
#ifdef EVENT_DEBUGGING
if (list_last_entry_by_type(&system->plugins, struct libinput_plugin, link) != plugin) {
log_debug(libinput_device_get_context(device),
"%s: --- empty frame queue - end of events ---\n",
plugin->name);
if (list_last_entry_by_type(&system->plugins,
struct libinput_plugin,
link) != plugin) {
log_debug(
libinput_device_get_context(device),
"%s: --- empty frame queue - end of events ---\n",
plugin->name);
}
#endif
/* No more events to process, stop here */
@ -696,14 +694,14 @@ plugin_timer_func(uint64_t now, void *data)
struct libinput_plugin_timer *
libinput_plugin_timer_new(struct libinput_plugin *plugin,
const char *name,
void (*func)(struct libinput_plugin *plugin, uint64_t now, void *data),
void (*func)(struct libinput_plugin *plugin,
uint64_t now,
void *data),
void *data)
{
struct libinput_plugin_timer *timer = zalloc(sizeof(*timer));
_autofree_ char *timer_name = strdup_printf("%s-%s",
plugin->name,
name);
_autofree_ char *timer_name = strdup_printf("%s-%s", plugin->name, name);
timer->plugin = plugin;
timer->refcount = 2; /* one for the caller, one for our list */
@ -757,8 +755,7 @@ libinput_plugin_timer_unref(struct libinput_plugin_timer *timer)
/* Set timer expire time, in absolute us CLOCK_MONOTONIC */
void
libinput_plugin_timer_set(struct libinput_plugin_timer *timer,
uint64_t expire)
libinput_plugin_timer_set(struct libinput_plugin_timer *timer, uint64_t expire)
{
libinput_timer_set(&timer->timer, expire);
}

View file

@ -25,10 +25,10 @@
#include "config.h"
#include <libevdev/libevdev.h>
#include <libudev.h>
#include <stdbool.h>
#include <stdint.h>
#include <libudev.h>
#include <libevdev/libevdev.h>
/* Forward declarations instead of #includes to make
* this header self-contained (bindgen, etc.) */
@ -68,9 +68,9 @@ struct libinput_plugin_interface {
* been added by libinput as struct libinput_device.
*/
void (*device_new)(struct libinput_plugin *plugin,
struct libinput_device *device,
struct libevdev *evdev,
struct udev_device *udev_device);
struct libinput_device *device,
struct libevdev *evdev,
struct udev_device *udev_device);
/**
* Notification that a device (previously announced with device_new)
* was ignored by libinput and was **never** added as struct
@ -139,8 +139,7 @@ void
libinput_plugin_unregister(struct libinput_plugin *plugin);
void
libinput_plugin_set_user_data(struct libinput_plugin *plugin,
void *user_data);
libinput_plugin_set_user_data(struct libinput_plugin *plugin, void *user_data);
void *
libinput_plugin_get_user_data(struct libinput_plugin *plugin);
@ -301,7 +300,9 @@ libinput_plugin_prepend_evdev_frame(struct libinput_plugin *libinput,
struct libinput_plugin_timer *
libinput_plugin_timer_new(struct libinput_plugin *plugin,
const char *name,
void (*func)(struct libinput_plugin *plugin, uint64_t now, void *user_data),
void (*func)(struct libinput_plugin *plugin,
uint64_t now,
void *user_data),
void *user_data);
struct libinput_plugin_timer *
@ -316,8 +317,7 @@ DEFINE_UNREF_CLEANUP_FUNC(libinput_plugin_timer);
/* Set timer expire time, in absolute us CLOCK_MONOTONIC */
void
libinput_plugin_timer_set(struct libinput_plugin_timer *timer,
uint64_t expire);
libinput_plugin_timer_set(struct libinput_plugin_timer *timer, uint64_t expire);
void
libinput_plugin_timer_set_user_data(struct libinput_plugin_timer *timer,

View file

@ -30,8 +30,7 @@
int
libinput_device_config_gesture_hold_is_available(struct libinput_device *device)
{
if (!libinput_device_has_capability(device,
LIBINPUT_DEVICE_CAP_GESTURE))
if (!libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_GESTURE))
return 0;
if (!device->config.gesture->get_hold_default(device))
@ -49,8 +48,8 @@ libinput_device_config_gesture_set_hold_enabled(struct libinput_device *device,
return LIBINPUT_CONFIG_STATUS_INVALID;
if (!libinput_device_config_gesture_hold_is_available(device)) {
return enable ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED :
LIBINPUT_CONFIG_STATUS_SUCCESS;
return enable ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED
: LIBINPUT_CONFIG_STATUS_SUCCESS;
}
return device->config.gesture->set_hold_enabled(device, enable);

View file

@ -35,15 +35,15 @@
#include <libwacom/libwacom.h>
#endif
#include "linux/input.h"
#include "util-newtype.h"
#include "libinput.h"
#include "libinput-log.h"
#include "libinput-plugin-system.h"
#include "libinput-private-config.h"
#include "libinput-util.h"
#include "libinput-version.h"
#include "util-newtype.h"
#include "libinput.h"
#include "linux/input.h"
struct libinput_source;
@ -68,7 +68,7 @@ DECLARE_NEWTYPE(keycode, uint32_t);
static inline pressure_offset_t
pressure_offset_from_range(double min, double max, double value)
{
return pressure_offset_from_double((value - min)/ (max - min));
return pressure_offset_from_double((value - min) / (max - min));
}
static inline pressure_offset_t
@ -76,7 +76,7 @@ pressure_offset_from_hundred(double hundred)
{
assert(hundred >= 0);
assert(hundred <= 100);
return pressure_offset_from_double(hundred/100);
return pressure_offset_from_double(hundred / 100);
}
static inline double
@ -92,9 +92,12 @@ pressure_offset_from_absinfo(const struct input_absinfo *abs, int value)
}
static inline int
pressure_offset_to_absinfo(pressure_offset_t pressure_offset, const struct input_absinfo *abs)
pressure_offset_to_absinfo(pressure_offset_t pressure_offset,
const struct input_absinfo *abs)
{
return (abs->maximum - abs->minimum) * pressure_offset_as_double(pressure_offset) + abs->minimum;
return (abs->maximum - abs->minimum) *
pressure_offset_as_double(pressure_offset) +
abs->minimum;
}
/* A coordinate pair in device coordinates */
@ -232,7 +235,7 @@ struct libinput {
#endif
};
typedef void (*libinput_seat_destroy_func) (struct libinput_seat *seat);
typedef void (*libinput_seat_destroy_func)(struct libinput_seat *seat);
struct libinput_seat {
struct libinput *libinput;
@ -252,60 +255,74 @@ struct libinput_seat {
struct libinput_device_config_tap {
int (*count)(struct libinput_device *device);
enum libinput_config_status (*set_enabled)(struct libinput_device *device,
enum libinput_config_tap_state enable);
enum libinput_config_status (*set_enabled)(
struct libinput_device *device,
enum libinput_config_tap_state enable);
enum libinput_config_tap_state (*get_enabled)(struct libinput_device *device);
enum libinput_config_tap_state (*get_default)(struct libinput_device *device);
enum libinput_config_status (*set_map)(struct libinput_device *device,
enum libinput_config_tap_button_map map);
enum libinput_config_tap_button_map map);
enum libinput_config_tap_button_map (*get_map)(struct libinput_device *device);
enum libinput_config_tap_button_map (*get_default_map)(struct libinput_device *device);
enum libinput_config_tap_button_map (*get_default_map)(
struct libinput_device *device);
enum libinput_config_status (*set_drag_enabled)(struct libinput_device *device,
enum libinput_config_drag_state);
enum libinput_config_drag_state (*get_drag_enabled)(struct libinput_device *device);
enum libinput_config_drag_state (*get_default_drag_enabled)(struct libinput_device *device);
enum libinput_config_status (*set_drag_enabled)(
struct libinput_device *device,
enum libinput_config_drag_state);
enum libinput_config_drag_state (*get_drag_enabled)(
struct libinput_device *device);
enum libinput_config_drag_state (*get_default_drag_enabled)(
struct libinput_device *device);
enum libinput_config_status (*set_draglock_enabled)(struct libinput_device *device,
enum libinput_config_drag_lock_state);
enum libinput_config_drag_lock_state (*get_draglock_enabled)(struct libinput_device *device);
enum libinput_config_drag_lock_state (*get_default_draglock_enabled)(struct libinput_device *device);
enum libinput_config_status (*set_draglock_enabled)(
struct libinput_device *device,
enum libinput_config_drag_lock_state);
enum libinput_config_drag_lock_state (*get_draglock_enabled)(
struct libinput_device *device);
enum libinput_config_drag_lock_state (*get_default_draglock_enabled)(
struct libinput_device *device);
};
struct libinput_device_config_3fg_drag {
int (*count)(struct libinput_device *device);
enum libinput_config_status (*set_enabled)(struct libinput_device *device,
enum libinput_config_3fg_drag_state enable);
enum libinput_config_3fg_drag_state (*get_enabled)(struct libinput_device *device);
enum libinput_config_3fg_drag_state (*get_default)(struct libinput_device *device);
enum libinput_config_status (*set_enabled)(
struct libinput_device *device,
enum libinput_config_3fg_drag_state enable);
enum libinput_config_3fg_drag_state (*get_enabled)(
struct libinput_device *device);
enum libinput_config_3fg_drag_state (*get_default)(
struct libinput_device *device);
};
struct libinput_device_config_calibration {
int (*has_matrix)(struct libinput_device *device);
enum libinput_config_status (*set_matrix)(struct libinput_device *device,
const float matrix[6]);
int (*get_matrix)(struct libinput_device *device,
float matrix[6]);
int (*get_default_matrix)(struct libinput_device *device,
float matrix[6]);
int (*get_matrix)(struct libinput_device *device, float matrix[6]);
int (*get_default_matrix)(struct libinput_device *device, float matrix[6]);
};
struct libinput_device_config_area {
int (*has_rectangle)(struct libinput_device *device);
enum libinput_config_status (*set_rectangle)(struct libinput_device *device,
const struct libinput_config_area_rectangle *rectangle);
struct libinput_config_area_rectangle (*get_rectangle)(struct libinput_device *device);
struct libinput_config_area_rectangle (*get_default_rectangle)(struct libinput_device *device);
enum libinput_config_status (*set_rectangle)(
struct libinput_device *device,
const struct libinput_config_area_rectangle *rectangle);
struct libinput_config_area_rectangle (*get_rectangle)(
struct libinput_device *device);
struct libinput_config_area_rectangle (*get_default_rectangle)(
struct libinput_device *device);
};
struct libinput_device_config_send_events {
uint32_t (*get_modes)(struct libinput_device *device);
enum libinput_config_status (*set_mode)(struct libinput_device *device,
enum libinput_config_send_events_mode mode);
enum libinput_config_send_events_mode (*get_mode)(struct libinput_device *device);
enum libinput_config_send_events_mode (*get_default_mode)(struct libinput_device *device);
enum libinput_config_status (*set_mode)(
struct libinput_device *device,
enum libinput_config_send_events_mode mode);
enum libinput_config_send_events_mode (*get_mode)(
struct libinput_device *device);
enum libinput_config_send_events_mode (*get_default_mode)(
struct libinput_device *device);
};
/**
@ -345,7 +362,7 @@ struct libinput_config_accel_custom_func {
struct libinput_config_accel {
enum libinput_config_accel_profile profile;
struct {
struct {
struct libinput_config_accel_custom_func *fallback;
struct libinput_config_accel_custom_func *motion;
struct libinput_config_accel_custom_func *scroll;
@ -362,10 +379,13 @@ struct libinput_device_config_accel {
uint32_t (*get_profiles)(struct libinput_device *device);
enum libinput_config_status (*set_profile)(struct libinput_device *device,
enum libinput_config_accel_profile);
enum libinput_config_accel_profile (*get_profile)(struct libinput_device *device);
enum libinput_config_accel_profile (*get_default_profile)(struct libinput_device *device);
enum libinput_config_status (*set_accel_config)(struct libinput_device *device,
struct libinput_config_accel *accel_config);
enum libinput_config_accel_profile (*get_profile)(
struct libinput_device *device);
enum libinput_config_accel_profile (*get_default_profile)(
struct libinput_device *device);
enum libinput_config_status (*set_accel_config)(
struct libinput_device *device,
struct libinput_config_accel *accel_config);
};
struct libinput_device_config_natural_scroll {
@ -378,86 +398,97 @@ struct libinput_device_config_natural_scroll {
struct libinput_device_config_left_handed {
int (*has)(struct libinput_device *device);
enum libinput_config_status (*set)(struct libinput_device *device, int left_handed);
enum libinput_config_status (*set)(struct libinput_device *device,
int left_handed);
int (*get)(struct libinput_device *device);
int (*get_default)(struct libinput_device *device);
};
struct libinput_device_config_scroll_method {
uint32_t (*get_methods)(struct libinput_device *device);
enum libinput_config_status (*set_method)(struct libinput_device *device,
enum libinput_config_scroll_method method);
enum libinput_config_scroll_method (*get_method)(struct libinput_device *device);
enum libinput_config_scroll_method (*get_default_method)(struct libinput_device *device);
enum libinput_config_status (*set_method)(
struct libinput_device *device,
enum libinput_config_scroll_method method);
enum libinput_config_scroll_method (*get_method)(
struct libinput_device *device);
enum libinput_config_scroll_method (*get_default_method)(
struct libinput_device *device);
enum libinput_config_status (*set_button)(struct libinput_device *device,
uint32_t button);
uint32_t (*get_button)(struct libinput_device *device);
uint32_t (*get_default_button)(struct libinput_device *device);
enum libinput_config_status (*set_button_lock)(struct libinput_device *device,
enum libinput_config_scroll_button_lock_state);
enum libinput_config_scroll_button_lock_state (*get_button_lock)(struct libinput_device *device);
enum libinput_config_scroll_button_lock_state (*get_default_button_lock)(struct libinput_device *device);
enum libinput_config_status (*set_button_lock)(
struct libinput_device *device,
enum libinput_config_scroll_button_lock_state);
enum libinput_config_scroll_button_lock_state (*get_button_lock)(
struct libinput_device *device);
enum libinput_config_scroll_button_lock_state (*get_default_button_lock)(
struct libinput_device *device);
};
struct libinput_device_config_click_method {
uint32_t (*get_methods)(struct libinput_device *device);
enum libinput_config_status (*set_method)(struct libinput_device *device,
enum libinput_config_click_method method);
enum libinput_config_status (*set_method)(
struct libinput_device *device,
enum libinput_config_click_method method);
enum libinput_config_click_method (*get_method)(struct libinput_device *device);
enum libinput_config_click_method (*get_default_method)(struct libinput_device *device);
enum libinput_config_status (*set_clickfinger_map)(struct libinput_device *device,
enum libinput_config_clickfinger_button_map map);
enum libinput_config_clickfinger_button_map (*get_clickfinger_map)(struct libinput_device *device);
enum libinput_config_clickfinger_button_map (*get_default_clickfinger_map)(struct libinput_device *device);
enum libinput_config_click_method (*get_default_method)(
struct libinput_device *device);
enum libinput_config_status (*set_clickfinger_map)(
struct libinput_device *device,
enum libinput_config_clickfinger_button_map map);
enum libinput_config_clickfinger_button_map (*get_clickfinger_map)(
struct libinput_device *device);
enum libinput_config_clickfinger_button_map (*get_default_clickfinger_map)(
struct libinput_device *device);
};
struct libinput_device_config_middle_emulation {
int (*available)(struct libinput_device *device);
enum libinput_config_status (*set)(
struct libinput_device *device,
enum libinput_config_middle_emulation_state);
enum libinput_config_status (*set)(struct libinput_device *device,
enum libinput_config_middle_emulation_state);
enum libinput_config_middle_emulation_state (*get)(
struct libinput_device *device);
struct libinput_device *device);
enum libinput_config_middle_emulation_state (*get_default)(
struct libinput_device *device);
struct libinput_device *device);
};
struct libinput_device_config_dwt {
int (*is_available)(struct libinput_device *device);
enum libinput_config_status (*set_enabled)(
struct libinput_device *device,
enum libinput_config_dwt_state enable);
enum libinput_config_dwt_state (*get_enabled)(
struct libinput_device *device);
struct libinput_device *device,
enum libinput_config_dwt_state enable);
enum libinput_config_dwt_state (*get_enabled)(struct libinput_device *device);
enum libinput_config_dwt_state (*get_default_enabled)(
struct libinput_device *device);
struct libinput_device *device);
};
struct libinput_device_config_dwtp {
int (*is_available)(struct libinput_device *device);
enum libinput_config_status (*set_enabled)(
struct libinput_device *device,
enum libinput_config_dwtp_state enable);
enum libinput_config_dwtp_state (*get_enabled)(
struct libinput_device *device);
struct libinput_device *device,
enum libinput_config_dwtp_state enable);
enum libinput_config_dwtp_state (*get_enabled)(struct libinput_device *device);
enum libinput_config_dwtp_state (*get_default_enabled)(
struct libinput_device *device);
struct libinput_device *device);
};
struct libinput_device_config_rotation {
int (*is_available)(struct libinput_device *device);
enum libinput_config_status (*set_angle)(
struct libinput_device *device,
unsigned int degrees_cw);
enum libinput_config_status (*set_angle)(struct libinput_device *device,
unsigned int degrees_cw);
unsigned int (*get_angle)(struct libinput_device *device);
unsigned int (*get_default_angle)(struct libinput_device *device);
};
struct libinput_device_config_gesture {
enum libinput_config_status (*set_hold_enabled)(struct libinput_device *device,
enum libinput_config_hold_state enabled);
enum libinput_config_hold_state (*get_hold_enabled)(struct libinput_device *device);
enum libinput_config_hold_state (*get_hold_default)(struct libinput_device *device);
enum libinput_config_status (*set_hold_enabled)(
struct libinput_device *device,
enum libinput_config_hold_state enabled);
enum libinput_config_hold_state (*get_hold_enabled)(
struct libinput_device *device);
enum libinput_config_hold_state (*get_hold_default)(
struct libinput_device *device);
};
struct libinput_device_config {
@ -539,18 +570,27 @@ enum pressure_heuristic_state {
struct libinput_tablet_tool_config_pressure_range {
int (*is_available)(struct libinput_tablet_tool *tool);
enum libinput_config_status (*set)(struct libinput_tablet_tool *tool, double min, double max);
enum libinput_config_status (*set)(struct libinput_tablet_tool *tool,
double min,
double max);
void (*get)(struct libinput_tablet_tool *tool, double *min, double *max);
void (*get_default)(struct libinput_tablet_tool *tool, double *min, double *max);
void (*get_default)(struct libinput_tablet_tool *tool,
double *min,
double *max);
};
struct libinput_tablet_tool_config_eraser_button {
bitmask_t (*get_modes)(struct libinput_tablet_tool *tool);
enum libinput_config_status (*set_mode)(struct libinput_tablet_tool *tool, enum libinput_config_eraser_button_mode mode);
enum libinput_config_eraser_button_mode (*get_mode)(struct libinput_tablet_tool *tool);
enum libinput_config_eraser_button_mode (*get_default_mode)(struct libinput_tablet_tool *tool);
enum libinput_config_status (*set_mode)(
struct libinput_tablet_tool *tool,
enum libinput_config_eraser_button_mode mode);
enum libinput_config_eraser_button_mode (*get_mode)(
struct libinput_tablet_tool *tool);
enum libinput_config_eraser_button_mode (*get_default_mode)(
struct libinput_tablet_tool *tool);
enum libinput_config_status (*set_button)(struct libinput_tablet_tool *tool, uint32_t button);
enum libinput_config_status (*set_button)(struct libinput_tablet_tool *tool,
uint32_t button);
unsigned int (*get_button)(struct libinput_tablet_tool *tool);
unsigned int (*get_default_button)(struct libinput_tablet_tool *tool);
};
@ -582,10 +622,10 @@ struct libinput_tablet_tool {
struct libinput_device *last_device;
struct {
/* We're assuming that the *configured* pressure range is per
* tool, not per tablet. The *adjusted* thresholds are then
* per-tablet. */
struct normalized_range range;
/* We're assuming that the *configured* pressure range is per
* tool, not per tablet. The *adjusted* thresholds are then
* per-tablet. */
struct normalized_range range;
struct normalized_range wanted_range;
bool has_configured_range;
@ -635,7 +675,9 @@ struct libinput_event {
struct libinput_event_listener {
struct list link;
void (*notify_func)(uint64_t time, struct libinput_event *ev, void *notify_func_data);
void (*notify_func)(uint64_t time,
struct libinput_event *ev,
void *notify_func_data);
void *notify_func_data;
};
@ -657,12 +699,10 @@ libinput_add_fd(struct libinput *libinput,
void *data);
void
libinput_remove_source(struct libinput *libinput,
struct libinput_source *source);
libinput_remove_source(struct libinput *libinput, struct libinput_source *source);
int
open_restricted(struct libinput *libinput,
const char *path, int flags);
open_restricted(struct libinput *libinput, const char *path, int flags);
void
close_restricted(struct libinput *libinput, int fd);
@ -678,16 +718,13 @@ libinput_seat_init(struct libinput_seat *seat,
libinput_seat_destroy_func destroy);
void
libinput_device_init(struct libinput_device *device,
struct libinput_seat *seat);
libinput_device_init(struct libinput_device *device, struct libinput_seat *seat);
struct libinput_device_group *
libinput_device_group_create(struct libinput *libinput,
const char *identifier);
libinput_device_group_create(struct libinput *libinput, const char *identifier);
struct libinput_device_group *
libinput_device_group_find_group(struct libinput *libinput,
const char *identifier);
libinput_device_group_find_group(struct libinput *libinput, const char *identifier);
void
libinput_device_set_device_group(struct libinput_device *device,
@ -699,10 +736,9 @@ libinput_device_init_event_listener(struct libinput_event_listener *listener);
void
libinput_device_add_event_listener(struct libinput_device *device,
struct libinput_event_listener *listener,
void (*notify_func)(
uint64_t time,
struct libinput_event *event,
void *notify_func_data),
void (*notify_func)(uint64_t time,
struct libinput_event *event,
void *notify_func_data),
void *notify_func_data);
void
@ -789,8 +825,7 @@ touch_notify_touch_cancel(struct libinput_device *device,
int32_t seat_slot);
void
touch_notify_frame(struct libinput_device *device,
uint64_t time);
touch_notify_frame(struct libinput_device *device, uint64_t time);
void
gesture_notify_swipe(struct libinput_device *device,
@ -937,7 +972,8 @@ device_average(const struct device_coords a, const struct device_coords b)
}
static inline struct device_float_coords
device_float_delta(const struct device_float_coords a, const struct device_float_coords b)
device_float_delta(const struct device_float_coords a,
const struct device_float_coords b)
{
struct device_float_coords delta;
@ -948,7 +984,8 @@ device_float_delta(const struct device_float_coords a, const struct device_float
}
static inline struct device_float_coords
device_float_average(const struct device_float_coords a, const struct device_float_coords b)
device_float_average(const struct device_float_coords a,
const struct device_float_coords b)
{
struct device_float_coords average;
@ -983,13 +1020,13 @@ length_in_mm(const struct phys_coords mm)
}
enum directions {
N = bit(0),
N = bit(0),
NE = bit(1),
E = bit(2),
E = bit(2),
SE = bit(3),
S = bit(4),
S = bit(4),
SW = bit(5),
W = bit(6),
W = bit(6),
NW = bit(7),
UNDEFINED_DIRECTION = 0xff
};
@ -1026,8 +1063,8 @@ xy_get_direction(double x, double y)
* d_8 = 8 * d_f
*/
r = atan2(y, x);
r = fmod(r + 2.5*M_PI, 2*M_PI);
r *= 4*M_1_PI;
r = fmod(r + 2.5 * M_PI, 2 * M_PI);
r *= 4 * M_1_PI;
/* Mark one or two close enough octants */
d1 = (int)(r + 0.9) % 8;
@ -1060,13 +1097,10 @@ device_float_get_direction(const struct device_float_coords coords)
* left edge but excluding the right edge.
*/
static inline bool
point_in_rect(const struct device_coords *point,
const struct device_coord_rect *rect)
point_in_rect(const struct device_coords *point, const struct device_coord_rect *rect)
{
return (point->x >= rect->x &&
point->x < rect->x + rect->w &&
point->y >= rect->y &&
point->y < rect->y + rect->h);
return (point->x >= rect->x && point->x < rect->x + rect->w &&
point->y >= rect->y && point->y < rect->y + rect->h);
}
#if HAVE_LIBWACOM
@ -1075,8 +1109,15 @@ libinput_libwacom_ref(struct libinput *li);
void
libinput_libwacom_unref(struct libinput *li);
#else
static inline void *libinput_libwacom_ref(struct libinput *li) { return NULL; }
static inline void libinput_libwacom_unref(struct libinput *li) {}
static inline void *
libinput_libwacom_ref(struct libinput *li)
{
return NULL;
}
static inline void
libinput_libwacom_unref(struct libinput *li)
{
}
#endif
#endif /* LIBINPUT_PRIVATE_H */

View file

@ -31,19 +31,19 @@
#warning "libinput relies on assert(). #defining NDEBUG is not recommended"
#endif
#include "libinput.h"
#include "util-bits.h"
#include "util-macros.h"
#include "util-list.h"
#include "util-macros.h"
#include "util-matrix.h"
#include "util-multivalue.h"
#include "util-strings.h"
#include "util-ratelimit.h"
#include "util-range.h"
#include "util-prop-parsers.h"
#include "util-time.h"
#include "util-mem.h"
#include "util-multivalue.h"
#include "util-prop-parsers.h"
#include "util-range.h"
#include "util-ratelimit.h"
#include "util-strings.h"
#include "util-time.h"
#include "libinput.h"
#define VENDOR_ID_APPLE 0x5ac
#define VENDOR_ID_CHICONY 0x4f2

View file

@ -25,8 +25,8 @@
#include "config.h"
#include <ctype.h>
#include <string.h>
#include <dirent.h>
#include <string.h>
#if !defined(HAVE_VERSIONSORT) || defined(TEST_VERSIONSORT)
static inline int
@ -39,23 +39,28 @@ libinput_strverscmp(const char *l0, const char *r0)
/* Find maximal matching prefix and track its maximal digit
* suffix and whether those digits are all zeros. */
for (dp=i=0; l[i]==r[i]; i++) {
for (dp = i = 0; l[i] == r[i]; i++) {
int c = l[i];
if (!c) return 0;
if (!isdigit(c)) dp=i+1, z=1;
else if (c!='0') z=0;
if (!c)
return 0;
if (!isdigit(c))
dp = i + 1, z = 1;
else if (c != '0')
z = 0;
}
if (l[dp]!='0' && r[dp]!='0') {
if (l[dp] != '0' && r[dp] != '0') {
/* If we're not looking at a digit sequence that began
* with a zero, longest digit string is greater. */
for (j=i; isdigit(l[j]); j++)
if (!isdigit(r[j])) return 1;
if (isdigit(r[j])) return -1;
} else if (z && dp<i && (isdigit(l[i]) || isdigit(r[i]))) {
for (j = i; isdigit(l[j]); j++)
if (!isdigit(r[j]))
return 1;
if (isdigit(r[j]))
return -1;
} else if (z && dp < i && (isdigit(l[i]) || isdigit(r[i]))) {
/* Otherwise, if common prefix of digit sequence is
* all zeros, digits order less than non-digits. */
return (unsigned char)(l[i]-'0') - (unsigned char)(r[i]-'0');
return (unsigned char)(l[i] - '0') - (unsigned char)(r[i] - '0');
}
return l[i] - r[i];

File diff suppressed because it is too large Load diff

View file

@ -29,10 +29,10 @@
extern "C" {
#endif
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <libudev.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#define LIBINPUT_ATTRIBUTE_PRINTF(_format, _args) \
__attribute__ ((format (printf, _format, _args)))
@ -346,17 +346,17 @@ enum libinput_tablet_pad_strip_axis_source {
* @since 1.2
*/
enum libinput_tablet_tool_type {
LIBINPUT_TABLET_TOOL_TYPE_PEN = 1, /**< A generic pen */
LIBINPUT_TABLET_TOOL_TYPE_ERASER, /**< Eraser */
LIBINPUT_TABLET_TOOL_TYPE_BRUSH, /**< A paintbrush-like tool */
LIBINPUT_TABLET_TOOL_TYPE_PENCIL, /**< Physical drawing tool, e.g.
Wacom Inking Pen */
LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH, /**< An airbrush-like tool */
LIBINPUT_TABLET_TOOL_TYPE_MOUSE, /**< A mouse bound to the tablet */
LIBINPUT_TABLET_TOOL_TYPE_LENS, /**< A mouse tool with a lens */
LIBINPUT_TABLET_TOOL_TYPE_TOTEM, /**< A rotary device with
positional and rotation
data */
LIBINPUT_TABLET_TOOL_TYPE_PEN = 1, /**< A generic pen */
LIBINPUT_TABLET_TOOL_TYPE_ERASER, /**< Eraser */
LIBINPUT_TABLET_TOOL_TYPE_BRUSH, /**< A paintbrush-like tool */
LIBINPUT_TABLET_TOOL_TYPE_PENCIL, /**< Physical drawing tool, e.g.
Wacom Inking Pen */
LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH, /**< An airbrush-like tool */
LIBINPUT_TABLET_TOOL_TYPE_MOUSE, /**< A mouse bound to the tablet */
LIBINPUT_TABLET_TOOL_TYPE_LENS, /**< A mouse tool with a lens */
LIBINPUT_TABLET_TOOL_TYPE_TOTEM, /**< A rotary device with
positional and rotation
data */
};
/**
@ -466,7 +466,7 @@ libinput_device_tablet_pad_get_num_mode_groups(struct libinput_device *device);
*
* @since 1.4
*/
struct libinput_tablet_pad_mode_group*
struct libinput_tablet_pad_mode_group *
libinput_device_tablet_pad_get_mode_group(struct libinput_device *device,
unsigned int index);
@ -503,7 +503,8 @@ libinput_tablet_pad_mode_group_get_index(struct libinput_tablet_pad_mode_group *
* @since 1.4
*/
unsigned int
libinput_tablet_pad_mode_group_get_num_modes(struct libinput_tablet_pad_mode_group *group);
libinput_tablet_pad_mode_group_get_num_modes(
struct libinput_tablet_pad_mode_group *group);
/**
* @ingroup tablet_pad_modes
@ -573,7 +574,7 @@ libinput_tablet_pad_mode_group_has_dial(struct libinput_tablet_pad_mode_group *g
*/
int
libinput_tablet_pad_mode_group_has_ring(struct libinput_tablet_pad_mode_group *group,
unsigned int ring);
unsigned int ring);
/**
* @ingroup tablet_pad_modes
@ -589,7 +590,7 @@ libinput_tablet_pad_mode_group_has_ring(struct libinput_tablet_pad_mode_group *g
*/
int
libinput_tablet_pad_mode_group_has_strip(struct libinput_tablet_pad_mode_group *group,
unsigned int strip);
unsigned int strip);
/**
* @ingroup tablet_pad_modes
@ -610,8 +611,9 @@ libinput_tablet_pad_mode_group_has_strip(struct libinput_tablet_pad_mode_group *
* @since 1.4
*/
int
libinput_tablet_pad_mode_group_button_is_toggle(struct libinput_tablet_pad_mode_group *group,
unsigned int button);
libinput_tablet_pad_mode_group_button_is_toggle(
struct libinput_tablet_pad_mode_group *group,
unsigned int button);
/**
* @ingroup tablet_pad_modes
@ -625,8 +627,7 @@ libinput_tablet_pad_mode_group_button_is_toggle(struct libinput_tablet_pad_mode_
* @since 1.4
*/
struct libinput_tablet_pad_mode_group *
libinput_tablet_pad_mode_group_ref(
struct libinput_tablet_pad_mode_group *group);
libinput_tablet_pad_mode_group_ref(struct libinput_tablet_pad_mode_group *group);
/**
* @ingroup tablet_pad_modes
@ -640,8 +641,7 @@ libinput_tablet_pad_mode_group_ref(
* @since 1.4
*/
struct libinput_tablet_pad_mode_group *
libinput_tablet_pad_mode_group_unref(
struct libinput_tablet_pad_mode_group *group);
libinput_tablet_pad_mode_group_unref(struct libinput_tablet_pad_mode_group *group);
/**
* @ingroup tablet_pad_modes
@ -658,8 +658,8 @@ libinput_tablet_pad_mode_group_unref(
*/
void
libinput_tablet_pad_mode_group_set_user_data(
struct libinput_tablet_pad_mode_group *group,
void *user_data);
struct libinput_tablet_pad_mode_group *group,
void *user_data);
/**
* @ingroup tablet_pad_modes
@ -674,7 +674,7 @@ libinput_tablet_pad_mode_group_set_user_data(
*/
void *
libinput_tablet_pad_mode_group_get_user_data(
struct libinput_tablet_pad_mode_group *group);
struct libinput_tablet_pad_mode_group *group);
/**
* @ingroup device
@ -881,8 +881,8 @@ enum libinput_event_type {
* with @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS events.
*
* Some tools may always be in proximity. For these tools, events of
* type @ref LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN are sent only once after @ref
* LIBINPUT_EVENT_DEVICE_ADDED, and events of type @ref
* type @ref LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN are sent only once after
* @ref LIBINPUT_EVENT_DEVICE_ADDED, and events of type @ref
* LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT are sent only once before @ref
* LIBINPUT_EVENT_DEVICE_REMOVED.
*
@ -1260,8 +1260,7 @@ libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event);
* @return The seat wide pressed key count for the key of this event
*/
uint32_t
libinput_event_keyboard_get_seat_key_count(
struct libinput_event_keyboard *event);
libinput_event_keyboard_get_seat_key_count(struct libinput_event_keyboard *event);
/**
* @defgroup event_pointer Pointer events
@ -1356,8 +1355,7 @@ libinput_event_pointer_get_dy(struct libinput_event_pointer *event);
* @return The unaccelerated relative x movement since the last event
*/
double
libinput_event_pointer_get_dx_unaccelerated(
struct libinput_event_pointer *event);
libinput_event_pointer_get_dx_unaccelerated(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
@ -1381,8 +1379,7 @@ libinput_event_pointer_get_dx_unaccelerated(
* @return The unaccelerated relative y movement since the last event
*/
double
libinput_event_pointer_get_dy_unaccelerated(
struct libinput_event_pointer *event);
libinput_event_pointer_get_dy_unaccelerated(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
@ -1438,9 +1435,8 @@ libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event);
* @return The current absolute x coordinate transformed to a screen coordinate
*/
double
libinput_event_pointer_get_absolute_x_transformed(
struct libinput_event_pointer *event,
uint32_t width);
libinput_event_pointer_get_absolute_x_transformed(struct libinput_event_pointer *event,
uint32_t width);
/**
* @ingroup event_pointer
@ -1460,9 +1456,8 @@ libinput_event_pointer_get_absolute_x_transformed(
* @return The current absolute y coordinate transformed to a screen coordinate
*/
double
libinput_event_pointer_get_absolute_y_transformed(
struct libinput_event_pointer *event,
uint32_t height);
libinput_event_pointer_get_absolute_y_transformed(struct libinput_event_pointer *event,
uint32_t height);
/**
* @ingroup event_pointer
@ -1508,8 +1503,7 @@ libinput_event_pointer_get_button_state(struct libinput_event_pointer *event);
* @return The seat wide pressed button count for the key of this event
*/
uint32_t
libinput_event_pointer_get_seat_button_count(
struct libinput_event_pointer *event);
libinput_event_pointer_get_seat_button_count(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
@ -2039,8 +2033,7 @@ libinput_event_gesture_get_dy(struct libinput_event_gesture *event);
* @return the unaccelerated relative x movement since the last event
*/
double
libinput_event_gesture_get_dx_unaccelerated(
struct libinput_event_gesture *event);
libinput_event_gesture_get_dx_unaccelerated(struct libinput_event_gesture *event);
/**
* @ingroup event_gesture
@ -2061,8 +2054,7 @@ libinput_event_gesture_get_dx_unaccelerated(
* @return the unaccelerated relative y movement since the last event
*/
double
libinput_event_gesture_get_dy_unaccelerated(
struct libinput_event_gesture *event);
libinput_event_gesture_get_dy_unaccelerated(struct libinput_event_gesture *event);
/**
* @ingroup event_gesture
@ -2164,8 +2156,7 @@ libinput_event_tablet_tool_get_base_event(struct libinput_event_tablet_tool *eve
* @since 1.2
*/
int
libinput_event_tablet_tool_x_has_changed(
struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_x_has_changed(struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2187,8 +2178,7 @@ libinput_event_tablet_tool_x_has_changed(
* @since 1.2
*/
int
libinput_event_tablet_tool_y_has_changed(
struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_y_has_changed(struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2211,7 +2201,7 @@ libinput_event_tablet_tool_y_has_changed(
*/
int
libinput_event_tablet_tool_pressure_has_changed(
struct libinput_event_tablet_tool *event);
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2236,7 +2226,7 @@ libinput_event_tablet_tool_pressure_has_changed(
*/
int
libinput_event_tablet_tool_distance_has_changed(
struct libinput_event_tablet_tool *event);
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2258,8 +2248,7 @@ libinput_event_tablet_tool_distance_has_changed(
* @since 1.2
*/
int
libinput_event_tablet_tool_tilt_x_has_changed(
struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_tilt_x_has_changed(struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2281,8 +2270,7 @@ libinput_event_tablet_tool_tilt_x_has_changed(
* @since 1.2
*/
int
libinput_event_tablet_tool_tilt_y_has_changed(
struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_tilt_y_has_changed(struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
@ -2304,7 +2292,7 @@ libinput_event_tablet_tool_tilt_y_has_changed(
*/
int
libinput_event_tablet_tool_rotation_has_changed(
struct libinput_event_tablet_tool *event);
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
@ -2325,8 +2313,7 @@ libinput_event_tablet_tool_rotation_has_changed(
* @since 1.2
*/
int
libinput_event_tablet_tool_slider_has_changed(
struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_slider_has_changed(struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2347,7 +2334,7 @@ libinput_event_tablet_tool_slider_has_changed(
*/
int
libinput_event_tablet_tool_size_major_has_changed(
struct libinput_event_tablet_tool *event);
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2368,7 +2355,7 @@ libinput_event_tablet_tool_size_major_has_changed(
*/
int
libinput_event_tablet_tool_size_minor_has_changed(
struct libinput_event_tablet_tool *event);
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2390,8 +2377,7 @@ libinput_event_tablet_tool_size_minor_has_changed(
* @since 1.2
*/
int
libinput_event_tablet_tool_wheel_has_changed(
struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_wheel_has_changed(struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2587,7 +2573,8 @@ libinput_event_tablet_tool_get_rotation(struct libinput_event_tablet_tool *event
* @since 1.2
*/
double
libinput_event_tablet_tool_get_slider_position(struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_get_slider_position(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2636,8 +2623,7 @@ libinput_event_tablet_tool_get_size_minor(struct libinput_event_tablet_tool *eve
* @see libinput_event_tablet_tool_get_wheel_delta_discrete
*/
double
libinput_event_tablet_tool_get_wheel_delta(
struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_get_wheel_delta(struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2653,7 +2639,7 @@ libinput_event_tablet_tool_get_wheel_delta(
*/
int
libinput_event_tablet_tool_get_wheel_delta_discrete(
struct libinput_event_tablet_tool *event);
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2713,7 +2699,7 @@ libinput_event_tablet_tool_get_y_transformed(struct libinput_event_tablet_tool *
*
* If the caller holds at least one reference, this struct is used
* whenever the tools enters proximity again.
*
*
* @note Physical tool tracking requires hardware support. If unavailable,
* libinput creates one tool per type per tablet. See
* libinput_tablet_tool_get_serial() for more details.
@ -2753,7 +2739,8 @@ libinput_event_tablet_tool_get_tool(struct libinput_event_tablet_tool *event);
* @since 1.2
*/
enum libinput_tablet_tool_proximity_state
libinput_event_tablet_tool_get_proximity_state(struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_get_proximity_state(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -2820,7 +2807,8 @@ libinput_event_tablet_tool_get_button_state(struct libinput_event_tablet_tool *e
* @since 1.2
*/
uint32_t
libinput_event_tablet_tool_get_seat_button_count(struct libinput_event_tablet_tool *event);
libinput_event_tablet_tool_get_seat_button_count(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
@ -3037,8 +3025,7 @@ libinput_tablet_tool_has_wheel(struct libinput_tablet_tool *tool);
* @since 1.2
*/
int
libinput_tablet_tool_has_button(struct libinput_tablet_tool *tool,
uint32_t code);
libinput_tablet_tool_has_button(struct libinput_tablet_tool *tool, uint32_t code);
/**
* @ingroup event_tablet
@ -3124,8 +3111,7 @@ libinput_tablet_tool_get_user_data(struct libinput_tablet_tool *tool);
* @since 1.2
*/
void
libinput_tablet_tool_set_user_data(struct libinput_tablet_tool *tool,
void *user_data);
libinput_tablet_tool_set_user_data(struct libinput_tablet_tool *tool, void *user_data);
/**
* @defgroup event_tablet_pad Tablet pad events
@ -3635,8 +3621,7 @@ libinput_udev_create_context(const struct libinput_interface *interface,
* @return 0 on success or -1 on failure.
*/
int
libinput_udev_assign_seat(struct libinput *libinput,
const char *seat_id);
libinput_udev_assign_seat(struct libinput *libinput, const char *seat_id);
/**
* @ingroup base
@ -3682,8 +3667,7 @@ libinput_path_create_context(const struct libinput_interface *interface,
* context initialized with libinput_udev_create_context().
*/
struct libinput_device *
libinput_path_add_device(struct libinput *libinput,
const char *path);
libinput_path_add_device(struct libinput *libinput, const char *path);
/**
* @ingroup base
@ -3777,8 +3761,7 @@ libinput_next_event_type(struct libinput *libinput);
* interfaces.
*/
void
libinput_set_user_data(struct libinput *libinput,
void *user_data);
libinput_set_user_data(struct libinput *libinput, void *user_data);
/**
* @ingroup base
@ -3917,8 +3900,8 @@ libinput_log_get_priority(const struct libinput *libinput);
*/
typedef void (*libinput_log_handler)(struct libinput *libinput,
enum libinput_log_priority priority,
const char *format, va_list args)
LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
const char *format,
va_list args) LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
/**
* @ingroup base
@ -3936,8 +3919,7 @@ typedef void (*libinput_log_handler)(struct libinput *libinput,
* @see libinput_log_get_priority
*/
void
libinput_log_set_handler(struct libinput *libinput,
libinput_log_handler log_handler);
libinput_log_set_handler(struct libinput *libinput, libinput_log_handler log_handler);
/**
* @defgroup seat Initialization and manipulation of seats
@ -4313,8 +4295,7 @@ libinput_device_get_seat(struct libinput_device *device);
* @return 0 on success, non-zero on error
*/
int
libinput_device_set_seat_logical_name(struct libinput_device *device,
const char *name);
libinput_device_set_seat_logical_name(struct libinput_device *device, const char *name);
/**
* @ingroup device
@ -4349,8 +4330,7 @@ libinput_device_get_udev_device(struct libinput_device *device);
* @param leds A mask of the LEDs to set, or unset.
*/
void
libinput_device_led_update(struct libinput_device *device,
enum libinput_led leds);
libinput_device_led_update(struct libinput_device *device, enum libinput_led leds);
/**
* @ingroup device
@ -4378,9 +4358,7 @@ libinput_device_has_capability(struct libinput_device *device,
* @return 0 on success, or nonzero otherwise
*/
int
libinput_device_get_size(struct libinput_device *device,
double *width,
double *height);
libinput_device_get_size(struct libinput_device *device, double *width, double *height);
/**
* @ingroup device
@ -4410,8 +4388,7 @@ libinput_device_pointer_has_button(struct libinput_device *device, uint32_t code
* on error.
*/
int
libinput_device_keyboard_has_key(struct libinput_device *device,
uint32_t code);
libinput_device_keyboard_has_key(struct libinput_device *device, uint32_t code);
/**
* @ingroup device
@ -4530,8 +4507,7 @@ libinput_device_tablet_pad_get_num_strips(struct libinput_device *device);
* @since 1.15
*/
int
libinput_device_tablet_pad_has_key(struct libinput_device *device,
uint32_t code);
libinput_device_tablet_pad_has_key(struct libinput_device *device, uint32_t code);
/**
* @ingroup device
@ -4644,10 +4620,10 @@ libinput_device_group_get_user_data(struct libinput_device_group *group);
* Status codes returned when applying configuration settings.
*/
enum libinput_config_status {
LIBINPUT_CONFIG_STATUS_SUCCESS = 0, /**< Config applied successfully */
LIBINPUT_CONFIG_STATUS_UNSUPPORTED, /**< Configuration not available on
this device */
LIBINPUT_CONFIG_STATUS_INVALID, /**< Invalid parameter range */
LIBINPUT_CONFIG_STATUS_SUCCESS = 0, /**< Config applied successfully */
LIBINPUT_CONFIG_STATUS_UNSUPPORTED, /**< Configuration not available on
this device */
LIBINPUT_CONFIG_STATUS_INVALID, /**< Invalid parameter range */
};
/**
@ -4668,8 +4644,8 @@ libinput_config_status_to_str(enum libinput_config_status status);
enum libinput_config_tap_state {
LIBINPUT_CONFIG_TAP_DISABLED, /**< Tapping is to be disabled, or is
currently disabled */
LIBINPUT_CONFIG_TAP_ENABLED, /**< Tapping is to be enabled, or is
currently enabled */
LIBINPUT_CONFIG_TAP_ENABLED, /**< Tapping is to be enabled, or is
currently enabled */
};
/**
@ -4804,7 +4780,7 @@ enum libinput_config_clickfinger_button_map {
*/
enum libinput_config_status
libinput_device_config_tap_set_button_map(struct libinput_device *device,
enum libinput_config_tap_button_map map);
enum libinput_config_tap_button_map map);
/**
* @ingroup config
@ -4973,8 +4949,9 @@ enum libinput_config_drag_lock_state {
* @see libinput_device_config_tap_get_default_drag_lock_enabled
*/
enum libinput_config_status
libinput_device_config_tap_set_drag_lock_enabled(struct libinput_device *device,
enum libinput_config_drag_lock_state enable);
libinput_device_config_tap_set_drag_lock_enabled(
struct libinput_device *device,
enum libinput_config_drag_lock_state enable);
/**
* @ingroup config
@ -5022,7 +4999,8 @@ libinput_device_config_tap_get_drag_lock_enabled(struct libinput_device *device)
* @see libinput_device_config_tap_get_drag_lock_enabled
*/
enum libinput_config_drag_lock_state
libinput_device_config_tap_get_default_drag_lock_enabled(struct libinput_device *device);
libinput_device_config_tap_get_default_drag_lock_enabled(
struct libinput_device *device);
/**
* @ingroup config
@ -5329,8 +5307,9 @@ libinput_device_config_area_has_rectangle(struct libinput_device *device);
* @see libinput_device_config_area_get_default_rectangle
*/
enum libinput_config_status
libinput_device_config_area_set_rectangle(struct libinput_device *device,
const struct libinput_config_area_rectangle *rect);
libinput_device_config_area_set_rectangle(
struct libinput_device *device,
const struct libinput_config_area_rectangle *rect);
/**
* @ingroup config
@ -5533,8 +5512,7 @@ libinput_device_config_accel_is_available(struct libinput_device *device);
* @see libinput_device_config_accel_get_default_speed
*/
enum libinput_config_status
libinput_device_config_accel_set_speed(struct libinput_device *device,
double speed);
libinput_device_config_accel_set_speed(struct libinput_device *device, double speed);
/**
* @ingroup config
@ -5902,7 +5880,8 @@ libinput_device_config_scroll_set_natural_scroll_enabled(struct libinput_device
* @see libinput_device_config_scroll_get_default_natural_scroll_enabled
*/
int
libinput_device_config_scroll_get_natural_scroll_enabled(struct libinput_device *device);
libinput_device_config_scroll_get_natural_scroll_enabled(
struct libinput_device *device);
/**
* @ingroup config
@ -5918,7 +5897,8 @@ libinput_device_config_scroll_get_natural_scroll_enabled(struct libinput_device
* @see libinput_device_config_scroll_get_natural_scroll_enabled
*/
int
libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput_device *device);
libinput_device_config_scroll_get_default_natural_scroll_enabled(
struct libinput_device *device);
/**
* @ingroup config
@ -5960,8 +5940,7 @@ libinput_device_config_left_handed_is_available(struct libinput_device *device);
* @see libinput_device_config_left_handed_get_default
*/
enum libinput_config_status
libinput_device_config_left_handed_set(struct libinput_device *device,
int left_handed);
libinput_device_config_left_handed_set(struct libinput_device *device, int left_handed);
/**
* @ingroup config
@ -6120,8 +6099,9 @@ libinput_device_config_click_get_default_method(struct libinput_device *device);
* @see libinput_device_config_click_get_default_clickfinger_button_map
*/
enum libinput_config_status
libinput_device_config_click_set_clickfinger_button_map(struct libinput_device *device,
enum libinput_config_clickfinger_button_map map);
libinput_device_config_click_set_clickfinger_button_map(
struct libinput_device *device,
enum libinput_config_clickfinger_button_map map);
/**
* @ingroup config
@ -6155,7 +6135,8 @@ libinput_device_config_click_get_clickfinger_button_map(struct libinput_device *
* @see libinput_device_config_click_get_clickfinger_button_map
*/
enum libinput_config_clickfinger_button_map
libinput_device_config_click_get_default_clickfinger_button_map(struct libinput_device *device);
libinput_device_config_click_get_default_clickfinger_button_map(
struct libinput_device *device);
/**
* @ingroup config
@ -6194,8 +6175,7 @@ enum libinput_config_middle_emulation_state {
* @see libinput_device_config_middle_emulation_get_default_enabled
*/
int
libinput_device_config_middle_emulation_is_available(
struct libinput_device *device);
libinput_device_config_middle_emulation_is_available(struct libinput_device *device);
/**
* @ingroup config
@ -6221,8 +6201,8 @@ libinput_device_config_middle_emulation_is_available(
*/
enum libinput_config_status
libinput_device_config_middle_emulation_set_enabled(
struct libinput_device *device,
enum libinput_config_middle_emulation_state enable);
struct libinput_device *device,
enum libinput_config_middle_emulation_state enable);
/**
* @ingroup config
@ -6248,8 +6228,7 @@ libinput_device_config_middle_emulation_set_enabled(
* @see libinput_device_config_middle_emulation_get_default_enabled
*/
enum libinput_config_middle_emulation_state
libinput_device_config_middle_emulation_get_enabled(
struct libinput_device *device);
libinput_device_config_middle_emulation_get_enabled(struct libinput_device *device);
/**
* @ingroup config
@ -6277,7 +6256,7 @@ libinput_device_config_middle_emulation_get_enabled(
*/
enum libinput_config_middle_emulation_state
libinput_device_config_middle_emulation_get_default_enabled(
struct libinput_device *device);
struct libinput_device *device);
/**
* @ingroup config
@ -6510,8 +6489,9 @@ enum libinput_config_scroll_button_lock_state {
* @see libinput_device_config_scroll_get_default_button
*/
enum libinput_config_status
libinput_device_config_scroll_set_button_lock(struct libinput_device *device,
enum libinput_config_scroll_button_lock_state state);
libinput_device_config_scroll_set_button_lock(
struct libinput_device *device,
enum libinput_config_scroll_button_lock_state state);
/**
* @ingroup config
@ -6705,7 +6685,7 @@ libinput_device_config_dwtp_is_available(struct libinput_device *device);
*/
enum libinput_config_status
libinput_device_config_dwtp_set_enabled(struct libinput_device *device,
enum libinput_config_dwtp_state enable);
enum libinput_config_dwtp_state enable);
/**
* @ingroup config
@ -6850,7 +6830,8 @@ libinput_device_config_rotation_get_default_angle(struct libinput_device *device
* @since 1.26
*/
int
libinput_tablet_tool_config_pressure_range_is_available(struct libinput_tablet_tool *tool);
libinput_tablet_tool_config_pressure_range_is_available(
struct libinput_tablet_tool *tool);
/**
* @ingroup config
@ -6905,7 +6886,8 @@ libinput_tablet_tool_config_pressure_range_set(struct libinput_tablet_tool *tool
* @since 1.26
*/
double
libinput_tablet_tool_config_pressure_range_get_minimum(struct libinput_tablet_tool *tool);
libinput_tablet_tool_config_pressure_range_get_minimum(
struct libinput_tablet_tool *tool);
/**
* @ingroup config
@ -6927,7 +6909,8 @@ libinput_tablet_tool_config_pressure_range_get_minimum(struct libinput_tablet_to
* @since 1.26
*/
double
libinput_tablet_tool_config_pressure_range_get_maximum(struct libinput_tablet_tool *tool);
libinput_tablet_tool_config_pressure_range_get_maximum(
struct libinput_tablet_tool *tool);
/**
* @ingroup config
@ -6949,7 +6932,8 @@ libinput_tablet_tool_config_pressure_range_get_maximum(struct libinput_tablet_to
* @since 1.26
*/
double
libinput_tablet_tool_config_pressure_range_get_default_minimum(struct libinput_tablet_tool *tool);
libinput_tablet_tool_config_pressure_range_get_default_minimum(
struct libinput_tablet_tool *tool);
/**
* @ingroup config
@ -6971,7 +6955,8 @@ libinput_tablet_tool_config_pressure_range_get_default_minimum(struct libinput_t
* @since 1.26
*/
double
libinput_tablet_tool_config_pressure_range_get_default_maximum(struct libinput_tablet_tool *tool);
libinput_tablet_tool_config_pressure_range_get_default_maximum(
struct libinput_tablet_tool *tool);
/**
* @ingroup config
@ -7051,8 +7036,9 @@ libinput_tablet_tool_config_eraser_button_get_modes(struct libinput_tablet_tool
* @since 1.29
*/
enum libinput_config_status
libinput_tablet_tool_config_eraser_button_set_mode(struct libinput_tablet_tool *tool,
enum libinput_config_eraser_button_mode mode);
libinput_tablet_tool_config_eraser_button_set_mode(
struct libinput_tablet_tool *tool,
enum libinput_config_eraser_button_mode mode);
/**
* @ingroup config
@ -7096,7 +7082,8 @@ libinput_tablet_tool_config_eraser_button_get_mode(struct libinput_tablet_tool *
* @since 1.29
*/
enum libinput_config_eraser_button_mode
libinput_tablet_tool_config_eraser_button_get_default_mode(struct libinput_tablet_tool *tool);
libinput_tablet_tool_config_eraser_button_get_default_mode(
struct libinput_tablet_tool *tool);
/**
* @ingroup config
@ -7173,7 +7160,8 @@ libinput_tablet_tool_config_eraser_button_get_button(struct libinput_tablet_tool
* @since 1.29
*/
unsigned int
libinput_tablet_tool_config_eraser_button_get_default_button(struct libinput_tablet_tool *tool);
libinput_tablet_tool_config_eraser_button_get_default_button(
struct libinput_tablet_tool *tool);
#ifdef __cplusplus
}

View file

@ -23,9 +23,9 @@
#include "config.h"
#include <libudev.h>
#include <string.h>
#include <sys/stat.h>
#include <libudev.h>
#include "evdev.h"
@ -53,8 +53,7 @@ path_disable_device(struct evdev_device *device)
struct libinput_seat *seat = device->base.seat;
struct evdev_device *dev;
list_for_each_safe(dev,
&seat->devices_list, base.link) {
list_for_each_safe(dev, &seat->devices_list, base.link) {
if (dev != device)
continue;
@ -66,14 +65,13 @@ path_disable_device(struct evdev_device *device)
static void
path_input_disable(struct libinput *libinput)
{
struct path_input *input = (struct path_input*)libinput;
struct path_input *input = (struct path_input *)libinput;
struct path_seat *seat;
struct evdev_device *device;
list_for_each_safe(seat, &input->base.seat_list, base.link) {
libinput_seat_ref(&seat->base);
list_for_each_safe(device,
&seat->base.devices_list, base.link)
list_for_each_safe(device, &seat->base.devices_list, base.link)
path_disable_device(device);
libinput_seat_unref(&seat->base);
}
@ -82,11 +80,11 @@ path_input_disable(struct libinput *libinput)
static void
path_seat_destroy(struct libinput_seat *seat)
{
struct path_seat *pseat = (struct path_seat*)seat;
struct path_seat *pseat = (struct path_seat *)seat;
free(pseat);
}
static struct path_seat*
static struct path_seat *
path_seat_create(struct path_input *input,
const char *seat_name,
const char *seat_logical_name)
@ -95,13 +93,16 @@ path_seat_create(struct path_input *input,
seat = zalloc(sizeof(*seat));
libinput_seat_init(&seat->base, &input->base, seat_name,
seat_logical_name, path_seat_destroy);
libinput_seat_init(&seat->base,
&input->base,
seat_name,
seat_logical_name,
path_seat_destroy);
return seat;
}
static struct path_seat*
static struct path_seat *
path_seat_get_named(struct path_input *input,
const char *seat_name_physical,
const char *seat_name_logical)
@ -138,7 +139,8 @@ path_seat_get_for_device(struct path_input *input,
seat_logical_name = safe_strdup(seat_logical_name_override);
} else {
seat_prop = udev_device_get_property_value(udev_device, "WL_SEAT");
seat_logical_name = safe_strdup(seat_prop ? seat_prop : default_seat_name);
seat_logical_name =
safe_strdup(seat_prop ? seat_prop : default_seat_name);
}
if (!seat_logical_name) {
@ -215,7 +217,7 @@ out:
static int
path_input_enable(struct libinput *libinput)
{
struct path_input *input = (struct path_input*)libinput;
struct path_input *input = (struct path_input *)libinput;
struct path_device *dev;
list_for_each(dev, &input->path_list, link) {
@ -239,14 +241,13 @@ path_device_destroy(struct path_device *dev)
static void
path_input_destroy(struct libinput *input)
{
struct path_input *path_input = (struct path_input*)input;
struct path_input *path_input = (struct path_input *)input;
struct path_device *dev;
udev_unref(path_input->udev);
list_for_each_safe(dev, &path_input->path_list, link)
path_device_destroy(dev);
}
static struct libinput_device *
@ -254,7 +255,7 @@ path_create_device(struct libinput *libinput,
struct udev_device *udev_device,
const char *seat_name)
{
struct path_input *input = (struct path_input*)libinput;
struct path_input *input = (struct path_input *)libinput;
struct path_device *dev;
struct libinput_device *device;
@ -272,8 +273,7 @@ path_create_device(struct libinput *libinput,
}
static int
path_device_change_seat(struct libinput_device *device,
const char *seat_name)
path_device_change_seat(struct libinput_device *device, const char *seat_name)
{
struct libinput *libinput = device->seat->libinput;
struct evdev_device *evdev = evdev_device(device);
@ -311,8 +311,8 @@ libinput_path_create_context(const struct libinput_interface *interface,
return NULL;
input = zalloc(sizeof *input);
if (libinput_init(&input->base, interface,
&interface_backend, user_data) != 0) {
if (libinput_init(&input->base, interface, &interface_backend, user_data) !=
0) {
free(input);
return NULL;
}
@ -342,8 +342,8 @@ udev_device_from_devnode(struct libinput *libinput,
count++;
if (count > 200) {
log_bug_libinput(libinput,
"udev device never initialized (%s)\n",
devnode);
"udev device never initialized (%s)\n",
devnode);
return NULL;
}
msleep(10);
@ -354,8 +354,7 @@ udev_device_from_devnode(struct libinput *libinput,
}
LIBINPUT_EXPORT struct libinput_device *
libinput_path_add_device(struct libinput *libinput,
const char *path)
libinput_path_add_device(struct libinput *libinput, const char *path)
{
struct path_input *input = (struct path_input *)libinput;
struct udev *udev = input->udev;
@ -373,7 +372,8 @@ libinput_path_add_device(struct libinput *libinput,
return NULL;
}
_unref_(udev_device) *udev_device = udev_device_from_devnode(libinput, udev, path);
_unref_(udev_device) *udev_device =
udev_device_from_devnode(libinput, udev, path);
if (!udev_device) {
log_bug_client(libinput, "Invalid path %s\n", path);
return NULL;
@ -401,7 +401,7 @@ LIBINPUT_EXPORT void
libinput_path_remove_device(struct libinput_device *device)
{
struct libinput *libinput = device->seat->libinput;
struct path_input *input = (struct path_input*)libinput;
struct path_input *input = (struct path_input *)libinput;
struct libinput_seat *seat;
struct evdev_device *evdev = evdev_device(device);
struct path_device *dev;

View file

@ -30,18 +30,17 @@
#undef NDEBUG /* You don't get to disable asserts here */
#include <assert.h>
#include <stdlib.h>
#include <libudev.h>
#include <dirent.h>
#include <fnmatch.h>
#include <libgen.h>
#include <libudev.h>
#include <stdlib.h>
#ifdef __FreeBSD__
#include <kenv.h>
#endif
#include "libinput-versionsort.h"
#include "libinput-util.h"
#include "libinput-versionsort.h"
#include "quirks.h"
/* Custom logging so we can have detailed output for the tool but minimal
@ -95,17 +94,17 @@ struct property {
};
enum match_flags {
M_NAME = bit(0),
M_BUS = bit(1),
M_VID = bit(2),
M_PID = bit(3),
M_DMI = bit(4),
M_UDEV_TYPE = bit(5),
M_DT = bit(6),
M_VERSION = bit(7),
M_UNIQ = bit(8),
M_NAME = bit(0),
M_BUS = bit(1),
M_VID = bit(2),
M_PID = bit(3),
M_DMI = bit(4),
M_UDEV_TYPE = bit(5),
M_DT = bit(6),
M_VERSION = bit(7),
M_UNIQ = bit(8),
M_LAST = M_UNIQ,
M_LAST = M_UNIQ,
};
enum bustype {
@ -119,13 +118,13 @@ enum bustype {
};
enum udev_type {
UDEV_MOUSE = bit(1),
UDEV_POINTINGSTICK = bit(2),
UDEV_TOUCHPAD = bit(3),
UDEV_TABLET = bit(4),
UDEV_TABLET_PAD = bit(5),
UDEV_JOYSTICK = bit(6),
UDEV_KEYBOARD = bit(7),
UDEV_MOUSE = bit(1),
UDEV_POINTINGSTICK = bit(2),
UDEV_TOUCHPAD = bit(3),
UDEV_TABLET = bit(4),
UDEV_TABLET_PAD = bit(5),
UDEV_JOYSTICK = bit(6),
UDEV_KEYBOARD = bit(7),
};
/**
@ -144,12 +143,12 @@ struct match {
uint32_t product[64]; /* zero-terminated */
uint32_t version;
char *dmi; /* dmi modalias with preceding "dmi:" */
char *dmi; /* dmi modalias with preceding "dmi:" */
/* We can have more than one type set, so this is a bitfield */
uint32_t udev_type;
char *dt; /* device tree compatible (first) string */
char *dt; /* device tree compatible (first) string */
};
/**
@ -158,10 +157,10 @@ struct match {
struct section {
struct list link;
bool has_match; /* to check for empty sections */
bool has_property; /* to check for empty sections */
bool has_match; /* to check for empty sections */
bool has_property; /* to check for empty sections */
char *name; /* the [Section Name] */
char *name; /* the [Section Name] */
struct match match;
struct list properties;
};
@ -241,58 +240,101 @@ quirk_log_msg(struct quirks_context *ctx,
va_start(args, format);
quirk_log_msg_va(ctx, priority, format, args);
va_end(args);
}
const char *
quirk_get_name(enum quirk q)
{
switch(q) {
case QUIRK_MODEL_ALPS_SERIAL_TOUCHPAD: return "ModelALPSSerialTouchpad";
case QUIRK_MODEL_APPLE_TOUCHPAD: return "ModelAppleTouchpad";
case QUIRK_MODEL_APPLE_TOUCHPAD_ONEBUTTON: return "ModelAppleTouchpadOneButton";
case QUIRK_MODEL_BOUNCING_KEYS: return "ModelBouncingKeys";
case QUIRK_MODEL_CHROMEBOOK: return "ModelChromebook";
case QUIRK_MODEL_CLEVO_W740SU: return "ModelClevoW740SU";
case QUIRK_MODEL_DELL_CANVAS_TOTEM: return "ModelDellCanvasTotem";
case QUIRK_MODEL_HP_PAVILION_DM4_TOUCHPAD: return "ModelHPPavilionDM4Touchpad";
case QUIRK_MODEL_HP_ZBOOK_STUDIO_G3: return "ModelHPZBookStudioG3";
case QUIRK_MODEL_INVERT_HORIZONTAL_SCROLLING: return "ModelInvertHorizontalScrolling";
case QUIRK_MODEL_LENOVO_SCROLLPOINT: return "ModelLenovoScrollPoint";
case QUIRK_MODEL_LENOVO_T450_TOUCHPAD: return "ModelLenovoT450Touchpad";
case QUIRK_MODEL_LENOVO_X1GEN6_TOUCHPAD: return "ModelLenovoX1Gen6Touchpad";
case QUIRK_MODEL_LENOVO_X230: return "ModelLenovoX230";
case QUIRK_MODEL_SYNAPTICS_SERIAL_TOUCHPAD: return "ModelSynapticsSerialTouchpad";
case QUIRK_MODEL_SYSTEM76_BONOBO: return "ModelSystem76Bonobo";
case QUIRK_MODEL_SYSTEM76_GALAGO: return "ModelSystem76Galago";
case QUIRK_MODEL_SYSTEM76_KUDU: return "ModelSystem76Kudu";
case QUIRK_MODEL_TABLET_MODE_NO_SUSPEND: return "ModelTabletModeNoSuspend";
case QUIRK_MODEL_TABLET_MODE_SWITCH_UNRELIABLE: return "ModelTabletModeSwitchUnreliable";
case QUIRK_MODEL_TOUCHPAD_VISIBLE_MARKER: return "ModelTouchpadVisibleMarker";
case QUIRK_MODEL_TOUCHPAD_PHANTOM_CLICKS: return "ModelTouchpadPhantomClicks";
case QUIRK_MODEL_TRACKBALL: return "ModelTrackball";
case QUIRK_MODEL_WACOM_TOUCHPAD: return "ModelWacomTouchpad";
case QUIRK_MODEL_PRESSURE_PAD: return "ModelPressurePad";
switch (q) {
case QUIRK_MODEL_ALPS_SERIAL_TOUCHPAD:
return "ModelALPSSerialTouchpad";
case QUIRK_MODEL_APPLE_TOUCHPAD:
return "ModelAppleTouchpad";
case QUIRK_MODEL_APPLE_TOUCHPAD_ONEBUTTON:
return "ModelAppleTouchpadOneButton";
case QUIRK_MODEL_BOUNCING_KEYS:
return "ModelBouncingKeys";
case QUIRK_MODEL_CHROMEBOOK:
return "ModelChromebook";
case QUIRK_MODEL_CLEVO_W740SU:
return "ModelClevoW740SU";
case QUIRK_MODEL_DELL_CANVAS_TOTEM:
return "ModelDellCanvasTotem";
case QUIRK_MODEL_HP_PAVILION_DM4_TOUCHPAD:
return "ModelHPPavilionDM4Touchpad";
case QUIRK_MODEL_HP_ZBOOK_STUDIO_G3:
return "ModelHPZBookStudioG3";
case QUIRK_MODEL_INVERT_HORIZONTAL_SCROLLING:
return "ModelInvertHorizontalScrolling";
case QUIRK_MODEL_LENOVO_SCROLLPOINT:
return "ModelLenovoScrollPoint";
case QUIRK_MODEL_LENOVO_T450_TOUCHPAD:
return "ModelLenovoT450Touchpad";
case QUIRK_MODEL_LENOVO_X1GEN6_TOUCHPAD:
return "ModelLenovoX1Gen6Touchpad";
case QUIRK_MODEL_LENOVO_X230:
return "ModelLenovoX230";
case QUIRK_MODEL_SYNAPTICS_SERIAL_TOUCHPAD:
return "ModelSynapticsSerialTouchpad";
case QUIRK_MODEL_SYSTEM76_BONOBO:
return "ModelSystem76Bonobo";
case QUIRK_MODEL_SYSTEM76_GALAGO:
return "ModelSystem76Galago";
case QUIRK_MODEL_SYSTEM76_KUDU:
return "ModelSystem76Kudu";
case QUIRK_MODEL_TABLET_MODE_NO_SUSPEND:
return "ModelTabletModeNoSuspend";
case QUIRK_MODEL_TABLET_MODE_SWITCH_UNRELIABLE:
return "ModelTabletModeSwitchUnreliable";
case QUIRK_MODEL_TOUCHPAD_VISIBLE_MARKER:
return "ModelTouchpadVisibleMarker";
case QUIRK_MODEL_TOUCHPAD_PHANTOM_CLICKS:
return "ModelTouchpadPhantomClicks";
case QUIRK_MODEL_TRACKBALL:
return "ModelTrackball";
case QUIRK_MODEL_WACOM_TOUCHPAD:
return "ModelWacomTouchpad";
case QUIRK_MODEL_PRESSURE_PAD:
return "ModelPressurePad";
case QUIRK_ATTR_SIZE_HINT: return "AttrSizeHint";
case QUIRK_ATTR_TOUCH_SIZE_RANGE: return "AttrTouchSizeRange";
case QUIRK_ATTR_PALM_SIZE_THRESHOLD: return "AttrPalmSizeThreshold";
case QUIRK_ATTR_LID_SWITCH_RELIABILITY: return "AttrLidSwitchReliability";
case QUIRK_ATTR_KEYBOARD_INTEGRATION: return "AttrKeyboardIntegration";
case QUIRK_ATTR_TRACKPOINT_INTEGRATION: return "AttrPointingStickIntegration";
case QUIRK_ATTR_TPKBCOMBO_LAYOUT: return "AttrTPKComboLayout";
case QUIRK_ATTR_PRESSURE_RANGE: return "AttrPressureRange";
case QUIRK_ATTR_PALM_PRESSURE_THRESHOLD: return "AttrPalmPressureThreshold";
case QUIRK_ATTR_RESOLUTION_HINT: return "AttrResolutionHint";
case QUIRK_ATTR_TRACKPOINT_MULTIPLIER: return "AttrTrackpointMultiplier";
case QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD: return "AttrThumbPressureThreshold";
case QUIRK_ATTR_USE_VELOCITY_AVERAGING: return "AttrUseVelocityAveraging";
case QUIRK_ATTR_TABLET_SMOOTHING: return "AttrTabletSmoothing";
case QUIRK_ATTR_THUMB_SIZE_THRESHOLD: return "AttrThumbSizeThreshold";
case QUIRK_ATTR_MSC_TIMESTAMP: return "AttrMscTimestamp";
case QUIRK_ATTR_EVENT_CODE: return "AttrEventCode";
case QUIRK_ATTR_INPUT_PROP: return "AttrInputProp";
case QUIRK_ATTR_IS_VIRTUAL: return "AttrIsVirtual";
case QUIRK_ATTR_SIZE_HINT:
return "AttrSizeHint";
case QUIRK_ATTR_TOUCH_SIZE_RANGE:
return "AttrTouchSizeRange";
case QUIRK_ATTR_PALM_SIZE_THRESHOLD:
return "AttrPalmSizeThreshold";
case QUIRK_ATTR_LID_SWITCH_RELIABILITY:
return "AttrLidSwitchReliability";
case QUIRK_ATTR_KEYBOARD_INTEGRATION:
return "AttrKeyboardIntegration";
case QUIRK_ATTR_TRACKPOINT_INTEGRATION:
return "AttrPointingStickIntegration";
case QUIRK_ATTR_TPKBCOMBO_LAYOUT:
return "AttrTPKComboLayout";
case QUIRK_ATTR_PRESSURE_RANGE:
return "AttrPressureRange";
case QUIRK_ATTR_PALM_PRESSURE_THRESHOLD:
return "AttrPalmPressureThreshold";
case QUIRK_ATTR_RESOLUTION_HINT:
return "AttrResolutionHint";
case QUIRK_ATTR_TRACKPOINT_MULTIPLIER:
return "AttrTrackpointMultiplier";
case QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD:
return "AttrThumbPressureThreshold";
case QUIRK_ATTR_USE_VELOCITY_AVERAGING:
return "AttrUseVelocityAveraging";
case QUIRK_ATTR_TABLET_SMOOTHING:
return "AttrTabletSmoothing";
case QUIRK_ATTR_THUMB_SIZE_THRESHOLD:
return "AttrThumbSizeThreshold";
case QUIRK_ATTR_MSC_TIMESTAMP:
return "AttrMscTimestamp";
case QUIRK_ATTR_EVENT_CODE:
return "AttrEventCode";
case QUIRK_ATTR_INPUT_PROP:
return "AttrInputProp";
case QUIRK_ATTR_IS_VIRTUAL:
return "AttrIsVirtual";
default:
abort();
}
@ -301,16 +343,34 @@ quirk_get_name(enum quirk q)
static inline const char *
matchflagname(enum match_flags f)
{
switch(f) {
case M_NAME: return "MatchName"; break;
case M_BUS: return "MatchBus"; break;
case M_VID: return "MatchVendor"; break;
case M_PID: return "MatchProduct"; break;
case M_VERSION: return "MatchVersion"; break;
case M_DMI: return "MatchDMIModalias"; break;
case M_UDEV_TYPE: return "MatchUdevType"; break;
case M_DT: return "MatchDeviceTree"; break;
case M_UNIQ: return "MatchUniq"; break;
switch (f) {
case M_NAME:
return "MatchName";
break;
case M_BUS:
return "MatchBus";
break;
case M_VID:
return "MatchVendor";
break;
case M_PID:
return "MatchProduct";
break;
case M_VERSION:
return "MatchVersion";
break;
case M_DMI:
return "MatchDMIModalias";
break;
case M_UDEV_TYPE:
return "MatchUdevType";
break;
case M_DT:
return "MatchDeviceTree";
break;
case M_UNIQ:
return "MatchUniq";
break;
default:
abort();
}
@ -382,8 +442,7 @@ init_dmi_linux(void)
udev_device = udev_device_new_from_syspath(udev, syspath);
if (udev_device)
modalias = udev_device_get_property_value(udev_device,
"MODALIAS");
modalias = udev_device_get_property_value(udev_device, "MODALIAS");
/* Not sure whether this could ever really fail, if so we should
* open the sysfs file directly. But then udev wouldn't have failed,
@ -441,11 +500,21 @@ init_dmi_freebsd(void)
else if (strcmp(chassis_type, "Detachable") == 0)
chassis_type_num = 0x20;
xasprintf(&modalias,
xasprintf(
&modalias,
"dmi:bvn%s:bvr%s:bd%s:svn%s:pn%s:pvr%s:rvn%s:rn%s:rvr%s:cvn%s:ct%d:cvr%s:",
bios_vendor, bios_version, bios_date, sys_vendor, product_name,
product_version, board_vendor, board_name, board_version, chassis_vendor,
chassis_type_num, chassis_version);
bios_vendor,
bios_version,
bios_date,
sys_vendor,
product_name,
product_version,
board_vendor,
board_name,
board_version,
chassis_vendor,
chassis_type_num,
chassis_version);
return modalias;
}
@ -532,10 +601,8 @@ section_destroy(struct section *s)
static inline bool
parse_hex(const char *value, unsigned int *parsed)
{
return strstartswith(value, "0x") &&
safe_atou_base(value, parsed, 16) &&
strspn(value, "0123456789xABCDEF") == strlen(value) &&
*parsed <= 0xFFFF;
return strstartswith(value, "0x") && safe_atou_base(value, parsed, 16) &&
strspn(value, "0123456789xABCDEF") == strlen(value) && *parsed <= 0xFFFF;
}
static int
@ -601,12 +668,15 @@ parse_match(struct quirks_context *ctx,
s->match.vendor = vendor;
} else if (streq(key, "MatchProduct")) {
unsigned int product[ARRAY_LENGTH(s->match.product)] = {0};
unsigned int product[ARRAY_LENGTH(s->match.product)] = { 0 };
const size_t max = ARRAY_LENGTH(s->match.product) - 1;
size_t nelems = 0;
char **strs = strv_from_string(value, ";", &nelems);
int rc = strv_for_each_n((const char**)strs, max, strv_parse_hex, product);
int rc = strv_for_each_n((const char **)strs,
max,
strv_parse_hex,
product);
strv_free(strs);
if (rc != 0)
goto out;
@ -689,8 +759,7 @@ parse_model(struct quirks_context *ctx,
do {
if (streq(key, quirk_get_name(q))) {
struct property *p = property_new();
p->id = q,
p->type = PT_BOOL;
p->id = q, p->type = PT_BOOL;
p->value.b = b;
list_append(&s->properties, &p->link);
s->has_property = true;
@ -751,8 +820,7 @@ parse_attr(struct quirks_context *ctx,
rc = true;
} else if (streq(key, quirk_get_name(QUIRK_ATTR_LID_SWITCH_RELIABILITY))) {
p->id = QUIRK_ATTR_LID_SWITCH_RELIABILITY;
if (!streq(value, "reliable") &&
!streq(value, "write_open") &&
if (!streq(value, "reliable") && !streq(value, "write_open") &&
!streq(value, "unreliable"))
goto out;
p->type = PT_STRING;
@ -848,8 +916,7 @@ parse_attr(struct quirks_context *ctx,
p->id = QUIRK_ATTR_EVENT_CODE;
if (!parse_evcode_property(value, events, &nevents) ||
nevents == 0)
if (!parse_evcode_property(value, events, &nevents) || nevents == 0)
goto out;
for (size_t i = 0; i < nevents; i++) {
@ -867,8 +934,7 @@ parse_attr(struct quirks_context *ctx,
p->id = QUIRK_ATTR_INPUT_PROP;
if (!parse_input_prop_property(value, props, &nprops) ||
nprops == 0)
if (!parse_input_prop_property(value, props, &nprops) || nprops == 0)
goto out;
for (size_t i = 0; i < nprops; i++) {
@ -1005,7 +1071,9 @@ parse_file(struct quirks_context *ctx, const char *path)
case '\t':
qlog_parser(ctx,
"%s:%d: Trailing whitespace '%s'\n",
path, lineno, line);
path,
lineno,
line);
goto out;
}
@ -1017,27 +1085,38 @@ parse_file(struct quirks_context *ctx, const char *path)
/* white space not allowed */
case ' ':
case '\t':
qlog_parser(ctx, "%s:%d: Preceding whitespace '%s'\n",
path, lineno, line);
qlog_parser(ctx,
"%s:%d: Preceding whitespace '%s'\n",
path,
lineno,
line);
goto out;
/* section title */
case '[':
if (line[strlen(line) - 1] != ']') {
qlog_parser(ctx, "%s:%d: Closing ] missing '%s'\n",
path, lineno, line);
qlog_parser(ctx,
"%s:%d: Closing ] missing '%s'\n",
path,
lineno,
line);
goto out;
}
if (state != STATE_SECTION &&
state != STATE_VALUE_OR_SECTION) {
qlog_parser(ctx, "%s:%d: expected section before %s\n",
path, lineno, line);
if (state != STATE_SECTION && state != STATE_VALUE_OR_SECTION) {
qlog_parser(ctx,
"%s:%d: expected section before %s\n",
path,
lineno,
line);
goto out;
}
if (section &&
(!section->has_match || !section->has_property)) {
qlog_parser(ctx, "%s:%d: previous section %s was empty\n",
path, lineno, section->name);
qlog_parser(ctx,
"%s:%d: previous section %s was empty\n",
path,
lineno,
section->name);
goto out; /* Previous section was empty */
}
@ -1048,19 +1127,29 @@ parse_file(struct quirks_context *ctx, const char *path)
default:
/* entries must start with A-Z */
if (line[0] < 'A' || line[0] > 'Z') {
qlog_parser(ctx, "%s:%d: Unexpected line %s\n",
path, lineno, line);
qlog_parser(ctx,
"%s:%d: Unexpected line %s\n",
path,
lineno,
line);
goto out;
}
switch (state) {
case STATE_SECTION:
qlog_parser(ctx, "%s:%d: expected [Section], got %s\n",
path, lineno, line);
qlog_parser(ctx,
"%s:%d: expected [Section], got %s\n",
path,
lineno,
line);
goto out;
case STATE_MATCH:
if (!strstartswith(line, "Match")) {
qlog_parser(ctx, "%s:%d: expected MatchFoo=bar, have %s\n",
path, lineno, line);
qlog_parser(
ctx,
"%s:%d: expected MatchFoo=bar, have %s\n",
path,
lineno,
line);
goto out;
}
state = STATE_MATCH_OR_VALUE;
@ -1071,8 +1160,12 @@ parse_file(struct quirks_context *ctx, const char *path)
break;
case STATE_VALUE_OR_SECTION:
if (strstartswith(line, "Match")) {
qlog_parser(ctx, "%s:%d: expected value or [Section], have %s\n",
path, lineno, line);
qlog_parser(
ctx,
"%s:%d: expected value or [Section], have %s\n",
path,
lineno,
line);
goto out;
}
break;
@ -1081,8 +1174,11 @@ parse_file(struct quirks_context *ctx, const char *path)
}
if (!parse_value_line(ctx, section, line)) {
qlog_parser(ctx, "%s:%d: failed to parse %s\n",
path, lineno, line);
qlog_parser(ctx,
"%s:%d: failed to parse %s\n",
path,
lineno,
line);
goto out;
}
break;
@ -1094,9 +1190,12 @@ parse_file(struct quirks_context *ctx, const char *path)
goto out;
}
if ((!section->has_match || !section->has_property)) {
qlog_parser(ctx, "%s:%d: previous section %s was empty\n",
path, lineno, section->name);
if (!section->has_match || !section->has_property) {
qlog_parser(ctx,
"%s:%d: previous section %s was empty\n",
path,
lineno,
section->name);
goto out; /* Previous section was empty */
}
@ -1109,7 +1208,8 @@ out:
}
static int
is_data_file(const struct dirent *dir) {
is_data_file(const struct dirent *dir)
{
return strendswith(dir->d_name, ".quirks");
}
@ -1122,20 +1222,14 @@ parse_files(struct quirks_context *ctx, const char *data_path)
ndev = scandir(data_path, &namelist, is_data_file, versionsort);
if (ndev <= 0) {
qlog_error(ctx,
"%s: failed to find data files\n",
data_path);
qlog_error(ctx, "%s: failed to find data files\n", data_path);
return false;
}
for (idx = 0; idx < ndev; idx++) {
char path[PATH_MAX];
snprintf(path,
sizeof(path),
"%s/%s",
data_path,
namelist[idx]->d_name);
snprintf(path, sizeof(path), "%s/%s", data_path, namelist[idx]->d_name);
if (!parse_file(ctx, path))
break;
@ -1281,8 +1375,7 @@ udev_prop(struct udev_device *device, const char *prop)
}
static inline void
match_fill_name(struct match *m,
struct udev_device *device)
match_fill_name(struct match *m, struct udev_device *device)
{
const char *str = udev_prop(device, "NAME");
size_t slen;
@ -1296,16 +1389,14 @@ match_fill_name(struct match *m,
m->name = safe_strdup(str);
slen = strlen(m->name);
if (slen > 1 &&
m->name[slen - 1] == '"')
if (slen > 1 && m->name[slen - 1] == '"')
m->name[slen - 1] = '\0';
m->bits |= M_NAME;
}
static inline void
match_fill_uniq(struct match *m,
struct udev_device *device)
match_fill_uniq(struct match *m, struct udev_device *device)
{
const char *str = udev_prop(device, "UNIQ");
size_t slen;
@ -1319,16 +1410,14 @@ match_fill_uniq(struct match *m,
m->uniq = safe_strdup(str);
slen = safe_strlen(m->uniq);
if (slen > 1 &&
m->uniq[slen - 1] == '"')
if (slen > 1 && m->uniq[slen - 1] == '"')
m->uniq[slen - 1] = '\0';
m->bits |= M_UNIQ;
}
static inline void
match_fill_bus_vid_pid(struct match *m,
struct udev_device *device)
match_fill_bus_vid_pid(struct match *m, struct udev_device *device)
{
const char *str;
unsigned int product, vendor, bus, version;
@ -1346,7 +1435,7 @@ match_fill_bus_vid_pid(struct match *m,
m->product[1] = 0;
m->vendor = vendor;
m->version = version;
m->bits |= M_PID|M_VID|M_VERSION;
m->bits |= M_PID | M_VID | M_VERSION;
switch (bus) {
case BUS_USB:
m->bus = BT_USB;
@ -1378,8 +1467,7 @@ match_fill_bus_vid_pid(struct match *m,
}
static inline void
match_fill_udev_type(struct match *m,
struct udev_device *device)
match_fill_udev_type(struct match *m, struct udev_device *device)
{
struct ut_map {
const char *prop;
@ -1417,8 +1505,7 @@ match_fill_dmi_dt(struct match *m, char *dmi, char *dt)
}
static struct match *
match_new(struct udev_device *device,
char *dmi, char *dt)
match_new(struct udev_device *device, char *dmi, char *dt)
{
struct match *m = zalloc(sizeof *m);
@ -1456,7 +1543,8 @@ quirk_merge_event_codes(struct quirks_context *ctx,
for (size_t j = 0; j < property->value.tuples.ntuples; j++) {
if (offset + j >= max)
break;
p->value.tuples.tuples[offset + j] = property->value.tuples.tuples[j];
p->value.tuples.tuples[offset + j] =
property->value.tuples.tuples[j];
p->value.tuples.ntuples++;
}
return;
@ -1494,8 +1582,10 @@ quirk_apply_section(struct quirks_context *ctx,
q->properties = tmp;
list_for_each(p, &s->properties, link) {
qlog_debug(ctx, "property added: %s from %s\n",
quirk_get_name(p->id), s->name);
qlog_debug(ctx,
"property added: %s from %s\n",
quirk_get_name(p->id),
s->name);
/* All quirks but AttrEventCode and AttrInputProp
* simply overwrite each other, so we can just append the
@ -1512,8 +1602,7 @@ quirk_apply_section(struct quirks_context *ctx,
* have one struct property in the list (not owned by a section)
* and we simply merge any extra sections onto that.
*/
if (p->id == QUIRK_ATTR_EVENT_CODE ||
p->id == QUIRK_ATTR_INPUT_PROP)
if (p->id == QUIRK_ATTR_EVENT_CODE || p->id == QUIRK_ATTR_INPUT_PROP)
quirk_merge_event_codes(ctx, q, p);
else
q->properties[q->nproperties++] = property_ref(p);
@ -1540,7 +1629,8 @@ quirk_match_section(struct quirks_context *ctx,
if ((m->bits & flag) == 0) {
qlog_debug(ctx,
"%s wants %s but we don't have that\n",
s->name, matchflagname(flag));
s->name,
matchflagname(flag));
continue;
}
@ -1614,8 +1704,7 @@ quirk_match_section(struct quirks_context *ctx,
}
struct quirks *
quirks_fetch_for_device(struct quirks_context *ctx,
struct udev_device *udev_device)
quirks_fetch_for_device(struct quirks_context *ctx, struct udev_device *udev_device)
{
struct section *s;
struct match *m;
@ -1623,8 +1712,7 @@ quirks_fetch_for_device(struct quirks_context *ctx,
if (!ctx)
return NULL;
qlog_debug(ctx, "%s: fetching quirks\n",
udev_device_get_devnode(udev_device));
qlog_debug(ctx, "%s: fetching quirks\n", udev_device_get_devnode(udev_device));
_unref_(quirks) *q = quirks_new();
@ -1755,9 +1843,7 @@ quirks_get_bool(struct quirks *q, enum quirk which, bool *val)
}
bool
quirks_get_dimensions(struct quirks *q,
enum quirk which,
struct quirk_dimensions *val)
quirks_get_dimensions(struct quirks *q, enum quirk which, struct quirk_dimensions *val)
{
struct property *p;
@ -1775,9 +1861,7 @@ quirks_get_dimensions(struct quirks *q,
}
bool
quirks_get_range(struct quirks *q,
enum quirk which,
struct quirk_range *val)
quirks_get_range(struct quirks *q, enum quirk which, struct quirk_range *val)
{
struct property *p;

View file

@ -25,13 +25,13 @@
#include "config.h"
#include <libudev.h>
#include <stdbool.h>
#include <stdint.h>
#include <libudev.h>
#include "util-mem.h"
#include "libinput.h"
#include "util-mem.h"
/**
* Handle to the quirks context.
@ -123,7 +123,7 @@ enum quirk {
* Returns a printable name for the quirk. This name is for developer
* tools, not user consumption. Do not display this in a GUI.
*/
const char*
const char *
quirk_get_name(enum quirk q);
/**
@ -196,8 +196,7 @@ quirks_context_ref(struct quirks_context *ctx);
* @return A new quirks struct, use quirks_unref() to release
*/
struct quirks *
quirks_fetch_for_device(struct quirks_context *ctx,
struct udev_device *device);
quirks_fetch_for_device(struct quirks_context *ctx, struct udev_device *device);
/**
* Reduce the refcount by one. When the refcount reaches zero, the
@ -225,9 +224,7 @@ quirks_has_quirk(struct quirks *q, enum quirk which);
* @return true if the quirk value is valid, false otherwise.
*/
bool
quirks_get_uint32(struct quirks *q,
enum quirk which,
uint32_t *val);
quirks_get_uint32(struct quirks *q, enum quirk which, uint32_t *val);
/**
* Get the value of the given quirk, as signed integer.
@ -238,9 +235,7 @@ quirks_get_uint32(struct quirks *q,
* @return true if the quirk value is valid, false otherwise.
*/
bool
quirks_get_int32(struct quirks *q,
enum quirk which,
int32_t *val);
quirks_get_int32(struct quirks *q, enum quirk which, int32_t *val);
/**
* Get the value of the given quirk, as double.
@ -251,9 +246,7 @@ quirks_get_int32(struct quirks *q,
* @return true if the quirk value is valid, false otherwise.
*/
bool
quirks_get_double(struct quirks *q,
enum quirk which,
double *val);
quirks_get_double(struct quirks *q, enum quirk which, double *val);
/**
* Get the value of the given quirk, as string.
@ -267,9 +260,7 @@ quirks_get_double(struct quirks *q,
* @return true if the quirk value is valid, false otherwise.
*/
bool
quirks_get_string(struct quirks *q,
enum quirk which,
char **val);
quirks_get_string(struct quirks *q, enum quirk which, char **val);
/**
* Get the value of the given quirk, as bool.
@ -280,9 +271,7 @@ quirks_get_string(struct quirks *q,
* @return true if the quirk value is valid, false otherwise.
*/
bool
quirks_get_bool(struct quirks *q,
enum quirk which,
bool *val);
quirks_get_bool(struct quirks *q, enum quirk which, bool *val);
/**
* Get the value of the given quirk, as dimension.
@ -293,9 +282,7 @@ quirks_get_bool(struct quirks *q,
* @return true if the quirk value is valid, false otherwise.
*/
bool
quirks_get_dimensions(struct quirks *q,
enum quirk which,
struct quirk_dimensions *val);
quirks_get_dimensions(struct quirks *q, enum quirk which, struct quirk_dimensions *val);
/**
* Get the value of the given quirk, as range.
@ -306,9 +293,7 @@ quirks_get_dimensions(struct quirks *q,
* @return true if the quirk value is valid, false otherwise.
*/
bool
quirks_get_range(struct quirks *q,
enum quirk which,
struct quirk_range *val);
quirks_get_range(struct quirks *q, enum quirk which, struct quirk_range *val);
/**
* Get the tuples of the given quirk.

View file

@ -44,8 +44,7 @@ libinput_timer_init(struct libinput_timer *timer,
timer->timer_func = timer_func;
timer->timer_func_data = timer_func_data;
/* 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, s2us(60 * 60), 5);
}
void
@ -81,15 +80,15 @@ libinput_timer_arm_timer_fd(struct libinput *libinput)
r = timerfd_settime(libinput->timer.fd, TFD_TIMER_ABSTIME, &its, NULL);
if (r)
log_error(libinput, "timer: timerfd_settime error: %s\n", strerror(errno));
log_error(libinput,
"timer: timerfd_settime error: %s\n",
strerror(errno));
libinput->timer.next_expiry = earliest_expire;
}
void
libinput_timer_set_flags(struct libinput_timer *timer,
uint64_t expire,
uint32_t flags)
libinput_timer_set_flags(struct libinput_timer *timer, uint64_t expire, uint32_t flags)
{
#ifndef NDEBUG
/* We only warn if we're more than 20ms behind */
@ -98,16 +97,18 @@ libinput_timer_set_flags(struct libinput_timer *timer,
if (expire < now) {
if ((flags & TIMER_FLAG_ALLOW_NEGATIVE) == 0 &&
now - expire > timer_warning_limit)
log_bug_client_ratelimit(timer->libinput,
&timer->libinput->timer.expiry_in_past_limit,
"timer %s: scheduled expiry is in the past (-%dms), your system is too slow\n",
timer->timer_name,
us2ms(now - expire));
log_bug_client_ratelimit(
timer->libinput,
&timer->libinput->timer.expiry_in_past_limit,
"timer %s: scheduled expiry is in the past (-%dms), your system is too slow\n",
timer->timer_name,
us2ms(now - expire));
} else if ((expire - now) > ms2us(5000)) {
log_bug_libinput(timer->libinput,
"timer %s: offset more than 5s, now %d expire %d\n",
timer->timer_name,
us2ms(now), us2ms(expire));
"timer %s: offset more than 5s, now %d expire %d\n",
timer->timer_name,
us2ms(now),
us2ms(expire));
}
#endif
@ -138,7 +139,7 @@ libinput_timer_cancel(struct libinput_timer *timer)
}
static void
libinput_timer_handler(struct libinput *libinput , uint64_t now)
libinput_timer_handler(struct libinput *libinput, uint64_t now)
{
struct libinput_timer *timer;
@ -191,8 +192,8 @@ libinput_timer_dispatch(void *data)
int
libinput_timer_subsys_init(struct libinput *libinput)
{
libinput->timer.fd = timerfd_create(CLOCK_MONOTONIC,
TFD_CLOEXEC | TFD_NONBLOCK);
libinput->timer.fd =
timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
if (libinput->timer.fd < 0)
return -1;
@ -244,8 +245,7 @@ libinput_timer_subsys_destroy(struct libinput *libinput)
void
libinput_timer_flush(struct libinput *libinput, uint64_t now)
{
if (libinput->timer.next_expiry == 0 ||
libinput->timer.next_expiry > now)
if (libinput->timer.next_expiry == 0 || libinput->timer.next_expiry > now)
return;
libinput_timer_handler(libinput, now);

View file

@ -42,7 +42,8 @@ struct libinput_timer {
};
void
libinput_timer_init(struct libinput_timer *timer, struct libinput *libinput,
libinput_timer_init(struct libinput_timer *timer,
struct libinput *libinput,
const char *timer_name,
void (*timer_func)(uint64_t now, void *timer_func_data),
void *timer_func_data);
@ -60,9 +61,7 @@ enum timer_flags {
};
void
libinput_timer_set_flags(struct libinput_timer *timer,
uint64_t expire,
uint32_t flags);
libinput_timer_set_flags(struct libinput_timer *timer, uint64_t expire, uint32_t flags);
void
libinput_timer_cancel(struct libinput_timer *timer);

View file

@ -24,8 +24,8 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "evdev.h"
@ -42,8 +42,7 @@ static struct udev_seat *
udev_seat_get_named(struct udev_input *input, const char *seat_name);
static inline bool
filter_duplicates(struct udev_seat *udev_seat,
struct udev_device *udev_device)
filter_duplicates(struct udev_seat *udev_seat, struct udev_device *udev_device)
{
struct libinput_device *device;
const char *new_syspath = udev_device_get_syspath(udev_device);
@ -152,8 +151,7 @@ device_removed(struct udev_device *udev_device, struct udev_input *input)
syspath = udev_device_get_syspath(udev_device);
list_for_each(seat, &input->base.seat_list, base.link) {
list_for_each_safe(device,
&seat->base.devices_list, base.link) {
list_for_each_safe(device, &seat->base.devices_list, base.link) {
if (streq(syspath,
udev_device_get_syspath(device->udev_device))) {
evdev_device_remove(device);
@ -205,13 +203,13 @@ evdev_udev_handler(void *data)
struct udev_input *input = data;
const char *action;
_unref_(udev_device) *udev_device = udev_monitor_receive_device(input->udev_monitor);
_unref_(udev_device) *udev_device =
udev_monitor_receive_device(input->udev_monitor);
if (!udev_device)
return;
action = udev_device_get_action(udev_device);
if (!action ||
!strstartswith(udev_device_get_sysname(udev_device), "event"))
if (!action || !strstartswith(udev_device_get_sysname(udev_device), "event"))
return;
if (streq(action, "add"))
@ -228,8 +226,7 @@ udev_input_remove_devices(struct udev_input *input)
list_for_each_safe(seat, &input->base.seat_list, base.link) {
libinput_seat_ref(&seat->base);
list_for_each_safe(device,
&seat->base.devices_list, base.link) {
list_for_each_safe(device, &seat->base.devices_list, base.link) {
evdev_device_remove(device);
}
libinput_seat_unref(&seat->base);
@ -239,7 +236,7 @@ udev_input_remove_devices(struct udev_input *input)
static void
udev_input_disable(struct libinput *libinput)
{
struct udev_input *input = (struct udev_input*)libinput;
struct udev_input *input = (struct udev_input *)libinput;
if (!input->udev_monitor)
return;
@ -255,7 +252,7 @@ udev_input_disable(struct libinput *libinput)
static int
udev_input_enable(struct libinput *libinput)
{
struct udev_input *input = (struct udev_input*)libinput;
struct udev_input *input = (struct udev_input *)libinput;
struct udev *udev = input->udev;
int fd;
@ -264,13 +261,13 @@ udev_input_enable(struct libinput *libinput)
input->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
if (!input->udev_monitor) {
log_info(libinput,
"udev: failed to create the udev monitor\n");
log_info(libinput, "udev: failed to create the udev monitor\n");
return -1;
}
if (udev_monitor_filter_add_match_subsystem_devtype(
input->udev_monitor, "input", NULL)) {
if (udev_monitor_filter_add_match_subsystem_devtype(input->udev_monitor,
"input",
NULL)) {
log_info(libinput, "udev: failed to set up filter\n");
return -1;
}
@ -283,10 +280,8 @@ udev_input_enable(struct libinput *libinput)
}
fd = udev_monitor_get_fd(input->udev_monitor);
input->udev_monitor_source = libinput_add_fd(&input->base,
fd,
evdev_udev_handler,
input);
input->udev_monitor_source =
libinput_add_fd(&input->base, fd, evdev_udev_handler, input);
if (!input->udev_monitor_source) {
udev_monitor_unref(input->udev_monitor);
input->udev_monitor = NULL;
@ -304,7 +299,7 @@ udev_input_enable(struct libinput *libinput)
static void
udev_input_destroy(struct libinput *input)
{
struct udev_input *udev_input = (struct udev_input*)input;
struct udev_input *udev_input = (struct udev_input *)input;
if (input == NULL)
return;
@ -316,7 +311,7 @@ udev_input_destroy(struct libinput *input)
static void
udev_seat_destroy(struct libinput_seat *seat)
{
struct udev_seat *useat = (struct udev_seat*)seat;
struct udev_seat *useat = (struct udev_seat *)seat;
free(useat);
}
@ -329,8 +324,10 @@ udev_seat_create(struct udev_input *input,
seat = zalloc(sizeof *seat);
libinput_seat_init(&seat->base, &input->base,
device_seat, seat_name,
libinput_seat_init(&seat->base,
&input->base,
device_seat,
seat_name,
udev_seat_destroy);
return seat;
@ -350,8 +347,7 @@ udev_seat_get_named(struct udev_input *input, const char *seat_name)
}
static int
udev_device_change_seat(struct libinput_device *device,
const char *seat_name)
udev_device_change_seat(struct libinput_device *device, const char *seat_name)
{
struct libinput *libinput = device->seat->libinput;
struct udev_input *input = (struct udev_input *)libinput;
@ -386,8 +382,8 @@ libinput_udev_create_context(const struct libinput_interface *interface,
input = zalloc(sizeof *input);
if (libinput_init(&input->base, interface,
&interface_backend, user_data) != 0) {
if (libinput_init(&input->base, interface, &interface_backend, user_data) !=
0) {
libinput_unref(&input->base);
free(input);
return NULL;
@ -399,10 +395,9 @@ libinput_udev_create_context(const struct libinput_interface *interface,
}
LIBINPUT_EXPORT int
libinput_udev_assign_seat(struct libinput *libinput,
const char *seat_id)
libinput_udev_assign_seat(struct libinput *libinput, const char *seat_id)
{
struct udev_input *input = (struct udev_input*)libinput;
struct udev_input *input = (struct udev_input *)libinput;
if (!seat_id)
return -1;

View file

@ -27,6 +27,7 @@
#include "config.h"
#include <libudev.h>
#include "libinput-private.h"
struct udev_seat {

View file

@ -27,8 +27,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <unistd.h>
#include "util-macros.h"
#include "util-strings.h"
@ -84,12 +84,13 @@ backtrace_print(FILE *fp,
status = WEXITSTATUS(status);
if (status != 0) {
fprintf(fp, "ERROR: gstack failed, no backtrace available: %s\n",
strerror(status));
fprintf(fp,
"ERROR: gstack failed, no backtrace available: %s\n",
strerror(status));
goto out;
}
char buf[2048] = {0};
char buf[2048] = { 0 };
fprintf(fp, "\nBacktrace:\n");
read(pipefd[0], buf, sizeof(buf) - 1);
if (!use_colors || (!highlight_after && !highlight_before)) {
@ -100,7 +101,8 @@ backtrace_print(FILE *fp,
char **line = lines;
bool highlight = highlight_after == NULL;
while (line && *line) {
if (highlight && highlight_before && strstr(*line, highlight_before))
if (highlight && highlight_before &&
strstr(*line, highlight_before))
highlight = false;
const char *hlcolor = highlight ? ANSI_BRIGHT_CYAN : "";
@ -109,11 +111,13 @@ backtrace_print(FILE *fp,
strstr(*line, highlight_extra))
hlcolor = ANSI_BRIGHT_MAGENTA;
fprintf(fp, "%s%s%s\n",
fprintf(fp,
"%s%s%s\n",
hlcolor,
*line,
highlight ? ANSI_NORMAL : "");
if (!highlight && highlight_after && strstr(*line, highlight_after))
if (!highlight && highlight_after &&
strstr(*line, highlight_after))
highlight = true;
line++;
}

View file

@ -55,7 +55,7 @@ set_bit(unsigned char *array, int bit)
array[bit / 8] |= (1 << (bit % 8));
}
static inline void
static inline void
clear_bit(unsigned char *array, int bit)
{
array[bit / 8] &= ~(1 << (bit % 8));
@ -113,22 +113,26 @@ bitmask_as_u32(bitmask_t mask)
}
static inline bool
bitmask_is_empty(bitmask_t mask) {
bitmask_is_empty(bitmask_t mask)
{
return mask.mask == 0;
}
static inline bool
bitmask_any(bitmask_t mask, bitmask_t bits) {
bitmask_any(bitmask_t mask, bitmask_t bits)
{
return !!(mask.mask & bits.mask);
}
static inline bool
bitmask_all(bitmask_t mask, bitmask_t bits) {
bitmask_all(bitmask_t mask, bitmask_t bits)
{
return bits.mask != 0 && (mask.mask & bits.mask) == bits.mask;
}
static inline bool
bitmask_merge(bitmask_t *mask, bitmask_t bits) {
bitmask_merge(bitmask_t *mask, bitmask_t bits)
{
bool all = bitmask_all(*mask, bits);
mask->mask |= bits.mask;
@ -137,7 +141,8 @@ bitmask_merge(bitmask_t *mask, bitmask_t bits) {
}
static inline bool
bitmask_clear(bitmask_t *mask, bitmask_t bits) {
bitmask_clear(bitmask_t *mask, bitmask_t bits)
{
bool all = bitmask_all(*mask, bits);
mask->mask &= ~bits.mask;
@ -146,43 +151,45 @@ bitmask_clear(bitmask_t *mask, bitmask_t bits) {
}
static inline bool
bitmask_bit_is_set(bitmask_t mask, unsigned int bit) {
bitmask_bit_is_set(bitmask_t mask, unsigned int bit)
{
return !!(mask.mask & bit(bit));
}
static inline bool
bitmask_set_bit(bitmask_t *mask, unsigned int bit) {
bitmask_set_bit(bitmask_t *mask, unsigned int bit)
{
bool isset = bitmask_bit_is_set(*mask, bit);
mask->mask |= bit(bit);
return isset;
}
static inline bool
bitmask_clear_bit(bitmask_t *mask, unsigned int bit) {
bitmask_clear_bit(bitmask_t *mask, unsigned int bit)
{
bool isset = bitmask_bit_is_set(*mask, bit);
mask->mask &= ~bit(bit);
return isset;
}
static inline bitmask_t
bitmask_new(void) {
bitmask_t m = {0};
bitmask_new(void)
{
bitmask_t m = { 0 };
return m;
}
static inline bitmask_t
bitmask_from_bit(unsigned int bit) {
bitmask_t m = {
.mask = bit(bit)
};
bitmask_from_bit(unsigned int bit)
{
bitmask_t m = { .mask = bit(bit) };
return m;
}
static inline bitmask_t
bitmask_from_u32(uint32_t mask) {
bitmask_t m = {
.mask = mask
};
bitmask_from_u32(uint32_t mask)
{
bitmask_t m = { .mask = mask };
return m;
}

View file

@ -23,11 +23,12 @@
#include "config.h"
#include "libinput-versionsort.h"
#include "util-macros.h"
#include "util-files.h"
#include "util-strings.h"
#include "util-list.h"
#include "util-macros.h"
#include "util-strings.h"
#include "libinput-versionsort.h"
struct file {
struct list link;
@ -81,16 +82,14 @@ filenamesort(const void *a, const void *b)
}
char **
list_files(const char **directories,
const char *suffix,
size_t *nfiles_out)
list_files(const char **directories, const char *suffix, size_t *nfiles_out)
{
struct list files = LIST_INIT(files);
if (!directories) {
if (nfiles_out)
*nfiles_out = 0;
return zalloc(1 * sizeof(char*));
return zalloc(1 * sizeof(char *));
}
const char **d = directories;

View file

@ -25,11 +25,11 @@
#include "config.h"
#include <errno.h>
#include <dirent.h>
#include <errno.h>
#include <libgen.h>
#include <unistd.h>
#include <sys/stat.h>
#include <unistd.h>
#include "util-strings.h"
@ -55,7 +55,7 @@ mkdir_p(const char *dir)
return (rc == -1 && errno != EEXIST) ? -errno : 0;
}
DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir);
DEFINE_TRIVIAL_CLEANUP_FUNC(DIR *, closedir);
static inline int
rmdir_r(const char *dir)
@ -110,9 +110,7 @@ xclose(int *fd)
* files returned (not including the NULL terminator).
*/
char **
list_files(const char **directories,
const char *suffix,
size_t *nfiles);
list_files(const char **directories, const char *suffix, size_t *nfiles);
struct tmpdir {
char *path;

View file

@ -25,19 +25,17 @@
#include "config.h"
#include "util-time.h"
#include <libevdev/libevdev.h>
#include <linux/input.h>
#include <stdbool.h>
#include <string.h>
#include "util-mem.h"
#include "util-newtype.h"
#include <string.h>
#include <stdbool.h>
#include <linux/input.h>
#include <libevdev/libevdev.h>
#include "util-time.h"
static inline struct input_event
input_event_init(uint64_t time,
unsigned int type,
unsigned int code,
int value)
input_event_init(uint64_t time, unsigned int type, unsigned int code, int value)
{
struct input_event ev;
struct timeval tval = us2tv(time);
@ -63,8 +61,7 @@ input_event_time(const struct input_event *e)
}
static inline void
input_event_set_time(struct input_event *e,
uint64_t time)
input_event_set_time(struct input_event *e, uint64_t time)
{
struct timeval tval = us2tv(time);
@ -81,7 +78,9 @@ absinfo_range(const struct input_absinfo *abs)
static inline double
absinfo_normalize_value(const struct input_absinfo *abs, int value)
{
return min(1.0, max(0.0, (double)(value - abs->minimum)/(abs->maximum - abs->minimum)));
return min(1.0,
max(0.0,
(double)(value - abs->minimum) / (abs->maximum - abs->minimum)));
}
static inline double
@ -100,5 +99,5 @@ static inline double
absinfo_convert_to_mm(const struct input_absinfo *absinfo, double v)
{
double value = v - absinfo->minimum;
return value/absinfo->resolution;
return value / absinfo->resolution;
}

View file

@ -25,18 +25,18 @@
#include <inttypes.h>
#include "libevdev/libevdev.h"
#include "util-libinput.h"
#include "util-mem.h"
#include "util-strings.h"
#include "util-libinput.h"
#include "libevdev/libevdev.h"
static const char *
event_type_to_str(enum libinput_event_type evtype)
{
const char *type;
switch(evtype) {
switch (evtype) {
case LIBINPUT_EVENT_NONE:
abort();
case LIBINPUT_EVENT_DEVICE_ADDED:
@ -185,54 +185,68 @@ print_device_options(struct libinput_device *dev)
_autofree_ char *pad = NULL;
if (libinput_device_config_tap_get_finger_count(dev)) {
tap = strdup_printf(" tap (dl %s)",
onoff(libinput_device_config_tap_get_drag_lock_enabled(dev)));
tap = strdup_printf(
" tap (dl %s)",
onoff(libinput_device_config_tap_get_drag_lock_enabled(dev)));
}
scroll_methods = libinput_device_config_scroll_get_methods(dev);
if (scroll_methods != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) {
scroll = strdup_printf(" scroll%s%s%s",
(scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG) ? "-2fg" : "",
scroll = strdup_printf(
" scroll%s%s%s",
(scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG) ? "-2fg" : "",
(scroll_methods & LIBINPUT_CONFIG_SCROLL_EDGE) ? "-edge" : "",
(scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) ? "-button" : "");
(scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)
? "-button"
: "");
}
click_methods = libinput_device_config_click_get_methods(dev);
if (click_methods != LIBINPUT_CONFIG_CLICK_METHOD_NONE) {
clickm = strdup_printf(" click%s%s",
(click_methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) ? "-buttonareas" : "",
(click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) ? "-clickfinger" : "");
clickm = strdup_printf(
" click%s%s",
(click_methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)
? "-buttonareas"
: "",
(click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER)
? "-clickfinger"
: "");
}
if (libinput_device_config_dwt_is_available(dev)) {
dwt = strdup_printf(" dwt-%s",
onoff(libinput_device_config_dwt_get_enabled(dev) == LIBINPUT_CONFIG_DWT_ENABLED));
onoff(libinput_device_config_dwt_get_enabled(dev) ==
LIBINPUT_CONFIG_DWT_ENABLED));
}
if (libinput_device_config_dwtp_is_available(dev)) {
dwtp = strdup_printf(" dwtp-%s",
onoff(libinput_device_config_dwtp_get_enabled(dev) == LIBINPUT_CONFIG_DWTP_ENABLED));
dwtp = strdup_printf(
" dwtp-%s",
onoff(libinput_device_config_dwtp_get_enabled(dev) ==
LIBINPUT_CONFIG_DWTP_ENABLED));
}
if (libinput_device_has_capability(dev,
LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
pad = strdup_printf(" buttons:%d strips:%d rings:%d mode groups:%d",
libinput_device_tablet_pad_get_num_buttons(dev),
libinput_device_tablet_pad_get_num_strips(dev),
libinput_device_tablet_pad_get_num_rings(dev),
libinput_device_tablet_pad_get_num_mode_groups(dev));
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
pad = strdup_printf(
" buttons:%d strips:%d rings:%d mode groups:%d",
libinput_device_tablet_pad_get_num_buttons(dev),
libinput_device_tablet_pad_get_num_strips(dev),
libinput_device_tablet_pad_get_num_rings(dev),
libinput_device_tablet_pad_get_num_mode_groups(dev));
}
return strdup_printf("%s%s%s%s%s%s%s%s%s",
tap ? tap : "",
libinput_device_config_left_handed_is_available(dev) ? " left" : "",
libinput_device_config_scroll_has_natural_scroll(dev) ? " scroll-nat" : "",
libinput_device_config_calibration_has_matrix(dev) ? " calib" : "",
scroll ? scroll : "",
clickm ? clickm : "",
dwt ? dwt : "",
dwtp ? dwtp : "",
pad ? pad : "");
return strdup_printf(
"%s%s%s%s%s%s%s%s%s",
tap ? tap : "",
libinput_device_config_left_handed_is_available(dev) ? " left" : "",
libinput_device_config_scroll_has_natural_scroll(dev) ? " scroll-nat"
: "",
libinput_device_config_calibration_has_matrix(dev) ? " calib" : "",
scroll ? scroll : "",
clickm ? clickm : "",
dwt ? dwt : "",
dwtp ? dwtp : "",
pad ? pad : "");
}
static char *
@ -252,34 +266,44 @@ print_device_notify(struct libinput_event *ev)
group_id = (intptr_t)libinput_device_group_get_user_data(group);
if (!group_id) {
group_id = ++next_group_id;
libinput_device_group_set_user_data(group, (void*)group_id);
libinput_device_group_set_user_data(group, (void *)group_id);
}
if (libinput_device_get_size(dev, &w, &h) == 0)
size = strdup_printf(" size %.0fx%.0fmm", w, h);
if (libinput_device_has_capability(dev,
LIBINPUT_DEVICE_CAP_TOUCH))
ntouches = strdup_printf(" ntouches %d", libinput_device_touch_get_touch_count(dev));
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH))
ntouches = strdup_printf(" ntouches %d",
libinput_device_touch_get_touch_count(dev));
if (libinput_event_get_type(ev) == LIBINPUT_EVENT_DEVICE_ADDED)
options = print_device_options(dev);
return strdup_printf("%-33s %5s %7s group%-2d cap:%s%s%s%s%s%s%s%s%s%s",
libinput_device_get_name(dev),
libinput_seat_get_physical_name(seat),
libinput_seat_get_logical_name(seat),
(int)group_id,
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD) ? "k" : "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER) ? "p" : "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH) ? "t" : "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_GESTURE) ? "g" : "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TABLET_TOOL) ? "T" : "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TABLET_PAD) ? "P" : "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_SWITCH) ? "S" : "",
size ? size : "",
ntouches ? ntouches : "",
options ? options : "");
return strdup_printf(
"%-33s %5s %7s group%-2d cap:%s%s%s%s%s%s%s%s%s%s",
libinput_device_get_name(dev),
libinput_seat_get_physical_name(seat),
libinput_seat_get_logical_name(seat),
(int)group_id,
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD) ? "k"
: "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER) ? "p"
: "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH) ? "t"
: "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_GESTURE) ? "g"
: "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TABLET_TOOL)
? "T"
: "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)
? "P"
: "",
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_SWITCH) ? "S"
: "",
size ? size : "",
ntouches ? ntouches : "",
options ? options : "");
}
static char *
@ -306,7 +330,8 @@ print_key_event(struct libinput_event *ev, const struct libinput_print_options *
time,
keyname,
key,
state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
state == LIBINPUT_KEY_STATE_PRESSED ? "pressed"
: "released");
}
static char *
@ -325,13 +350,16 @@ print_motion_event(struct libinput_event *ev, const struct libinput_print_option
}
static char *
print_absmotion_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_absmotion_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
double x = libinput_event_pointer_get_absolute_x_transformed(
p, opts->screen_width);
double y = libinput_event_pointer_get_absolute_y_transformed(
p, opts->screen_height);
double x =
libinput_event_pointer_get_absolute_x_transformed(p,
opts->screen_width);
double y =
libinput_event_pointer_get_absolute_y_transformed(p,
opts->screen_height);
char time[16];
print_event_time(time, opts->start_time, libinput_event_pointer_get_time(p));
@ -339,7 +367,8 @@ print_absmotion_event(struct libinput_event *ev, const struct libinput_print_opt
}
static char *
print_pointer_button_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_pointer_button_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
enum libinput_button_state state;
@ -357,7 +386,8 @@ print_pointer_button_event(struct libinput_event *ev, const struct libinput_prin
time,
buttonname ? buttonname : "???",
button,
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed"
: "released",
libinput_event_pointer_get_seat_button_count(p));
}
@ -380,8 +410,10 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
x = libinput_event_tablet_tool_get_tilt_x(t);
y = libinput_event_tablet_tool_get_tilt_y(t);
tilt = strdup_printf("\ttilt: %.2f%s/%.2f%s",
x, changed_sym(t, tilt_x),
y, changed_sym(t, tilt_y));
x,
changed_sym(t, tilt_x),
y,
changed_sym(t, tilt_y));
}
if (libinput_tablet_tool_has_distance(tool) ||
@ -390,29 +422,32 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
double pressure = libinput_event_tablet_tool_get_pressure(t);
if (dist)
distance = strdup_printf("\tdistance: %.2f%s",
dist, changed_sym(t, distance));
dist,
changed_sym(t, distance));
else
distance = strdup_printf("\tpressure: %.2f%s",
pressure, changed_sym(t, pressure));
pressure,
changed_sym(t, pressure));
}
if (libinput_tablet_tool_has_rotation(tool)) {
double rotation = libinput_event_tablet_tool_get_rotation(t);
rot = strdup_printf("\trotation: %6.2f%s",
rotation, changed_sym(t, rotation));
rotation,
changed_sym(t, rotation));
}
if (libinput_tablet_tool_has_slider(tool)) {
double slider = libinput_event_tablet_tool_get_slider_position(t);
sld = strdup_printf("\tslider: %.2f%s",
slider, changed_sym(t, slider));
sld = strdup_printf("\tslider: %.2f%s", slider, changed_sym(t, slider));
}
if (libinput_tablet_tool_has_wheel(tool)) {
double wheel = libinput_event_tablet_tool_get_wheel_delta(t);
double delta = libinput_event_tablet_tool_get_wheel_delta_discrete(t);
whl = strdup_printf("\twheel: %.2f%s (%d)",
wheel, changed_sym(t, wheel),
wheel,
changed_sym(t, wheel),
(int)delta);
}
@ -420,15 +455,19 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
double major = libinput_event_tablet_tool_get_size_major(t);
double minor = libinput_event_tablet_tool_get_size_minor(t);
size = strdup_printf("\tsize: %.2f%s/%.2f%s",
major, changed_sym(t, size_major),
minor, changed_sym(t, size_minor));
major,
changed_sym(t, size_major),
minor,
changed_sym(t, size_minor));
}
x = libinput_event_tablet_tool_get_x(t);
y = libinput_event_tablet_tool_get_y(t);
return strdup_printf("\t%.2f%s/%.2f%s%s%s%s%s%s%s",
x, changed_sym(t, x),
y, changed_sym(t, y),
x,
changed_sym(t, x),
y,
changed_sym(t, y),
tilt ? tilt : "",
distance ? distance : "",
rot ? rot : "",
@ -438,13 +477,16 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
}
static char *
print_tablet_tip_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_tablet_tip_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
enum libinput_tablet_tool_tip_state state;
char time[16];
print_event_time(time, opts->start_time, libinput_event_tablet_tool_get_time(t));
print_event_time(time,
opts->start_time,
libinput_event_tablet_tool_get_time(t));
_autofree_ char *axes = print_tablet_axes(t);
@ -456,7 +498,8 @@ print_tablet_tip_event(struct libinput_event *ev, const struct libinput_print_op
}
static char *
print_tablet_button_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_tablet_button_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_tablet_tool *p = libinput_event_get_tablet_tool_event(ev);
enum libinput_button_state state;
@ -464,7 +507,9 @@ print_tablet_button_event(struct libinput_event *ev, const struct libinput_print
int button;
char time[16];
print_event_time(time, opts->start_time, libinput_event_tablet_tool_get_time(p));
print_event_time(time,
opts->start_time,
libinput_event_tablet_tool_get_time(p));
button = libinput_event_tablet_tool_get_button(p);
buttonname = libevdev_event_code_get_name(EV_KEY, button);
@ -474,17 +519,18 @@ print_tablet_button_event(struct libinput_event *ev, const struct libinput_print
time,
button,
buttonname ? buttonname : "???",
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed"
: "released",
libinput_event_tablet_tool_get_seat_button_count(p));
}
static char *
print_pointer_axis_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_pointer_axis_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
double v = 0, h = 0, v120 = 0, h120 = 0;
const char *have_vert = "",
*have_horiz = "";
const char *have_vert = "", *have_horiz = "";
const char *source = NULL;
enum libinput_pointer_axis axis;
enum libinput_event_type type;
@ -525,30 +571,38 @@ print_pointer_axis_event(struct libinput_event *ev, const struct libinput_print_
print_event_time(time, opts->start_time, libinput_event_pointer_get_time(p));
return strdup_printf("%s\tvert %.2f/%.1f%s horiz %.2f/%.1f%s (%s)",
time,
v, v120, have_vert,
h, h120, have_horiz, source);
v,
v120,
have_vert,
h,
h120,
have_horiz,
source);
}
static char *
print_tablet_axis_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_tablet_axis_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
char time[16];
print_event_time(time, opts->start_time, libinput_event_tablet_tool_get_time(t));
print_event_time(time,
opts->start_time,
libinput_event_tablet_tool_get_time(t));
_autofree_ char *axes = print_tablet_axes(t);
return strdup_printf("%s\t%s", time, axes);
}
static char *
print_proximity_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_proximity_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
struct libinput_tablet_tool *tool = libinput_event_tablet_tool_get_tool(t);
enum libinput_tablet_tool_proximity_state state;
const char *tool_str,
*state_str;
const char *tool_str, *state_str;
char time[16];
_autofree_ char *axes = NULL;
_autofree_ char *proxin = NULL;
@ -584,7 +638,9 @@ print_proximity_event(struct libinput_event *ev, const struct libinput_print_opt
state = libinput_event_tablet_tool_get_proximity_state(t);
print_event_time(time, opts->start_time, libinput_event_tablet_tool_get_time(t));
print_event_time(time,
opts->start_time,
libinput_event_tablet_tool_get_time(t));
if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN) {
axes = print_tablet_axes(t);
@ -597,23 +653,24 @@ print_proximity_event(struct libinput_event *ev, const struct libinput_print_opt
}
if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN) {
proxin = strdup_printf("\taxes:%s%s%s%s%s%s\tbtn:%s%s%s%s%s%s%s%s%s%s",
libinput_tablet_tool_has_distance(tool) ? "d" : "",
libinput_tablet_tool_has_pressure(tool) ? "p" : "",
libinput_tablet_tool_has_tilt(tool) ? "t" : "",
libinput_tablet_tool_has_rotation(tool) ? "r" : "",
libinput_tablet_tool_has_slider(tool) ? "s" : "",
libinput_tablet_tool_has_wheel(tool) ? "w" : "",
libinput_tablet_tool_has_size(tool) ? "S" : "",
libinput_tablet_tool_has_button(tool, BTN_TOUCH) ? "T" : "",
libinput_tablet_tool_has_button(tool, BTN_STYLUS) ? "S" : "",
libinput_tablet_tool_has_button(tool, BTN_STYLUS2) ? "S2" : "",
libinput_tablet_tool_has_button(tool, BTN_LEFT) ? "L" : "",
libinput_tablet_tool_has_button(tool, BTN_MIDDLE) ? "M" : "",
libinput_tablet_tool_has_button(tool, BTN_RIGHT) ? "R" : "",
libinput_tablet_tool_has_button(tool, BTN_SIDE) ? "Sd" : "",
libinput_tablet_tool_has_button(tool, BTN_EXTRA) ? "Ex" : "",
libinput_tablet_tool_has_button(tool, BTN_0) ? "0" : "");
proxin = strdup_printf(
"\taxes:%s%s%s%s%s%s\tbtn:%s%s%s%s%s%s%s%s%s%s",
libinput_tablet_tool_has_distance(tool) ? "d" : "",
libinput_tablet_tool_has_pressure(tool) ? "p" : "",
libinput_tablet_tool_has_tilt(tool) ? "t" : "",
libinput_tablet_tool_has_rotation(tool) ? "r" : "",
libinput_tablet_tool_has_slider(tool) ? "s" : "",
libinput_tablet_tool_has_wheel(tool) ? "w" : "",
libinput_tablet_tool_has_size(tool) ? "S" : "",
libinput_tablet_tool_has_button(tool, BTN_TOUCH) ? "T" : "",
libinput_tablet_tool_has_button(tool, BTN_STYLUS) ? "S" : "",
libinput_tablet_tool_has_button(tool, BTN_STYLUS2) ? "S2" : "",
libinput_tablet_tool_has_button(tool, BTN_LEFT) ? "L" : "",
libinput_tablet_tool_has_button(tool, BTN_MIDDLE) ? "M" : "",
libinput_tablet_tool_has_button(tool, BTN_RIGHT) ? "R" : "",
libinput_tablet_tool_has_button(tool, BTN_SIDE) ? "Sd" : "",
libinput_tablet_tool_has_button(tool, BTN_EXTRA) ? "Ex" : "",
libinput_tablet_tool_has_button(tool, BTN_0) ? "0" : "");
}
return strdup_printf("%s\t%s\t%-8s (%#" PRIx64 ", id %#" PRIx64 ") %s%s",
@ -643,10 +700,11 @@ print_touch_event(struct libinput_event *ev, const struct libinput_print_options
libinput_event_touch_get_seat_slot(t));
}
if (type == LIBINPUT_EVENT_TOUCH_DOWN ||
type == LIBINPUT_EVENT_TOUCH_MOTION) {
double x = libinput_event_touch_get_x_transformed(t, opts->screen_width);
double y = libinput_event_touch_get_y_transformed(t, opts->screen_height);
if (type == LIBINPUT_EVENT_TOUCH_DOWN || type == LIBINPUT_EVENT_TOUCH_MOTION) {
double x =
libinput_event_touch_get_x_transformed(t, opts->screen_width);
double y =
libinput_event_touch_get_y_transformed(t, opts->screen_height);
double xmm = libinput_event_touch_get_x(t);
double ymm = libinput_event_touch_get_y(t);
@ -657,7 +715,8 @@ print_touch_event(struct libinput_event *ev, const struct libinput_print_options
}
static char *
print_gesture_event_without_coords(struct libinput_event *ev, const struct libinput_print_options *opts)
print_gesture_event_without_coords(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_gesture *t = libinput_event_get_gesture_event(ev);
int finger_count = libinput_event_gesture_get_finger_count(t);
@ -670,14 +729,18 @@ print_gesture_event_without_coords(struct libinput_event *ev, const struct libin
if (type == LIBINPUT_EVENT_GESTURE_SWIPE_END ||
type == LIBINPUT_EVENT_GESTURE_PINCH_END ||
type == LIBINPUT_EVENT_GESTURE_HOLD_END)
cancelled = libinput_event_gesture_get_cancelled(t);
cancelled = libinput_event_gesture_get_cancelled(t);
print_event_time(time, opts->start_time, libinput_event_gesture_get_time(t));
return strdup_printf("%s\t%d%s", time, finger_count, cancelled ? " cancelled" : "");
return strdup_printf("%s\t%d%s",
time,
finger_count,
cancelled ? " cancelled" : "");
}
static char *
print_gesture_event_with_coords(struct libinput_event *ev, const struct libinput_print_options *opts)
print_gesture_event_with_coords(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_gesture *t = libinput_event_get_gesture_event(ev);
double dx = libinput_event_gesture_get_dx(t);
@ -689,8 +752,7 @@ print_gesture_event_with_coords(struct libinput_event *ev, const struct libinput
print_event_time(time, opts->start_time, libinput_event_gesture_get_time(t));
if (libinput_event_get_type(ev) ==
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE) {
if (libinput_event_get_type(ev) == LIBINPUT_EVENT_GESTURE_PINCH_UPDATE) {
double scale = libinput_event_gesture_get_scale(t);
double angle = libinput_event_gesture_get_angle_delta(t);
@ -700,12 +762,16 @@ print_gesture_event_with_coords(struct libinput_event *ev, const struct libinput
return strdup_printf("%s\t%d %5.2f/%5.2f (%5.2f/%5.2f unaccelerated)%s",
time,
libinput_event_gesture_get_finger_count(t),
dx, dy, dx_unaccel, dy_unaccel,
dx,
dy,
dx_unaccel,
dy_unaccel,
pinch ? pinch : "");
}
static char *
print_tablet_pad_button_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_tablet_pad_button_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
struct libinput_tablet_pad_mode_group *group;
@ -726,13 +792,15 @@ print_tablet_pad_button_event(struct libinput_event *ev, const struct libinput_p
return strdup_printf("%3d %s (mode %d)%s",
button,
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed"
: "released",
mode,
toggle ? toggle : "");
}
static char *
print_tablet_pad_ring_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_tablet_pad_ring_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
const char *source = NULL;
@ -760,7 +828,8 @@ print_tablet_pad_ring_event(struct libinput_event *ev, const struct libinput_pri
}
static char *
print_tablet_pad_strip_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_tablet_pad_strip_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
const char *source = NULL;
@ -788,7 +857,8 @@ print_tablet_pad_strip_event(struct libinput_event *ev, const struct libinput_pr
}
static char *
print_tablet_pad_key_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_tablet_pad_key_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
enum libinput_key_state state;
@ -811,11 +881,13 @@ print_tablet_pad_key_event(struct libinput_event *ev, const struct libinput_prin
time,
keyname,
key,
state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
state == LIBINPUT_KEY_STATE_PRESSED ? "pressed"
: "released");
}
static char *
print_tablet_pad_dial_event(struct libinput_event *ev, const struct libinput_print_options *opts)
print_tablet_pad_dial_event(struct libinput_event *ev,
const struct libinput_print_options *opts)
{
struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
unsigned int mode;
@ -869,8 +941,12 @@ libinput_event_to_str(struct libinput_event *ev,
struct libinput_print_options opts = {
.start_time = options ? options->start_time : 0,
.show_keycodes = options ? options->show_keycodes : true,
.screen_width = (options && options->screen_width > 0) ? options->screen_width : 100,
.screen_height = (options && options->screen_height > 0) ? options->screen_height : 100,
.screen_width = (options && options->screen_width > 0)
? options->screen_width
: 100,
.screen_height = (options && options->screen_height > 0)
? options->screen_height
: 100,
};

View file

@ -26,10 +26,11 @@
#include "config.h"
#include <assert.h>
#include <stddef.h>
#include <stdbool.h>
#include <stddef.h>
#include "util-list.h"
#include "libinput-util.h"
#if 0

View file

@ -69,23 +69,28 @@ struct list {
* head. This function *must not* be called for a node to be added to a
* list.
*/
void list_init(struct list *list);
void
list_init(struct list *list);
/**
* Insert an element at the front of the list
*/
void list_insert(struct list *list, struct list *elm);
void
list_insert(struct list *list, struct list *elm);
/**
* Append an element to the back of the list
*/
void list_append(struct list *list, struct list *elm);
void
list_append(struct list *list, struct list *elm);
/**
* Chain other onto list, resetting other to be the empty list.
*/
void list_chain(struct list *list, struct list *other);
void
list_chain(struct list *list, struct list *other);
size_t list_length(const struct list *list);
size_t
list_length(const struct list *list);
/**
* Takes the given pointer ands inserts it to the list with the pointer's field.
@ -122,11 +127,13 @@ size_t list_length(const struct list *list);
* whether the list node has already been removed.
*
*/
void list_remove(struct list *elm);
void
list_remove(struct list *elm);
/**
* Returns true if the given list head is an empty list.
*/
bool list_empty(const struct list *list);
bool
list_empty(const struct list *list);
/**
* Return the 'type' parent container struct of 'ptr' of which

View file

@ -106,8 +106,8 @@
* will produce:
* int foo_123;
*/
#define CONCAT2(X,Y) X##Y
#define CONCAT(X,Y) CONCAT2(X,Y)
#define CONCAT2(X, Y) X##Y
#define CONCAT(X, Y) CONCAT2(X,Y)
#define _unused_ __attribute__((unused))
#define _fallthrough_ __attribute__((fallthrough))
@ -129,10 +129,23 @@
/* Return the 16th argument passed in. See _VARIABLE_MACRO_NARGS above for usage.
* Note this is 1-indexed.
*/
#define _VARIABLE_MACRO_NTH_ARG( \
_1, _2, _3, _4, _5, _6, _7, _8, \
_9, _10, _11, _12, _13, _14, _15,\
N, ...) N
#define _VARIABLE_MACRO_NTH_ARG(_1, \
_2, \
_3, \
_4, \
_5, \
_6, \
_7, \
_8, \
_9, \
_10, \
_11, \
_12, \
_13, \
_14, \
_15, \
N, \
...) N
/* Defines a different expansion of macros depending on the
* number of arguments, e.g. it turns

View file

@ -26,9 +26,9 @@
#include "config.h"
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
struct matrix {
float val[3][3]; /* [row][col] */
@ -101,21 +101,13 @@ matrix_init_rotate(struct matrix *m, int degrees)
static inline bool
matrix_is_identity(const struct matrix *m)
{
return (m->val[0][0] == 1 &&
m->val[0][1] == 0 &&
m->val[0][2] == 0 &&
m->val[1][0] == 0 &&
m->val[1][1] == 1 &&
m->val[1][2] == 0 &&
m->val[2][0] == 0 &&
m->val[2][1] == 0 &&
m->val[2][2] == 1);
return (m->val[0][0] == 1 && m->val[0][1] == 0 && m->val[0][2] == 0 &&
m->val[1][0] == 0 && m->val[1][1] == 1 && m->val[1][2] == 0 &&
m->val[2][0] == 0 && m->val[2][1] == 0 && m->val[2][2] == 1);
}
static inline void
matrix_mult(struct matrix *dest,
const struct matrix *m1,
const struct matrix *m2)
matrix_mult(struct matrix *dest, const struct matrix *m1, const struct matrix *m2)
{
struct matrix m; /* allow for dest == m1 or dest == m2 */
int row, col, i;

View file

@ -27,8 +27,8 @@
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static inline void *
@ -74,20 +74,34 @@ zalloc(size_t size)
*/
#define _free_(_type) __attribute__((cleanup(_type##_freep))) struct _type
static inline void _free_ptr_(void *p) { free(*(void**)p); }
static inline void
_free_ptr_(void *p)
{
free(*(void **)p);
}
/**
* Use: _autofree_ char *data;
*/
#define _autofree_ _cleanup_(_free_ptr_)
static inline void _close_fd_(int *fd) { if (*fd != -1) close(*fd); }
static inline void
_close_fd_(int *fd)
{
if (*fd != -1)
close(*fd);
}
/**
* Use: _autoclose_ int fd = open(...);
*/
#define _autoclose_ _cleanup_(_close_fd_)
static inline void _close_file_(FILE **fp) { if (*fp) fclose(*fp); }
static inline void
_close_file_(FILE **fp)
{
if (*fp)
fclose(*fp);
}
/**
* Use: _autofclose_ FILE *fp = fopen(...);
@ -145,9 +159,10 @@ static inline void _close_file_(FILE **fp) { if (*fp) fclose(*fp); }
} \
struct __useless_struct_to_allow_trailing_semicolon__
static inline void*
_steal(void *ptr) {
void **original = (void**)ptr;
static inline void *
_steal(void *ptr)
{
void **original = (void **)ptr;
void *swapped = *original;
*original = NULL;
return swapped;
@ -165,7 +180,8 @@ _steal(void *ptr) {
(typeof(*ptr_))_steal(ptr_)
static inline int
steal_fd(int *fd) {
steal_fd(int *fd)
{
int copy = *fd;
*fd = -1;
return copy;

View file

@ -26,8 +26,8 @@
#include "config.h"
#include <stdint.h>
#include <stdbool.h>
#include <stdint.h>
#include "util-strings.h"
@ -48,20 +48,33 @@ static inline void
multivalue_extract(const struct multivalue *v, void *ptr)
{
/* ignore false positives from gcc:
* ../src/util-multivalue.h:52:33: warning: array subscript double[0] is partly outside array bounds of int32_t[1] {aka int[1]} [-Warray-bounds=]
* ../src/util-multivalue.h:52:33: warning: array subscript double[0] is
* partly outside array bounds of int32_t[1] {aka int[1]} [-Warray-bounds=]
* 52 | case 'd': *(double*)ptr = v->value.d; break;
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
switch (v->type) {
case 'b': *(bool *)ptr = v->value.b; break;
case 'c': *(char *)ptr = v->value.c; break;
case 'u': *(uint32_t *)ptr = v->value.u; break;
case 'i': *(int32_t *)ptr = v->value.i; break;
case 'd': *(double *)ptr = v->value.d; break;
case 's': *(const char **)ptr = v->value.s; break;
case 'b':
*(bool *)ptr = v->value.b;
break;
case 'c':
*(char *)ptr = v->value.c;
break;
case 'u':
*(uint32_t *)ptr = v->value.u;
break;
case 'i':
*(int32_t *)ptr = v->value.i;
break;
case 'd':
*(double *)ptr = v->value.d;
break;
case 's':
*(const char **)ptr = v->value.s;
break;
default:
abort();
abort();
}
#pragma GCC diagnostic pop
}
@ -83,9 +96,7 @@ multivalue_copy(const struct multivalue *v)
static inline struct multivalue
multivalue_new_string(const char *str)
{
struct multivalue v = {
.type = 's'
};
struct multivalue v = { .type = 's' };
assert(strlen(str) < sizeof(v.value.s));

View file

@ -24,6 +24,7 @@
#pragma once
#include "config.h"
#include "util-macros.h"
/**

View file

@ -109,7 +109,7 @@ parse_mouse_wheel_click_count_property(const char *prop)
if (!safe_atoi(prop, &count) || abs(count) > 360)
return 0;
return count;
return count;
}
/**
@ -133,7 +133,7 @@ parse_mouse_wheel_click_angle_property(const char *prop)
if (!safe_atoi(prop, &angle) || abs(angle) > 360)
return 0;
return angle;
return angle;
}
/**
@ -234,8 +234,7 @@ parse_switch_reliability_property(const char *prop,
* @return true on success, false otherwise
*/
bool
parse_tpkbcombo_layout_poperty(const char *prop,
enum tpkbcombo_layout *layout)
parse_tpkbcombo_layout_poperty(const char *prop, enum tpkbcombo_layout *layout)
{
if (!prop)
return false;
@ -316,11 +315,8 @@ parse_evcode_string(const char *s, int *type_out, int *code_out)
const char *str;
int type;
} map[] = {
{ "KEY_", EV_KEY },
{ "BTN_", EV_KEY },
{ "ABS_", EV_ABS },
{ "REL_", EV_REL },
{ "SW_", EV_SW },
{ "KEY_", EV_KEY }, { "BTN_", EV_KEY }, { "ABS_", EV_ABS },
{ "REL_", EV_REL }, { "SW_", EV_SW },
};
bool found = false;
@ -384,8 +380,12 @@ parse_evcode_property(const char *prop, struct input_event *events, size_t *neve
bool enable;
switch (*s) {
case '+': enable = true; break;
case '-': enable = false; break;
case '+':
enable = true;
break;
case '-':
enable = false;
break;
default:
goto out;
}
@ -399,13 +399,13 @@ parse_evcode_property(const char *prop, struct input_event *events, size_t *neve
goto out;
} else {
int consumed;
char stype[13] = {0}; /* EV_FF_STATUS + '\0' */
char stype[13] = { 0 }; /* EV_FF_STATUS + '\0' */
if (sscanf(s, "%12[A-Z_]:%x%n", stype, &code, &consumed) != 2 ||
strlen(s) != (size_t)consumed ||
(type = libevdev_event_type_from_name(stype)) == -1 ||
code < 0 || code > libevdev_event_type_get_max(type))
goto out;
goto out;
}
evs[idx].type = type;
@ -435,7 +435,9 @@ out:
* On success, props contains nprops elements.
*/
bool
parse_input_prop_property(const char *prop, struct input_prop *props_out, size_t *nprops)
parse_input_prop_property(const char *prop,
struct input_prop *props_out,
size_t *nprops)
{
bool rc = false;
struct input_prop props[INPUT_PROP_CNT]; /* doubling up on quirks is a bug */
@ -452,8 +454,12 @@ parse_input_prop_property(const char *prop, struct input_prop *props_out, size_t
bool enable;
switch (*s) {
case '+': enable = true; break;
case '-': enable = false; break;
case '+':
enable = true;
break;
case '-':
enable = false;
break;
default:
goto out;
}

View file

@ -35,23 +35,34 @@ struct input_prop {
bool enabled;
};
int parse_mouse_dpi_property(const char *prop);
int parse_mouse_wheel_click_angle_property(const char *prop);
int parse_mouse_wheel_click_count_property(const char *prop);
bool parse_dimension_property(const char *prop, size_t *width, size_t *height);
bool parse_calibration_property(const char *prop, float calibration[6]);
bool parse_range_property(const char *prop, int *hi, int *lo);
bool parse_boolean_property(const char *prop, bool *b);
int
parse_mouse_dpi_property(const char *prop);
int
parse_mouse_wheel_click_angle_property(const char *prop);
int
parse_mouse_wheel_click_count_property(const char *prop);
bool
parse_dimension_property(const char *prop, size_t *width, size_t *height);
bool
parse_calibration_property(const char *prop, float calibration[6]);
bool
parse_range_property(const char *prop, int *hi, int *lo);
bool
parse_boolean_property(const char *prop, bool *b);
#define EVENT_CODE_UNDEFINED 0xffff
bool parse_evcode_property(const char *prop, struct input_event *events, size_t *nevents);
bool parse_input_prop_property(const char *prop, struct input_prop *props_out, size_t *nprops);
bool
parse_evcode_property(const char *prop, struct input_event *events, size_t *nevents);
bool
parse_input_prop_property(const char *prop,
struct input_prop *props_out,
size_t *nprops);
enum tpkbcombo_layout {
TPKBCOMBO_LAYOUT_UNKNOWN,
TPKBCOMBO_LAYOUT_BELOW,
};
bool parse_tpkbcombo_layout_poperty(const char *prop,
enum tpkbcombo_layout *layout);
bool
parse_tpkbcombo_layout_poperty(const char *prop, enum tpkbcombo_layout *layout);
enum switch_reliability {
RELIABILITY_RELIABLE,
@ -71,4 +82,5 @@ enum {
ABS_MASK_FLAT = 0x10,
};
uint32_t parse_evdev_abs_prop(const char *prop, struct input_absinfo *abs);
uint32_t
parse_evdev_abs_prop(const char *prop, struct input_absinfo *abs);

View file

@ -32,17 +32,20 @@ struct range {
};
static inline struct range
range_init_empty(void) {
range_init_empty(void)
{
return (struct range){ .lower = 0, .upper = -1 };
}
static inline struct range
range_init_inclusive(int lower, int upper) {
return (struct range) { .lower = lower, .upper = upper + 1};
range_init_inclusive(int lower, int upper)
{
return (struct range){ .lower = lower, .upper = upper + 1 };
}
static inline struct range
range_init_exclusive(int lower, int upper) {
range_init_exclusive(int lower, int upper)
{
return (struct range){ .lower = lower, .upper = upper };
}

View file

@ -73,8 +73,7 @@ ratelimit_test(struct ratelimit *r)
if (r->num < r->burst) {
/* continue burst */
return (++r->num == r->burst) ? RATELIMIT_THRESHOLD
: RATELIMIT_PASS;
return (++r->num == r->burst) ? RATELIMIT_THRESHOLD : RATELIMIT_PASS;
}
return RATELIMIT_EXCEEDED;

View file

@ -41,5 +41,7 @@ struct ratelimit {
unsigned int num;
};
void ratelimit_init(struct ratelimit *r, uint64_t ival_us, unsigned int burst);
enum ratelimit_state ratelimit_test(struct ratelimit *r);
void
ratelimit_init(struct ratelimit *r, uint64_t ival_us, unsigned int burst);
enum ratelimit_state
ratelimit_test(struct ratelimit *r);

View file

@ -57,7 +57,6 @@ stringbuf_reset(struct stringbuf *b)
b->data = NULL;
b->sz = 0;
b->len = 0;
}
static inline struct stringbuf *

View file

@ -128,7 +128,7 @@ strv_append_take(char **strv, char **str)
*
* @return A null-terminated string array or NULL on errors
*/
char**
char **
strv_from_argv(int argc, char **argv)
{
char **strv = NULL;
@ -271,7 +271,8 @@ strv_join(char **strv, const char *joiner)
*
* @return zero on success, otherwise the error returned by the callback
*/
int strv_for_each_n(const char **strv, size_t max, strv_foreach_callback_t func, void *data)
int
strv_for_each_n(const char **strv, size_t max, strv_foreach_callback_t func, void *data)
{
for (size_t i = 0; i < max && strv && strv[i]; i++) {
int ret = func(strv[i], i, data);
@ -288,7 +289,8 @@ int strv_for_each_n(const char **strv, size_t max, strv_foreach_callback_t func,
*
* @return zero on success, otherwise the error returned by the callback
*/
int strv_for_each(const char **strv, strv_foreach_callback_t func, void *data)
int
strv_for_each(const char **strv, strv_foreach_callback_t func, void *data)
{
return strv_for_each_n(strv, SIZE_MAX, func, data);
}
@ -386,5 +388,5 @@ trunkname(const char *filename)
if (suffix == NULL)
return safe_strdup(base);
else
return strndup(base, suffix-base);
return strndup(base, suffix - base);
}

View file

@ -31,12 +31,12 @@
#include <errno.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
@ -76,7 +76,7 @@ strneq(const char *str1, const char *str2, size_t n)
* string is NULL. If the input string is a string pointer, we strdup or
* abort on failure.
*/
static inline char*
static inline char *
safe_strdup(const char *str)
{
char *s;
@ -112,8 +112,7 @@ safe_strlen(const char *str)
* upon success or -1 upon failure. In the case of failure the pointer is set
* to NULL.
*/
__attribute__ ((format (printf, 2, 3)))
static inline int
__attribute__((format(printf, 2, 3))) static inline int
xasprintf(char **strp, const char *fmt, ...)
{
int rc = 0;
@ -128,8 +127,7 @@ xasprintf(char **strp, const char *fmt, ...)
return rc;
}
__attribute__ ((format (printf, 2, 0)))
static inline int
__attribute__((format(printf, 2, 0))) static inline int
xvasprintf(char **strp, const char *fmt, va_list args)
{
int rc = 0;
@ -140,8 +138,7 @@ xvasprintf(char **strp, const char *fmt, va_list args)
return rc;
}
__attribute__ ((format (printf, 1, 2)))
static inline char *
__attribute__((format(printf, 1, 2))) static inline char *
strdup_printf(const char *fmt, ...)
{
int rc = 0;
@ -156,8 +153,7 @@ strdup_printf(const char *fmt, ...)
return strp;
}
__attribute__ ((format (printf, 1, 0)))
static inline char *
__attribute__((format(printf, 1, 0))) static inline char *
strdup_vprintf(const char *fmt, va_list args)
{
char *strp;
@ -281,8 +277,8 @@ safe_atod(const char *str, double *val)
char c = str[i];
if (isdigit(c))
continue;
switch(c) {
continue;
switch (c) {
case '+':
case '-':
case '.':
@ -320,27 +316,41 @@ safe_atod(const char *str, double *val)
}
/* Returns the length of the strv, including the terminating NULL */
size_t strv_len(char **strv);
char **strv_from_argv(int argc, char **argv);
char **strv_from_string(const char *in, const char *separator, size_t *num_elements);
char *strv_join(char **strv, const char *joiner);
char **strv_append_strdup(char **strv, const char *s);
size_t
strv_len(char **strv);
char **
strv_from_argv(int argc, char **argv);
char **
strv_from_string(const char *in, const char *separator, size_t *num_elements);
char *
strv_join(char **strv, const char *joiner);
char **
strv_append_strdup(char **strv, const char *s);
/* Takes ownership of the string and appends it to strv, s is set to NULL */
char **strv_append_take(char **strv, char **s);
__attribute__ ((format (printf, 2, 3)))
char **strv_append_printf(char **strv, const char *fmt, ...);
__attribute__ ((format (printf, 2, 0)))
char **strv_append_vprintf(char **strv, const char *fmt, va_list args);
char **
strv_append_take(char **strv, char **s);
__attribute__((format(printf, 2, 3))) char **
strv_append_printf(char **strv, const char *fmt, ...);
__attribute__((format(printf, 2, 0))) char **
strv_append_vprintf(char **strv, const char *fmt, va_list args);
bool strv_find(char **strv, const char *needle, size_t *index_out);
bool strv_find_substring(char **strv, const char *needle, size_t *index_out);
bool
strv_find(char **strv, const char *needle, size_t *index_out);
bool
strv_find_substring(char **strv, const char *needle, size_t *index_out);
typedef int (*strv_foreach_callback_t)(const char *str, size_t index, void *data);
int strv_for_each(const char **strv, strv_foreach_callback_t func, void *data);
int strv_for_each_n(const char **strv, size_t max, strv_foreach_callback_t func, void *data);
int
strv_for_each(const char **strv, strv_foreach_callback_t func, void *data);
int
strv_for_each_n(const char **strv,
size_t max,
strv_foreach_callback_t func,
void *data);
static inline void
strv_free(char **strv) {
strv_free(char **strv)
{
char **s = strv;
if (!strv)
@ -348,11 +358,11 @@ strv_free(char **strv) {
while (*s != NULL) {
free(*s);
*s = (char*)0x1; /* detect use-after-free */
*s = (char *)0x1; /* detect use-after-free */
s++;
}
free (strv);
free(strv);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(char **, strv_free);
@ -372,9 +382,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(char **, strv_free);
* @return true when parsed successfully otherwise false
*/
static inline double *
double_array_from_string(const char *in,
const char *separator,
size_t *length)
double_array_from_string(const char *in, const char *separator, size_t *length)
{
assert(in != NULL);
assert(separator != NULL);
@ -407,7 +415,7 @@ out:
return result;
}
struct key_value_str{
struct key_value_str {
char *key;
char *value;
};
@ -426,8 +434,8 @@ kv_double_from_string(const char *string,
{
struct key_value_double *result = NULL;
if (!pair_separator || pair_separator[0] == '\0' ||
!kv_separator || kv_separator[0] == '\0')
if (!pair_separator || pair_separator[0] == '\0' || !kv_separator ||
kv_separator[0] == '\0')
return -1;
size_t npairs;
@ -443,8 +451,7 @@ kv_double_from_string(const char *string,
char **kv = strv_from_string(pair, kv_separator, &nelem);
double k, v;
if (!kv || nelem != 2 ||
!safe_atod(kv[0], &k) ||
if (!kv || nelem != 2 || !safe_atod(kv[0], &k) ||
!safe_atod(kv[1], &v)) {
strv_free(kv);
goto error;

View file

@ -27,10 +27,10 @@
#include <assert.h>
#include <errno.h>
#include <time.h>
#include <stdint.h>
#include <unistd.h>
#include <linux/input.h>
#include <stdint.h>
#include <time.h>
#include <unistd.h>
#include "util-macros.h"
@ -148,17 +148,13 @@ to_human_time(uint64_t us)
unsigned int change_from_previous;
uint64_t limit;
} conversion[] = {
{"us", 1, 5000},
{"ms", 1000, 5000},
{"s", 1000, 120},
{"min", 60, 120},
{"h", 60, 48},
{"d", 24, ~0},
{ "us", 1, 5000 }, { "ms", 1000, 5000 }, { "s", 1000, 120 },
{ "min", 60, 120 }, { "h", 60, 48 }, { "d", 24, ~0 },
};
uint64_t value = us;
ARRAY_FOR_EACH(conversion, c) {
value = value/c->change_from_previous;
value = value / c->change_from_previous;
if (value < c->limit) {
t.unit = c->unit;
t.value = value;

View file

@ -27,6 +27,7 @@
#include "config.h"
#include <libudev.h>
#include "util-strings.h"
static inline bool

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_id input_id = {
.bustype = 0x11,
@ -63,18 +63,17 @@ static struct input_absinfo absinfo[] = {
/* This device only exists to verify that the EVDEV_ABS override bits work
* correctly */
TEST_DEVICE(LITEST_ABSINFO_OVERRIDE,
.features = LITEST_IGNORED,
.interface = NULL,
.features = LITEST_IGNORED,
.interface = NULL,
.name = "absinfo override",
.id = &input_id,
.absinfo = absinfo,
.events = events,
.udev_properties = {
{ "EVDEV_ABS_00", "1:1000:100:10" },
{ "EVDEV_ABS_01", "2:2000:200:20" },
{ "EVDEV_ABS_35", "3:3000:300:30" },
{ "EVDEV_ABS_36", "4:4000:400:40" },
{ NULL },
},
)
.name = "absinfo override",
.id = &input_id,
.absinfo = absinfo,
.events = events,
.udev_properties = {
{ "EVDEV_ABS_00", "1:1000:100:10" },
{ "EVDEV_ABS_01", "2:2000:200:20" },
{ "EVDEV_ABS_35", "3:3000:300:30" },
{ "EVDEV_ABS_36", "4:4000:400:40" },
{ NULL },
}, )

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_id input_id = {
.bustype = 0x3,
@ -191,11 +191,10 @@ static int events[] = {
/* clang-format on */
TEST_DEVICE(LITEST_ACER_HAWAII_KEYBOARD,
.features = LITEST_KEYS,
.interface = NULL,
.features = LITEST_KEYS,
.interface = NULL,
.name = "Chicony ACER Hawaii Keyboard",
.id = &input_id,
.events = events,
.absinfo = NULL,
)
.name = "Chicony ACER Hawaii Keyboard",
.id = &input_id,
.events = events,
.absinfo = NULL, )

View file

@ -23,11 +23,11 @@
#include "config.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
@ -39,7 +39,7 @@ static struct input_event down[] = {
static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
@ -86,15 +86,14 @@ static struct input_absinfo absinfo[] = {
/* clang-format on */
TEST_DEVICE(LITEST_ACER_HAWAII_TOUCHPAD,
.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
.interface = &interface,
.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON,
.interface = &interface,
.name = "Chicony ACER Hawaii Keyboard Touchpad",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.udev_properties = {
{ "ID_INPUT_TOUCHPAD_INTEGRATION", "external" },
{ NULL },
}
)
.name = "Chicony ACER Hawaii Keyboard Touchpad",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.udev_properties = {
{ "ID_INPUT_TOUCHPAD_INTEGRATION", "external" },
{ NULL },
})

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_event proximity_in[] = {
/* Note: this device does not send BTN_TOOL_PEN */
@ -151,11 +151,10 @@ static int events[] = {
/* clang-format on */
TEST_DEVICE(LITEST_AIPTEK,
.features = LITEST_TABLET | LITEST_HOVER | LITEST_FORCED_PROXOUT,
.interface = &interface,
.features = LITEST_TABLET | LITEST_HOVER | LITEST_FORCED_PROXOUT,
.interface = &interface,
.name = "Aiptek",
.id = &input_id,
.events = events,
.absinfo = absinfo,
)
.name = "Aiptek",
.id = &input_id,
.events = events,
.absinfo = absinfo, )

View file

@ -26,9 +26,8 @@
#include <assert.h>
#include "libinput-util.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
struct alps {
unsigned int first, second;
@ -59,7 +58,7 @@ touch_down(struct litest_device *d, unsigned int slot, double x, double y)
* litest takes care of BTN_TOOL_* for us. */
if (alps->active_touches > 2) {
/* Need to send SYN_REPORT to flush litest's BTN_TOOL_* updates */
litest_event(d, EV_SYN, SYN_REPORT, 0);
litest_event(d, EV_SYN, SYN_REPORT, 0);
return true;
}
@ -71,9 +70,7 @@ touch_move(struct litest_device *d, unsigned int slot, double x, double y)
{
struct alps *alps = d->private;
if (alps->active_touches > 2 &&
slot != alps->first &&
slot != alps->second)
if (alps->active_touches > 2 && slot != alps->first && slot != alps->second)
return true;
return false;
@ -88,10 +85,8 @@ touch_up(struct litest_device *d, unsigned int slot)
alps->active_touches--;
/* Need to send SYN_REPORT to flush litest's BTN_TOOL_* updates */
if (alps->active_touches > 2 &&
slot != alps->first &&
slot != alps->second) {
litest_event(d, EV_SYN, SYN_REPORT, 0);
if (alps->active_touches > 2 && slot != alps->first && slot != alps->second) {
litest_event(d, EV_SYN, SYN_REPORT, 0);
return true;
}
@ -104,7 +99,7 @@ touch_up(struct litest_device *d, unsigned int slot)
}
static struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
@ -116,7 +111,7 @@ static struct input_event down[] = {
static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
@ -171,12 +166,11 @@ static struct input_absinfo absinfo[] = {
/* clang-format on */
TEST_DEVICE(LITEST_ALPS_3FG,
.features = LITEST_TOUCHPAD | LITEST_BUTTON,
.interface = &interface,
.features = LITEST_TOUCHPAD | LITEST_BUTTON,
.interface = &interface,
.name = "AlpsPS/2 ALPS GlidePoint",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.create = alps_create,
)
.name = "AlpsPS/2 ALPS GlidePoint",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.create = alps_create, )

View file

@ -26,12 +26,11 @@
#include <assert.h>
#include "libinput-util.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
@ -44,7 +43,7 @@ static struct input_event down[] = {
static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
@ -109,17 +108,16 @@ static struct input_absinfo absinfo[] = {
/* clang-format on */
static const char quirk_file[] =
"[litest ALPS Touchpad]\n"
"MatchName=litest AlpsPS/2 ALPS DualPoint TouchPad\n"
"ModelTouchpadVisibleMarker=1\n";
"[litest ALPS Touchpad]\n"
"MatchName=litest AlpsPS/2 ALPS DualPoint TouchPad\n"
"ModelTouchpadVisibleMarker=1\n";
TEST_DEVICE(LITEST_ALPS_DUALPOINT,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SEMI_MT,
.interface = &interface,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SEMI_MT,
.interface = &interface,
.name = "AlpsPS/2 ALPS DualPoint TouchPad",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.quirk_file = quirk_file,
)
.name = "AlpsPS/2 ALPS DualPoint TouchPad",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.quirk_file = quirk_file, )

View file

@ -26,12 +26,11 @@
#include <assert.h>
#include "libinput-util.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
@ -44,7 +43,7 @@ static struct input_event down[] = {
static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
@ -108,11 +107,10 @@ static struct input_absinfo absinfo[] = {
/* clang-format on */
TEST_DEVICE(LITEST_ALPS_SEMI_MT,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SEMI_MT,
.interface = &interface,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SEMI_MT,
.interface = &interface,
.name = "AlpsPS/2 ALPS GlidePoint",
.id = &input_id,
.events = events,
.absinfo = absinfo,
)
.name = "AlpsPS/2 ALPS GlidePoint",
.id = &input_id,
.events = events,
.absinfo = absinfo, )

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
/* Recording from https://bugs.freedesktop.org/show_bug.cgi?id=93474
* This is the keyboard device for this mouse.
@ -211,11 +211,10 @@ static struct input_absinfo absinfo[] = {
/* clang-format on */
TEST_DEVICE(LITEST_ANKER_MOUSE_KBD,
.features = LITEST_KEYS | LITEST_WHEEL,
.interface = NULL,
.features = LITEST_KEYS | LITEST_WHEEL,
.interface = NULL,
.name = "USB Laser Game Mouse",
.id = &input_id,
.absinfo = absinfo,
.events = events,
)
.name = "USB Laser Game Mouse",
.id = &input_id,
.absinfo = absinfo,
.events = events, )

View file

@ -23,11 +23,11 @@
#include "config.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
@ -35,7 +35,7 @@ static struct input_event down[] = {
};
static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
@ -88,17 +88,16 @@ static struct input_absinfo absinfo[] = {
/* clang-format on */
static const char quirk_file[] =
"[litest Apple Touchpad]\n"
"MatchName=litest appletouch\n"
"ModelAppleTouchpadOneButton=1\n";
"[litest Apple Touchpad]\n"
"MatchName=litest appletouch\n"
"ModelAppleTouchpadOneButton=1\n";
TEST_DEVICE(LITEST_APPLETOUCH,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SINGLE_TOUCH,
.interface = &interface,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SINGLE_TOUCH,
.interface = &interface,
.name = "appletouch",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.quirk_file = quirk_file,
)
.name = "appletouch",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.quirk_file = quirk_file, )

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_id input_id = {
.bustype = 0x3,
@ -220,11 +220,10 @@ static int events[] = {
/* clang-format on */
TEST_DEVICE(LITEST_APPLE_KEYBOARD,
.features = LITEST_KEYS,
.interface = NULL,
.features = LITEST_KEYS,
.interface = NULL,
.name = "Apple Inc. Apple Internal Keyboard / Trackpad",
.id = &input_id,
.events = events,
.absinfo = NULL,
)
.name = "Apple Inc. Apple Internal Keyboard / Trackpad",
.id = &input_id,
.events = events,
.absinfo = NULL, )

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
@ -87,19 +87,18 @@ static struct input_absinfo absinfo[] = {
/* clang-format on */
TEST_DEVICE(LITEST_MAGICMOUSE,
.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
.interface = &interface,
.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
.interface = &interface,
.name = "Apple Magic Mouse",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.name = "Apple Magic Mouse",
.id = &input_id,
.events = events,
.absinfo = absinfo,
/* Force MOUSE_DPI to 1000. systemd commit f013e99e160f says it's 1300
* but our test were written with different assumptions and it's not worth
* re-writing those, so let's assume the default */
.udev_properties = {
{ "MOUSE_DPI", "1000" },
{ NULL },
},
)
/* Force MOUSE_DPI to 1000. systemd commit f013e99e160f says it's 1300
* but our test were written with different assumptions and it's not worth
* re-writing those, so let's assume the default */
.udev_properties = {
{ "MOUSE_DPI", "1000" },
{ NULL },
}, )

View file

@ -23,8 +23,8 @@
#include "config.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
/* Note: this is the second event node of this mouse only, the first event
* node is just a normal mouse */
@ -317,11 +317,10 @@ static struct input_absinfo absinfo[] = {
/* clang-format on */
TEST_DEVICE(LITEST_MOUSE_GLADIUS,
.features = LITEST_RELATIVE | LITEST_WHEEL | LITEST_KEYS,
.interface = NULL,
.features = LITEST_RELATIVE | LITEST_WHEEL | LITEST_KEYS,
.interface = NULL,
.name = "ASUS ROG GLADIUS",
.id = &input_id,
.absinfo = absinfo,
.events = events,
)
.name = "ASUS ROG GLADIUS",
.id = &input_id,
.absinfo = absinfo,
.events = events, )

View file

@ -26,20 +26,19 @@
#include <assert.h>
#include "libinput-util.h"
#include "litest.h"
#include "litest-int.h"
#include "litest.h"
static struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_DISTANCE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
@ -48,11 +47,11 @@ static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_POSITION_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_DISTANCE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
@ -61,7 +60,7 @@ static struct input_event up[] = {
{ .type = EV_ABS, .code = ABS_MT_SLOT, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_MT_TRACKING_ID, .value = -1 },
{ .type = EV_ABS, .code = ABS_MT_DISTANCE, .value = 1 },
{ .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = 0 },
{ .type = EV_ABS, .code = ABS_MT_PRESSURE, .value = 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
@ -126,11 +125,11 @@ static struct input_absinfo absinfo[] = {
/* clang-format on */
TEST_DEVICE(LITEST_ATMEL_HOVER,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_CLICKPAD | LITEST_HOVER,
.interface = &interface,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_CLICKPAD |
LITEST_HOVER,
.interface = &interface,
.name = "Atmel maXTouch Touchpad",
.id = &input_id,
.events = events,
.absinfo = absinfo,
)
.name = "Atmel maXTouch Touchpad",
.id = &input_id,
.events = events,
.absinfo = absinfo, )

Some files were not shown because too many files have changed in this diff Show more