mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-26 14:30:06 +01:00
Merge branch 'wip/wheel-tilt-source'
This commit is contained in:
commit
ebeba8e8ff
10 changed files with 166 additions and 6 deletions
31
src/evdev.c
31
src/evdev.c
|
|
@ -958,6 +958,7 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
|
|||
{
|
||||
struct normalized_coords wheel_degrees = { 0.0, 0.0 };
|
||||
struct discrete_coords discrete = { 0.0, 0.0 };
|
||||
enum libinput_pointer_axis_source source;
|
||||
|
||||
if (fallback_reject_relative(device, e, time))
|
||||
return;
|
||||
|
|
@ -980,11 +981,16 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
|
|||
wheel_degrees.y = -1 * e->value *
|
||||
device->scroll.wheel_click_angle.x;
|
||||
discrete.y = -1 * e->value;
|
||||
|
||||
source = device->scroll.is_tilt.vertical ?
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT:
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL;
|
||||
|
||||
evdev_notify_axis(
|
||||
device,
|
||||
time,
|
||||
AS_MASK(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL),
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL,
|
||||
source,
|
||||
&wheel_degrees,
|
||||
&discrete);
|
||||
break;
|
||||
|
|
@ -993,11 +999,16 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
|
|||
wheel_degrees.x = e->value *
|
||||
device->scroll.wheel_click_angle.y;
|
||||
discrete.x = e->value;
|
||||
|
||||
source = device->scroll.is_tilt.horizontal ?
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT:
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL;
|
||||
|
||||
evdev_notify_axis(
|
||||
device,
|
||||
time,
|
||||
AS_MASK(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL),
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL,
|
||||
source,
|
||||
&wheel_degrees,
|
||||
&discrete);
|
||||
break;
|
||||
|
|
@ -2110,6 +2121,21 @@ evdev_read_wheel_click_props(struct evdev_device *device)
|
|||
return angles;
|
||||
}
|
||||
|
||||
static inline struct wheel_tilt_flags
|
||||
evdev_read_wheel_tilt_props(struct evdev_device *device)
|
||||
{
|
||||
struct wheel_tilt_flags flags;
|
||||
|
||||
flags.vertical = parse_udev_flag(device,
|
||||
device->udev_device,
|
||||
"MOUSE_WHEEL_TILT_VERTICAL");
|
||||
|
||||
flags.horizontal = parse_udev_flag(device,
|
||||
device->udev_device,
|
||||
"MOUSE_WHEEL_TILT_HORIZONTAL");
|
||||
return flags;
|
||||
}
|
||||
|
||||
static inline int
|
||||
evdev_get_trackpoint_dpi(struct evdev_device *device)
|
||||
{
|
||||
|
|
@ -2848,6 +2874,7 @@ evdev_device_create(struct libinput_seat *seat,
|
|||
device->scroll.direction = 0;
|
||||
device->scroll.wheel_click_angle =
|
||||
evdev_read_wheel_click_props(device);
|
||||
device->scroll.is_tilt = evdev_read_wheel_tilt_props(device);
|
||||
device->model_flags = evdev_read_model_flags(device);
|
||||
device->dpi = DEFAULT_MOUSE_DPI;
|
||||
|
||||
|
|
|
|||
|
|
@ -198,6 +198,8 @@ struct evdev_device {
|
|||
|
||||
/* angle per REL_WHEEL click in degrees */
|
||||
struct wheel_angle wheel_click_angle;
|
||||
|
||||
struct wheel_tilt_flags is_tilt;
|
||||
} scroll;
|
||||
|
||||
struct {
|
||||
|
|
|
|||
|
|
@ -94,6 +94,11 @@ struct phys_coords {
|
|||
double y;
|
||||
};
|
||||
|
||||
/* A pair of tilt flags */
|
||||
struct wheel_tilt_flags {
|
||||
bool vertical, horizontal;
|
||||
};
|
||||
|
||||
struct tablet_axes {
|
||||
struct device_coords point;
|
||||
struct normalized_coords delta;
|
||||
|
|
|
|||
|
|
@ -259,6 +259,12 @@ enum libinput_pointer_axis_source {
|
|||
* The event is caused by the motion of some device.
|
||||
*/
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
|
||||
/**
|
||||
* The event is caused by the tilting of a mouse wheel rather than
|
||||
* its rotation. This method is commonly used on mice without
|
||||
* separate horizontal scroll wheels.
|
||||
*/
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1285,6 +1291,15 @@ libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event,
|
|||
* The coordinate system is identical to the cursor movement, i.e. a
|
||||
* scroll value of 1 represents the equivalent relative motion of 1.
|
||||
*
|
||||
* If the source is @ref LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT, no
|
||||
* terminating event is guaranteed (though it may happen).
|
||||
* Scrolling is in discrete steps and there is no physical equivalent for
|
||||
* the value returned here. For backwards compatibility, the value returned
|
||||
* by this function is identical to a single mouse wheel rotation by this
|
||||
* device (see the documentation for @ref LIBINPUT_POINTER_AXIS_SOURCE_WHEEL
|
||||
* above). Callers should not use this value but instead exclusively refer
|
||||
* to the value returned by libinput_event_pointer_get_axis_value_discrete().
|
||||
*
|
||||
* For pointer events that are not of type @ref LIBINPUT_EVENT_POINTER_AXIS,
|
||||
* this function returns 0.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ liblitest_la_SOURCES = \
|
|||
litest-device-nexus4-touch-screen.c \
|
||||
litest-device-magic-trackpad.c \
|
||||
litest-device-mouse.c \
|
||||
litest-device-mouse-wheel-tilt.c \
|
||||
litest-device-mouse-roccat.c \
|
||||
litest-device-mouse-low-dpi.c \
|
||||
litest-device-mouse-wheel-click-angle.c \
|
||||
|
|
|
|||
76
test/litest-device-mouse-wheel-tilt.c
Normal file
76
test/litest-device-mouse-wheel-tilt.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright © 2016 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.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "litest.h"
|
||||
#include "litest-int.h"
|
||||
|
||||
static void litest_mouse_setup(void)
|
||||
{
|
||||
struct litest_device *d = litest_create_device(LITEST_MOUSE_WHEEL_TILT);
|
||||
litest_set_current_device(d);
|
||||
}
|
||||
|
||||
static struct input_id input_id = {
|
||||
.bustype = 0x3,
|
||||
.vendor = 0x17ef,
|
||||
.product = 0x6019,
|
||||
};
|
||||
|
||||
static int events[] = {
|
||||
EV_KEY, BTN_LEFT,
|
||||
EV_KEY, BTN_RIGHT,
|
||||
EV_KEY, BTN_MIDDLE,
|
||||
EV_REL, REL_X,
|
||||
EV_REL, REL_Y,
|
||||
EV_REL, REL_WHEEL,
|
||||
EV_REL, REL_HWHEEL,
|
||||
-1 , -1,
|
||||
};
|
||||
|
||||
static const char udev_rule[] =
|
||||
"ACTION==\"remove\", GOTO=\"wheel_wheel_tilt_end\"\n"
|
||||
"KERNEL!=\"event*\", GOTO=\"wheel_wheel_tilt_end\"\n"
|
||||
"\n"
|
||||
"ATTRS{name}==\"litest Wheel Tilt Mouse*\",\\\n"
|
||||
" ENV{MOUSE_WHEEL_TILT_HORIZONTAL}=\"1\",\\\n"
|
||||
" ENV{MOUSE_WHEEL_TILT_VERTICAL}=\"1\"\n"
|
||||
"\n"
|
||||
"LABEL=\"wheel_wheel_tilt_end\"";
|
||||
|
||||
struct litest_test_device litest_mouse_wheel_tilt_device = {
|
||||
.type = LITEST_MOUSE_WHEEL_TILT,
|
||||
.features = LITEST_RELATIVE | LITEST_BUTTON | LITEST_WHEEL,
|
||||
.shortname = "mouse-wheel-tilt",
|
||||
.setup = litest_mouse_setup,
|
||||
.interface = NULL,
|
||||
|
||||
.name = "Wheel Tilt Mouse",
|
||||
.id = &input_id,
|
||||
.absinfo = NULL,
|
||||
.events = events,
|
||||
.udev_rule = udev_rule,
|
||||
};
|
||||
|
|
@ -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_mouse_wheel_tilt_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_mouse_wheel_tilt_device,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ enum litest_device_type {
|
|||
LITEST_ACER_HAWAII_KEYBOARD,
|
||||
LITEST_ACER_HAWAII_TOUCHPAD,
|
||||
LITEST_SYNAPTICS_RMI4,
|
||||
LITEST_MOUSE_WHEEL_TILT,
|
||||
};
|
||||
|
||||
enum litest_device_feature {
|
||||
|
|
|
|||
|
|
@ -546,6 +546,33 @@ out:
|
|||
return angle;
|
||||
}
|
||||
|
||||
static enum libinput_pointer_axis_source
|
||||
wheel_source(struct litest_device *dev, int which)
|
||||
{
|
||||
struct udev_device *d;
|
||||
bool is_tilt = false;
|
||||
|
||||
d = libinput_device_get_udev_device(dev->libinput_device);
|
||||
litest_assert_ptr_notnull(d);
|
||||
|
||||
switch(which) {
|
||||
case REL_WHEEL:
|
||||
is_tilt = !!udev_device_get_property_value(d, "MOUSE_WHEEL_TILT_VERTICAL");
|
||||
break;
|
||||
case REL_HWHEEL:
|
||||
is_tilt = !!udev_device_get_property_value(d, "MOUSE_WHEEL_TILT_HORIZONTAL");
|
||||
break;
|
||||
default:
|
||||
litest_abort_msg("Invalid source axis %d\n", which);
|
||||
break;
|
||||
}
|
||||
|
||||
udev_device_unref(d);
|
||||
return is_tilt ?
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT :
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL;
|
||||
}
|
||||
|
||||
static void
|
||||
test_wheel_event(struct litest_device *dev, int which, int amount)
|
||||
{
|
||||
|
|
@ -553,10 +580,12 @@ test_wheel_event(struct litest_device *dev, int which, int amount)
|
|||
struct libinput_event *event;
|
||||
struct libinput_event_pointer *ptrev;
|
||||
enum libinput_pointer_axis axis;
|
||||
enum libinput_pointer_axis_source source;
|
||||
|
||||
double scroll_step, expected, discrete;
|
||||
|
||||
scroll_step = wheel_click_angle(dev, which);
|
||||
source = wheel_source(dev, which);
|
||||
expected = amount * scroll_step;
|
||||
discrete = amount;
|
||||
|
||||
|
|
@ -576,10 +605,9 @@ test_wheel_event(struct litest_device *dev, int which, int amount)
|
|||
axis = (which == REL_WHEEL) ?
|
||||
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL :
|
||||
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
|
||||
|
||||
event = libinput_get_event(li);
|
||||
ptrev = litest_is_axis_event(event,
|
||||
axis,
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL);
|
||||
ptrev = litest_is_axis_event(event, axis, source);
|
||||
|
||||
litest_assert_double_eq(
|
||||
libinput_event_pointer_get_axis_value(ptrev, axis),
|
||||
|
|
@ -693,7 +721,7 @@ START_TEST(pointer_scroll_has_axis_invalid)
|
|||
event = libinput_get_event(li);
|
||||
pev = litest_is_axis_event(event,
|
||||
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
|
||||
LIBINPUT_POINTER_AXIS_SOURCE_WHEEL);
|
||||
0);
|
||||
|
||||
ck_assert_int_eq(libinput_event_pointer_has_axis(pev, -1), 0);
|
||||
ck_assert_int_eq(libinput_event_pointer_has_axis(pev, 2), 0);
|
||||
|
|
|
|||
|
|
@ -377,6 +377,9 @@ print_pointer_axis_event(struct libinput_event *ev)
|
|||
case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS:
|
||||
source = "continuous";
|
||||
break;
|
||||
case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT:
|
||||
source = "tilt";
|
||||
break;
|
||||
}
|
||||
|
||||
if (libinput_event_pointer_has_axis(p,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue