...
 
Commits (24)
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
This diff is collapsed.
......@@ -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 },
......
......@@ -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:
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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 \
......
/*
* 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,
};
......@@ -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\"";
......
......@@ -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\"";
......
......@@ -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,
};
......
......@@ -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 {
......
......@@ -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,
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
##########################################
......