Commit 5c9c4810 authored by Peter Hutterer's avatar Peter Hutterer

tablet: rename axis_has_changed into an axis-specific API set

First part of the big revamp to get rid of libinput_tablet_tool_axis and
replace it with a set of axis-specific APIs.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Acked-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarLyude <cpaul@redhat.com>
parent 67b92ade
......@@ -913,8 +913,8 @@ libinput_event_gesture_get_angle_delta(struct libinput_event_gesture *event)
}
LIBINPUT_EXPORT int
libinput_event_tablet_tool_axis_has_changed(struct libinput_event_tablet_tool *event,
enum libinput_tablet_tool_axis axis)
libinput_event_tablet_tool_x_has_changed(
struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
......@@ -923,8 +923,128 @@ libinput_event_tablet_tool_axis_has_changed(struct libinput_event_tablet_tool *e
LIBINPUT_EVENT_TABLET_TOOL_TIP,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
return (NCHARS(axis) <= sizeof(event->changed_axes)) ?
bit_is_set(event->changed_axes, axis) : 0;
return bit_is_set(event->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_X);
}
LIBINPUT_EXPORT int
libinput_event_tablet_tool_y_has_changed(
struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
0,
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
LIBINPUT_EVENT_TABLET_TOOL_TIP,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
return bit_is_set(event->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_Y);
}
LIBINPUT_EXPORT int
libinput_event_tablet_tool_pressure_has_changed(
struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
0,
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
LIBINPUT_EVENT_TABLET_TOOL_TIP,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
return bit_is_set(event->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
}
LIBINPUT_EXPORT int
libinput_event_tablet_tool_distance_has_changed(
struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
0,
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
LIBINPUT_EVENT_TABLET_TOOL_TIP,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
return bit_is_set(event->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
}
LIBINPUT_EXPORT int
libinput_event_tablet_tool_tilt_x_has_changed(
struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
0,
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
LIBINPUT_EVENT_TABLET_TOOL_TIP,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
return bit_is_set(event->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
}
LIBINPUT_EXPORT int
libinput_event_tablet_tool_tilt_y_has_changed(
struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
0,
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
LIBINPUT_EVENT_TABLET_TOOL_TIP,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
return bit_is_set(event->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
}
LIBINPUT_EXPORT int
libinput_event_tablet_tool_rotation_has_changed(
struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
0,
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
LIBINPUT_EVENT_TABLET_TOOL_TIP,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
return bit_is_set(event->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
}
LIBINPUT_EXPORT int
libinput_event_tablet_tool_slider_has_changed(
struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
0,
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
LIBINPUT_EVENT_TABLET_TOOL_TIP,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
return bit_is_set(event->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
}
LIBINPUT_EXPORT int
libinput_event_tablet_tool_wheel_has_changed(
struct libinput_event_tablet_tool *event)
{
require_event_type(libinput_event_get_context(&event->base),
event->base.type,
0,
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
LIBINPUT_EVENT_TABLET_TOOL_TIP,
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
return bit_is_set(event->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
}
LIBINPUT_EXPORT double
......
......@@ -1361,20 +1361,161 @@ libinput_event_tablet_tool_get_base_event(struct libinput_event_tablet_tool *eve
/**
* @ingroup event_tablet
*
* Checks if an axis was updated in this event or return 0 otherwise.
* For tablet events that are not of type @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS or
* type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
* Check if the x axis was updated in this event.
* For tablet events that are not of type @ref
* LIBINPUT_EVENT_TABLET_TOOL_AXIS, @ref LIBINPUT_EVENT_TABLET_TOOL_TIP, or
* @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
*
* @param event The libinput tablet event
* @param axis The axis to check for updates
* @return 1 if the axis was updated or 0 otherwise
*/
int
libinput_event_tablet_tool_axis_has_changed(struct libinput_event_tablet_tool *event,
enum libinput_tablet_tool_axis axis);
libinput_event_tablet_tool_x_has_changed(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
* Check if the y axis was updated in this event.
* For tablet events that are not of type @ref
* LIBINPUT_EVENT_TABLET_TOOL_AXIS, @ref LIBINPUT_EVENT_TABLET_TOOL_TIP, or
* @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
*
* @param event The libinput tablet event
* @return 1 if the axis was updated or 0 otherwise
*/
int
libinput_event_tablet_tool_y_has_changed(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
* Check if the pressure axis was updated in this event.
* For tablet events that are not of type @ref
* LIBINPUT_EVENT_TABLET_TOOL_AXIS, @ref LIBINPUT_EVENT_TABLET_TOOL_TIP, or
* @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
*
* @param event The libinput tablet event
* @return 1 if the axis was updated or 0 otherwise
*/
int
libinput_event_tablet_tool_pressure_has_changed(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
* Check if the distance axis was updated in this event.
* For tablet events that are not of type @ref
* LIBINPUT_EVENT_TABLET_TOOL_AXIS, @ref LIBINPUT_EVENT_TABLET_TOOL_TIP, or
* @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
*
* @param event The libinput tablet event
* @return 1 if the axis was updated or 0 otherwise
*/
int
libinput_event_tablet_tool_distance_has_changed(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
* Check if the tilt x axis was updated in this event.
* For tablet events that are not of type @ref
* LIBINPUT_EVENT_TABLET_TOOL_AXIS, @ref LIBINPUT_EVENT_TABLET_TOOL_TIP, or
* @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
*
* @param event The libinput tablet event
* @return 1 if the axis was updated or 0 otherwise
*/
int
libinput_event_tablet_tool_tilt_x_has_changed(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
* Check if the tilt y axis was updated in this event.
* For tablet events that are not of type @ref
* LIBINPUT_EVENT_TABLET_TOOL_AXIS, @ref LIBINPUT_EVENT_TABLET_TOOL_TIP, or
* @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
*
* @param event The libinput tablet event
* @return 1 if the axis was updated or 0 otherwise
*/
int
libinput_event_tablet_tool_tilt_y_has_changed(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
* Check if the z-rotation axis was updated in this event.
* For tablet events that are not of type @ref
* LIBINPUT_EVENT_TABLET_TOOL_AXIS, @ref LIBINPUT_EVENT_TABLET_TOOL_TIP, or
* @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
*
* @param event The libinput tablet event
* @return 1 if the axis was updated or 0 otherwise
*/
int
libinput_event_tablet_tool_rotation_has_changed(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
* Check if the slider axis was updated in this event.
* For tablet events that are not of type @ref
* LIBINPUT_EVENT_TABLET_TOOL_AXIS, @ref LIBINPUT_EVENT_TABLET_TOOL_TIP, or
* @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
*
* @param event The libinput tablet event
* @return 1 if the axis was updated or 0 otherwise
*/
int
libinput_event_tablet_tool_slider_has_changed(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
*
* Check if the wheel axis was updated in this event.
* For tablet events that are not of type @ref
* LIBINPUT_EVENT_TABLET_TOOL_AXIS, @ref LIBINPUT_EVENT_TABLET_TOOL_TIP, or
* @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS and @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY.
*
* @param event The libinput tablet event
* @return 1 if the axis was updated or 0 otherwise
*/
int
libinput_event_tablet_tool_wheel_has_changed(
struct libinput_event_tablet_tool *event);
/**
* @ingroup event_tablet
......@@ -1406,7 +1547,7 @@ libinput_event_tablet_tool_axis_has_changed(struct libinput_event_tablet_tool *e
* libinput_event_tablet_tool_get_axis_delta() instead.
*
* @note This function may be called for a specific axis even if
* libinput_event_tablet_tool_axis_has_changed() returns 0 for that axis.
* libinput_event_tablet_tool_*_has_changed() returns 0 for that axis.
* libinput always includes all device axes in the event.
*
* If the event is of type @ref LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY and the
......@@ -1465,7 +1606,7 @@ libinput_event_tablet_tool_get_axis_delta_discrete(
* screen coordinates.
*
* @note This function may be called for a specific axis even if
* libinput_event_tablet_tool_axis_has_changed() returns 0 for that axis.
* libinput_event_tablet_tool_*_has_changed() returns 0 for that axis.
* libinput always includes all device axes in the event.
*
* @param event The libinput tablet event
......@@ -1483,7 +1624,7 @@ libinput_event_tablet_tool_get_x_transformed(struct libinput_event_tablet_tool *
* screen coordinates.
*
* @note This function may be called for a specific axis even if
* libinput_event_tablet_tool_axis_has_changed() returns 0 for that axis.
* libinput_event_tablet_tool_*_has_changed() returns 0 for that axis.
* libinput always includes all device axes in the event.
*
* @param event The libinput tablet event
......
......@@ -185,7 +185,15 @@ LIBINPUT_1.1 {
* keep them separate */
LIBINPUT_TABLET_SUPPORT {
libinput_event_get_tablet_tool_event;
libinput_event_tablet_tool_axis_has_changed;
libinput_event_tablet_tool_x_has_changed;
libinput_event_tablet_tool_y_has_changed;
libinput_event_tablet_tool_pressure_has_changed;
libinput_event_tablet_tool_distance_has_changed;
libinput_event_tablet_tool_rotation_has_changed;
libinput_event_tablet_tool_tilt_x_has_changed;
libinput_event_tablet_tool_tilt_y_has_changed;
libinput_event_tablet_tool_wheel_has_changed;
libinput_event_tablet_tool_slider_has_changed;
libinput_event_tablet_tool_get_axis_delta;
libinput_event_tablet_tool_get_axis_delta_discrete;
libinput_event_tablet_tool_get_axis_value;
......
This diff is collapsed.
......@@ -332,16 +332,6 @@ print_pointer_axis_event(struct libinput_event *ev)
printf("vert %.2f%s horiz %.2f%s\n", v, have_vert, h, have_horiz);
}
static const char*
tablet_axis_changed_sym(struct libinput_event_tablet_tool *t,
enum libinput_tablet_tool_axis axis)
{
if (libinput_event_tablet_tool_axis_has_changed(t, axis))
return "*";
else
return "";
}
static void
print_tablet_axes(struct libinput_event_tablet_tool *t)
{
......@@ -351,13 +341,16 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
double rotation, slider, wheel;
double delta;
#define changed_sym(ev, ax) \
(libinput_event_tablet_tool_##ax##_has_changed(ev) ? "*" : "")
x = libinput_event_tablet_tool_get_axis_value(t, LIBINPUT_TABLET_TOOL_AXIS_X);
y = libinput_event_tablet_tool_get_axis_value(t, LIBINPUT_TABLET_TOOL_AXIS_Y);
dx = libinput_event_tablet_tool_get_axis_delta(t, LIBINPUT_TABLET_TOOL_AXIS_X);
dy = libinput_event_tablet_tool_get_axis_delta(t, LIBINPUT_TABLET_TOOL_AXIS_Y);
printf("\t%.2f%s/%.2f%s (%.2f/%.2f)",
x, tablet_axis_changed_sym(t, LIBINPUT_TABLET_TOOL_AXIS_X),
y, tablet_axis_changed_sym(t, LIBINPUT_TABLET_TOOL_AXIS_Y),
x, changed_sym(t, x),
y, changed_sym(t, y),
dx, dy);
if (libinput_tablet_tool_has_axis(tool, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
......@@ -371,10 +364,8 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
dy = libinput_event_tablet_tool_get_axis_delta(t,
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
printf("\ttilt: %.2f%s/%.2f%s (%.2f/%.2f)",
x, tablet_axis_changed_sym(t,
LIBINPUT_TABLET_TOOL_AXIS_TILT_X),
y, tablet_axis_changed_sym(t,
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y),
x, changed_sym(t, tilt_x),
y, changed_sym(t, tilt_y),
dx, dy);
}
......@@ -388,17 +379,13 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
delta = libinput_event_tablet_tool_get_axis_delta(t,
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
printf("\tdistance: %.2f%s (%.2f)",
dist,
tablet_axis_changed_sym(t,
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE),
dist, changed_sym(t, distance),
delta);
} else {
delta = libinput_event_tablet_tool_get_axis_delta(t,
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
printf("\tpressure: %.2f%s (%.2f)",
pressure,
tablet_axis_changed_sym(t,
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE),
pressure, changed_sym(t, pressure),
delta);
}
}
......@@ -409,9 +396,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
delta = libinput_event_tablet_tool_get_axis_delta(t,
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
printf("\trotation: %.2f%s (%.2f)",
rotation,
tablet_axis_changed_sym(t,
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z),
rotation, changed_sym(t, rotation),
delta);
}
......@@ -421,9 +406,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
delta = libinput_event_tablet_tool_get_axis_delta(t,
LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
printf("\tslider: %.2f%s (%.2f)",
slider,
tablet_axis_changed_sym(t,
LIBINPUT_TABLET_TOOL_AXIS_SLIDER),
slider, changed_sym(t, slider),
delta);
}
......@@ -433,9 +416,7 @@ print_tablet_axes(struct libinput_event_tablet_tool *t)
delta = libinput_event_tablet_tool_get_axis_delta_discrete(t,
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
printf("\twheel: %.2f%s (%d)",
wheel,
tablet_axis_changed_sym(t,
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL),
wheel, changed_sym(t, wheel),
(int)delta);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment