-
-
Notifications
You must be signed in to change notification settings - Fork 193
C++ Rewrite #443
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
base: master
Are you sure you want to change the base?
C++ Rewrite #443
Conversation
|
I can test it on linux - are they changes how to build it or still |
@ChrisLauinger77 Thank you, yes they are exactly as before. Readme is also updated: https://github.com/Sapd/HeadsetControl/blob/236d4f79044b9bc313c65c9c1527c31111024637/README.md |
|
looks like it still works :) Good job ! |
|
Ah sorry I was too fast. Chatmix is here so is equalizer_presets_count (the preset names for the count 4 - never worked for this headset - not sure if they supposed to) |
Rewrite codebase from C to modern C++20 Complete modernization introducing type safety, better error handling, and a cleaner architecture. - **Language**: C → C++20 (requires GCC 10+, Clang 10+, MSVC 2019+) - **Structure**: Reorganized into lib/, cli/, tests/ - **Error handling**: Result<T> type with rich error information - **Device code**: 50-70% reduction via protocol templates - High-level C++ API (headsetcontrol.hpp) - C API for FFI bindings (headsetcontrol_c.h) - Shared library support (-DBUILD_SHARED_LIBRARY=ON) - Protocol templates: HIDPPDevice, SteelSeriesNovaDevice - Data-driven capability system - Test suite - HIDDevice base class with virtual methods per capability - Device registry singleton for device lookup - Capability descriptors as single source of truth - Feature handler registry (replaces switch statements) CLI interface unchanged - fully backwards compatible. - See docs/ADDING_A_DEVICE.md for adding devices - See docs/ADDING_A_CAPABILITY.md for adding features - See docs/LIBRARY_USAGE.md for library integration CI: Use GCC 13 on Ubuntu, add verbose test output
|
@ChrisLauinger77 Indeed I missed parts of chatmix and equalizer. Can you please test again? |
|
here we go: |
|
When I add --test-device I get: going offline now - can continue tomorrow |
|
Ah yes thank you, they are now populated |
|
I get this when no headset is connected: But Should be reported - I rely on them in my tools. |
|
Yep, fixed |
|
here we go: |
|
I cannot manage to build with MSVC. Mingw works fine. MSVC Compilation Failures SummaryEnvironment:
Issues:
This suggests MSVC may not be parsing designated initializers correctly even with C++20 enabled. |
|
@floraaubry Yeah it was not really programmed with MSVC in mind. That said providing that support was not too hard any more. To do so: Prerequisites: # Install VCPKG first if not yet
git clone https://github.com/microsoft/vcpkg C:\vcpkg
C:\vcpkg\bootstrap-vcpkg.bat
# Install getopt
C:\vcpkg\vcpkg install hidapi:x64-windows getopt:x64-windowsBuild: cd HeadsetControl
cmake -B build -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build |
|
Managed to build! Small errors when building shared: # Library dependencies
if(MSVC)
target_link_libraries(headsetcontrol_lib PUBLIC ${HIDAPI_LIBRARIES})
else()
target_link_libraries(headsetcontrol_lib PUBLIC m ${HIDAPI_LIBRARIES})
endif()Conditional import for libm, but missing same conditional for shared # Optionally build shared library for FFI bindings
if(BUILD_SHARED_LIBRARY)
add_library(headsetcontrol_shared SHARED ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
set_target_properties(headsetcontrol_shared PROPERTIES
OUTPUT_NAME "headsetcontrol"
VERSION "${GIT_VERSION}"
SOVERSION 1
)
target_include_directories(headsetcontrol_shared PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_CURRENT_SOURCE_DIR}/lib/devices
${HIDAPI_INCLUDE_DIRS}
)
target_link_libraries(headsetcontrol_shared PUBLIC m ${HIDAPI_LIBRARIES}) # <--
# Export symbols for the C API on Windows
if(WIN32)
target_compile_definitions(headsetcontrol_shared PRIVATE HSC_BUILDING_DLL)
endif()
endif()Another issue when building shared: i manged to fix it by temporary renaming # Set library properties
set_target_properties(headsetcontrol_lib PROPERTIES
OUTPUT_NAME "headsetcontrol"
POSITION_INDEPENDENT_CODE ON
)to # Set library properties
set_target_properties(headsetcontrol_lib PROPERTIES
OUTPUT_NAME "headsetcontrol_static"
POSITION_INDEPENDENT_CODE ON
) |
|
@floraaubry Can you try again please? |
|
|
@floraaubry I also renamed it in code. You are linking the application right (not using json output or similar)?, so I guess that aspects works fully now |
|
Yep i diteched the executable in profit of the lib. All i can test is sidetone, lights, battery status and level, and everything is working flawlesly |




Rewrite codebase from C to modern C++20.
A part of it was obviously done using AI Agents, it would have been impossible otherwise.
See docs/ for examples how now the modern library works.
Complete modernization introducing type safety, better error handling, and a cleaner architecture.
CLI interface unchanged - fully backwards compatible.
Fixes #431