tablet: minor rework to remove one ifdef HAVE_LIBWACOM

Change to a boolean for more obvious return values and move the ifdef
into the function so we can skip the ifdef in the caller.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1073>
This commit is contained in:
Peter Hutterer 2024-10-29 09:23:09 +10:00
parent 384e946960
commit d3bc0c79ff

View file

@ -929,12 +929,12 @@ copy_button_cap(const struct tablet_dispatch *tablet,
set_bit(tool->buttons, button); set_bit(tool->buttons, button);
} }
#if HAVE_LIBWACOM static inline bool
static inline int
tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet, tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
struct libinput_tablet_tool *tool) struct libinput_tablet_tool *tool)
{ {
int rc = 1; bool rc = false;
#if HAVE_LIBWACOM
WacomDeviceDatabase *db; WacomDeviceDatabase *db;
const WacomStylus *s = NULL; const WacomStylus *s = NULL;
int code; int code;
@ -992,11 +992,10 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
if (axes & WACOM_AXIS_TYPE_PRESSURE) if (axes & WACOM_AXIS_TYPE_PRESSURE)
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE); copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
rc = 0; rc = true;
#endif
return rc; return rc;
} }
#endif
static void static void
tool_set_bits(const struct tablet_dispatch *tablet, tool_set_bits(const struct tablet_dispatch *tablet,
@ -1007,10 +1006,9 @@ tool_set_bits(const struct tablet_dispatch *tablet,
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_X); copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_X);
copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_Y); copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_Y);
#if HAVE_LIBWACOM if (tool_set_bits_from_libwacom(tablet, tool))
if (tool_set_bits_from_libwacom(tablet, tool) == 0)
return; return;
#endif
/* If we don't have libwacom, we simply copy any axis we have on the /* If we don't have libwacom, we simply copy any axis we have on the
tablet onto the tool. Except we know that mice only have rotation tablet onto the tool. Except we know that mice only have rotation
anyway. anyway.