tablet: minor rework to remove one ifdef HAVE_LIBWACOM
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 28 Oct 2024 23:23:09 +0000 (09:23 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 31 Oct 2024 03:38:28 +0000 (13:38 +1000)
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>

src/evdev-tablet.c

index 075ae57bbe6e9906e8658700a8922cc33ef62b5c..c90168bc26f07e78d759a4ba80d24837a591876a 100644 (file)
@@ -929,12 +929,12 @@ copy_button_cap(const struct tablet_dispatch *tablet,
                set_bit(tool->buttons, button);
 }
 
-#if HAVE_LIBWACOM
-static inline int
+static inline bool
 tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
                            struct libinput_tablet_tool *tool)
 {
-       int rc = 1;
+       bool rc = false;
+#if HAVE_LIBWACOM
        WacomDeviceDatabase *db;
        const WacomStylus *s = NULL;
        int code;
@@ -992,11 +992,10 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
        if (axes & WACOM_AXIS_TYPE_PRESSURE)
                copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
 
-       rc = 0;
-
+       rc = true;
+#endif
        return rc;
 }
-#endif
 
 static void
 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_Y);
 
-#if HAVE_LIBWACOM
-       if (tool_set_bits_from_libwacom(tablet, tool) == 0)
+       if (tool_set_bits_from_libwacom(tablet, tool))
                return;
-#endif
+
        /* 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
           anyway.