mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-24 22:50:05 +01:00
tablet: rename libinput_tablet_tool_has_axis into an axis-specific API set
Part of the big revamp to get rid of libinput_tablet_tool_axis and replace it with a set of axis-specific APIs. Note that this commit drops the ability to check whether a tablet has an x or y axis. If it doesn't, libinput won't initialize the tablet anyway so this was superfluous already. Likewise with the tilt axes - either we have x and y tilt or we have neither, so separate checks for tilt_x and tilt_y is unnecessary. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Lyude <cpaul@redhat.com>
This commit is contained in:
parent
e5a33086bc
commit
828ca69c77
5 changed files with 128 additions and 52 deletions
|
|
@ -1359,10 +1359,45 @@ libinput_tablet_tool_get_serial(struct libinput_tablet_tool *tool)
|
|||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
libinput_tablet_tool_has_axis(struct libinput_tablet_tool *tool,
|
||||
enum libinput_tablet_tool_axis axis)
|
||||
libinput_tablet_tool_has_pressure(struct libinput_tablet_tool *tool)
|
||||
{
|
||||
return bit_is_set(tool->axis_caps, axis);
|
||||
return bit_is_set(tool->axis_caps,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
libinput_tablet_tool_has_distance(struct libinput_tablet_tool *tool)
|
||||
{
|
||||
return bit_is_set(tool->axis_caps,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
libinput_tablet_tool_has_tilt(struct libinput_tablet_tool *tool)
|
||||
{
|
||||
return bit_is_set(tool->axis_caps,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
libinput_tablet_tool_has_rotation(struct libinput_tablet_tool *tool)
|
||||
{
|
||||
return bit_is_set(tool->axis_caps,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
libinput_tablet_tool_has_slider(struct libinput_tablet_tool *tool)
|
||||
{
|
||||
return bit_is_set(tool->axis_caps,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
libinput_tablet_tool_has_wheel(struct libinput_tablet_tool *tool)
|
||||
{
|
||||
return bit_is_set(tool->axis_caps,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int
|
||||
|
|
|
|||
|
|
@ -1880,15 +1880,68 @@ libinput_tablet_tool_unref(struct libinput_tablet_tool *tool);
|
|||
/**
|
||||
* @ingroup event_tablet
|
||||
*
|
||||
* Return whether or not a tablet tool supports the specified axis
|
||||
* Return whether the tablet tool supports pressure.
|
||||
*
|
||||
* @param tool The tool to check the axis capabilities of
|
||||
* @param axis The axis to check for support
|
||||
* @return Whether or not the axis is supported
|
||||
* @return Nonzero if the axis is available, zero otherwise.
|
||||
*/
|
||||
int
|
||||
libinput_tablet_tool_has_axis(struct libinput_tablet_tool *tool,
|
||||
enum libinput_tablet_tool_axis axis);
|
||||
libinput_tablet_tool_has_pressure(struct libinput_tablet_tool *tool);
|
||||
|
||||
/**
|
||||
* @ingroup event_tablet
|
||||
*
|
||||
* Return whether the tablet tool supports distance.
|
||||
*
|
||||
* @param tool The tool to check the axis capabilities of
|
||||
* @return Nonzero if the axis is available, zero otherwise.
|
||||
*/
|
||||
int
|
||||
libinput_tablet_tool_has_distance(struct libinput_tablet_tool *tool);
|
||||
|
||||
/**
|
||||
* @ingroup event_tablet
|
||||
*
|
||||
* Return whether the tablet tool supports tilt.
|
||||
*
|
||||
* @param tool The tool to check the axis capabilities of
|
||||
* @return Nonzero if the axis is available, zero otherwise.
|
||||
*/
|
||||
int
|
||||
libinput_tablet_tool_has_tilt(struct libinput_tablet_tool *tool);
|
||||
|
||||
/**
|
||||
* @ingroup event_tablet
|
||||
*
|
||||
* Return whether the tablet tool supports z-rotation.
|
||||
*
|
||||
* @param tool The tool to check the axis capabilities of
|
||||
* @return Nonzero if the axis is available, zero otherwise.
|
||||
*/
|
||||
int
|
||||
libinput_tablet_tool_has_rotation(struct libinput_tablet_tool *tool);
|
||||
|
||||
/**
|
||||
* @ingroup event_tablet
|
||||
*
|
||||
* Return whether the tablet tool has a slider axis.
|
||||
*
|
||||
* @param tool The tool to check the axis capabilities of
|
||||
* @return Nonzero if the axis is available, zero otherwise.
|
||||
*/
|
||||
int
|
||||
libinput_tablet_tool_has_slider(struct libinput_tablet_tool *tool);
|
||||
|
||||
/**
|
||||
* @ingroup event_tablet
|
||||
*
|
||||
* Return whether the tablet tool has a relative wheel.
|
||||
*
|
||||
* @param tool The tool to check the axis capabilities of
|
||||
* @return Nonzero if the axis is available, zero otherwise.
|
||||
*/
|
||||
int
|
||||
libinput_tablet_tool_has_wheel(struct libinput_tablet_tool *tool);
|
||||
|
||||
/**
|
||||
* @ingroup event_tablet
|
||||
|
|
|
|||
|
|
@ -219,8 +219,13 @@ LIBINPUT_TABLET_SUPPORT {
|
|||
libinput_tablet_tool_get_tool_id;
|
||||
libinput_tablet_tool_get_type;
|
||||
libinput_tablet_tool_get_user_data;
|
||||
libinput_tablet_tool_has_pressure;
|
||||
libinput_tablet_tool_has_distance;
|
||||
libinput_tablet_tool_has_rotation;
|
||||
libinput_tablet_tool_has_tilt;
|
||||
libinput_tablet_tool_has_wheel;
|
||||
libinput_tablet_tool_has_slider;
|
||||
libinput_tablet_tool_has_button;
|
||||
libinput_tablet_tool_has_axis;
|
||||
libinput_tablet_tool_ref;
|
||||
libinput_tablet_tool_set_user_data;
|
||||
libinput_tablet_tool_unref;
|
||||
|
|
|
|||
|
|
@ -722,7 +722,7 @@ START_TEST(proximity_has_axes)
|
|||
litest_assert_double_ne(x, 0);
|
||||
litest_assert_double_ne(y, 0);
|
||||
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) {
|
||||
if (libinput_tablet_tool_has_distance(tool)) {
|
||||
ck_assert(libinput_event_tablet_tool_distance_has_changed(
|
||||
tablet_event));
|
||||
|
||||
|
|
@ -730,8 +730,7 @@ START_TEST(proximity_has_axes)
|
|||
litest_assert_double_ne(distance, 0);
|
||||
}
|
||||
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) &&
|
||||
libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
|
||||
if (libinput_tablet_tool_has_tilt(tool)) {
|
||||
ck_assert(libinput_event_tablet_tool_tilt_x_has_changed(
|
||||
tablet_event));
|
||||
ck_assert(libinput_event_tablet_tool_tilt_y_has_changed(
|
||||
|
|
@ -758,11 +757,10 @@ START_TEST(proximity_has_axes)
|
|||
|
||||
last_x = libinput_event_tablet_tool_get_x(tablet_event);
|
||||
last_y = libinput_event_tablet_tool_get_y(tablet_event);
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE))
|
||||
if (libinput_tablet_tool_has_distance(tool))
|
||||
last_distance = libinput_event_tablet_tool_get_distance(
|
||||
tablet_event);
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) &&
|
||||
libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
|
||||
if (libinput_tablet_tool_has_tilt(tool)) {
|
||||
last_tx = libinput_event_tablet_tool_get_tilt_x(tablet_event);
|
||||
last_ty = libinput_event_tablet_tool_get_tilt_y(tablet_event);
|
||||
}
|
||||
|
|
@ -786,7 +784,7 @@ START_TEST(proximity_has_axes)
|
|||
litest_assert_double_eq(x, last_x);
|
||||
litest_assert_double_eq(y, last_y);
|
||||
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) {
|
||||
if (libinput_tablet_tool_has_distance(tool)) {
|
||||
ck_assert(!libinput_event_tablet_tool_distance_has_changed(
|
||||
tablet_event));
|
||||
|
||||
|
|
@ -795,8 +793,7 @@ START_TEST(proximity_has_axes)
|
|||
litest_assert_double_eq(distance, last_distance);
|
||||
}
|
||||
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) &&
|
||||
libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
|
||||
if (libinput_tablet_tool_has_tilt(tool)) {
|
||||
ck_assert(!libinput_event_tablet_tool_tilt_x_has_changed(
|
||||
tablet_event));
|
||||
ck_assert(!libinput_event_tablet_tool_tilt_y_has_changed(
|
||||
|
|
@ -1651,14 +1648,9 @@ START_TEST(tool_capabilities)
|
|||
t = libinput_event_get_tablet_tool_event(event);
|
||||
tool = libinput_event_tablet_tool_get_tool(t);
|
||||
|
||||
ck_assert(libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE));
|
||||
ck_assert(libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE));
|
||||
ck_assert(!libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_TILT_X));
|
||||
ck_assert(!libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y));
|
||||
ck_assert(libinput_tablet_tool_has_pressure(tool));
|
||||
ck_assert(libinput_tablet_tool_has_distance(tool));
|
||||
ck_assert(!libinput_tablet_tool_has_tilt(tool));
|
||||
|
||||
libinput_event_destroy(event);
|
||||
litest_assert_empty_queue(li);
|
||||
|
|
@ -1674,14 +1666,9 @@ START_TEST(tool_capabilities)
|
|||
t = libinput_event_get_tablet_tool_event(event);
|
||||
tool = libinput_event_tablet_tool_get_tool(t);
|
||||
|
||||
ck_assert(libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE));
|
||||
ck_assert(libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE));
|
||||
ck_assert(libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_TILT_X));
|
||||
ck_assert(libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y));
|
||||
ck_assert(libinput_tablet_tool_has_pressure(tool));
|
||||
ck_assert(libinput_tablet_tool_has_distance(tool));
|
||||
ck_assert(libinput_tablet_tool_has_tilt(tool));
|
||||
|
||||
libinput_event_destroy(event);
|
||||
litest_assert_empty_queue(li);
|
||||
|
|
@ -1946,8 +1933,7 @@ START_TEST(mouse_wheel)
|
|||
|
||||
libinput_event_destroy(event);
|
||||
|
||||
ck_assert(libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL));
|
||||
ck_assert(libinput_tablet_tool_has_wheel(tool));
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
litest_event(dev, EV_REL, REL_WHEEL, -1);
|
||||
|
|
@ -2116,8 +2102,7 @@ START_TEST(artpen_tool)
|
|||
ck_assert_notnull(tool);
|
||||
ck_assert_int_eq(libinput_tablet_tool_get_type(tool),
|
||||
LIBINPUT_TABLET_TOOL_TYPE_PEN);
|
||||
ck_assert(libinput_tablet_tool_has_axis(tool,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z));
|
||||
ck_assert(libinput_tablet_tool_has_rotation(tool));
|
||||
|
||||
libinput_event_destroy(event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -353,8 +353,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
|
|||
y, changed_sym(t, y),
|
||||
dx, dy);
|
||||
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
|
||||
libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)) {
|
||||
if (libinput_tablet_tool_has_tilt(tool)) {
|
||||
x = libinput_event_tablet_tool_get_tilt_x(t);
|
||||
y = libinput_event_tablet_tool_get_tilt_y(t);
|
||||
dx = libinput_event_tablet_tool_get_axis_delta(t,
|
||||
|
|
@ -367,8 +366,8 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
|
|||
dx, dy);
|
||||
}
|
||||
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE) ||
|
||||
libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE)) {
|
||||
if (libinput_tablet_tool_has_distance(tool) ||
|
||||
libinput_tablet_tool_has_pressure(tool)) {
|
||||
dist = libinput_event_tablet_tool_get_distance(t);
|
||||
pressure = libinput_event_tablet_tool_get_pressure(t);
|
||||
if (dist) {
|
||||
|
|
@ -386,7 +385,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
|
|||
}
|
||||
}
|
||||
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z)) {
|
||||
if (libinput_tablet_tool_has_rotation(tool)) {
|
||||
rotation = libinput_event_tablet_tool_get_rotation(t);
|
||||
delta = libinput_event_tablet_tool_get_axis_delta(t,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
|
||||
|
|
@ -395,7 +394,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
|
|||
delta);
|
||||
}
|
||||
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_SLIDER)) {
|
||||
if (libinput_tablet_tool_has_slider(tool)) {
|
||||
slider = libinput_event_tablet_tool_get_slider_position(t);
|
||||
delta = libinput_event_tablet_tool_get_axis_delta(t,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
|
||||
|
|
@ -404,7 +403,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
|
|||
delta);
|
||||
}
|
||||
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL)) {
|
||||
if (libinput_tablet_tool_has_wheel(tool)) {
|
||||
wheel = libinput_event_tablet_tool_get_axis_delta(t,
|
||||
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
|
||||
delta = libinput_event_tablet_tool_get_axis_delta_discrete(t,
|
||||
|
|
@ -490,18 +489,17 @@ print_proximity_event(struct libinput_event *ev)
|
|||
state_str);
|
||||
|
||||
printf("\taxes:");
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE))
|
||||
if (libinput_tablet_tool_has_distance(tool))
|
||||
printf("d");
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE))
|
||||
if (libinput_tablet_tool_has_pressure(tool))
|
||||
printf("p");
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
|
||||
libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y))
|
||||
if (libinput_tablet_tool_has_tilt(tool))
|
||||
printf("t");
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z))
|
||||
if (libinput_tablet_tool_has_rotation(tool))
|
||||
printf("r");
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_SLIDER))
|
||||
if (libinput_tablet_tool_has_slider(tool))
|
||||
printf("s");
|
||||
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL))
|
||||
if (libinput_tablet_tool_has_wheel(tool))
|
||||
printf("w");
|
||||
|
||||
printf("\tbtn:");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue