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
@ -114,14 +114,14 @@ 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,
evdev_post_scroll(device,
time,
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
&normalized);
}
@ -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;
}
@ -248,9 +244,9 @@ 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,
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,
@ -277,8 +273,7 @@ fallback_flush_wheels(struct fallback_dispatch *dispatch,
v120.x = value;
wheel_degrees.x = value / 120.0 * device->scroll.wheel_click_angle.x;
evdev_notify_axis_wheel(
device,
evdev_notify_axis_wheel(device,
time,
bit(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
&wheel_degrees,
@ -335,7 +330,8 @@ fallback_flush_mt_down(struct fallback_dispatch *dispatch,
slot = &dispatch->mt.slots[slot_idx];
if (slot->seat_slot != -1) {
evdev_log_bug_kernel(device,
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,7 +452,8 @@ fallback_flush_st_down(struct fallback_dispatch *dispatch,
return false;
if (dispatch->abs.seat_slot != -1) {
evdev_log_bug_kernel(device,
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);
}
}
@ -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,8 +750,7 @@ 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,
libinput_device_add_event_listener(&kbd->device->base,
&kbd->listener,
fallback_lid_keyboard_event,
dispatch);
@ -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,7 +824,8 @@ 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,
evdev_log_bug_libinput_ratelimit(
device,
&device->nonpointer_rel_limit,
"REL_X/Y from a non-pointer device\n");
return true;
@ -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;
@ -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,8 +1175,7 @@ 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,
evdev_pointer_notify_button(device,
time,
usage,
LIBINPUT_BUTTON_STATE_RELEASED);
@ -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
@ -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,13 +1435,12 @@ 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
@ -1482,8 +1449,7 @@ fallback_pair_tablet_mode(struct evdev_device *keyboard,
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)
@ -1504,8 +1470,8 @@ fallback_pair_tablet_mode(struct evdev_device *keyboard,
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;
@ -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;
}
@ -1686,19 +1649,16 @@ 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;
@ -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;
}
@ -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,
@ -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_))
@ -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);
}
/**
@ -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

@ -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)
@ -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);
@ -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);
@ -394,17 +369,9 @@ tp_button_top_to_ignore_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,
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:
@ -484,7 +451,8 @@ tp_button_handle_event(struct tp_dispatch *tp,
}
if (current != t->button.state)
evdev_log_debug(tp->device,
evdev_log_debug(
tp->device,
"button state: touch %d from %-20s event %-24s to %-20s\n",
t->index,
button_state_to_str(current),
@ -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,8 +621,7 @@ 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)) {
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;
@ -815,17 +777,14 @@ tp_clickpad_middlebutton_apply_config(struct evdev_device *device)
{
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);
}
@ -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,
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,
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 &&
} 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,8 +967,8 @@ 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;
@ -1026,10 +980,14 @@ tp_init_buttons(struct tp_dispatch *tp,
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);
}
}
@ -1155,8 +1114,7 @@ tp_clickfinger_within_distance(struct tp_dispatch *tp,
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 },
@ -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

@ -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,7 +151,8 @@ 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,
evdev_log_bug_libinput(
tp->device,
"edge-scroll: touch %d: unexpected scroll event %d in none state\n",
t->index,
event);
@ -171,7 +168,8 @@ tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp,
{
switch (event) {
case SCROLL_EVENT_TOUCH:
evdev_log_bug_libinput(tp->device,
evdev_log_bug_libinput(
tp->device,
"edge-scroll: touch %d: unexpected scroll event %d in edge new state\n",
t->index,
event);
@ -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,7 +201,8 @@ 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,
evdev_log_bug_libinput(
tp->device,
"edge-scroll: touch %d: unexpected scroll event %d in edge state\n",
t->index,
event);
@ -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;
@ -253,10 +243,7 @@ tp_edge_scroll_handle_area(struct tp_dispatch *tp,
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;
}
}
@ -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,8 +412,7 @@ 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) {
@ -477,9 +453,9 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
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

@ -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
@ -355,8 +350,7 @@ tp_gesture_apply_scroll_constraints(struct tp_dispatch *tp,
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;
}
@ -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);
}
@ -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);
@ -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:
@ -652,8 +643,10 @@ tp_gesture_handle_event_on_state_hold(struct tp_dispatch *tp,
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;
@ -708,8 +701,10 @@ tp_gesture_handle_event_on_state_hold_and_motion(struct tp_dispatch *tp,
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;
@ -762,7 +757,8 @@ 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,
gesture_notify_hold_begin(&tp->device->base,
time,
tp->gesture.finger_count);
}
break;
@ -888,7 +884,8 @@ tp_gesture_handle_event_on_state_pinch(struct tp_dispatch *tp,
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);
@ -1128,9 +1125,7 @@ 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;
@ -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,
gesture_notify_pinch(&tp->device->base,
time,
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
tp->gesture.finger_count,
&zero, &zero, 1.0, 0.0);
&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,8 +1728,7 @@ 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 };
@ -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,8 +1848,7 @@ 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 &&
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);
@ -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
@ -2027,9 +2021,7 @@ 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 if (active_touches != tp->gesture.finger_count_pending) {
@ -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

@ -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,
libinput_timer_set(
&tp->tap.timer,
time + DEFAULT_DRAG_TIMEOUT_PERIOD_BASE +
(nfingers_tapped *
DEFAULT_DRAG_TIMEOUT_PERIOD_PERFINGER));
(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)
{
@ -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);
@ -1162,8 +1170,7 @@ tp_tap_handle_event(struct tp_dispatch *tp,
}
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 */
@ -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;
}
@ -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 ||
@ -169,8 +160,7 @@ 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) {
tp->thumb.state == THUMB_STATE_PINCH || tp->thumb.index != t->index) {
tp_thumb_set_state(tp, t, THUMB_STATE_SUPPRESSED);
return;
}
@ -182,8 +172,7 @@ 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)
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);
@ -204,9 +193,7 @@ tp_thumb_revive(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)
{
if (!tp->thumb.detect_thumbs)
return;
@ -214,8 +201,7 @@ 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) {
@ -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;
@ -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;
@ -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;
}

File diff suppressed because it is too large Load diff

View file

@ -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 {
@ -572,8 +572,7 @@ tp_libinput_context(const struct tp_dispatch *tp)
}
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);

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,7 +48,8 @@ evdev_print_event(struct evdev_device *device,
switch (evdev_usage_enum(e->usage)) {
case EVDEV_SYN_REPORT:
evdev_log_debug(device,
evdev_log_debug(
device,
"%u.%03u ----------------- EV_SYN ----------------- +%ums\n",
time / 1000,
time % 1000,
@ -78,9 +79,7 @@ evdev_print_event(struct evdev_device *device,
}
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;
@ -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"
@ -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,7 +250,8 @@ 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,
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);
@ -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;
}
@ -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,7 +458,8 @@ 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);
switch (flags & WACOM_BUTTON_MODESWITCH) {
@ -492,22 +491,36 @@ pad_init_leds_from_libwacom(struct pad_dispatch *pad,
break;
#endif
default:
evdev_log_error(pad->device,
evdev_log_error(
pad->device,
"unable to init pad mode group: button %c has multiple modeswitch flags 0x%x\n",
btn, flags);
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,9 +550,11 @@ 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,
evdev_log_bug_libinput(
pad->device,
"Failed to find group %d for button %i\n",
group_index,
b);
@ -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;
@ -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;
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,13 +22,15 @@
*/
#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
@ -38,8 +40,7 @@
#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,7 +145,8 @@ 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,
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));
@ -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,7 +496,8 @@ 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,
tablet_pad_notify_button(
base,
time,
pad_button_from_uint32_t(button),
state,
@ -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,13 +768,15 @@ 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,
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,
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),
@ -811,12 +793,14 @@ pad_init(struct pad_dispatch *pad, struct evdev_device *device)
/* 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) ||
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);
@ -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

@ -22,13 +22,15 @@
* DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
#include "evdev-tablet.h"
#include "util-input-event.h"
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include "util-input-event.h"
#include "evdev-tablet.h"
#if HAVE_LIBWACOM
#include <libwacom/libwacom.h>
#else
@ -45,8 +47,7 @@ enum notify {
#define tablet_has_status(tablet_, s_) (!!((tablet_)->status & (s_)))
static inline void
tablet_get_pressed_buttons(struct tablet_dispatch *tablet,
struct button_state *buttons)
tablet_get_pressed_buttons(struct tablet_dispatch *tablet, struct button_state *buttons)
{
size_t i;
const struct button_state *state = &tablet->button_state,
@ -65,8 +66,7 @@ tablet_get_released_buttons(struct tablet_dispatch *tablet,
*prev_state = &tablet->prev_button_state;
for (i = 0; i < sizeof(buttons->bits); i++)
buttons->bits[i] = prev_state->bits[i] &
~(state->bits[i]);
buttons->bits[i] = prev_state->bits[i] & ~(state->bits[i]);
}
static struct libinput_tablet_tool_pressure_threshold *
@ -104,16 +104,14 @@ tablet_history_reset(struct tablet_dispatch *tablet)
}
static inline void
tablet_history_push(struct tablet_dispatch *tablet,
const struct tablet_axes *axes)
tablet_history_push(struct tablet_dispatch *tablet, const struct tablet_axes *axes)
{
unsigned int index = (tablet->history.index + 1) %
tablet_history_size(tablet);
unsigned int index = (tablet->history.index + 1) % tablet_history_size(tablet);
tablet->history.samples[index] = *axes;
tablet->history.index = index;
tablet->history.count = min(tablet->history.count + 1,
tablet_history_size(tablet));
tablet->history.count =
min(tablet->history.count + 1, tablet_history_size(tablet));
if (tablet->history.count < tablet_history_size(tablet))
tablet_history_push(tablet, axes);
@ -150,28 +148,16 @@ tablet_device_has_axis(struct tablet_dispatch *tablet,
unsigned int code;
if (axis == LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z) {
has_axis = (libevdev_has_event_code(evdev,
EV_KEY,
BTN_TOOL_MOUSE) &&
libevdev_has_event_code(evdev,
EV_ABS,
ABS_TILT_X) &&
libevdev_has_event_code(evdev,
EV_ABS,
ABS_TILT_Y));
has_axis = (libevdev_has_event_code(evdev, EV_KEY, BTN_TOOL_MOUSE) &&
libevdev_has_event_code(evdev, EV_ABS, ABS_TILT_X) &&
libevdev_has_event_code(evdev, EV_ABS, ABS_TILT_Y));
code = axis_to_evcode(axis);
has_axis |= libevdev_has_event_code(evdev,
EV_ABS,
code);
has_axis |= libevdev_has_event_code(evdev, EV_ABS, code);
} else if (axis == LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL) {
has_axis = libevdev_has_event_code(evdev,
EV_REL,
REL_WHEEL);
has_axis = libevdev_has_event_code(evdev, EV_REL, REL_WHEEL);
} else {
code = axis_to_evcode(axis);
has_axis = libevdev_has_event_code(evdev,
EV_ABS,
code);
has_axis = libevdev_has_event_code(evdev, EV_ABS, code);
}
return has_axis;
@ -275,7 +261,9 @@ tablet_change_area(struct evdev_device *device)
{
struct tablet_dispatch *tablet = tablet_dispatch(device->dispatch);
if (memcmp(&tablet->area.rect, &tablet->area.want_rect, sizeof(tablet->area.rect)) == 0)
if (memcmp(&tablet->area.rect,
&tablet->area.want_rect,
sizeof(tablet->area.rect)) == 0)
return;
if (!tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY))
@ -292,10 +280,14 @@ tablet_change_area(struct evdev_device *device)
const struct input_absinfo *absx = device->abs.absinfo_x;
const struct input_absinfo *absy = device->abs.absinfo_y;
tablet->area.x.minimum = axis_range_percentage(absx, tablet->area.rect.x1 * 100);
tablet->area.x.maximum = axis_range_percentage(absx, tablet->area.rect.x2 * 100);
tablet->area.y.minimum = axis_range_percentage(absy, tablet->area.rect.y1 * 100);
tablet->area.y.maximum = axis_range_percentage(absy, tablet->area.rect.y2 * 100);
tablet->area.x.minimum =
axis_range_percentage(absx, tablet->area.rect.x1 * 100);
tablet->area.x.maximum =
axis_range_percentage(absx, tablet->area.rect.x2 * 100);
tablet->area.y.minimum =
axis_range_percentage(absy, tablet->area.rect.y1 * 100);
tablet->area.y.maximum =
axis_range_percentage(absy, tablet->area.rect.y2 * 100);
}
static void
@ -364,8 +356,7 @@ tablet_update_tool(struct tablet_dispatch *tablet,
tablet->current_tool.type = tool;
tablet_set_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
}
else if (!tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY)) {
} else if (!tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY)) {
tablet_set_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY);
}
}
@ -413,9 +404,7 @@ adjust_tilt(const struct input_absinfo *absinfo)
/* If resolution is nonzero, it's in units/radian. But require
* a min/max less/greater than zero so we can assume 0 is the
* center */
if (absinfo->resolution != 0 &&
absinfo->maximum > 0 &&
absinfo->minimum < 0) {
if (absinfo->resolution != 0 && absinfo->maximum > 0 && absinfo->minimum < 0) {
value = rad2deg((double)absinfo->value / absinfo->resolution);
} else {
/* Wacom supports physical [-64, 64] degrees, so map to that by
@ -471,8 +460,7 @@ convert_to_degrees(const struct input_absinfo *absinfo, double offset)
}
static inline double
normalize_wheel(struct tablet_dispatch *tablet,
int value)
normalize_wheel(struct tablet_dispatch *tablet, int value)
{
struct evdev_device *device = tablet->device;
@ -491,8 +479,10 @@ is_inside_area(struct tablet_dispatch *tablet,
assert(normalized_margin > 0.0);
assert(normalized_margin <= 1.0);
int xmargin = (tablet->area.x.maximum - tablet->area.x.minimum) * normalized_margin;
int ymargin = (tablet->area.y.maximum - tablet->area.y.minimum) * normalized_margin;
int xmargin =
(tablet->area.x.maximum - tablet->area.x.minimum) * normalized_margin;
int ymargin =
(tablet->area.y.maximum - tablet->area.y.minimum) * normalized_margin;
return (point->x >= tablet->area.x.minimum - xmargin &&
point->x <= tablet->area.x.maximum + xmargin &&
@ -526,8 +516,7 @@ apply_tablet_area(struct tablet_dispatch *tablet,
}
static inline void
tablet_update_xy(struct tablet_dispatch *tablet,
struct evdev_device *device)
tablet_update_xy(struct tablet_dispatch *tablet, struct evdev_device *device)
{
const struct input_absinfo *absinfo;
int value;
@ -576,8 +565,7 @@ tablet_tool_process_delta(struct tablet_dispatch *tablet,
/* When tool contact changes, we probably got a cursor jump. Don't
try to calculate a delta for that event */
if (!tablet_has_status(tablet,
TABLET_TOOL_ENTERING_PROXIMITY) &&
if (!tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY) &&
!tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT) &&
!tablet_has_status(tablet, TABLET_TOOL_LEAVING_CONTACT) &&
(bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_X) ||
@ -599,10 +587,7 @@ tablet_tool_process_delta(struct tablet_dispatch *tablet,
if (device_float_is_zero(accel))
return zero;
return filter_dispatch(device->pointer.filter,
&accel,
tool,
time);
return filter_dispatch(device->pointer.filter, &accel, tool, time);
}
static inline void
@ -610,8 +595,8 @@ tablet_update_pressure(struct tablet_dispatch *tablet,
struct evdev_device *device,
struct libinput_tablet_tool *tool)
{
const struct input_absinfo *abs = libevdev_get_abs_info(device->evdev,
ABS_PRESSURE);
const struct input_absinfo *abs =
libevdev_get_abs_info(device->evdev, ABS_PRESSURE);
if (!abs)
return;
@ -623,40 +608,35 @@ tablet_update_pressure(struct tablet_dispatch *tablet,
}
static inline void
tablet_update_distance(struct tablet_dispatch *tablet,
struct evdev_device *device)
tablet_update_distance(struct tablet_dispatch *tablet, struct evdev_device *device)
{
const struct input_absinfo *absinfo;
if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_DISTANCE))
return;
if (bit_is_set(tablet->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) {
if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) {
absinfo = libevdev_get_abs_info(device->evdev, ABS_DISTANCE);
tablet->axes.distance = normalize_distance(absinfo);
}
}
static inline void
tablet_update_slider(struct tablet_dispatch *tablet,
struct evdev_device *device)
tablet_update_slider(struct tablet_dispatch *tablet, struct evdev_device *device)
{
const struct input_absinfo *absinfo;
if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_WHEEL))
return;
if (bit_is_set(tablet->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_SLIDER)) {
if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_SLIDER)) {
absinfo = libevdev_get_abs_info(device->evdev, ABS_WHEEL);
tablet->axes.slider = normalize_slider(absinfo);
}
}
static inline void
tablet_update_tilt(struct tablet_dispatch *tablet,
struct evdev_device *device)
tablet_update_tilt(struct tablet_dispatch *tablet, struct evdev_device *device)
{
const struct input_absinfo *absinfo;
@ -666,10 +646,8 @@ tablet_update_tilt(struct tablet_dispatch *tablet,
/* mouse rotation resets tilt to 0 so always fetch both axes if
* either has changed */
if (bit_is_set(tablet->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
bit_is_set(tablet->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
absinfo = libevdev_get_abs_info(device->evdev, ABS_TILT_X);
tablet->axes.tilt.x = adjust_tilt(absinfo);
@ -693,10 +671,8 @@ tablet_update_artpen_rotation(struct tablet_dispatch *tablet,
if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_Z))
return;
if (bit_is_set(tablet->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z)) {
absinfo = libevdev_get_abs_info(device->evdev,
ABS_Z);
if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z)) {
absinfo = libevdev_get_abs_info(device->evdev, ABS_Z);
/* artpen has 0 with buttons pointing east */
tablet->axes.rotation = convert_to_degrees(absinfo, 90);
}
@ -706,17 +682,14 @@ static inline void
tablet_update_mouse_rotation(struct tablet_dispatch *tablet,
struct evdev_device *device)
{
if (bit_is_set(tablet->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
bit_is_set(tablet->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
convert_tilt_to_rotation(tablet);
}
}
static inline void
tablet_update_rotation(struct tablet_dispatch *tablet,
struct evdev_device *device)
tablet_update_rotation(struct tablet_dispatch *tablet, struct evdev_device *device)
{
/* We must check ROTATION_Z after TILT_X/Y so that the tilt axes are
* already normalized and set if we have the mouse/lens tool */
@ -742,16 +715,15 @@ tablet_update_rotation(struct tablet_dispatch *tablet,
}
static inline void
tablet_update_wheel(struct tablet_dispatch *tablet,
struct evdev_device *device)
tablet_update_wheel(struct tablet_dispatch *tablet, struct evdev_device *device)
{
int a;
a = LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL;
if (bit_is_set(tablet->changed_axes, a)) {
/* tablet->axes.wheel_discrete is already set */
tablet->axes.wheel = normalize_wheel(tablet,
tablet->axes.wheel_discrete);
tablet->axes.wheel =
normalize_wheel(tablet, tablet->axes.wheel_discrete);
} else {
tablet->axes.wheel = 0;
tablet->axes.wheel_discrete = 0;
@ -759,8 +731,7 @@ tablet_update_wheel(struct tablet_dispatch *tablet,
}
static void
tablet_smoothen_axes(const struct tablet_dispatch *tablet,
struct tablet_axes *axes)
tablet_smoothen_axes(const struct tablet_dispatch *tablet, struct tablet_axes *axes)
{
size_t i;
size_t count = tablet_history_size(tablet);
@ -881,13 +852,27 @@ tablet_evdev_usage_to_tool(evdev_usage_t usage)
enum libinput_tablet_tool_type type;
switch (evdev_usage_enum(usage)) {
case EVDEV_BTN_TOOL_PEN: type = LIBINPUT_TABLET_TOOL_TYPE_PEN; break;
case EVDEV_BTN_TOOL_RUBBER: type = LIBINPUT_TABLET_TOOL_TYPE_ERASER; break;
case EVDEV_BTN_TOOL_BRUSH: type = LIBINPUT_TABLET_TOOL_TYPE_BRUSH; break;
case EVDEV_BTN_TOOL_PENCIL: type = LIBINPUT_TABLET_TOOL_TYPE_PENCIL; break;
case EVDEV_BTN_TOOL_AIRBRUSH: type = LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH; break;
case EVDEV_BTN_TOOL_MOUSE: type = LIBINPUT_TABLET_TOOL_TYPE_MOUSE; break;
case EVDEV_BTN_TOOL_LENS: type = LIBINPUT_TABLET_TOOL_TYPE_LENS; break;
case EVDEV_BTN_TOOL_PEN:
type = LIBINPUT_TABLET_TOOL_TYPE_PEN;
break;
case EVDEV_BTN_TOOL_RUBBER:
type = LIBINPUT_TABLET_TOOL_TYPE_ERASER;
break;
case EVDEV_BTN_TOOL_BRUSH:
type = LIBINPUT_TABLET_TOOL_TYPE_BRUSH;
break;
case EVDEV_BTN_TOOL_PENCIL:
type = LIBINPUT_TABLET_TOOL_TYPE_PENCIL;
break;
case EVDEV_BTN_TOOL_AIRBRUSH:
type = LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH;
break;
case EVDEV_BTN_TOOL_MOUSE:
type = LIBINPUT_TABLET_TOOL_TYPE_MOUSE;
break;
case EVDEV_BTN_TOOL_LENS:
type = LIBINPUT_TABLET_TOOL_TYPE_LENS;
break;
default:
abort();
}
@ -930,11 +915,9 @@ tablet_process_key(struct tablet_dispatch *tablet,
if (!bit_is_set(tablet->axis_caps,
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE)) {
if (e->value)
tablet_set_status(tablet,
TABLET_TOOL_ENTERING_CONTACT);
tablet_set_status(tablet, TABLET_TOOL_ENTERING_CONTACT);
else
tablet_set_status(tablet,
TABLET_TOOL_LEAVING_CONTACT);
tablet_set_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
}
break;
default:
@ -1052,15 +1035,10 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
if (axes & WACOM_AXIS_TYPE_TILT) {
/* tilt on the puck is converted to rotation */
if (type == WSTYLUS_PUCK) {
set_bit(tool->axis_caps,
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
set_bit(tool->axis_caps, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
} else {
copy_axis_cap(tablet,
tool,
LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
copy_axis_cap(tablet,
tool,
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
}
}
if (axes & WACOM_AXIS_TYPE_ROTATION_Z)
@ -1113,9 +1091,10 @@ tool_set_bits(const struct tablet_dispatch *tablet,
* ABS_Z, otherwise we try to get the value from it later on
* proximity in and go boom because the absinfo isn't there.
*/
if (libevdev_has_event_code(tablet->device->evdev, EV_ABS,
ABS_Z))
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
if (libevdev_has_event_code(tablet->device->evdev, EV_ABS, ABS_Z))
copy_axis_cap(tablet,
tool,
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
break;
case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
case LIBINPUT_TABLET_TOOL_TYPE_LENS:
@ -1152,9 +1131,7 @@ tool_set_bits(const struct tablet_dispatch *tablet,
}
static bool
tablet_get_quirked_pressure_thresholds(struct tablet_dispatch *tablet,
int *hi,
int *lo)
tablet_get_quirked_pressure_thresholds(struct tablet_dispatch *tablet, int *hi, int *lo)
{
struct evdev_device *device = tablet->device;
struct quirk_range r;
@ -1169,7 +1146,8 @@ tablet_get_quirked_pressure_thresholds(struct tablet_dispatch *tablet,
*lo = r.upper;
status = true;
} else {
evdev_log_info(device, "Invalid pressure range, using defaults\n");
evdev_log_info(device,
"Invalid pressure range, using defaults\n");
}
}
@ -1399,15 +1377,15 @@ tool_init_eraser_button(struct tablet_dispatch *tablet,
* but we don't have any separate erasers with buttons so
* we only need to exclude INVERT
*/
if (s &&
libwacom_stylus_has_eraser(s) &&
if (s && libwacom_stylus_has_eraser(s) &&
libwacom_stylus_get_eraser_type(s) == WACOM_ERASER_INVERT) {
return;
}
#endif
/* All other pens need eraser button handling because most of the time
* we don't know if they have one (Huion, XP-Pen, ...) */
bitmask_t available_modes = bitmask_from_masks(LIBINPUT_CONFIG_ERASER_BUTTON_BUTTON);
bitmask_t available_modes =
bitmask_from_masks(LIBINPUT_CONFIG_ERASER_BUTTON_BUTTON);
tool->eraser_button.available_modes = available_modes;
tool->eraser_button.want_button = eraser_button_get_default_button(tool);
@ -1462,7 +1440,8 @@ tablet_new_tool(struct tablet_dispatch *tablet,
.config.eraser_button.get_default_mode = eraser_button_get_default_mode,
.config.eraser_button.set_button = eraser_button_set_button,
.config.eraser_button.get_button = eraser_button_get_button,
.config.eraser_button.get_default_button = eraser_button_get_default_button,
.config.eraser_button.get_default_button =
eraser_button_get_default_button,
};
tool_init_pressure_thresholds(tablet, tool, &tool->pressure.threshold);
@ -1585,12 +1564,7 @@ tablet_notify_buttons(struct tablet_dispatch *tablet,
else
tablet_get_released_buttons(tablet, &buttons);
tablet_notify_button_mask(tablet,
device,
time,
tool,
&buttons,
state);
tablet_notify_button_mask(tablet, device, time, tool, &buttons, state);
}
static void
@ -1598,8 +1572,7 @@ sanitize_pressure_distance(struct tablet_dispatch *tablet,
struct libinput_tablet_tool *tool)
{
bool tool_in_contact;
const struct input_absinfo *distance,
*pressure;
const struct input_absinfo *distance, *pressure;
distance = libevdev_get_abs_info(tablet->device->evdev, ABS_DISTANCE);
/* Note: for pressure/distance sanitization we use the real pressure
@ -1609,8 +1582,10 @@ sanitize_pressure_distance(struct tablet_dispatch *tablet,
if (!pressure || !distance)
return;
bool pressure_changed = bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
bool distance_changed = bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
bool pressure_changed =
bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
bool distance_changed =
bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
if (!pressure_changed && !distance_changed)
return;
@ -1623,8 +1598,7 @@ sanitize_pressure_distance(struct tablet_dispatch *tablet,
tool_in_contact = (pressure->value > threshold->threshold.lower);
/* Keep distance and pressure mutually exclusive */
if (distance &&
distance->value > distance->minimum &&
if (distance && distance->value > distance->minimum &&
pressure->value > pressure->minimum) {
if (tool_in_contact) {
clear_bit(tablet->changed_axes,
@ -1658,8 +1632,7 @@ sanitize_mouse_lens_rotation(struct tablet_dispatch *tablet)
}
static void
sanitize_tablet_axes(struct tablet_dispatch *tablet,
struct libinput_tablet_tool *tool)
sanitize_tablet_axes(struct tablet_dispatch *tablet, struct libinput_tablet_tool *tool)
{
sanitize_pressure_distance(tablet, tool);
sanitize_mouse_lens_rotation(tablet);
@ -1676,7 +1649,8 @@ set_pressure_offset(struct libinput_tablet_tool_pressure_threshold *threshold,
* device coordinates) between upper and lower as before which isn't
* technically correct (our range shrunk) but it's easy to calculate.
*/
int units = pressure_offset_to_absinfo(offset_in_percent, &threshold->abs_pressure);
int units =
pressure_offset_to_absinfo(offset_in_percent, &threshold->abs_pressure);
int gap = threshold->threshold.upper - threshold->threshold.lower;
threshold->threshold.lower = units;
threshold->threshold.upper = units + gap;
@ -1702,7 +1676,8 @@ update_pressure_offset(struct tablet_dispatch *tablet,
* If we are still pending the offset decision, only update the observed
* offset value, don't actually set it to have an offset.
*/
pressure_offset_t offset = pressure_offset_from_absinfo(pressure, pressure->value);
pressure_offset_t offset =
pressure_offset_from_absinfo(pressure, pressure->value);
struct libinput_tablet_tool_pressure_threshold *threshold =
tablet_tool_get_threshold(tablet, tool);
if (threshold->has_offset) {
@ -1753,7 +1728,8 @@ detect_pressure_offset(struct tablet_dispatch *tablet,
* deciding prox-in arrives we should know the minimum offset.
*/
if (units > pressure->minimum)
threshold->offset = pressure_offset_min(offset, threshold->offset);
threshold->offset =
pressure_offset_min(offset, threshold->offset);
switch (threshold->heuristic_state) {
case PRESSURE_HEURISTIC_STATE_PROXIN1:
@ -1775,7 +1751,8 @@ detect_pressure_offset(struct tablet_dispatch *tablet,
}
if (pressure_offset_gt(offset, 0.5)) {
evdev_log_error(device,
evdev_log_error(
device,
"Ignoring pressure offset greater than 50%% detected on tool %s (serial %#x). "
"See %s/tablet-support.html\n",
tablet_tool_type_to_string(tool->type),
@ -1807,17 +1784,14 @@ detect_tool_contact(struct tablet_dispatch *tablet,
/* if we have pressure, always use that for contact, not BTN_TOUCH */
if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT))
evdev_log_bug_libinput(device,
"Invalid status: entering contact\n");
evdev_log_bug_libinput(device, "Invalid status: entering contact\n");
if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_CONTACT) &&
!tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY))
evdev_log_bug_libinput(device,
"Invalid status: leaving contact\n");
evdev_log_bug_libinput(device, "Invalid status: leaving contact\n");
p = libevdev_get_abs_info(tablet->device->evdev, ABS_PRESSURE);
if (!p) {
evdev_log_bug_libinput(device,
"Missing pressure axis\n");
evdev_log_bug_libinput(device, "Missing pressure axis\n");
return;
}
pressure = p->value;
@ -1837,13 +1811,10 @@ static void
tablet_mark_all_axes_changed(struct tablet_dispatch *tablet,
struct libinput_tablet_tool *tool)
{
static_assert(sizeof(tablet->changed_axes) ==
sizeof(tool->axis_caps),
static_assert(sizeof(tablet->changed_axes) == sizeof(tool->axis_caps),
"Mismatching array sizes");
memcpy(tablet->changed_axes,
tool->axis_caps,
sizeof(tablet->changed_axes));
memcpy(tablet->changed_axes, tool->axis_caps, sizeof(tablet->changed_axes));
}
static void
@ -1867,10 +1838,8 @@ tablet_update_proximity_state(struct tablet_dispatch *tablet,
if (dist < dist_max &&
(tablet_has_status(tablet, TABLET_TOOL_OUT_OF_RANGE) ||
tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY))) {
tablet_unset_status(tablet,
TABLET_TOOL_OUT_OF_RANGE);
tablet_unset_status(tablet,
TABLET_TOOL_OUT_OF_PROXIMITY);
tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_RANGE);
tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
tablet_set_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
tablet_mark_all_axes_changed(tablet, tool);
@ -1888,12 +1857,9 @@ tablet_update_proximity_state(struct tablet_dispatch *tablet,
return;
/* Tool entered prox but is outside of permitted range */
if (tablet_has_status(tablet,
TABLET_TOOL_ENTERING_PROXIMITY)) {
tablet_set_status(tablet,
TABLET_TOOL_OUT_OF_RANGE);
tablet_unset_status(tablet,
TABLET_TOOL_ENTERING_PROXIMITY);
if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY)) {
tablet_set_status(tablet, TABLET_TOOL_OUT_OF_RANGE);
tablet_unset_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
return;
}
@ -2076,8 +2042,7 @@ tablet_send_axes(struct tablet_dispatch *tablet,
if (!tablet_has_status(tablet, TABLET_AXES_UPDATED))
return;
if (tablet_has_status(tablet,
TABLET_TOOL_IN_CONTACT))
if (tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT))
tip_state = LIBINPUT_TABLET_TOOL_TIP_DOWN;
else
tip_state = LIBINPUT_TABLET_TOOL_TIP_UP;
@ -2210,8 +2175,7 @@ update_pressure_range(struct tablet_dispatch *tablet,
/* Only use the quirk pressure range if we don't have a custom range */
int hi, lo;
if (tool->pressure.range.min != 0.0 ||
tool->pressure.range.max != 1.0 ||
if (tool->pressure.range.min != 0.0 || tool->pressure.range.max != 1.0 ||
!tablet_get_quirked_pressure_thresholds(tablet, &hi, &lo)) {
/* 5 and 1% of the pressure range */
hi = axis_range_percentage(&abs, 5);
@ -2235,9 +2199,7 @@ update_pressure_range(struct tablet_dispatch *tablet,
}
static void
tablet_flush(struct tablet_dispatch *tablet,
struct evdev_device *device,
uint64_t time)
tablet_flush(struct tablet_dispatch *tablet, struct evdev_device *device, uint64_t time)
{
struct libinput_tablet_tool *tool;
@ -2257,9 +2219,7 @@ tablet_flush(struct tablet_dispatch *tablet,
if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY)) {
/* Release all stylus buttons */
memset(tablet->button_state.bits,
0,
sizeof(tablet->button_state.bits));
memset(tablet->button_state.bits, 0, sizeof(tablet->button_state.bits));
tablet_set_status(tablet, TABLET_BUTTONS_RELEASED);
if (tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT))
tablet_set_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
@ -2272,9 +2232,9 @@ tablet_flush(struct tablet_dispatch *tablet,
* implement so let's wait for someone to actually complain
* about it.
*
* We allow a margin of 3% (6mm on a 200mm tablet) to be "within"
* the area - there we clip to the area but do not ignore the
* sequence.
* We allow a margin of 3% (6mm on a 200mm tablet) to be
* "within" the area - there we clip to the area but do not
* ignore the sequence.
*/
const struct device_coords point = {
device->abs.absinfo_x->value,
@ -2291,7 +2251,8 @@ tablet_flush(struct tablet_dispatch *tablet,
sanitize_tablet_axes(tablet, tool);
} else {
tablet_set_status(tablet, TABLET_TOOL_OUTSIDE_AREA);
tablet_unset_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
tablet_unset_status(tablet,
TABLET_TOOL_ENTERING_PROXIMITY);
}
} else if (tablet_has_status(tablet, TABLET_AXES_UPDATED)) {
update_pressure_offset(tablet, device, tool);
@ -2350,13 +2311,10 @@ tablet_toggle_touch_device(struct tablet_dispatch *tablet,
struct phys_rect r = { 0 };
struct phys_rect *rect = NULL;
if (tablet_has_status(tablet,
TABLET_TOOL_OUT_OF_RANGE) ||
if (tablet_has_status(tablet, TABLET_TOOL_OUT_OF_RANGE) ||
tablet_has_status(tablet, TABLET_NONE) ||
tablet_has_status(tablet,
TABLET_TOOL_LEAVING_PROXIMITY) ||
tablet_has_status(tablet,
TABLET_TOOL_OUT_OF_PROXIMITY)) {
tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY) ||
tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY)) {
which = ARBITRATION_NOT_ACTIVE;
} else if (tablet->axes.tilt.x == 0) {
which = ARBITRATION_IGNORE_ALL;
@ -2370,10 +2328,7 @@ tablet_toggle_touch_device(struct tablet_dispatch *tablet,
return;
}
tablet_set_touch_device_enabled(tablet,
which,
rect,
time);
tablet_set_touch_device_enabled(tablet, which, rect, time);
}
static inline void
@ -2430,17 +2385,13 @@ tablet_process(struct evdev_dispatch *dispatch,
}
static void
tablet_suspend(struct evdev_dispatch *dispatch,
struct evdev_device *device)
tablet_suspend(struct evdev_dispatch *dispatch, struct evdev_device *device)
{
struct tablet_dispatch *tablet = tablet_dispatch(dispatch);
struct libinput *li = tablet_libinput_context(tablet);
uint64_t now = libinput_now(li);
tablet_set_touch_device_enabled(tablet,
ARBITRATION_NOT_ACTIVE,
NULL,
now);
tablet_set_touch_device_enabled(tablet, ARBITRATION_NOT_ACTIVE, NULL, now);
if (!tablet_has_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY)) {
tablet_set_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY);
@ -2498,8 +2449,10 @@ tablet_setup_touch_arbitration(struct evdev_device *device,
* heuristics in case we find a "better" device.
*/
if (tablet->touch_device != NULL) {
struct libinput_device_group *group1 = libinput_device_get_device_group(&device->base);
struct libinput_device_group *group2 = libinput_device_get_device_group(&new_device->base);
struct libinput_device_group *group1 =
libinput_device_get_device_group(&device->base);
struct libinput_device_group *group2 =
libinput_device_get_device_group(&new_device->base);
/* same phsical device? -> better, otherwise keep the one we have */
if (group1 != group2)
@ -2525,12 +2478,13 @@ tablet_setup_touch_arbitration(struct evdev_device *device,
}
static void
tablet_setup_rotation(struct evdev_device *device,
struct evdev_device *new_device)
tablet_setup_rotation(struct evdev_device *device, struct evdev_device *new_device)
{
struct tablet_dispatch *tablet = tablet_dispatch(device->dispatch);
struct libinput_device_group *group1 = libinput_device_get_device_group(&device->base);
struct libinput_device_group *group2 = libinput_device_get_device_group(&new_device->base);
struct libinput_device_group *group1 =
libinput_device_get_device_group(&device->base);
struct libinput_device_group *group2 =
libinput_device_get_device_group(&new_device->base);
if (tablet->rotation.touch_device == NULL && (group1 == group2)) {
evdev_log_debug(device,
@ -2547,13 +2501,12 @@ tablet_setup_rotation(struct evdev_device *device,
}
static void
tablet_device_added(struct evdev_device *device,
struct evdev_device *added_device)
tablet_device_added(struct evdev_device *device, struct evdev_device *added_device)
{
bool is_touchscreen, is_ext_touchpad;
is_touchscreen = evdev_device_has_capability(added_device,
LIBINPUT_DEVICE_CAP_TOUCH);
is_touchscreen =
evdev_device_has_capability(added_device, LIBINPUT_DEVICE_CAP_TOUCH);
is_ext_touchpad = evdev_device_has_capability(added_device,
LIBINPUT_DEVICE_CAP_POINTER) &&
(added_device->tags & EVDEV_TAG_EXTERNAL_TOUCHPAD);
@ -2566,8 +2519,7 @@ tablet_device_added(struct evdev_device *device,
}
static void
tablet_device_removed(struct evdev_device *device,
struct evdev_device *removed_device)
tablet_device_removed(struct evdev_device *device, struct evdev_device *removed_device)
{
struct tablet_dispatch *tablet = tablet_dispatch(device->dispatch);
@ -2595,10 +2547,8 @@ tablet_check_initial_proximity(struct evdev_device *device,
code = tablet_tool_to_evcode(tool);
/* we only expect one tool to be in proximity at a time */
if (libevdev_fetch_event_value(device->evdev,
EV_KEY,
code,
&state) && state) {
if (libevdev_fetch_event_value(device->evdev, EV_KEY, code, &state) &&
state) {
tablet->tool_state = bit(tool);
tablet->prev_tool_state = bit(tool);
break;
@ -2611,9 +2561,7 @@ tablet_check_initial_proximity(struct evdev_device *device,
tablet_update_tool(tablet, device, tool, state);
tablet->current_tool.id =
libevdev_get_event_value(device->evdev,
EV_ABS,
ABS_MISC);
libevdev_get_event_value(device->evdev, EV_ABS, ABS_MISC);
/* we can't fetch MSC_SERIAL from the kernel, so we set the serial
* to 0 for now. On the first real event from the device we get the
@ -2667,7 +2615,8 @@ tablet_init_calibration(struct tablet_dispatch *tablet,
struct evdev_device *device,
bool is_display_tablet)
{
if (is_display_tablet || libevdev_has_property(device->evdev, INPUT_PROP_DIRECT))
if (is_display_tablet ||
libevdev_has_property(device->evdev, INPUT_PROP_DIRECT))
evdev_init_calibration(device, &tablet->calibration);
}
@ -2687,8 +2636,8 @@ tablet_area_set_rectangle(struct libinput_device *device,
if (rectangle->x1 >= rectangle->x2 || rectangle->y1 >= rectangle->y2)
return LIBINPUT_CONFIG_STATUS_INVALID;
if (rectangle->x1 < 0.0 || rectangle->x2 > 1.0 ||
rectangle->y1 < 0.0 || rectangle->y2 > 1.0)
if (rectangle->x1 < 0.0 || rectangle->x2 > 1.0 || rectangle->y1 < 0.0 ||
rectangle->y2 > 1.0)
return LIBINPUT_CONFIG_STATUS_INVALID;
tablet->area.want_rect = *rectangle;
@ -2711,17 +2660,22 @@ static struct libinput_config_area_rectangle
tablet_area_get_default_rectangle(struct libinput_device *device)
{
struct libinput_config_area_rectangle rect = {
0.0, 0.0, 1.0, 1.0,
0.0,
0.0,
1.0,
1.0,
};
return rect;
}
static void
tablet_init_area(struct tablet_dispatch *tablet,
struct evdev_device *device)
tablet_init_area(struct tablet_dispatch *tablet, struct evdev_device *device)
{
tablet->area.rect = (struct libinput_config_area_rectangle){
0.0, 0.0, 1.0, 1.0,
0.0,
0.0,
1.0,
1.0,
};
tablet->area.want_rect = tablet->area.rect;
tablet->area.x = *device->abs.absinfo_x;
@ -2732,7 +2686,8 @@ tablet_init_area(struct tablet_dispatch *tablet,
tablet->area.config.has_rectangle = tablet_area_has_rectangle;
tablet->area.config.set_rectangle = tablet_area_set_rectangle;
tablet->area.config.get_rectangle = tablet_area_get_rectangle;
tablet->area.config.get_default_rectangle = tablet_area_get_default_rectangle;
tablet->area.config.get_default_rectangle =
tablet_area_get_default_rectangle;
}
}
@ -2794,8 +2749,7 @@ tablet_init_accel(struct tablet_dispatch *tablet, struct evdev_device *device)
x = device->abs.absinfo_x;
y = device->abs.absinfo_y;
filter = create_pointer_accelerator_filter_tablet(x->resolution,
y->resolution);
filter = create_pointer_accelerator_filter_tablet(x->resolution, y->resolution);
if (!filter)
return -1;
@ -2806,14 +2760,14 @@ tablet_init_accel(struct tablet_dispatch *tablet, struct evdev_device *device)
device->pointer.config.get_profiles = tablet_accel_config_get_profiles;
device->pointer.config.set_profile = tablet_accel_config_set_profile;
device->pointer.config.get_profile = tablet_accel_config_get_profile;
device->pointer.config.get_default_profile = tablet_accel_config_get_default_profile;
device->pointer.config.get_default_profile =
tablet_accel_config_get_default_profile;
return 0;
}
static void
tablet_init_left_handed(struct evdev_device *device,
WacomDevice *wacom)
tablet_init_left_handed(struct evdev_device *device, WacomDevice *wacom)
{
bool has_left_handed = true;
@ -2821,8 +2775,7 @@ tablet_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,
tablet_change_to_left_handed);
evdev_init_left_handed(device, tablet_change_to_left_handed);
}
static inline bool
@ -2830,7 +2783,8 @@ tablet_is_display_tablet(WacomDevice *wacom)
{
#if HAVE_LIBWACOM
return !wacom ||
(libwacom_get_integration_flags(wacom) & (WACOM_DEVICE_INTEGRATED_SYSTEM|WACOM_DEVICE_INTEGRATED_DISPLAY));
(libwacom_get_integration_flags(wacom) &
(WACOM_DEVICE_INTEGRATED_SYSTEM | WACOM_DEVICE_INTEGRATED_DISPLAY));
#else
return true;
#endif
@ -2914,8 +2868,7 @@ tablet_reject_device(struct evdev_device *device)
}
static void
tablet_fix_tilt(struct tablet_dispatch *tablet,
struct evdev_device *device)
tablet_fix_tilt(struct tablet_dispatch *tablet, struct evdev_device *device)
{
struct libevdev *evdev = device->evdev;
@ -2965,8 +2918,7 @@ tablet_fix_tilt(struct tablet_dispatch *tablet,
}
static int
tablet_init(struct tablet_dispatch *tablet,
struct evdev_device *device)
tablet_init(struct tablet_dispatch *tablet, struct evdev_device *device)
{
static unsigned int tablet_ids = 0;
struct libinput *li = evdev_libinput_context(device);
@ -2984,13 +2936,15 @@ tablet_init(struct tablet_dispatch *tablet,
evdev_device_get_sysname(device));
wacom = libwacom_new_from_path(db, event_path, WFALLBACK_NONE, NULL);
if (!wacom) {
wacom = libwacom_new_from_usbid(db,
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,
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),
@ -3037,8 +2991,7 @@ tablet_init(struct tablet_dispatch *tablet,
tablet_init_left_handed(device, wacom);
tablet_init_smoothing(device, tablet, is_aes, is_virtual);
for (axis = LIBINPUT_TABLET_TOOL_AXIS_X;
axis <= LIBINPUT_TABLET_TOOL_AXIS_MAX;
for (axis = LIBINPUT_TABLET_TOOL_AXIS_X; axis <= LIBINPUT_TABLET_TOOL_AXIS_MAX;
axis++) {
if (tablet_device_has_axis(tablet, axis))
set_bit(tablet->axis_caps, axis);

View file

@ -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 {
@ -158,7 +159,8 @@ totem_set_touch_device_enabled(struct totem_dispatch *totem,
abort();
case ARBITRATION_NOT_ACTIVE:
if (dispatch->interface->touch_arbitration_toggle)
dispatch->interface->touch_arbitration_toggle(dispatch,
dispatch->interface->touch_arbitration_toggle(
dispatch,
touch_device,
state,
rect,
@ -166,7 +168,8 @@ totem_set_touch_device_enabled(struct totem_dispatch *totem,
break;
case ARBITRATION_IGNORE_RECT:
if (dispatch->interface->touch_arbitration_update_rect)
dispatch->interface->touch_arbitration_update_rect(dispatch,
dispatch->interface->touch_arbitration_update_rect(
dispatch,
touch_device,
rect,
time);
@ -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) {
@ -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;
@ -326,7 +323,6 @@ totem_slot_fetch_axes(struct totem_dispatch *totem,
out:
*axes_out = axes;
return rc;
}
static void
@ -334,34 +330,27 @@ totem_slot_mark_all_axes_changed(struct totem_dispatch *totem,
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;
}
@ -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)
@ -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));
@ -652,14 +635,17 @@ totem_interface_device_added(struct evdev_device *device,
return;
if (totem->touch_device != NULL) {
evdev_log_bug_libinput(device,
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;
@ -748,7 +734,8 @@ totem_reject_device(struct evdev_device *device)
has_xy = libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) &&
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) &&
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 =
@ -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,18 +28,19 @@
#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
@ -183,10 +184,13 @@ struct evdev_device {
bool is_suspended;
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,7 +200,8 @@ struct evdev_device {
int apply_calibration;
struct matrix calibration;
struct matrix default_calibration; /* from LIBINPUT_CALIBRATION_MATRIX */
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,8 +347,7 @@ 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_state (*get_switch_state)(struct evdev_dispatch *dispatch,
enum libinput_switch which);
void (*left_handed_toggle)(struct evdev_dispatch *dispatch,
@ -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,12 +405,10 @@ 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,
@ -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,
@ -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,8 +732,7 @@ 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));
lag_y = sqrt((margin_distance + lag_x) * (margin_distance - lag_x));
} else { /* Infinite gradient */
lag_x = 0.0;
lag_y = margin_distance;
@ -784,7 +766,8 @@ 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) ? device->log_prefix_name
: "",
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? ": " : "",
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,7 +804,8 @@ 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) ? device->log_prefix_name
: "",
(priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? ": " : "",
format);
@ -842,7 +825,6 @@ evdev_log_msg_ratelimit(struct evdev_device *device,
ratelimit->burst,
ht.value,
ht.unit);
}
}
@ -876,8 +858,7 @@ evdev_device_unit_delta_to_mm(const struct evdev_device* device,
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);
@ -904,8 +885,7 @@ evdev_device_units_to_mm(const struct evdev_device* device,
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);
@ -932,8 +912,7 @@ evdev_device_mm_to_units(const struct evdev_device *device,
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 };
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,11 +995,15 @@ evdev_device_check_abs_axis_range(struct evdev_device *device,
}
if (value < min || value > max) {
log_info_ratelimit(evdev_libinput_context(device),
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,
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,15 +280,13 @@ 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,
fallback =
create_custom_accel_function(config->custom.fallback->step,
config->custom.fallback->points,
config->custom.fallback->npoints);
if (!fallback)
@ -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

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;

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.
@ -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;
/* 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,9 +158,7 @@ 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;
@ -179,8 +177,7 @@ accelerator_destroy(struct motion_filter *filter)
}
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.
@ -88,7 +88,8 @@ 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_factor = calculate_acceleration_simpsons(
&accel->base,
accel->profile,
data,
velocity, /* normalized coords */
@ -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,8 +191,7 @@ 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;
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;

View file

@ -33,21 +33,21 @@ struct motion_filter_interface {
struct normalized_coords (*filter)(
struct motion_filter *filter,
const struct device_float_coords *unaccelerated,
void *data, uint64_t time);
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);
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);
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);
};
@ -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,

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 tablet_accelerator_flat {
struct motion_filter base;
@ -95,7 +95,8 @@ tablet_accelerator_filter_flat_pen(struct tablet_accelerator_flat *filter,
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;
@ -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;

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.

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,
@ -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,7 +130,8 @@ 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;
@ -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 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,9 +186,7 @@ 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;
@ -217,8 +217,7 @@ accelerator_destroy_x230(struct motion_filter *filter)
}
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;
@ -263,8 +261,8 @@ 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 */
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

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
@ -93,16 +93,14 @@ 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);
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);
@ -267,7 +260,8 @@ touchpad_accel_profile_linear(struct motion_filter *filter,
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;
@ -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,7 +44,8 @@ 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;
@ -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,13 +99,11 @@ 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;

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;
@ -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,13 +132,11 @@ 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;
@ -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)
@ -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);
@ -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);

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
@ -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);
@ -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:
@ -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);
@ -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);
@ -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,
@ -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)
@ -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,15 +374,13 @@ 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,
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);
@ -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,7 +424,8 @@ 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,
pd->scroll_timer =
libinput_plugin_timer_new(libinput_plugin,
libinput_device_get_sysname(device),
wheel_on_scroll_timer_timeout,
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;
@ -87,7 +87,8 @@ 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,
libinput_plugin_system_notify_tablet_tool_configured(
struct libinput_plugin_system *system,
struct libinput_tablet_tool *tool);
void

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,
@ -189,8 +188,12 @@ double_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
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 ? "|" : ".");
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,7 +217,8 @@ 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,
plugin_log_debug(
libinput_plugin,
"device %s: device is fine, unregistering device\n",
libinput_device_get_name(device->device));
plugin_device_destroy(device);
@ -227,7 +231,8 @@ 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,
double_tool_plugin_filter_frame(
libinput_plugin,
frame,
SKIP_ERASER | PEN_OUT_OF_PROX);
libinput_plugin_prepend_evdev_frame(libinput_plugin,
@ -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,7 +259,8 @@ 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,
double_tool_plugin_filter_frame(
libinput_plugin,
frame,
SKIP_PEN | ERASER_OUT_OF_PROX);
@ -261,11 +268,12 @@ double_tool_plugin_device_handle_frame(struct libinput_plugin *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,
double_tool_plugin_filter_frame(
libinput_plugin,
frame,
SKIP_ERASER | PEN_IN_PROX);
libinput_plugin_prepend_evdev_frame(libinput_plugin,
@ -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 */
@ -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",
@ -334,7 +330,8 @@ eraser_button_button_held_handle_event(struct plugin_device *device,
&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,13 +395,22 @@ 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;
}
@ -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);
@ -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,
plugin_log_bug(
device->parent->plugin,
"Eraser button timer fired without a frame in state %s\n",
eraser_button_state_str(device->state)
);
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
@ -571,7 +584,8 @@ eraser_button_plugin_tool_configured(struct libinput_plugin *libinput_plugin,
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:
@ -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;
@ -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,7 +261,8 @@ 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,
pd->prox_out_timer =
libinput_plugin_timer_new(libinput_plugin,
libinput_device_get_sysname(device),
tablet_proximity_out_quirk_timer_func,
pd);

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;
}
@ -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);
}
@ -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);
}
}
@ -463,7 +455,8 @@ libinput_plugin_system_notify_device_ignored(struct libinput_plugin_system *syst
}
void
libinput_plugin_system_notify_tablet_tool_configured(struct libinput_plugin_system *system,
libinput_plugin_system_notify_tablet_tool_configured(
struct libinput_plugin_system *system,
struct libinput_tablet_tool *tool)
{
struct libinput_plugin *plugin;
@ -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,7 +518,8 @@ print_frame(struct libinput *libinput,
switch (evdev_usage_enum(e->usage)) {
case EVDEV_SYN_REPORT:
log_debug(libinput,
log_debug(
libinput,
"%s%u.%03u ----------------- EV_SYN ----------------- +%ums\n",
prefix,
time / 1000,
@ -617,10 +609,13 @@ plugin_system_notify_evdev_frame(struct libinput_plugin_system *system,
continue;
}
#ifdef EVENT_DEBUGGING
_autofree_ char *prefix = strdup_printf("plugin %-25s - %s:",
_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);
print_frame(libinput_device_get_context(device),
event->frame,
prefix);
#endif
libinput_plugin_process_frame(plugin,
@ -635,8 +630,11 @@ 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),
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);
}
@ -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.) */
@ -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;
@ -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 */
@ -252,7 +255,8 @@ 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_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);
@ -260,52 +264,65 @@ struct libinput_device_config_tap {
enum libinput_config_status (*set_map)(struct libinput_device *device,
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_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_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_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_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_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_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,
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_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_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_send_events_mode (*get_mode)(
struct libinput_device *device);
enum libinput_config_send_events_mode (*get_default_mode)(
struct libinput_device *device);
};
/**
@ -362,9 +379,12 @@ 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,
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);
};
@ -378,43 +398,54 @@ 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_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_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_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_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_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_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_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_status (*set)(struct libinput_device *device,
enum libinput_config_middle_emulation_state);
enum libinput_config_middle_emulation_state (*get)(
struct libinput_device *device);
@ -427,8 +458,7 @@ struct libinput_device_config_dwt {
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);
enum libinput_config_dwt_state (*get_enabled)(struct libinput_device *device);
enum libinput_config_dwt_state (*get_default_enabled)(
struct libinput_device *device);
};
@ -438,26 +468,27 @@ struct libinput_device_config_dwtp {
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);
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_config_rotation {
int (*is_available)(struct libinput_device *device);
enum libinput_config_status (*set_angle)(
struct libinput_device *device,
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_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_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);
};
@ -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,8 +736,7 @@ 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,
void (*notify_func)(uint64_t time,
struct libinput_event *event,
void *notify_func_data),
void *notify_func_data);
@ -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;
@ -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
@ -41,17 +41,22 @@ libinput_strverscmp(const char *l0, const char *r0)
* suffix and whether those digits are all zeros. */
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 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;
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. */

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)))
@ -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
@ -610,7 +611,8 @@ 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,
libinput_tablet_pad_mode_group_button_is_toggle(
struct libinput_tablet_pad_mode_group *group,
unsigned int button);
/**
@ -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
@ -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,8 +1435,7 @@ 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,
libinput_event_pointer_get_absolute_x_transformed(struct libinput_event_pointer *event,
uint32_t width);
/**
@ -1460,8 +1456,7 @@ 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,
libinput_event_pointer_get_absolute_y_transformed(struct libinput_event_pointer *event,
uint32_t height);
/**
@ -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
@ -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
*
@ -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
@ -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
@ -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
@ -4973,7 +4949,8 @@ 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,
libinput_device_config_tap_set_drag_lock_enabled(
struct libinput_device *device,
enum libinput_config_drag_lock_state enable);
/**
@ -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,7 +5307,8 @@ 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,
libinput_device_config_area_set_rectangle(
struct libinput_device *device,
const struct libinput_config_area_rectangle *rect);
/**
@ -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,7 +6099,8 @@ 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,
libinput_device_config_click_set_clickfinger_button_map(
struct libinput_device *device,
enum libinput_config_clickfinger_button_map map);
/**
@ -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
@ -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
@ -6510,7 +6489,8 @@ 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,
libinput_device_config_scroll_set_button_lock(
struct libinput_device *device,
enum libinput_config_scroll_button_lock_state state);
/**
@ -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,7 +7036,8 @@ 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,
libinput_tablet_tool_config_eraser_button_set_mode(
struct libinput_tablet_tool *tool,
enum libinput_config_eraser_button_mode mode);
/**
@ -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;
@ -72,8 +71,7 @@ path_input_disable(struct libinput *libinput)
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);
}
@ -95,8 +93,11 @@ 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;
}
@ -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) {
@ -246,7 +248,6 @@ path_input_destroy(struct libinput *input)
list_for_each_safe(dev, &path_input->path_list, link)
path_device_destroy(dev);
}
static struct libinput_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;
}
@ -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;

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
@ -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";
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();
}
@ -302,15 +344,33 @@ 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;
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
@ -606,7 +673,10 @@ parse_match(struct quirks_context *ctx,
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;
@ -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.
@ -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,7 +97,8 @@ 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,
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,
@ -107,7 +107,8 @@ libinput_timer_set_flags(struct libinput_timer *timer,
log_bug_libinput(timer->libinput,
"timer %s: offset more than 5s, now %d expire %d\n",
timer->timer_name,
us2ms(now), us2ms(expire));
us2ms(now),
us2ms(expire));
}
#endif
@ -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);
@ -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;
@ -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,8 +395,7 @@ 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;

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,7 +84,8 @@ backtrace_print(FILE *fp,
status = WEXITSTATUS(status);
if (status != 0) {
fprintf(fp, "ERROR: gstack failed, no backtrace available: %s\n",
fprintf(fp,
"ERROR: gstack failed, no backtrace available: %s\n",
strerror(status));
goto out;
}
@ -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

@ -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_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,9 +82,7 @@ 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);

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"
@ -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

View file

@ -25,11 +25,11 @@
#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)
@ -185,48 +185,62 @@ 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)",
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 = 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",
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",
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_scroll_has_natural_scroll(dev) ? " scroll-nat"
: "",
libinput_device_config_calibration_has_matrix(dev) ? " calib" : "",
scroll ? scroll : "",
clickm ? clickm : "",
@ -258,25 +272,35 @@ print_device_notify(struct libinput_event *ev)
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",
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" : "",
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 : "");
@ -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,7 +653,8 @@ 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",
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" : "",
@ -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);
@ -673,11 +732,15 @@ print_gesture_event_without_coords(struct libinput_event *ev, const struct libin
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

@ -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(...);
@ -146,7 +160,8 @@ static inline void _close_file_(FILE **fp) { if (*fp) fclose(*fp); }
struct __useless_struct_to_allow_trailing_semicolon__
static inline void *
_steal(void *ptr) {
_steal(void *ptr)
{
void **original = (void **)ptr;
void *swapped = *original;
*original = NULL;
@ -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,18 +48,31 @@ 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();
}
@ -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

@ -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;
}
@ -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) {
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

@ -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);
}

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
@ -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;
@ -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)
@ -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);
@ -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,12 +148,8 @@ 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;

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,
@ -76,5 +76,4 @@ TEST_DEVICE(LITEST_ABSINFO_OVERRIDE,
{ "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,
@ -197,5 +197,4 @@ TEST_DEVICE(LITEST_ACER_HAWAII_KEYBOARD,
.name = "Chicony ACER Hawaii Keyboard",
.id = &input_id,
.events = events,
.absinfo = NULL,
)
.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_X, .value = LITEST_AUTO_ASSIGN },
@ -96,5 +96,4 @@ TEST_DEVICE(LITEST_ACER_HAWAII_TOUCHPAD,
.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 */
@ -157,5 +157,4 @@ TEST_DEVICE(LITEST_AIPTEK,
.name = "Aiptek",
.id = &input_id,
.events = events,
.absinfo = absinfo,
)
.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;
@ -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,9 +85,7 @@ 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) {
if (alps->active_touches > 2 && slot != alps->first && slot != alps->second) {
litest_event(d, EV_SYN, SYN_REPORT, 0);
return true;
}
@ -178,5 +173,4 @@ TEST_DEVICE(LITEST_ALPS_3FG,
.id = &input_id,
.events = events,
.absinfo = absinfo,
.create = alps_create,
)
.create = alps_create, )

View file

@ -26,9 +26,8 @@
#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 },
@ -121,5 +120,4 @@ TEST_DEVICE(LITEST_ALPS_DUALPOINT,
.id = &input_id,
.events = events,
.absinfo = absinfo,
.quirk_file = quirk_file,
)
.quirk_file = quirk_file, )

View file

@ -26,9 +26,8 @@
#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 },
@ -114,5 +113,4 @@ TEST_DEVICE(LITEST_ALPS_SEMI_MT,
.name = "AlpsPS/2 ALPS GlidePoint",
.id = &input_id,
.events = events,
.absinfo = absinfo,
)
.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.
@ -217,5 +217,4 @@ TEST_DEVICE(LITEST_ANKER_MOUSE_KBD,
.name = "USB Laser Game Mouse",
.id = &input_id,
.absinfo = absinfo,
.events = events,
)
.events = events, )

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_X, .value = LITEST_AUTO_ASSIGN },
@ -100,5 +100,4 @@ TEST_DEVICE(LITEST_APPLETOUCH,
.id = &input_id,
.events = events,
.absinfo = absinfo,
.quirk_file = quirk_file,
)
.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,
@ -226,5 +226,4 @@ TEST_DEVICE(LITEST_APPLE_KEYBOARD,
.name = "Apple Inc. Apple Internal Keyboard / Trackpad",
.id = &input_id,
.events = events,
.absinfo = NULL,
)
.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 },
@ -101,5 +101,4 @@ TEST_DEVICE(LITEST_MAGICMOUSE,
.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 */
@ -323,5 +323,4 @@ TEST_DEVICE(LITEST_MOUSE_GLADIUS,
.name = "ASUS ROG GLADIUS",
.id = &input_id,
.absinfo = absinfo,
.events = events,
)
.events = events, )

View file

@ -26,9 +26,8 @@
#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 },
@ -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,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_CLICKPAD |
LITEST_HOVER,
.interface = &interface,
.name = "Atmel maXTouch Touchpad",
.id = &input_id,
.events = events,
.absinfo = absinfo,
)
.absinfo = absinfo, )

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_X, .value = LITEST_AUTO_ASSIGN },
@ -120,12 +120,11 @@ static int events[] = {
/* clang-format on */
TEST_DEVICE(LITEST_BCM5974,
.features = LITEST_TOUCHPAD | LITEST_CLICKPAD |
LITEST_BUTTON | LITEST_APPLE_CLICKPAD,
.features = LITEST_TOUCHPAD | LITEST_CLICKPAD | LITEST_BUTTON |
LITEST_APPLE_CLICKPAD,
.interface = &interface,
.name = "bcm5974",
.id = &input_id,
.events = events,
.absinfo = absinfo,
)
.absinfo = absinfo, )

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