Files
xone_macos/CMakeLists.txt
T
portersky fafca4c265 feat: add Xbox One HID report layout and mapping
Phase 4 foundation, independent of the presentation mechanism:

- hid/hid_report.hpp: standard Xbox One report layout (64-byte input:
  buttons/guide/triggers/sticks; 64-byte output: motors), the HID
  report descriptor, and GIP state to report mapping.
- make_input_report(): remaps GIP button bits to the standard Xbox
  bitmask, scales 10-bit triggers to 8-bit, sticks pass through.
- parse_output_report(): extracts motor intensities from output
  reports for the rumble relay; malformed reports stop the motors.
- test_hid: unit tests for the mapping, scaling, and descriptor.

Report packing verified with a descriptor walker: input and output
are exactly 64 bytes each. Next step is presentation via DriverKit,
which needs a Developer ID with the DriverKit entitlement.

Co-Authored-By: qwen3.8-27b@q3_k_xl: implemented HID report layer
2026-08-29 15:39:03 +02:00

134 lines
5.3 KiB
CMake

# CMake supports Swift only with the Ninja and Xcode generators.
if(NOT CMAKE_GENERATOR MATCHES "^(Ninja|Xcode)$")
message(FATAL_ERROR
"This project requires the Ninja or Xcode generator for Swift support.\n"
" Configure with: cmake -S . -B build -G Ninja")
endif()
cmake_minimum_required(VERSION 3.21)
project(xone_macos VERSION 0.1.28 LANGUAGES CXX Swift)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Add the deps directory to the module path
# Required for find_package injection
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps")
# Platform and compiler detection
include(Platform)
include(Flags)
include(Sanitizers)
# ==============================================================================
# Module libraries (bottom-up layering, mirrors medusalix/xone structure)
# ==============================================================================
# USB transport (IOKit / IOUSBFamily)
add_library(xone_usb STATIC
"src/usb/usb_transport.cpp"
)
target_include_directories(xone_usb PUBLIC "${CMAKE_SOURCE_DIR}/include")
target_compile_features(xone_usb PRIVATE cxx_std_23)
target_compile_options(xone_usb PRIVATE ${BASE_OPTIONS})
target_compile_definitions(xone_usb PRIVATE ${BASE_DEFINITIONS})
find_library(XONE_IOKIT IOKit)
find_library(XONE_COREFOUNDATION CoreFoundation)
target_link_libraries(xone_usb PUBLIC "${XONE_IOKIT}" "${XONE_COREFOUNDATION}")
# Auth + crypto (AES-CCMP key setup, ECDH, RSA — port from auth/)
add_library(xone_auth STATIC
"src/auth/crypto.cpp"
"src/auth/auth.cpp"
)
target_include_directories(xone_auth PUBLIC "${CMAKE_SOURCE_DIR}/include")
target_compile_features(xone_auth PRIVATE cxx_std_23)
target_compile_options(xone_auth PRIVATE ${BASE_OPTIONS})
target_compile_definitions(xone_auth PRIVATE ${BASE_DEFINITIONS})
find_library(XONE_SECURITY Security)
find_library(XONE_COREFOUNDATION CoreFoundation)
target_link_libraries(xone_auth PUBLIC "${XONE_SECURITY}" "${XONE_COREFOUNDATION}")
# MT76 chip protocol (firmware load, EFUSE, radio init, beacons)
add_library(xone_mt76 STATIC
"src/mt76/mt76.cpp"
)
target_include_directories(xone_mt76 PUBLIC "${CMAKE_SOURCE_DIR}/include")
target_compile_features(xone_mt76 PRIVATE cxx_std_23)
target_compile_options(xone_mt76 PRIVATE ${BASE_OPTIONS})
target_compile_definitions(xone_mt76 PRIVATE ${BASE_DEFINITIONS})
target_link_libraries(xone_mt76 PUBLIC xone_usb)
# GIP protocol (client lifecycle, handshake, status reports)
add_library(xone_gip STATIC
"src/gip/protocol.cpp"
)
target_include_directories(xone_gip PUBLIC "${CMAKE_SOURCE_DIR}/include")
target_compile_features(xone_gip PRIVATE cxx_std_23)
target_compile_options(xone_gip PRIVATE ${BASE_OPTIONS})
target_compile_definitions(xone_gip PRIVATE ${BASE_DEFINITIONS})
target_link_libraries(xone_gip PUBLIC xone_auth xone_mt76)
# Virtual HID gamepad presentation
add_library(xone_hid STATIC
"src/hid/hid_device.cpp"
"src/hid/hid_report.cpp"
)
target_include_directories(xone_hid PUBLIC "${CMAKE_SOURCE_DIR}/include")
target_compile_features(xone_hid PRIVATE cxx_std_23)
target_compile_options(xone_hid PRIVATE ${BASE_OPTIONS})
target_compile_definitions(xone_hid PRIVATE ${BASE_DEFINITIONS})
target_link_libraries(xone_hid PUBLIC xone_gip)
# C ABI bridge consumed by the Swift app and the test suite
add_library(xone_api STATIC
"src/app/api.cpp"
)
target_include_directories(xone_api PUBLIC "${CMAKE_SOURCE_DIR}/include")
target_compile_features(xone_api PRIVATE cxx_std_23)
target_compile_options(xone_api PRIVATE ${BASE_OPTIONS})
target_compile_definitions(xone_api PRIVATE XONE_VERSION="${PROJECT_VERSION}")
target_link_libraries(xone_api PUBLIC xone_hid)
# ==============================================================================
# macOS app (Swift entry point)
# ==============================================================================
add_executable(xone_app
"src/app/main.swift"
"src/app/XoneModels.swift"
"src/app/XoneStore.swift"
"src/app/ContentView.swift"
"src/app/DongleCardView.swift"
"src/app/ControllerCardView.swift"
"src/app/GamepadViews.swift"
)
target_include_directories(xone_app PRIVATE "${CMAKE_SOURCE_DIR}/include")
target_compile_definitions(xone_app PRIVATE ${BASE_DEFINITIONS})
target_compile_features(xone_app PRIVATE cxx_std_23)
target_link_libraries(xone_app PRIVATE xone_api ${BASE_LIBRARIES})
# Swift sees the C ABI via a bridging header (no module map required)
target_compile_options(xone_app PRIVATE
-import-objc-header "${CMAKE_SOURCE_DIR}/include/app/xone_api.h"
)
# ==============================================================================
# Command line tool (protocol stack debugging against hardware)
# ==============================================================================
add_executable(xone_cli
"src/cli/main.cpp"
)
target_include_directories(xone_cli PRIVATE "${CMAKE_SOURCE_DIR}/include")
target_compile_definitions(xone_cli PRIVATE ${BASE_DEFINITIONS})
target_compile_features(xone_cli PRIVATE cxx_std_23)
target_link_libraries(xone_cli PRIVATE xone_mt76)
# ==============================================================================
# Tests
# ==============================================================================
option(BUILD_TESTING OFF "Build Unity test suites")
if (BUILD_TESTING)
enable_testing()
find_package(Unity REQUIRED)
add_subdirectory(tests)
endif()