Commit [1] introduced a dependency with the HID plugin in the HoG code As a result, building with --disable-hid --enable-hog caused linker errors due to undefined references to HID-related functions: ``` > ./configure --disable-hid --enable-hog > make /usr/bin/ld: profiles/input/bluetoothd-hog.o: in function `hog_accept': /home/../bluez/profiles/input/hog.c:184:(.text.hog_accept+0xbb): undefined reference to `input_get_auto_sec' /usr/bin/ld: profiles/input/bluetoothd-hog.o: in function `hog_disconnect': /home/../bluez/profiles/input/hog.c:205:(.text.hog_disconnect+0x12): undefined reference to `input_get_userspace_hid' collect2: error: ld returned 1 exit status make[1]: *** [Makefile:6344: src/bluetoothd] Error 1 make: *** [Makefile:4695: all] Error 2 ``` This patch introduces the HAVE_HID symbol to conditionally call the HID-related code in the HoG plugin only when HID is enabled. Additionally, hog_disconnect() reverts to its pre-[1] behavior when the HID plugin is unavailable. [1] 1782bfd79 input: Add support for UserspaceHID=persist Fixes: https://github.com/bluez/bluez/issues/1228 --- configure.ac | 3 +++ profiles/input/hog.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1e089aaa7..aa56b7b81 100644 --- a/configure.ac +++ b/configure.ac @@ -194,6 +194,9 @@ AM_CONDITIONAL(NETWORK, test "${enable_network}" != "no") AC_ARG_ENABLE(hid, AS_HELP_STRING([--disable-hid], [disable HID profile]), [enable_hid=${enableval}]) AM_CONDITIONAL(HID, test "${enable_hid}" != "no") +if test "${enable_hid}" != "no"; then + AC_DEFINE(HAVE_HID, 1, [Define to 1 if you have HID support.]) +fi AC_ARG_ENABLE(hog, AS_HELP_STRING([--disable-hog], [disable HoG profile]), [enable_hog=${enableval}]) diff --git a/profiles/input/hog.c b/profiles/input/hog.c index 97224f0d1..7ad94c474 100644 --- a/profiles/input/hog.c +++ b/profiles/input/hog.c @@ -40,13 +40,16 @@ #include "src/shared/gatt-client.h" #include "src/plugin.h" -#include "device.h" #include "suspend.h" #include "attrib/att.h" #include "attrib/gattrib.h" #include "attrib/gatt.h" #include "hog-lib.h" +#ifdef HAVE_HID +#include "device.h" +#endif /* HAVE_HID */ + struct hog_device { struct btd_device *device; struct bt_hog *hog; @@ -181,8 +184,10 @@ static int hog_accept(struct btd_service *service) if (!device_is_bonded(device, btd_device_get_bdaddr_type(device))) { struct bt_gatt_client *client; +#ifdef HAVE_HID if (!input_get_auto_sec()) return -ECONNREFUSED; +#endif /* HAVE_HID */ client = btd_device_get_gatt_client(device); if (!bt_gatt_client_set_security(client, @@ -202,10 +207,14 @@ static int hog_disconnect(struct btd_service *service) { struct hog_device *dev = btd_service_get_user_data(service); +#ifdef HAVE_HID if (input_get_userspace_hid() == UHID_PERSIST) bt_hog_detach(dev->hog, false); else bt_hog_detach(dev->hog, true); +#else + bt_hog_detach(dev->hog, false); +#endif /* HAVE_HID */ btd_service_disconnecting_complete(service, 0); -- 2.49.0