Compare commits

...

24 commits
main ... 1.6.3

Author SHA1 Message Date
Peter Hutterer
b2325b33fc configure.ac: libinput 1.6.3
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-03-08 17:02:29 +10:00
Peter Hutterer
4e1610a286 touchpad: ignore hovering touches for the software button state
If a touch started hovering in the main area, the button state would start
with AREA and never move to the real button state, despite the finger
triggering the pressure thresholds correctly in one of the areas.

This could even happen across touch sequences if a touch went below pressure
in the software button area, it changed to hovering and the button state
changed to NONE. On the next event, the touch is still hovering and the
current position of the touch is taken for the button state machine.

https://bugs.freedesktop.org/show_bug.cgi?id=99976

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit c0dbd6eb38)
2017-03-08 16:42:35 +10:00
Peter Hutterer
8dea77ff49 tools: fix printing of tablet coordinates
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 07ce6c8954)
2017-03-08 16:42:19 +10:00
Peter Hutterer
2fcf482d06 touchpad: reduce minimum height for horiz edge scrolling to 40mm
Introduced in commit 8e7f99c27a we only allowed horizontal edge scrolling
on devices larger than 50mm to leave enough reactive space on the touchpad.
Looking at a ruler, a 50mm high touchpad is still large enough to leave the
bottom 7mm as an horizontal edge scroll area. Reduce the minimum size to 40mm
instead, that's closer to where it starts to get a bit iffy.

https://bugzilla.redhat.com/show_bug.cgi?id=1422221

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit d6379bc3f3)
2017-03-08 16:41:49 +10:00
Peter Hutterer
3940ab7f40 tools: add mode group info to libinput-list-devices
We don't cater for the special case of groups having a different number of
modes, there is no hardware right now that does that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 38c675c959)
2017-02-27 13:42:49 +10:00
Peter Hutterer
7b11fef349 Fix a crash when requesting invalid mode group indices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit c787ccf270)
2017-02-27 13:42:43 +10:00
Peter Hutterer
e2fc437342 doc: minor documentation fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit d248049f8d)
2017-02-27 13:42:37 +10:00
Peter Hutterer
7942aa51ad configure.ac: libinput 1.6.2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-21 11:34:39 +10:00
Peter Hutterer
005efbf843 Add the matching @see tags to the accel config
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit c5d9ecbdae)
2017-02-21 11:31:04 +10:00
Peter Hutterer
ca416f94d7 tools: print the key as -1 for obfuscated keys
Missing from 8c1aa1de where we hid the human-readable parts but the keycode
itself is still enough information to recover the typed bits.
Print it as -1 as that keycode doesn't exist for real keys so it stands out
nicely.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit a6b550cb78)
2017-02-21 11:31:04 +10:00
Peter Hutterer
1c6e6a6814 tools: hide key codes by default
libinput-debug-events prints keycodes as they come in. This makes it dangerous
to be run by users (especially in the background) because it will leak
sensitive information as it is typed. Obfuscate the base set of keycodes
by default, require a --show-keycodes switch to show it.

The few times we actually need the keycodes, we can run the switch in the
debugging tool.

This does not affect keys outside of the main block on the keyboard (F-keys,
multimedia keys).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 8c1aa1de00)
2017-02-21 11:22:30 +10:00
Peter Hutterer
d0cd796095 touchpad: mark the Apple onebutton touchpad as clickfinger-default
We don't initialize click methods on devices with physical buttons. This model
is a special case, it's not a clickpad but it only has one button (because one
button is all you ever need and whatnot).

https://bugs.freedesktop.org/show_bug.cgi?id=99283

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit f2f616a1fc)
2017-02-17 15:38:54 +10:00
Peter Hutterer
aff9cd213b test: check if left-handed is available for the left-handed tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit a04ba9a276)
2017-02-17 15:38:40 +10:00
Peter Hutterer
1321202d50 pad: don't warn about failure to initialize the LEDs on litest devices
We don't init the required /sysfs files, so let's not spew a lot of warnings
during the test suite.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit df18c6b1aa)
2017-02-17 09:59:32 +10:00
Peter Hutterer
ce583a8c67 touchpad: expand top middle button to cover 40mm to 60mm
42 and 58 were within the middle button already, 40/60 are more accurate
values.

https://bugs.freedesktop.org/show_bug.cgi?id=99212

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit cbe9a3bfc3)
2017-02-17 09:59:22 +10:00
Peter Hutterer
254bd281f7 configure.ac: libinput 1.6.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-02 17:20:46 +10:00
Peter Hutterer
d7f6702e1b Revert "touchpad: reduce the initial timeout for tapping after touch"
The timeout is too short, a number of users are unable to tap now.

https://bugs.freedesktop.org/show_bug.cgi?id=99447

This reverts commit d0ba1e2b38.

(cherry picked from commit e86fdd5883)
2017-02-02 11:10:36 +10:00
Peter Hutterer
cc12b91a44 evdev: fix a comment typo
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit ab563d0920)
2017-02-02 11:10:36 +10:00
Peter Hutterer
e9d9681300 doc: add a table of contents to the FAQ
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit a5cefb76ac)
2017-02-02 11:10:36 +10:00
Peter Hutterer
049a4da864 pad: implement kernel-based pad led handling
For each device open the various led devices (brightness only) and map the one
nonzero brightness to the current mode.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 5eb71b65e4)
2017-02-02 11:10:36 +10:00
Peter Hutterer
72788e809a test: fix two test udev rules
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 9672e2f407)
2017-02-02 11:10:36 +10:00
Peter Hutterer
feb677344f doc: update the FAQ entry with how config options are stored
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit aae997e60e)
2017-02-02 11:10:36 +10:00
Peter Hutterer
22e8de0dcd evdev: fix an error message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 13a2336beb)
2017-02-02 11:10:36 +10:00
Peter Hutterer
6e094af2b6 test: fix pointer accel defaults test
Loop immediately exited, this code was never triggered.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 4d20130e05)
2017-02-02 11:08:47 +10:00
26 changed files with 901 additions and 53 deletions

View file

@ -2,7 +2,7 @@ AC_PREREQ([2.64])
m4_define([libinput_major_version], [1])
m4_define([libinput_minor_version], [6])
m4_define([libinput_micro_version], [0])
m4_define([libinput_micro_version], [3])
m4_define([libinput_version],
[libinput_major_version.libinput_minor_version.libinput_micro_version])
@ -35,7 +35,7 @@ AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
# b) If interfaces have been changed or added, but binary compatibility has
# been preserved, change to C+1:0:A+1
# c) If the interface is the same as the previous version, change to C:R+1:A
LIBINPUT_LT_VERSION=21:2:11
LIBINPUT_LT_VERSION=21:5:11
AC_SUBST(LIBINPUT_LT_VERSION)
AM_SILENT_RULES([yes])
@ -232,7 +232,7 @@ AC_ARG_ENABLE(libwacom,
[use_libwacom="$enableval"],
[use_libwacom="yes"])
if test "x$use_libwacom" = "xyes"; then
PKG_CHECK_MODULES(LIBWACOM, [libwacom >= 0.12], [HAVE_LIBWACOM="yes"])
PKG_CHECK_MODULES(LIBWACOM, [libwacom >= 0.20], [HAVE_LIBWACOM="yes"])
AC_DEFINE(HAVE_LIBWACOM, 1, [Build with libwacom])
OLD_LIBS=$LIBS

View file

@ -108,7 +108,7 @@ ENV{ID_MODEL_ID}=="034b", ENV{ID_INPUT_TOUCHPAD}="", ENV{ID_INPUT_TABLET}="1"
@section model_specific_configuration Model-specific configuration
libinput reserves the property prefixes <b>LIBINPUT_MODEL_</b> and
<b>LIBINPUT_ATTR_*</b> for model-specific configuration. <b>These prefixes
<b>LIBINPUT_ATTR_</b> for model-specific configuration. <b>These prefixes
are reserved as private API, do not use.</b>
The effect of these properties may be to enable or disable certain

View file

@ -3,6 +3,8 @@
Frequently asked questions about libinput.
@tableofcontents
@section faq_fast_mouse My mouse moves too fast, even at the slowest setting
This is a symptom of high-dpi mice (greater than 1000dpi). These devices
@ -40,12 +42,20 @@ manage these and decide which configuration option to apply to each device.
This must be done at startup, after a resume and whenever a new device is
detected.
In a GNOME X.Org stack a user would usually toggle an option in
the gnome-control-center which adjusts a gsettings entry. That change is
picked up by gnome-settings-daemon and applied to the device by adjusting
input device properties that the xf86-input-libinput driver provides.
The input device property changes map to the respective libinput
configuration options.
One commonly used way to configure libinput is to have the Wayland
compositor expose a compositor-specific configuration option. For example,
in a GNOME stack, the gnome-control-center modifies dconf entries. These
changes are read by mutter and applied to libinput. Changing these entries
via the gsettings commandline tool has the same effect.
Another commonly used way to configure libinput is to have xorg.conf.d
snippets. When libinput is used with the xf86-input-libinput driver in an
X.Org stack, these options are read on startup and apply to each device.
Changing properties at runtime with the xinput commandline tool has the same
effect.
In both cases, the selection of available options and how they are exposed
depends on the libinput caller (e.g. mutter or xf86-input-libinput).
@dotfile libinput-stack-gnome.gv

View file

@ -458,7 +458,7 @@ tp_button_handle_state(struct tp_dispatch *tp, uint64_t time)
struct tp_touch *t;
tp_for_each_touch(tp, t) {
if (t->state == TOUCH_NONE)
if (t->state == TOUCH_NONE || t->state == TOUCH_HOVERING)
continue;
if (t->state == TOUCH_END) {
@ -610,13 +610,13 @@ tp_init_top_softbuttons(struct tp_dispatch *tp,
evdev_device_get_size(device, &width, &height);
mm.x = width * 0.58;
mm.x = width * 0.60;
mm.y = topsize_mm;
edges = evdev_device_mm_to_units(device, &mm);
tp->buttons.top_area.bottom_edge = edges.y;
tp->buttons.top_area.rightbutton_left_edge = edges.x;
mm.x = width * 0.42;
mm.x = width * 0.40;
edges = evdev_device_mm_to_units(device, &mm);
tp->buttons.top_area.leftbutton_right_edge = edges.x;
} else {
@ -637,6 +637,9 @@ tp_button_config_click_get_methods(struct libinput_device *device)
methods |= LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
}
if (evdev->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON)
methods |= LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
return methods;
}
@ -695,16 +698,17 @@ tp_click_get_default_method(struct tp_dispatch *tp)
EVDEV_MODEL_SYSTEM76_BONOBO |
EVDEV_MODEL_SYSTEM76_GALAGO |
EVDEV_MODEL_SYSTEM76_KUDU |
EVDEV_MODEL_CLEVO_W740SU;
EVDEV_MODEL_CLEVO_W740SU |
EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON;
if (device->model_flags & clickfinger_models)
return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
if (!tp->buttons.is_clickpad)
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
else if (libevdev_get_id_vendor(tp->device->evdev) == VENDOR_ID_APPLE)
return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
if (device->model_flags & clickfinger_models)
return LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
return LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
}
@ -1177,7 +1181,8 @@ tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
int
tp_post_button_events(struct tp_dispatch *tp, uint64_t time)
{
if (tp->buttons.is_clickpad)
if (tp->buttons.is_clickpad ||
tp->device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON)
return tp_post_clickpadbutton_buttons(tp, time);
else
return tp_post_physical_buttons(tp, time);

View file

@ -291,14 +291,14 @@ tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device)
struct phys_coords mm = { 0.0, 0.0 };
evdev_device_get_size(device, &width, &height);
/* Touchpads smaller than 50mm are not tall enough to have a
/* Touchpads smaller than 40mm are not tall enough to have a
horizontal scroll area, it takes too much space away. But
clickpads have enough space here anyway because of the
software button area (and all these tiny clickpads were built
when software buttons were a thing, e.g. Lenovo *20 series)
*/
if (!tp->buttons.is_clickpad)
want_horiz_scroll = (height >= 50);
want_horiz_scroll = (height >= 40);
/* 7mm edge size */
mm.x = width - 7;

View file

@ -33,7 +33,6 @@
#include "evdev-mt-touchpad.h"
#define DEFAULT_TAP_INITIAL_TIMEOUT_PERIOD ms2us(100)
#define DEFAULT_TAP_TIMEOUT_PERIOD ms2us(180)
#define DEFAULT_DRAG_TIMEOUT_PERIOD ms2us(300)
#define DEFAULT_TAP_MOVE_THRESHOLD TP_MM_TO_DPI_NORMALIZED(1.3)
@ -127,13 +126,6 @@ tp_tap_notify(struct tp_dispatch *tp,
state);
}
static void
tp_tap_set_initial_timer(struct tp_dispatch *tp, uint64_t time)
{
libinput_timer_set(&tp->tap.timer,
time + DEFAULT_TAP_INITIAL_TIMEOUT_PERIOD);
}
static void
tp_tap_set_timer(struct tp_dispatch *tp, uint64_t time)
{
@ -163,7 +155,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_TOUCH:
tp->tap.state = TAP_STATE_TOUCH;
tp->tap.first_press_time = time;
tp_tap_set_initial_timer(tp, time);
tp_tap_set_timer(tp, time);
break;
case TAP_EVENT_RELEASE:
break;

View file

@ -2400,6 +2400,7 @@ struct evdev_dispatch *
evdev_mt_touchpad_create(struct evdev_device *device)
{
struct tp_dispatch *tp;
bool want_left_handed = true;
evdev_tag_touchpad(device, device->udev_device);
@ -2420,7 +2421,10 @@ evdev_mt_touchpad_create(struct evdev_device *device)
tp->sendevents.config.get_mode = tp_sendevents_get_mode;
tp->sendevents.config.get_default_mode = tp_sendevents_get_default_mode;
evdev_init_left_handed(device, tp_change_to_left_handed);
if (device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON)
want_left_handed = false;
if (want_left_handed)
evdev_init_left_handed(device, tp_change_to_left_handed);
return &tp->base;
}

View file

@ -29,14 +29,143 @@
#include "evdev-tablet-pad.h"
#if HAVE_LIBWACOM
#include <libwacom/libwacom.h>
#endif
struct pad_led_group {
struct libinput_tablet_pad_mode_group base;
struct list led_list;
struct list toggle_button_list;
};
struct pad_mode_toggle_button {
struct list link;
unsigned int button_index;
};
struct pad_mode_led {
struct list link;
/* /sys/devices/..../input1235/input1235::wacom-led_0.1/brightness */
int brightness_fd;
int mode_idx;
};
static inline struct pad_mode_toggle_button *
pad_mode_toggle_button_new(struct pad_dispatch *pad,
struct libinput_tablet_pad_mode_group *group,
unsigned int button_index)
{
struct pad_mode_toggle_button *button;
button = zalloc(sizeof *button);
if (!button)
return NULL;
button->button_index = button_index;
return button;
}
static inline void
pad_mode_toggle_button_destroy(struct pad_mode_toggle_button* button)
{
list_remove(&button->link);
free(button);
}
static inline int
pad_led_group_get_mode(struct pad_led_group *group)
{
char buf[4] = {0};
int rc;
unsigned int brightness;
struct pad_mode_led *led;
list_for_each(led, &group->led_list, link) {
rc = lseek(led->brightness_fd, 0, SEEK_SET);
if (rc == -1)
return -errno;
rc = read(led->brightness_fd, buf, sizeof(buf) - 1);
if (rc == -1)
return -errno;
rc = sscanf(buf, "%u\n", &brightness);
if (rc != 1)
return -EINVAL;
/* Assumption: only one LED lit up at any time */
if (brightness != 0)
return led->mode_idx;
}
return -EINVAL;
}
static inline void
pad_led_destroy(struct libinput *libinput,
struct pad_mode_led *led)
{
list_remove(&led->link);
if (led->brightness_fd != -1)
close_restricted(libinput, led->brightness_fd);
free(led);
}
static inline struct pad_mode_led *
pad_led_new(struct libinput *libinput, const char *prefix, int group, int mode)
{
struct pad_mode_led *led;
char path[PATH_MAX];
int rc, fd;
led = zalloc(sizeof *led);
if (!led)
return NULL;
led->brightness_fd = -1;
led->mode_idx = mode;
list_init(&led->link);
/* /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);
if (rc == -1)
goto error;
fd = open_restricted(libinput, path, O_RDONLY);
if (fd < 0) {
errno = -fd;
goto error;
}
led->brightness_fd = fd;
return led;
error:
pad_led_destroy(libinput, led);
return NULL;
}
static void
pad_led_group_destroy(struct libinput_tablet_pad_mode_group *g)
{
struct pad_led_group *group = (struct pad_led_group *)g;
struct pad_mode_toggle_button *button, *tmp;
struct pad_mode_led *led, *tmpled;
list_for_each_safe(button, tmp, &group->toggle_button_list, link)
pad_mode_toggle_button_destroy(button);
list_for_each_safe(led, tmpled, &group->led_list, link)
pad_led_destroy(g->device->seat->libinput, led);
free(group);
}
@ -58,10 +187,165 @@ pad_group_new_basic(struct pad_dispatch *pad,
group->base.current_mode = 0;
group->base.num_modes = nleds;
group->base.destroy = pad_led_group_destroy;
list_init(&group->toggle_button_list);
list_init(&group->led_list);
return group;
}
static inline bool
is_litest_device(struct evdev_device *device)
{
return !!udev_device_get_property_value(device->udev_device,
"LIBINPUT_TEST_DEVICE");
}
static inline struct pad_led_group *
pad_group_new(struct pad_dispatch *pad,
unsigned int group_index,
int nleds,
const char *syspath)
{
struct libinput *libinput = pad->device->base.seat->libinput;
struct pad_led_group *group;
int rc;
group = pad_group_new_basic(pad, group_index, nleds);
if (!group)
return NULL;
while (nleds--) {
struct pad_mode_led *led;
led = pad_led_new(libinput, syspath, group_index, nleds);
if (!led)
goto error;
list_insert(&group->led_list, &led->link);
}
rc = pad_led_group_get_mode(group);
if (rc < 0) {
errno = -rc;
goto error;
}
group->base.current_mode = rc;
return group;
error:
if (!is_litest_device(pad->device))
log_error(libinput,
"%s: unable to init LED group: %s\n",
pad->device->devname,
strerror(errno));
pad_led_group_destroy(&group->base);
return NULL;
}
static inline bool
pad_led_get_sysfs_base_path(struct evdev_device *device,
char *path_out,
size_t path_out_sz)
{
struct udev_device *parent, *udev_device;
const char *test_path;
int rc;
udev_device = device->udev_device;
/* For testing purposes only allow for a base path set through a
* udev rule. We still expect the normal directory hierarchy inside */
test_path = udev_device_get_property_value(udev_device,
"LIBINPUT_TEST_TABLET_PAD_SYSFS_PATH");
if (test_path) {
rc = snprintf(path_out, path_out_sz, "%s", test_path);
return rc != -1;
}
parent = udev_device_get_parent_with_subsystem_devtype(udev_device,
"input",
NULL);
if (!parent)
return false;
rc = snprintf(path_out,
path_out_sz,
"%s/%s::wacom-",
udev_device_get_syspath(parent),
udev_device_get_sysname(parent));
return rc != -1;
}
#if HAVE_LIBWACOM
static int
pad_init_led_groups(struct pad_dispatch *pad,
struct evdev_device *device,
WacomDevice *wacom)
{
struct libinput *libinput = device->base.seat->libinput;
const WacomStatusLEDs *leds;
int nleds, nmodes;
int i;
struct pad_led_group *group;
char syspath[PATH_MAX];
leds = libwacom_get_status_leds(wacom, &nleds);
if (nleds == 0)
return 1;
/* syspath is /sys/class/leds/input1234/input12345::wacom-" and
only needs the group + mode appended */
if (!pad_led_get_sysfs_base_path(device, syspath, sizeof(syspath)))
return 1;
for (i = 0; i < nleds; i++) {
switch(leds[i]) {
case WACOM_STATUS_LED_UNAVAILABLE:
log_bug_libinput(libinput,
"Invalid led type %d\n",
leds[i]);
return 1;
case WACOM_STATUS_LED_RING:
nmodes = libwacom_get_ring_num_modes(wacom);
group = pad_group_new(pad, i, nmodes, syspath);
if (!group)
return 1;
list_insert(&pad->modes.mode_group_list, &group->base.link);
break;
case WACOM_STATUS_LED_RING2:
nmodes = libwacom_get_ring2_num_modes(wacom);
group = pad_group_new(pad, i, nmodes, syspath);
if (!group)
return 1;
list_insert(&pad->modes.mode_group_list, &group->base.link);
break;
case WACOM_STATUS_LED_TOUCHSTRIP:
nmodes = libwacom_get_strips_num_modes(wacom);
group = pad_group_new(pad, i, nmodes, syspath);
if (!group)
return 1;
list_insert(&pad->modes.mode_group_list, &group->base.link);
break;
case WACOM_STATUS_LED_TOUCHSTRIP2:
/* there is no get_strips2_... */
nmodes = libwacom_get_strips_num_modes(wacom);
group = pad_group_new(pad, i, nmodes, syspath);
if (!group)
return 1;
list_insert(&pad->modes.mode_group_list, &group->base.link);
break;
}
}
return 0;
}
#endif
static inline struct libinput_tablet_pad_mode_group *
pad_get_mode_group(struct pad_dispatch *pad, unsigned int index)
{
@ -75,6 +359,192 @@ pad_get_mode_group(struct pad_dispatch *pad, unsigned int index)
return NULL;
}
#if HAVE_LIBWACOM
static inline int
pad_find_button_group(WacomDevice *wacom,
int button_index,
WacomButtonFlags button_flags)
{
int i;
WacomButtonFlags flags;
for (i = 0; i < libwacom_get_num_buttons(wacom); i++) {
if (i == button_index)
continue;
flags = libwacom_get_button_flag(wacom, 'A' + i);
if ((flags & WACOM_BUTTON_MODESWITCH) == 0)
continue;
if ((flags & WACOM_BUTTON_DIRECTION) ==
(button_flags & WACOM_BUTTON_DIRECTION))
return libwacom_get_button_led_group(wacom, 'A' + i);
}
return -1;
}
static int
pad_init_mode_buttons(struct pad_dispatch *pad,
WacomDevice *wacom)
{
struct libinput *libinput = pad_libinput_context(pad);
struct libinput_tablet_pad_mode_group *group;
unsigned int group_idx;
int i;
WacomButtonFlags flags;
/* libwacom numbers buttons as 'A', 'B', etc. We number them with 0,
* 1, ...
*/
for (i = 0; i < libwacom_get_num_buttons(wacom); i++) {
group_idx = libwacom_get_button_led_group(wacom, 'A' + i);
flags = libwacom_get_button_flag(wacom, 'A' + i);
/* If this button is not a mode toggle button, find the mode
* toggle button with the same position flags and take that
* button's group idx */
if ((int)group_idx == -1) {
group_idx = pad_find_button_group(wacom, i, flags);
}
if ((int)group_idx == -1) {
log_bug_libinput(libinput,
"%s: unhandled position for button %i\n",
pad->device->devname,
i);
return 1;
}
group = pad_get_mode_group(pad, group_idx);
if (!group) {
log_bug_libinput(libinput,
"%s: Failed to find group %d for button %i\n",
pad->device->devname,
group_idx,
i);
return 1;
}
group->button_mask |= 1 << i;
if (flags & WACOM_BUTTON_MODESWITCH) {
struct pad_mode_toggle_button *b;
struct pad_led_group *g;
b = pad_mode_toggle_button_new(pad, group, i);
if (!b)
return 1;
g = (struct pad_led_group*)group;
list_insert(&g->toggle_button_list, &b->link);
group->toggle_button_mask |= 1 << i;
}
}
return 0;
}
static void
pad_init_mode_rings(struct pad_dispatch *pad, WacomDevice *wacom)
{
struct libinput_tablet_pad_mode_group *group;
const WacomStatusLEDs *leds;
int i, nleds;
leds = libwacom_get_status_leds(wacom, &nleds);
if (nleds == 0)
return;
for (i = 0; i < nleds; i++) {
switch(leds[i]) {
case WACOM_STATUS_LED_RING:
group = pad_get_mode_group(pad, i);
group->ring_mask |= 0x1;
break;
case WACOM_STATUS_LED_RING2:
group = pad_get_mode_group(pad, i);
group->ring_mask |= 0x2;
break;
default:
break;
}
}
}
static void
pad_init_mode_strips(struct pad_dispatch *pad, WacomDevice *wacom)
{
struct libinput_tablet_pad_mode_group *group;
const WacomStatusLEDs *leds;
int i, nleds;
leds = libwacom_get_status_leds(wacom, &nleds);
if (nleds == 0)
return;
for (i = 0; i < nleds; i++) {
switch(leds[i]) {
case WACOM_STATUS_LED_TOUCHSTRIP:
group = pad_get_mode_group(pad, i);
group->strip_mask |= 0x1;
break;
case WACOM_STATUS_LED_TOUCHSTRIP2:
group = pad_get_mode_group(pad, i);
group->strip_mask |= 0x2;
break;
default:
break;
}
}
}
static int
pad_init_leds_from_libwacom(struct pad_dispatch *pad,
struct evdev_device *device)
{
struct libinput *libinput = device->base.seat->libinput;
WacomDeviceDatabase *db = NULL;
WacomDevice *wacom = NULL;
int rc = 1;
db = libwacom_database_new();
if (!db) {
log_info(libinput,
"Failed to initialize libwacom context.\n");
goto out;
}
wacom = libwacom_new_from_path(db,
udev_device_get_devnode(device->udev_device),
WFALLBACK_NONE,
NULL);
if (!wacom)
goto out;
rc = pad_init_led_groups(pad, device, wacom);
if (rc != 0)
goto out;
if ((rc = pad_init_mode_buttons(pad, wacom)) != 0)
goto out;
pad_init_mode_rings(pad, wacom);
pad_init_mode_strips(pad, wacom);
out:
if (wacom)
libwacom_destroy(wacom);
if (db)
libwacom_database_destroy(db);
if (rc != 0)
pad_destroy_leds(pad);
return rc;
}
#endif /* HAVE_LIBWACOM */
static int
pad_init_fallback_group(struct pad_dispatch *pad)
{
@ -112,11 +582,12 @@ pad_init_leds(struct pad_dispatch *pad,
return rc;
}
/* Eventually we slot the libwacom-based led detection in here. That
* requires getting the kernel ready first. For now we just init the
* fallback single-mode group.
*/
rc = pad_init_fallback_group(pad);
/* If libwacom fails, we init one fallback group anyway */
#if HAVE_LIBWACOM
rc = pad_init_leds_from_libwacom(pad, device);
#endif
if (rc != 0)
rc = pad_init_fallback_group(pad);
return rc;
}
@ -136,6 +607,7 @@ pad_button_update_mode(struct libinput_tablet_pad_mode_group *g,
enum libinput_button_state state)
{
struct pad_led_group *group = (struct pad_led_group*)g;
int rc;
if (state != LIBINPUT_BUTTON_STATE_PRESSED)
return;
@ -143,9 +615,9 @@ pad_button_update_mode(struct libinput_tablet_pad_mode_group *g,
if (!libinput_tablet_pad_mode_group_button_is_toggle(g, button_index))
return;
log_bug_libinput(group->base.device->seat->libinput,
"Button %d should not be a toggle button",
button_index);
rc = pad_led_group_get_mode(group);
if (rc >= 0)
group->base.current_mode = rc;
}
int
@ -173,5 +645,9 @@ evdev_device_tablet_pad_get_mode_group(struct evdev_device *device,
if (!(device->seat_caps & EVDEV_DEVICE_TABLET_PAD))
return NULL;
if (index >=
(unsigned int)evdev_device_tablet_pad_get_num_mode_groups(device))
return NULL;
return pad_get_mode_group(pad, index);
}

View file

@ -2077,7 +2077,7 @@ evdev_read_wheel_click_count_prop(struct evdev_device *device,
}
log_error(evdev_libinput_context(device),
"Mouse wheel click count '%s' is present but invalid, "
"Mouse wheel click count for '%s' is present but invalid, "
"using %d degrees for angle instead instead\n",
device->devname,
DEFAULT_WHEEL_CLICK_ANGLE);
@ -2208,6 +2208,7 @@ evdev_read_model_flags(struct evdev_device *device)
MODEL(HP6910_TOUCHPAD),
MODEL(HP_ZBOOK_STUDIO_G3),
MODEL(HP_PAVILION_DM4_TOUCHPAD),
MODEL(APPLE_TOUCHPAD_ONEBUTTON),
#undef MODEL
{ "ID_INPUT_TRACKBALL", EVDEV_MODEL_TRACKBALL },
{ NULL, EVDEV_MODEL_DEFAULT },

View file

@ -123,6 +123,7 @@ enum evdev_device_model {
EVDEV_MODEL_HP6910_TOUCHPAD = (1 << 22),
EVDEV_MODEL_HP_ZBOOK_STUDIO_G3 = (1 << 23),
EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD = (1 << 24),
EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON = (1 << 25),
};
struct mt_slot {
@ -546,7 +547,7 @@ evdev_to_left_handed(struct evdev_device *device,
/**
* Apply a hysteresis filtering to the coordinate in, based on the current
* hystersis center and the margin. If 'in' is within 'margin' of center,
* hysteresis center and the margin. If 'in' is within 'margin' of center,
* return the center (and thus filter the motion). If 'in' is outside,
* return a point on the edge of the new margin. So for a point x in the
* space outside c + margin we return r:

View file

@ -47,6 +47,7 @@
#define VENDOR_ID_WACOM 0x56a
#define VENDOR_ID_SYNAPTICS_SERIAL 0x002
#define PRODUCT_ID_APPLE_KBD_TOUCHPAD 0x273
#define PRODUCT_ID_APPLE_APPLETOUCH 0x21a
#define PRODUCT_ID_SYNAPTICS_SERIAL 0x007
/* The HW DPI rate we normalize to before calculating pointer acceleration */

View file

@ -4246,6 +4246,10 @@ libinput_device_config_send_events_get_default_mode(struct libinput_device *devi
* @param device The device to configure
*
* @return 0 if the device is not accelerated, nonzero if it is accelerated
*
* @see libinput_device_config_accel_set_speed
* @see libinput_device_config_accel_get_speed
* @see libinput_device_config_accel_get_default_speed
*/
int
libinput_device_config_accel_is_available(struct libinput_device *device);
@ -4265,6 +4269,10 @@ libinput_device_config_accel_is_available(struct libinput_device *device);
* @param speed The normalized speed, in a range of [-1, 1]
*
* @return A config status code
*
* @see libinput_device_config_accel_is_available
* @see libinput_device_config_accel_get_speed
* @see libinput_device_config_accel_get_default_speed
*/
enum libinput_config_status
libinput_device_config_accel_set_speed(struct libinput_device *device,
@ -4280,6 +4288,10 @@ libinput_device_config_accel_set_speed(struct libinput_device *device,
* @param device The device to configure
*
* @return The current speed, range -1 to 1
*
* @see libinput_device_config_accel_is_available
* @see libinput_device_config_accel_set_speed
* @see libinput_device_config_accel_get_default_speed
*/
double
libinput_device_config_accel_get_speed(struct libinput_device *device);
@ -4293,6 +4305,10 @@ libinput_device_config_accel_get_speed(struct libinput_device *device);
*
* @param device The device to configure
* @return The default speed setting for this device.
*
* @see libinput_device_config_accel_is_available
* @see libinput_device_config_accel_set_speed
* @see libinput_device_config_accel_get_speed
*/
double
libinput_device_config_accel_get_default_speed(struct libinput_device *device);

View file

@ -19,6 +19,7 @@ liblitest_la_SOURCES = \
litest-device-alps-semi-mt.c \
litest-device-alps-dualpoint.c \
litest-device-anker-mouse-kbd.c \
litest-device-apple-appletouch.c \
litest-device-apple-internal-keyboard.c \
litest-device-apple-magicmouse.c \
litest-device-asus-rog-gladius.c \

View file

@ -0,0 +1,115 @@
/*
* Copyright © 2017 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
#include "litest.h"
#include "litest-int.h"
static void
litest_appletouch_setup(void)
{
struct litest_device *d = litest_create_device(LITEST_APPLETOUCH);
litest_set_current_device(d);
}
static struct input_event down[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
static struct input_event move[] = {
{ .type = EV_ABS, .code = ABS_X, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_Y, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_ABS, .code = ABS_PRESSURE, .value = LITEST_AUTO_ASSIGN },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
{ .type = -1, .code = -1 },
};
static int
get_axis_default(struct litest_device *d, unsigned int evcode, int32_t *value)
{
switch (evcode) {
case ABS_PRESSURE:
case ABS_MT_PRESSURE:
*value = 70;
return 0;
}
return 1;
}
static struct litest_device_interface interface = {
.touch_down_events = down,
.touch_move_events = move,
.get_axis_default = get_axis_default,
};
static struct input_id input_id = {
.bustype = 0x03,
.vendor = 0x5ac,
.product = 0x21a,
};
static int events[] = {
EV_KEY, BTN_LEFT,
EV_KEY, BTN_TOOL_FINGER,
EV_KEY, BTN_TOUCH,
EV_KEY, BTN_TOOL_DOUBLETAP,
EV_KEY, BTN_TOOL_TRIPLETAP,
-1, -1,
};
static struct input_absinfo absinfo[] = {
{ ABS_X, 0, 1215, 0, 0, 0 },
{ ABS_Y, 0, 588, 0, 0, 0 },
{ ABS_PRESSURE, 0, 300, 0, 0, 0 },
{ .value = -1 }
};
static const char udev_rule[] =
"ACTION==\"remove\", GOTO=\"touchpad_end\"\n"
"KERNEL!=\"event*\", GOTO=\"touchpad_end\"\n"
"ENV{ID_INPUT_TOUCHPAD}==\"\", GOTO=\"touchpad_end\"\n"
"\n"
"ATTRS{name}==\"litest appletouch\","
" ENV{LIBINPUT_MODEL_APPLE_TOUCHPAD_ONEBUTTON}=\"1\"\n"
"\n"
"LABEL=\"touchpad_end\"";
struct litest_test_device litest_appletouch_device = {
.type = LITEST_APPLETOUCH,
.features = LITEST_TOUCHPAD | LITEST_BUTTON | LITEST_SINGLE_TOUCH,
.shortname = "appletouch",
.setup = litest_appletouch_setup,
.interface = &interface,
.name = "appletouch",
.id = &input_id,
.events = events,
.absinfo = absinfo,
.udev_rule = udev_rule,
};

View file

@ -53,7 +53,7 @@ static const char udev_rule[] =
"KERNEL!=\"event*\", GOTO=\"wheel_click_angle_end\"\n"
"\n"
"ATTRS{name}==\"litest Wheel Click Angle Mouse*\",\\\n"
" ENV{MOUSE_WHEEL_CLICK_ANGLE}=\"-7\",\n"
" ENV{MOUSE_WHEEL_CLICK_ANGLE}=\"-7\",\\\n"
" ENV{MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL}=\"13\"\n"
"\n"
"LABEL=\"wheel_click_angle_end\"";

View file

@ -232,7 +232,7 @@ static const char udev_rule[] =
"ENV{ID_INPUT_TABLET}==\"\", GOTO=\"waltop_end\"\n"
"\n"
"ATTRS{name}==\"litest WALTOP Batteryless Tablet*\",\\\n"
" ENV{LIBINPUT_ATTR_SIZE_HINT}=\"200x200\",\n"
" ENV{LIBINPUT_ATTR_SIZE_HINT}=\"200x200\"\n"
"\n"
"LABEL=\"touchpad_end\"";

View file

@ -407,6 +407,7 @@ extern struct litest_test_device litest_calibrated_touchscreen_device;
extern struct litest_test_device litest_acer_hawaii_keyboard_device;
extern struct litest_test_device litest_acer_hawaii_touchpad_device;
extern struct litest_test_device litest_synaptics_rmi4_device;
extern struct litest_test_device litest_appletouch_device;
struct litest_test_device* devices[] = {
&litest_synaptics_clickpad_device,
@ -468,6 +469,7 @@ struct litest_test_device* devices[] = {
&litest_acer_hawaii_keyboard_device,
&litest_acer_hawaii_touchpad_device,
&litest_synaptics_rmi4_device,
&litest_appletouch_device,
NULL,
};

View file

@ -227,6 +227,7 @@ enum litest_device_type {
LITEST_ACER_HAWAII_KEYBOARD,
LITEST_ACER_HAWAII_TOUCHPAD,
LITEST_SYNAPTICS_RMI4,
LITEST_APPLETOUCH,
};
enum litest_device_feature {

View file

@ -774,6 +774,10 @@ START_TEST(pointer_left_handed_defaults)
struct libinput_device *d = dev->libinput_device;
int rc;
if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE &&
libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH)
return;
rc = libinput_device_config_left_handed_is_available(d);
ck_assert_int_ne(rc, 0);
@ -1062,7 +1066,7 @@ START_TEST(pointer_accel_defaults)
speed);
}
for (speed = 1.2; speed <= -2.0; speed += 0.2) {
for (speed = 1.2; speed <= 2.0; speed += 0.2) {
status = libinput_device_config_accel_set_speed(device,
speed);
ck_assert_int_eq(status,

View file

@ -93,6 +93,10 @@ START_TEST(touchpad_click_defaults_none)
uint32_t methods, method;
enum libinput_config_status status;
if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE &&
libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH)
return;
/* call this test for non-clickpads */
methods = libinput_device_config_click_get_methods(device);
@ -828,6 +832,110 @@ START_TEST(touchpad_clickfinger_4fg_tool_position)
}
END_TEST
START_TEST(touchpad_clickfinger_appletouch_config)
{
struct litest_device *dev = litest_current_device();
struct libinput_device *device = dev->libinput_device;
uint32_t methods, method;
enum libinput_config_status status;
methods = libinput_device_config_click_get_methods(device);
ck_assert(!(methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS));
ck_assert(methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
method = libinput_device_config_click_get_method(device);
ck_assert_int_eq(method, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
status = libinput_device_config_click_set_method(device,
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
status = libinput_device_config_click_set_method(device,
LIBINPUT_CONFIG_CLICK_METHOD_NONE);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
}
END_TEST
START_TEST(touchpad_clickfinger_appletouch_1fg)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
litest_enable_clickfinger(dev);
litest_drain_events(li);
litest_touch_down(dev, 0, 50, 50);
litest_event(dev, EV_KEY, BTN_LEFT, 1);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
litest_event(dev, EV_KEY, BTN_LEFT, 0);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
litest_touch_up(dev, 0);
libinput_dispatch(li);
litest_assert_button_event(li, BTN_LEFT,
LIBINPUT_BUTTON_STATE_PRESSED);
litest_assert_button_event(li, BTN_LEFT,
LIBINPUT_BUTTON_STATE_RELEASED);
}
END_TEST
START_TEST(touchpad_clickfinger_appletouch_2fg)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
litest_enable_clickfinger(dev);
litest_drain_events(li);
litest_touch_down(dev, 0, 50, 50);
litest_touch_down(dev, 1, 50, 50);
litest_event(dev, EV_KEY, BTN_LEFT, 1);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
litest_event(dev, EV_KEY, BTN_LEFT, 0);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
litest_touch_up(dev, 0);
litest_touch_up(dev, 1);
libinput_dispatch(li);
litest_assert_button_event(li, BTN_RIGHT,
LIBINPUT_BUTTON_STATE_PRESSED);
litest_assert_button_event(li, BTN_RIGHT,
LIBINPUT_BUTTON_STATE_RELEASED);
}
END_TEST
START_TEST(touchpad_clickfinger_appletouch_3fg)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
litest_enable_clickfinger(dev);
litest_drain_events(li);
litest_touch_down(dev, 0, 50, 50);
litest_touch_down(dev, 1, 50, 50);
litest_touch_down(dev, 2, 50, 50);
litest_event(dev, EV_KEY, BTN_LEFT, 1);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
litest_event(dev, EV_KEY, BTN_LEFT, 0);
litest_event(dev, EV_SYN, SYN_REPORT, 0);
litest_touch_up(dev, 0);
litest_touch_up(dev, 1);
litest_touch_up(dev, 2);
libinput_dispatch(li);
litest_assert_button_event(li, BTN_MIDDLE,
LIBINPUT_BUTTON_STATE_PRESSED);
litest_assert_button_event(li, BTN_MIDDLE,
LIBINPUT_BUTTON_STATE_RELEASED);
}
END_TEST
START_TEST(touchpad_btn_left)
{
struct litest_device *dev = litest_current_device();
@ -1368,6 +1476,37 @@ START_TEST(clickpad_softbutton_right_to_left)
}
END_TEST
START_TEST(clickpad_softbutton_hover_into_buttons)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
litest_drain_events(li);
litest_hover_start(dev, 0, 50, 50);
libinput_dispatch(li);
litest_hover_move_to(dev, 0, 50, 50, 90, 90, 10, 0);
libinput_dispatch(li);
litest_touch_move_to(dev, 0, 90, 90, 91, 91, 1, 0);
litest_button_click(dev, BTN_LEFT, true);
libinput_dispatch(li);
litest_assert_button_event(li,
BTN_RIGHT,
LIBINPUT_BUTTON_STATE_PRESSED);
litest_assert_empty_queue(li);
litest_button_click(dev, BTN_LEFT, false);
litest_touch_up(dev, 0);
litest_assert_button_event(li,
BTN_RIGHT,
LIBINPUT_BUTTON_STATE_RELEASED);
}
END_TEST
START_TEST(clickpad_topsoftbuttons_left)
{
struct litest_device *dev = litest_current_device();
@ -1830,6 +1969,11 @@ litest_setup_tests_touchpad_buttons(void)
litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_3fg_tool_position, LITEST_SYNAPTICS_TOPBUTTONPAD);
litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_4fg_tool_position, LITEST_SYNAPTICS_TOPBUTTONPAD);
litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_config, LITEST_APPLETOUCH);
litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_1fg, LITEST_APPLETOUCH);
litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_2fg, LITEST_APPLETOUCH);
litest_add_for_device("touchpad:clickfinger", touchpad_clickfinger_appletouch_3fg, LITEST_APPLETOUCH);
litest_add("touchpad:click", touchpad_click_defaults_clickfinger, LITEST_APPLE_CLICKPAD, LITEST_ANY);
litest_add("touchpad:click", touchpad_click_defaults_btnarea, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
litest_add("touchpad:click", touchpad_click_defaults_none, LITEST_TOUCHPAD, LITEST_CLICKPAD);
@ -1848,6 +1992,7 @@ litest_setup_tests_touchpad_buttons(void)
litest_add("touchpad:softbutton", clickpad_softbutton_left_2nd_fg_move, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
litest_add("touchpad:softbutton", clickpad_softbutton_left_to_right, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
litest_add("touchpad:softbutton", clickpad_softbutton_right_to_left, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
litest_add("touchpad:softbutton", clickpad_softbutton_hover_into_buttons, LITEST_CLICKPAD|LITEST_HOVER, LITEST_APPLE_CLICKPAD);
litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_left, LITEST_TOPBUTTONPAD, LITEST_ANY);
litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_right, LITEST_TOPBUTTONPAD, LITEST_ANY);

View file

@ -462,7 +462,7 @@ touchpad_has_horiz_edge_scroll_size(struct litest_device *dev)
rc = libinput_device_get_size(dev->libinput_device, &width, &height);
return rc == 0 && height >= 50;
return rc == 0 && height >= 40;
}
START_TEST(touchpad_edge_scroll_horiz)
@ -556,15 +556,21 @@ START_TEST(touchpad_scroll_defaults)
struct libevdev *evdev = dev->evdev;
enum libinput_config_scroll_method method, expected;
enum libinput_config_status status;
bool should_have_2fg = false;
if (libevdev_get_num_slots(evdev) > 1 ||
(libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE &&
libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH))
should_have_2fg = true;
method = libinput_device_config_scroll_get_methods(device);
ck_assert(method & LIBINPUT_CONFIG_SCROLL_EDGE);
if (libevdev_get_num_slots(evdev) > 1)
if (should_have_2fg)
ck_assert(method & LIBINPUT_CONFIG_SCROLL_2FG);
else
ck_assert((method & LIBINPUT_CONFIG_SCROLL_2FG) == 0);
if (libevdev_get_num_slots(evdev) > 1)
if (should_have_2fg)
expected = LIBINPUT_CONFIG_SCROLL_2FG;
else
expected = LIBINPUT_CONFIG_SCROLL_EDGE;
@ -580,7 +586,7 @@ START_TEST(touchpad_scroll_defaults)
status = libinput_device_config_scroll_set_method(device,
LIBINPUT_CONFIG_SCROLL_2FG);
if (libevdev_get_num_slots(evdev) > 1)
if (should_have_2fg)
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
else
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
@ -1290,6 +1296,10 @@ START_TEST(touchpad_left_handed)
struct libinput *li = dev->libinput;
enum libinput_config_status status;
if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_APPLE &&
libevdev_get_id_product(dev->evdev) == PRODUCT_ID_APPLE_APPLETOUCH)
return;
status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
@ -1328,6 +1338,19 @@ START_TEST(touchpad_left_handed)
}
END_TEST
START_TEST(touchpad_left_handed_appletouch)
{
struct litest_device *dev = litest_current_device();
struct libinput_device *d = dev->libinput_device;
enum libinput_config_status status;
ck_assert_int_eq(libinput_device_config_left_handed_is_available(d), 0);
status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
ck_assert_int_eq(libinput_device_config_left_handed_get(d), 0);
}
END_TEST
START_TEST(touchpad_left_handed_clickpad)
{
struct litest_device *dev = litest_current_device();
@ -1335,6 +1358,9 @@ START_TEST(touchpad_left_handed_clickpad)
struct libinput *li = dev->libinput;
enum libinput_config_status status;
if (!libinput_device_config_left_handed_is_available(d))
return;
status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
@ -1386,6 +1412,9 @@ START_TEST(touchpad_left_handed_clickfinger)
struct libinput *li = dev->libinput;
enum libinput_config_status status;
if (!libinput_device_config_left_handed_is_available(d))
return;
status = libinput_device_config_left_handed_set(d, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
@ -1427,6 +1456,9 @@ START_TEST(touchpad_left_handed_tapping)
struct libinput *li = dev->libinput;
enum libinput_config_status status;
if (!libinput_device_config_left_handed_is_available(d))
return;
litest_enable_tap(dev->libinput_device);
status = libinput_device_config_left_handed_set(d, 1);
@ -1458,6 +1490,9 @@ START_TEST(touchpad_left_handed_tapping_2fg)
struct libinput *li = dev->libinput;
enum libinput_config_status status;
if (!libinput_device_config_left_handed_is_available(d))
return;
litest_enable_tap(dev->libinput_device);
status = libinput_device_config_left_handed_set(d, 1);
@ -1491,6 +1526,9 @@ START_TEST(touchpad_left_handed_delayed)
struct libinput *li = dev->libinput;
enum libinput_config_status status;
if (!libinput_device_config_left_handed_is_available(d))
return;
litest_drain_events(li);
litest_button_click(dev, BTN_LEFT, 1);
libinput_dispatch(li);
@ -1543,6 +1581,9 @@ START_TEST(touchpad_left_handed_clickpad_delayed)
struct libinput *li = dev->libinput;
enum libinput_config_status status;
if (!libinput_device_config_left_handed_is_available(d))
return;
litest_drain_events(li);
litest_touch_down(dev, 0, 10, 90);
litest_button_click(dev, BTN_LEFT, 1);
@ -4699,6 +4740,7 @@ litest_setup_tests_touchpad(void)
litest_add("touchpad:palm", touchpad_palm_detect_both_edges, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("touchpad:left-handed", touchpad_left_handed, LITEST_TOUCHPAD|LITEST_BUTTON, LITEST_CLICKPAD);
litest_add_for_device("touchpad:left-handed", touchpad_left_handed_appletouch, LITEST_APPLETOUCH);
litest_add("touchpad:left-handed", touchpad_left_handed_clickpad, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
litest_add("touchpad:left-handed", touchpad_left_handed_clickfinger, LITEST_APPLE_CLICKPAD, LITEST_ANY);
litest_add("touchpad:left-handed", touchpad_left_handed_tapping, LITEST_TOUCHPAD, LITEST_ANY);

View file

@ -261,20 +261,32 @@ print_device_notify(struct libinput_event *ev)
}
static void
print_key_event(struct libinput_event *ev)
print_key_event(struct libinput *li, struct libinput_event *ev)
{
struct libinput_event_keyboard *k = libinput_event_get_keyboard_event(ev);
struct tools_context *context;
struct tools_options *options;
enum libinput_key_state state;
uint32_t key;
const char *keyname;
context = libinput_get_user_data(li);
options = &context->options;
print_event_time(libinput_event_keyboard_get_time(k));
state = libinput_event_keyboard_get_key_state(k);
key = libinput_event_keyboard_get_key(k);
keyname = libevdev_event_code_get_name(EV_KEY, key);
if (!options->show_keycodes &&
(key >= KEY_ESC && key < KEY_ZENKAKUHANKAKU)) {
keyname = "***";
key = -1;
} else {
keyname = libevdev_event_code_get_name(EV_KEY, key);
keyname = keyname ? keyname : "???";
}
printf("%s (%d) %s\n",
keyname ? keyname : "???",
keyname,
key,
state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
}
@ -409,7 +421,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
(libinput_event_tablet_tool_##ax##_has_changed(ev) ? "*" : "")
x = libinput_event_tablet_tool_get_x(t);
y = libinput_event_tablet_tool_get_x(t);
y = libinput_event_tablet_tool_get_y(t);
printf("\t%.2f%s/%.2f%s",
x, changed_sym(t, x),
y, changed_sym(t, y));
@ -723,7 +735,7 @@ handle_and_print_events(struct libinput *li)
&context.options);
break;
case LIBINPUT_EVENT_KEYBOARD_KEY:
print_key_event(ev);
print_key_event(li, ev);
break;
case LIBINPUT_EVENT_POINTER_MOTION:
print_motion_event(ev);

View file

@ -245,16 +245,23 @@ rotation_default(struct libinput_device *device)
static void
print_pad_info(struct libinput_device *device)
{
int nbuttons, nrings, nstrips;
int nbuttons, nrings, nstrips, ngroups, nmodes;
struct libinput_tablet_pad_mode_group *group;
nbuttons = libinput_device_tablet_pad_get_num_buttons(device);
nrings = libinput_device_tablet_pad_get_num_rings(device);
nstrips = libinput_device_tablet_pad_get_num_strips(device);
ngroups = libinput_device_tablet_pad_get_num_mode_groups(device);
group = libinput_device_tablet_pad_get_mode_group(device, 0);
nmodes = libinput_tablet_pad_mode_group_get_num_modes(group);
printf("Pad:\n");
printf(" Rings: %d\n", nrings);
printf(" Strips: %d\n", nstrips);
printf(" Buttons: %d\n", nbuttons);
printf(" Mode groups: %d (%d modes)\n", ngroups, nmodes);
}
static void

View file

@ -62,6 +62,7 @@ enum options {
OPT_SCROLL_BUTTON,
OPT_SPEED,
OPT_PROFILE,
OPT_SHOW_KEYCODES,
};
LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
@ -103,6 +104,7 @@ tools_usage(void)
"--set-profile=[adaptive|flat].... set pointer acceleration profile\n"
"--set-speed=<value>.... set pointer acceleration speed (allowed range [-1, 1]) \n"
"--set-tap-map=[lrm|lmr] ... set button mapping for tapping\n"
"--show-keycodes.... show all key codes while typing\n"
"\n"
"These options apply to all applicable devices, if a feature\n"
"is not explicitly specified it is left at each device's default.\n"
@ -137,6 +139,7 @@ tools_init_context(struct tools_context *context)
options->seat = "seat0";
options->speed = 0.0;
options->profile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
options->show_keycodes = false;
}
int
@ -173,6 +176,7 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
{ "set-profile", 1, 0, OPT_PROFILE },
{ "set-tap-map", 1, 0, OPT_TAP_MAP },
{ "set-speed", 1, 0, OPT_SPEED },
{ "show-keycodes", 0, 0, OPT_SHOW_KEYCODES },
{ 0, 0, 0, 0}
};
@ -337,6 +341,9 @@ tools_parse_args(int argc, char **argv, struct tools_context *context)
return 1;
}
break;
case OPT_SHOW_KEYCODES:
options->show_keycodes = true;
break;
default:
tools_usage();
return 1;

View file

@ -24,6 +24,8 @@
#ifndef _SHARED_H_
#define _SHARED_H_
#include <stdbool.h>
#include <libinput.h>
enum tools_backend {
@ -36,6 +38,7 @@ struct tools_options {
const char *device; /* if backend is BACKEND_DEVICE */
const char *seat; /* if backend is BACKEND_UDEV */
int grab; /* EVIOCGRAB */
bool show_keycodes; /* show keycodes */
int verbose;
int tapping;

View file

@ -41,6 +41,9 @@ libinput:name:*Apple Inc. Apple Internal Keyboard*:dmi:*
libinput:mouse:input:b0005v05ACp030D*
LIBINPUT_MODEL_APPLE_MAGICMOUSE=1
libinput:touchpad:input:b0003v05ACp021A*
LIBINPUT_MODEL_APPLE_TOUCHPAD_ONEBUTTON=1
##########################################
# Asus
##########################################