Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LegacyControllerMappingFileHandler: Add missing cond-compile for building without HID #12649

Merged
merged 1 commit into from
Jan 27, 2024

Conversation

fwcd
Copy link
Member

@fwcd fwcd commented Jan 27, 2024

This is something I stumbled upon while building Mixxx without HID support. Everything in controllers/hid is only available when -DHID=ON, including legacyhidcontrollermappingfilehandler.h:

mixxx/CMakeLists.txt

Lines 3354 to 3408 in 59ca3a2

option(HID "USB HID controller support" ON)
if(HID)
# hidapi 0.11.2 is the first release, that implements hid_get_input_report
# for the Linux hidraw backend.
find_package(hidapi 0.11.2)
if(NOT hidapi_FOUND)
message(STATUS "Linking internal libhidapi statically")
add_library(mixxx-hidapi STATIC EXCLUDE_FROM_ALL)
target_include_directories(mixxx-hidapi SYSTEM PUBLIC lib/hidapi/hidapi)
if(WIN32)
target_sources(mixxx-hidapi PRIVATE lib/hidapi/windows/hid.c)
find_library(Setupapi_LIBRARY Setupapi REQUIRED)
target_link_libraries(mixxx-hidapi PUBLIC ${Setupapi_LIBRARY})
elseif(APPLE)
target_sources(mixxx-hidapi PRIVATE lib/hidapi/mac/hid.c)
find_library(AppKit_LIBRARY AppKit REQUIRED)
target_link_libraries(mixxx-hidapi PUBLIC ${AppKit_LIBRARY})
elseif(UNIX)
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
find_library(libudev_LIBRARY udev REQUIRED)
target_sources(mixxx-hidapi PRIVATE lib/hidapi/linux/hid.c)
target_link_libraries(mixxx-hidapi PRIVATE ${libudev_LIBRARY})
else()
if(NOT LibUSB_FOUND)
message(FATAL_ERROR "USB HID controller support on Unix with statically linked libhidapi-libusb requires libusb 1.0 and its development headers.")
endif()
target_sources(mixxx-hidapi PRIVATE lib/hidapi/libusb/hid.c)
target_link_libraries(mixxx-hidapi PRIVATE LibUSB::LibUSB)
endif()
else()
message(FATAL_ERROR "USB HID controller support only possible on Windows/Mac OS/Linux/BSD.")
endif()
target_link_libraries(mixxx-lib PRIVATE mixxx-hidapi)
else()
# hidapi has two backends on Linux, one using the kernel's hidraw API and one using libusb.
# libusb obviously does not support Bluetooth HID devices, so use the hidraw backend. The
# libusb backend is the default, so hidraw needs to be selected explicitly at link time.
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
target_link_libraries(mixxx-lib PRIVATE hidapi::hidraw)
else()
target_link_libraries(mixxx-lib PRIVATE hidapi::hidapi)
endif()
endif()
target_sources(mixxx-lib PRIVATE
src/controllers/hid/hidcontroller.cpp
src/controllers/hid/hidiothread.cpp
src/controllers/hid/hidioglobaloutputreportfifo.cpp
src/controllers/hid/hidiooutputreport.cpp
src/controllers/hid/hiddevice.cpp
src/controllers/hid/hidenumerator.cpp
src/controllers/hid/legacyhidcontrollermapping.cpp
src/controllers/hid/legacyhidcontrollermappingfilehandler.cpp
)
target_compile_definitions(mixxx-lib PUBLIC __HID__)
endif()

LegacyControllerMappingFileHandler was missing a cond-compile around the HID handler, therefore this patch.

@fwcd fwcd mentioned this pull request Jan 27, 2024
54 tasks
@JoergAtGithub
Copy link
Member

LGTM! Thank you!

@JoergAtGithub JoergAtGithub merged commit f87a5db into mixxxdj:2.4 Jan 27, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants