mirror of
https://github.com/baketnk/frame-yap.git
synced 2026-10-06 03:00:04 +02:00
Wire native OpenVR voice-typing POC with safe review and grip controls
This commit is contained in:
1 parent
73dc4fda06
commit
d60d8d2f5d
21 files changed
+1929
-29
No files matched your search
+103
-13
@@ -1,19 +1,109 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(frame_dictation VERSION 0.1.0 LANGUAGES CXX)
|
||||
project(frameyap VERSION 0.1.0 LANGUAGES C CXX)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
option(FRAMEYAP_NATIVE "Build opt-in OpenVR/SDL3/Gamescope runtime (no automatic downloads)" OFF)
|
||||
|
||||
add_executable(frame-dictation src/main.cpp)
|
||||
target_compile_features(frame-dictation PRIVATE cxx_std_20)
|
||||
set_target_properties(frame-dictation PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_compile_definitions(frame-dictation PRIVATE FRAME_DICTATION_VERSION="${PROJECT_VERSION}")
|
||||
add_library(frameyap_core src/core.cpp)
|
||||
target_include_directories(frameyap_core PUBLIC src)
|
||||
add_executable(frameyap src/main.cpp)
|
||||
target_link_libraries(frameyap PRIVATE frameyap_core)
|
||||
target_compile_definitions(frameyap PRIVATE FRAMEYAP_VERSION="${PROJECT_VERSION}")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_library(frameyap_worker src/worker.cpp)
|
||||
target_include_directories(frameyap_worker PUBLIC src)
|
||||
endif()
|
||||
if(FRAMEYAP_NATIVE)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
message(FATAL_ERROR "Native POC supports Linux only")
|
||||
endif()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SDL3 REQUIRED IMPORTED_TARGET sdl3>=3.2)
|
||||
# SDL's .pc can inject its producer-prefix RPATH. Let CMake manage build
|
||||
# RPATH and install only our relative path, never a developer environment.
|
||||
get_target_property(SDL3_LINK_OPTIONS PkgConfig::SDL3 INTERFACE_LINK_OPTIONS)
|
||||
if(SDL3_LINK_OPTIONS)
|
||||
list(FILTER SDL3_LINK_OPTIONS EXCLUDE REGEX "^-Wl,-rpath,")
|
||||
set_property(TARGET PkgConfig::SDL3 PROPERTY INTERFACE_LINK_OPTIONS "${SDL3_LINK_OPTIONS}")
|
||||
endif()
|
||||
pkg_check_modules(WAYLAND REQUIRED IMPORTED_TARGET wayland-client)
|
||||
pkg_check_modules(FREETYPE REQUIRED IMPORTED_TARGET freetype2)
|
||||
find_program(WAYLAND_SCANNER wayland-scanner REQUIRED)
|
||||
set(OPENVR_ROOT "" CACHE PATH "Explicit standalone OpenVR v2.15.6 SDK root")
|
||||
find_path(OPENVR_INCLUDE_DIR openvr.h HINTS "${OPENVR_ROOT}/headers" REQUIRED)
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)$")
|
||||
set(OPENVR_PLATFORM linuxarm64)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64)$")
|
||||
set(OPENVR_PLATFORM linux64)
|
||||
else()
|
||||
message(FATAL_ERROR "Native POC requires Linux ARM64 or x86-64")
|
||||
endif()
|
||||
find_library(OPENVR_LIBRARY openvr_api HINTS "${OPENVR_ROOT}/lib/${OPENVR_PLATFORM}" "${OPENVR_ROOT}/bin/${OPENVR_PLATFORM}" REQUIRED)
|
||||
set(PROTOCOL "${CMAKE_CURRENT_SOURCE_DIR}/protocol/gamescope-input-method.xml")
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method-client.h"
|
||||
COMMAND "${WAYLAND_SCANNER}" client-header "${PROTOCOL}" "${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method-client.h"
|
||||
DEPENDS "${PROTOCOL}" VERBATIM)
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method.c"
|
||||
COMMAND "${WAYLAND_SCANNER}" private-code "${PROTOCOL}" "${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method.c"
|
||||
DEPENDS "${PROTOCOL}" VERBATIM)
|
||||
target_sources(frameyap PRIVATE src/runtime.cpp src/overlay.cpp src/audio.cpp src/text_input.cpp
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method.c" "${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method-client.h")
|
||||
target_include_directories(frameyap PRIVATE "${OPENVR_INCLUDE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
target_link_libraries(frameyap PRIVATE frameyap_worker PkgConfig::SDL3 PkgConfig::WAYLAND PkgConfig::FREETYPE "${OPENVR_LIBRARY}")
|
||||
target_compile_definitions(frameyap PRIVATE FRAMEYAP_NATIVE=1)
|
||||
set_target_properties(frameyap PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
|
||||
endif()
|
||||
install(TARGETS frameyap RUNTIME DESTINATION bin)
|
||||
install(DIRECTORY assets/ DESTINATION assets)
|
||||
install(DIRECTORY python/frameyap DESTINATION python FILES_MATCHING PATTERN "*.py" PATTERN "__pycache__" EXCLUDE)
|
||||
|
||||
include(CTest)
|
||||
if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
|
||||
add_test(NAME frame_dictation.cli
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-DAPP=$<TARGET_FILE:frame-dictation>"
|
||||
"-DEXPECTED_VERSION=${PROJECT_VERSION}"
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/tests/cli.cmake")
|
||||
add_test(NAME frame_dictation.install_preflight
|
||||
COMMAND sh "${CMAKE_CURRENT_SOURCE_DIR}/tests/install-preflight.sh"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/install-preflight.sh")
|
||||
add_test(NAME frameyap.cli COMMAND "${CMAKE_COMMAND}" "-DAPP=$<TARGET_FILE:frameyap>"
|
||||
"-DEXPECTED_VERSION=${PROJECT_VERSION}" -P "${CMAKE_CURRENT_SOURCE_DIR}/tests/cli.cmake")
|
||||
add_test(NAME frameyap.install_preflight COMMAND sh "${CMAKE_CURRENT_SOURCE_DIR}/tests/install-preflight.sh"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/install-preflight.sh")
|
||||
add_executable(frameyap_core_test tests/core_test.cpp)
|
||||
target_link_libraries(frameyap_core_test PRIVATE frameyap_core)
|
||||
add_test(NAME frameyap.core COMMAND frameyap_core_test)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_executable(frameyap_lock_test tests/lock_test.cpp)
|
||||
target_include_directories(frameyap_lock_test PRIVATE src)
|
||||
add_test(NAME frameyap.instance_lock COMMAND frameyap_lock_test)
|
||||
endif()
|
||||
add_executable(frameyap_gestures_test tests/gestures_test.cpp)
|
||||
target_include_directories(frameyap_gestures_test PRIVATE src)
|
||||
target_compile_options(frameyap_gestures_test PRIVATE -UNDEBUG)
|
||||
add_test(NAME frameyap.gestures COMMAND frameyap_gestures_test)
|
||||
find_package(Python3 3.10 COMPONENTS Interpreter)
|
||||
if(FRAMEYAP_NATIVE)
|
||||
pkg_check_modules(WAYLAND_SERVER IMPORTED_TARGET wayland-server)
|
||||
if(WAYLAND_SERVER_FOUND)
|
||||
find_package(Threads REQUIRED)
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method-server.h"
|
||||
COMMAND "${WAYLAND_SCANNER}" server-header "${PROTOCOL}" "${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method-server.h"
|
||||
DEPENDS "${PROTOCOL}" VERBATIM)
|
||||
add_executable(frameyap_text_input_test tests/text_input_test.cpp src/text_input.cpp
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method.c"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method-client.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/gamescope-input-method-server.h")
|
||||
target_include_directories(frameyap_text_input_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
target_link_libraries(frameyap_text_input_test PRIVATE frameyap_core PkgConfig::WAYLAND PkgConfig::WAYLAND_SERVER Threads::Threads)
|
||||
add_test(NAME frameyap.text_input_protocol COMMAND frameyap_text_input_test)
|
||||
set_tests_properties(frameyap.text_input_protocol PROPERTIES TIMEOUT 15)
|
||||
endif()
|
||||
endif()
|
||||
if(Python3_FOUND)
|
||||
add_test(NAME frameyap.python_worker COMMAND "${Python3_EXECUTABLE}" -m unittest discover -s tests -p test_worker.py)
|
||||
add_test(NAME frameyap.installer COMMAND "${Python3_EXECUTABLE}" -m unittest discover -s tests -p test_installer.py)
|
||||
set_tests_properties(frameyap.python_worker frameyap.installer PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" TIMEOUT 60)
|
||||
if(TARGET frameyap_worker)
|
||||
add_executable(frameyap_worker_test tests/worker_test.cpp)
|
||||
target_link_libraries(frameyap_worker_test PRIVATE frameyap_worker)
|
||||
target_compile_options(frameyap_worker_test PRIVATE -UNDEBUG)
|
||||
add_test(NAME frameyap.worker_ipc COMMAND frameyap_worker_test "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_worker.py")
|
||||
set_tests_properties(frameyap.worker_ipc PROPERTIES TIMEOUT 30)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
Reference in new issue
Block a user