From aa066bdd4622d4f6824fee864f6be6806813f04d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 07:37:41 +0100 Subject: move to subdirectory-based build system Closes #224 --- CMakeLists.txt | 636 +++------------------------------------------------------ 1 file changed, 26 insertions(+), 610 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index a444bce3..0b43189c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,615 +1,31 @@ project(opentrack) cmake_minimum_required(VERSION 2.8.11) -cmake_policy(SET CMP0020 NEW) -if(POLICY CMP0058) - cmake_policy(SET CMP0058 OLD) -endif() -if(POLICY CMP0028) - cmake_policy(SET CMP0028 OLD) -endif() -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif() - -include(CMakeParseArguments) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/) -include(GetGitRevisionDescription) -find_package(Git QUIET) -if(GIT_FOUND) - git_describe(OPENTRACK_COMMIT --tags --always --dirty) - git_describe(OPENTRACK_TAG_EXACT --tag --exact) -endif() - -file(WRITE ${CMAKE_BINARY_DIR}/opentrack-version.h "#define OPENTRACK_VERSION \"${OPENTRACK_COMMIT}\"") - -## start crapola - -set(version-string " -#include \"opentrack-compat/export.hpp\" - -#ifdef __cplusplus -extern \"C\" -#endif -OPENTRACK_EXPORT -const char* opentrack_version; - -const char* opentrack_version = \"${OPENTRACK_COMMIT}\"; -") - -set(crapola-ver) -if(EXISTS ${CMAKE_BINARY_DIR}/version.cc) - file(READ ${CMAKE_BINARY_DIR}/version.cc crapola-ver) -endif() - -if(NOT (crapola-ver STREQUAL version-string)) - file(WRITE ${CMAKE_BINARY_DIR}/version.cc "${version-string}") -endif() - -## end crapola - -SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -SET(CMAKE_SKIP_INSTALL_RPATH FALSE) -SET(CMAKE_SKIP_RPATH FALSE) -SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}) -set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_AUTOMOC OFF) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -find_package(OpenCV 3.0) - -find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET) -find_package(Qt5 COMPONENTS SerialPort QUIET) -include_directories(SYSTEM ${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) -add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}) - -if(MSVC) - add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_WARNINGS) -endif() - -set(MY_QT_LIBS ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES}) - -# note, hatire supports both ftnoir and opentrack -# don't remove without being sure as hell -sh 20140922 -add_definitions(-DOPENTRACK_API) - -if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") - set(CMAKE_COMPILER_IS_GNUCC TRUE) - set(CMAKE_COMPILER_IS_GNUCXX TRUE) -endif() - -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - if(MINGW) - set(version-script mingw) - else() - set(version-script posix) - endif() -endif() - -if(APPLE) - set(CMAKE_MACOSX_RPATH OFF) - set(apple-frameworks "-stdlib=libc++ -framework Cocoa -framework CoreFoundation -lobjc -lz -framework Carbon") - set(CMAKE_SHARED_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_SHARED_LINKER_FLAGS}") - #set(CMAKE_STATIC_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_STATIC_LINKER_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_EXE_LINKER_FLAGS}") - set(CMAKE_MODULE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_MODULE_LINKER_FLAGS}") - set(CMAKE_CXX_FLAGS " -stdlib=libc++ ${CMAKE_CXX_FLAGS}") -endif() - -if(CMAKE_COMPILER_IS_GNUCXX OR APPLE) - set(CMAKE_CXX_FLAGS " -std=c++11 ${CMAKE_CXX_FLAGS} ") -endif() - -set_property(GLOBAL PROPERTY USE_FOLDERS OFF) - -macro(opentrack_module n dir) - file(GLOB ${n}-c ${dir}/*.cpp ${dir}/*.c ${dir}/*.h ${dir}/*.hpp) - file(GLOB ${n}-res ${dir}/*.rc) - foreach(f ${n}-res) - set_source_files_properties(${f} PROPERTIES LANGUAGE RC) - endforeach() - file(GLOB ${n}-ui ${dir}/*.ui) - file(GLOB ${n}-rc ${dir}/*.qrc) -endmacro() - -macro(opentrack_qt n) - qt5_wrap_cpp(${n}-moc ${${n}-c} OPTIONS --no-notes) - QT5_WRAP_UI(${n}-uih ${${n}-ui}) - QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc}) - set(${n}-all ${${n}-c} ${${n}-rc} ${${n}-rcc} ${${n}-uih} ${${n}-moc} ${${n}-res}) -endmacro() - -set(msvc-subsystem "/VERSION:5.1 /SUBSYSTEM:WINDOWS,5.01") -function(opentrack_compat target) - if(MSVC) - set_target_properties(${target} PROPERTIES LINK_FLAGS "${msvc-subsystem} /DEBUG /OPT:ICF") - endif() -endfunction() - -macro(opentrack_library n dir) - cmake_parse_arguments(foolib "" "LINK;COMPILE;GNU-LINK;GNU-COMPILE;STATIC" "" ${ARGN}) - if(NOT " ${foolib_UNPARSED_ARGUMENTS}" STREQUAL " ") - message(FATAL_ERROR "opentrack_library bad formals") - endif() - opentrack_module(${n} ${dir}) - opentrack_qt(${n}) - set(link-mode SHARED) - if (foolib_STATIC) - set(link-mode STATIC) - endif() - add_library(${n} ${link-mode} ${${n}-all}) - target_link_libraries(${n} opentrack-api ${MY_QT_LIBS} opentrack-compat) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(${n} PROPERTIES - LINK_FLAGS "${foolib_LINK} ${foolib_GNU-LINK} -Wl,--as-needed -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack-compat/${version-script}-version-script.txt\"" - COMPILE_FLAGS "${foolib_COMPILE} ${foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden" - ) - else() - set(link-flags) - if(MSVC) - set(link-flags "${msvc-subsystem} /DEBUG /OPT:ICF") - endif() - set_target_properties(${n} PROPERTIES LINK_FLAGS "${link-flags} ${foolib_LINK}" COMPILE_FLAGS "${foolib_COMPILE}") - endif() - if(NOT foolib_STATIC) - install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) - endif() - opentrack_compat(${n}) -endmacro() - -function(link_with_dinput8 n) - if(WIN32) - target_link_libraries(${n} dinput8 dxguid strmiids) - endif() -endfunction() - -# ---- - -# cache variables - -# ---- - -IF(WIN32) - SET(SDK_VJOY "" CACHE PATH "VJoy SDK path") - SET(SDK_CONSOLE_DEBUG FALSE CACHE BOOL "Console window visible at runtime") -ENDIF() - -IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(LINUX TRUE) -endif() - -if(LINUX OR APPLE) - set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK") - set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support") -endif() - -SET(SDK_HYDRA "" CACHE PATH "libSixense path for Razer Hydra") -SET(SDK_HYDRA_AMD64 FALSE CACHE BOOL "whether libSixense is amd64 (else ia-32)") -SET(SDK_RIFT_080 "" CACHE PATH "libOVR path for Oculus Rift") -SET(SDK_RIFT_042 "" CACHE PATH "libOVR path for Oculus Rift") -SET(SDK_RIFT_025 "" CACHE PATH "libOVR 0.2.5 path for Oculus Rift") - -set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Aruco paper marker tracker static library path") - -set(SDK_HT "" CACHE FILEPATH "Path to headtracker library") -set(SDK_HT_FLANDMARK "" CACHE FILEPATH "Path to flandmark library for headtracker") - -if(WIN32) - set(SDK_FSUIPC "" CACHE PATH "FSUIPC for older MS FSX path") -endif() - -if(NOT WIN32) - set(SDK_WINE_PREFIX "" CACHE PATH "Wine install prefix") - set(SDK_WINE_NO_WRAPPER FALSE CACHE BOOL "disable Wine wrapper -- use Wine only for X-Plane") -endif() - -# --- tarball - -string(TIMESTAMP filename-date "%Y%m%d") -set(filename-ostype ${CMAKE_SYSTEM_NAME}) -get_git_head_revision(filename-branch_0 filename-hash_0) -if(filename-hash_0) - string(SUBSTRING "${filename-hash_0}" 0 7 filename-hash) -endif() -string(REPLACE "refs/heads/" "" filename-branch_1 "${filename-branch_0}") -string(REPLACE "/" "-" filename-branch "${filename-branch_1}") -set(filename_0 "${OPENTRACK_COMMIT}") -set(filename_1) -if (NOT OPENTRACK_TAG_EXACT STREQUAL OPENTRACK_COMMIT) - string(TIMESTAMP filename_1 "-%Y%m%d%H%M%S") -endif() -set(filename "${CMAKE_BINARY_DIR}/${filename_0}${filename_1}.zip") - -add_custom_target(tarball-real) -add_custom_target(tarball-real2) -add_custom_command(TARGET tarball-real COMMAND cmake -P ${CMAKE_SOURCE_DIR}/cmake/tarball.cmake) - -add_custom_command(TARGET tarball-real2 COMMAND /usr/bin/env sh - "${CMAKE_SOURCE_DIR}/make-tar.sh" "${CMAKE_INSTALL_PREFIX}" - "${filename}" "${CMAKE_BINARY_DIR}") -add_custom_target(tarball DEPENDS tarball-real) - -# -- end tarball - -opentrack_module(opentrack-api opentrack) -opentrack_qt(opentrack-api) -add_library(opentrack-api STATIC ${opentrack-api-all}) -opentrack_compat(opentrack-api) -target_link_libraries(opentrack-api ${MY_QT_LIBS}) -if(NOT WIN32) - target_link_libraries(opentrack-api dl) -else() - target_link_libraries(opentrack-api winmm) -endif() - -opentrack_module(opentrack-compat opentrack-compat) -add_library(opentrack-compat STATIC ${opentrack-compat-c}) -opentrack_compat(opentrack-compat) # uh... -if(NOT WIN32 AND NOT APPLE) - target_link_libraries(opentrack-compat rt) -endif() - -# ---- - -# conditional targets - -# ---- - -set(opentrack-perms PERMISSIONS WORLD_READ WORLD_EXECUTE OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) - -if(WIN32) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres) - SET(CMAKE_RC_COMPILE_OBJECT " --use-temp-file -O coff -i -o ") - endif() - ENABLE_LANGUAGE(RC) -endif(WIN32) - -opentrack_module(opentrack-xplane-plugin x-plane-plugin) - -if(SDK_XPLANE) - # probably librt already included - add_library(opentrack-xplane-plugin SHARED ${opentrack-xplane-plugin-c}) - target_include_directories(opentrack-xplane-plugin SYSTEM PUBLIC ${SDK_XPLANE}/CHeaders ${SDK_XPLANE}/CHeaders/XPLM) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-xplane-plugin - PROPERTIES LINK_FLAGS - "-Wl,--version-script=${CMAKE_SOURCE_DIR}/x-plane-plugin/version-script.txt -shared -rdynamic -nodefaultlibs -undefined_warning -fPIC" - COMPILE_FLAGS "-Wall -O2 -pipe -fPIC -DLIN -DXPLM200 -DXPLM210" - LIBRARY_OUTPUT_NAME "opentrack.xpl" - PREFIX "" SUFFIX "") - endif() - if(APPLE) - SET_TARGET_PROPERTIES(opentrack-xplane-plugin PROPERTIES - COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM200 -DXPLM210 -framework XPLM -framework XPWidgets" - LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets" - LIBRARY_OUTPUT_NAME "opentrack.xpl" - PREFIX "" SUFFIX "") - endif() - if(UNIX AND NOT APPLE) - target_link_libraries(opentrack-xplane-plugin rt) - endif() -endif() - -opentrack_module(opentrack-csv csv) -add_library(opentrack-csv STATIC ${opentrack-csv-c}) -opentrack_compat(opentrack-csv) -target_link_libraries(opentrack-csv ${MY_QT_LIBS}) - -opentrack_module(opentrack-pose-widget pose-widget) -opentrack_qt(opentrack-pose-widget) - -add_library(opentrack-pose-widget STATIC ${opentrack-pose-widget-all}) -opentrack_compat(opentrack-pose-widget) -target_include_directories(opentrack-pose-widget PUBLIC pose-widget/) # else Qt moc breaks -target_link_libraries(opentrack-pose-widget ${MY_QT_LIBS}) - -opentrack_module(opentrack-spline-widget qfunctionconfigurator) -opentrack_qt(opentrack-spline-widget) -add_library(opentrack-spline-widget STATIC ${opentrack-spline-widget-all}) -opentrack_compat(opentrack-spline-widget) -target_include_directories(opentrack-spline-widget PUBLIC qfunctionconfigurator/) -target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) - -add_library(opentrack-version STATIC ${CMAKE_BINARY_DIR}/version.cc) -opentrack_compat(opentrack-version) - -opentrack_library(opentrack-filter-accela ftnoir_filter_accela) -target_link_libraries(opentrack-filter-accela opentrack-spline-widget) -opentrack_library(opentrack-filter-ewma ftnoir_filter_ewma2) - -opentrack_library(opentrack-proto-fgfs ftnoir_protocol_fg) - -if(SDK_VJOY) - opentrack_library(opentrack-proto-vjoy ftnoir_protocol_vjoy GNU-LINK "-Wl,--enable-stdcall-fixup") - if(MSVC) - set(ext .lib) - else() - set(ext .dll) - endif() - target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} ${SDK_VJOY}/VJoy${ext}) - target_include_directories(opentrack-proto-vjoy SYSTEM PUBLIC ${SDK_VJOY}) -endif() - -if(SDK_ENABLE_LIBEVDEV) - include(FindPkgConfig) - opentrack_library(opentrack-proto-libevdev ftnoir_protocol_libevdev) - pkg_check_modules(libevdev REQUIRED QUIET libevdev) - target_link_libraries(opentrack-proto-libevdev ${libevdev_LIBRARIES}) - include_directories(opentrack-proto-libevdev SYSTEM PUBLIC ${libevdev_INCLUDE_DIRS}) -endif() - -if(SDK_FSUIPC) - opentrack_library(opentrack-proto-fsuipc ftnoir_protocol_fsuipc) - target_link_libraries(opentrack-proto-fsuipc ${SDK_FSUIPC}/FSUIPC_User.lib) - target_include_directories(opentrack-proto-fsuipc SYSTEM PUBLIC ${SDK_FSUIPC}) - if(MSVC) - set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBC.lib") - endif() - #target_link_directories(${SDK_FSUIPC}) -endif() - -if(WIN32) - opentrack_library(opentrack-proto-simconnect ftnoir_protocol_sc) -endif() - -if(WIN32) - opentrack_library(opentrack-proto-freetrack ftnoir_protocol_ft) - target_link_libraries(opentrack-proto-freetrack opentrack-csv opentrack-compat) - opentrack_library(opentrack-proto-win32-mouse ftnoir_protocol_mouse) -endif() - -opentrack_library(opentrack-proto-udp ftnoir_protocol_ftn) - -if(WIN32) - opentrack_library(opentrack-tracker-joystick ftnoir_tracker_joystick) -endif() - -if(Qt5SerialPort_FOUND) - opentrack_library(opentrack-tracker-hatire ftnoir_tracker_hatire) - target_link_libraries(opentrack-tracker-hatire ${Qt5SerialPort_LIBRARIES}) - target_include_directories(opentrack-tracker-hatire SYSTEM PUBLIC ${Qt5SerialPort_INCLUDE_DIRS}) -endif() - -if(SDK_WINE_PREFIX) - opentrack_library(opentrack-proto-wine ftnoir_protocol_wine) - target_link_libraries(opentrack-proto-wine opentrack-compat opentrack-csv) - if(NOT SDK_WINE_NO_WRAPPER) - set(my-rt -lrt) - if(APPLE) - set(my-rt) - endif() - file(GLOB wine-deps ${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/*.cxx) - add_custom_command( - OUTPUT opentrack-wrapper-wine.exe.so - DEPENDS ${wine-deps} - COMMAND ${SDK_WINE_PREFIX}/bin/wineg++ -g -DNOMINMAX -O2 -m32 -std=c++11 -o - opentrack-wrapper-wine.exe -I "${CMAKE_SOURCE_DIR}" - ${wine-deps} - ${my-rt}) - add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) - add_dependencies(opentrack-proto-wine wine-wrapper) - add_dependencies(wine-wrapper opentrack-compat) - endif() -endif() - -opentrack_library(opentrack-tracker-udp ftnoir_tracker_udp) -opentrack_library(opentrack-tracker-freepie-udp ftnoir_tracker_freepie-udp) - -if(WIN32) - opentrack_library(opentrack-tracker-rs ftnoir_tracker_rs) -endif() - -if(OpenCV_FOUND) - opentrack_library(opentrack-tracker-pt ftnoir_tracker_pt) - target_link_libraries(opentrack-tracker-pt ${OpenCV_LIBS}) - target_include_directories(opentrack-tracker-pt SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) - link_with_dinput8(opentrack-tracker-pt) - - if(SDK_ARUCO_LIBPATH) - opentrack_library(opentrack-tracker-aruco ftnoir_tracker_aruco) - target_link_libraries(opentrack-tracker-aruco ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) - target_include_directories(opentrack-tracker-aruco SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) - link_with_dinput8(opentrack-tracker-aruco) - endif() - - opentrack_library(opentrack-filter-kalman ftnoir_filter_kalman) - target_link_libraries(opentrack-filter-kalman ${OpenCV_LIBS}) - target_include_directories(opentrack-filter-kalman SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) - - if(SDK_HT AND SDK_HT_FLANDMARK) - opentrack_library(opentrack-tracker-ht ftnoir_tracker_ht) - target_link_libraries(opentrack-tracker-ht ${SDK_HT} ${SDK_HT_FLANDMARK} ${OpenCV_LIBS}) - link_with_dinput8(opentrack-tracker-ht) - target_include_directories(opentrack-tracker-ht SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) - endif() -endif() - -link_with_dinput8(opentrack-tracker-joystick) - -foreach(ver 025 042 080) - if(SDK_RIFT_${ver}) - set(link-flags) - set(c-flags) - if(APPLE) - set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") - set(c-flags "-fno-strict-aliasing") - else() - if(NOT MSVC) - set(c-flags "-fno-strict-aliasing") - endif() - endif() - opentrack_library(opentrack-tracker-rift-${ver} ftnoir_tracker_rift_${ver} LINK ${link-flags} COMPILE ${c-flags}) - target_include_directories(opentrack-tracker-rift-${ver} SYSTEM PUBLIC - ${SDK_RIFT_${ver}}/Include ${SDK_RIFT_${ver}}/Src - ) - if(WIN32) - if(MSVC) - set(ext lib) - set(p) - else() - set(ext a) - set(p lib) - endif() - target_link_libraries(opentrack-tracker-rift-${ver} ${SDK_RIFT_${ver}}/${p}LibOVR.${ext} winmm setupapi ws2_32 imagehlp wbemuuid) - else() - if(NOT APPLE) - target_link_libraries(opentrack-tracker-rift-${ver} ${SDK_RIFT_${ver}}/libLibOVR.a udev Xinerama) - else() - target_link_libraries(opentrack-tracker-rift-${ver} ${SDK_RIFT_${ver}}/libLibOVR.a) - endif() - endif() - endif() +include(CMakeParseArguments) +include(opentrack-policy) +include(opentrack-platform) +include(opentrack-macros) +include(opentrack-qt) +include(opentrack-version) +include(opentrack-tarball) +include(opentrack-install) + +set(C CMakeLists.txt) +file(GLOB opentrack-subprojects + "tracker-*/${C}" + "protocol-*/${C}" + "filter-*/${C}" + "opentrack*/${C}" + "facetracknoir/${C}" + "x-plane-plugin/${C}" + "csv/${C}" + "pose-widget/${C}" + "spline-widget/${C}" +) +foreach(i ${opentrack-subprojects}) + get_filename_component(i ${i} DIRECTORY) + get_filename_component(j ${i} NAME) + message(STATUS "project ${j}") + add_subdirectory(${i}) endforeach() - -if(SDK_HYDRA) - opentrack_library(opentrack-tracker-hydra ftnoir_tracker_hydra) - target_include_directories(opentrack-tracker-hydra SYSTEM PUBLIC ${SDK_HYDRA}/include ${SDK_HYDRA}/include/sixense_utils) - if(WIN32) - if(MSVC) - set(dir lib) - set(ext lib) - else() - set(dir bin) - set(ext dll) - endif() - target_link_libraries(opentrack-tracker-hydra - "${SDK_HYDRA}/${dir}/win32/release_dll/sixense.${ext}" - #"${SDK_HYDRA}/${dir}/win32/release_dll/sixense_utils.${ext}" - ) - install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" - #"${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" - DESTINATION . ${opentrack-perms}) - else() - if(SDK_HYDRA_AMD64) - set(underscore-sixtyfour _x64) - else() - set(underscore-sixtyfour) - endif() - if(APPLE) - set(underscore-dll _dll) - set(soext dylib) - set(sixense-plat osx) - else() - set(underscore-dll) - set(soext so) - set(sixense-plat linux) - endif() - install(FILES - "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" - #"${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}" - DESTINATION . - ) - target_link_libraries(opentrack-tracker-hydra - "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" - #"${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}" - ) - endif() -endif() - -if(UNIX OR APPLE) - # Qxt bundled :: sorry for this, but gentoo ebuild is broken - include_directories("qxt-mini/") - if(APPLE) - set(qxt-plat mac) - else() - set(qxt-plat x11) - endif() - file(GLOB qxt-mini-c qxt-mini/*.h qxt-mini/qxtglobalshortcut.cpp qxt-mini/plat/qxtglobalshortcut_${qxt-plat}.cpp) - opentrack_qt(qxt-mini) - add_library(opentrack-qxt-mini STATIC ${qxt-mini-all}) - target_link_libraries(opentrack-qxt-mini ${MY_QT_LIBS}) - if(NOT APPLE) - target_link_libraries(opentrack-qxt-mini X11) - endif() -endif() - -if(WIN32 AND NOT SDK_CONSOLE_DEBUG) - set(opentrack-win32-executable WIN32) -else() - set(opentrack-win32-executable "") -endif() - -opentrack_module(opentrack facetracknoir) -if(UNIX OR APPLE) - list(APPEND opentrack-c qxt-mini/qxtglobalshortcut.h) -endif() -opentrack_qt(opentrack) -add_executable(opentrack ${opentrack-win32-executable} ${opentrack-all}) -opentrack_compat(opentrack) -if(NOT WIN32) - set_target_properties(opentrack PROPERTIES SUFFIX ".bin") -endif() -target_link_libraries(opentrack opentrack-api opentrack-version opentrack-pose-widget opentrack-spline-widget) - -if(APPLE) - SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES LINK_FLAGS "-framework Carbon -framework CoreFoundation") -endif() - -if(UNIX OR APPLE) - target_link_libraries(opentrack opentrack-qxt-mini) -endif() - -link_with_dinput8(opentrack) -target_link_libraries(opentrack ${MY_QT_LIBS}) - -if(APPLE) - # for process detector - target_link_libraries(opentrack proc) -endif() - -if(LINUX) - # for process detector - target_link_libraries(opentrack procps) -endif() - -# ---- - -# make install - -# ---- - -install(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION .) - -if(SDK_XPLANE) - install(TARGETS opentrack-xplane-plugin RUNTIME DESTINATION . LIBRARY DESTINATION . ) -endif() - -install(DIRECTORY ${CMAKE_SOURCE_DIR}/3rdparty-notices DESTINATION .) - -install(FILES "${CMAKE_SOURCE_DIR}/bin/freetrackclient.dll" DESTINATION . ${opentrack-perms}) -install(FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe" DESTINATION . - ${opentrack-perms}) -install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/contrib" DESTINATION .) - -if(NOT WIN32 AND SDK_WINE_PREFIX AND NOT SDK_WINE_NO_WRAPPER) - install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" - DESTINATION .) -endif() - -install(TARGETS opentrack DESTINATION .) - -if(SDK_VJOY) - install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION . ${opentrack-perms}) -endif() - -if(WIN32) - install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) -endif() - -if(WIN32) - install(FILES "${CMAKE_SOURCE_DIR}/ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exe" DESTINATION . ${opentrack-perms}) - install(FILES - "${CMAKE_SOURCE_DIR}/ftnoir_tracker_rs/redist/intel_rs_sdk_runtime_websetup_6.0.21.6598.exe" DESTINATION ./contrib/ ${opentrack-perms}) -endif() - -if(APPLE) - install(CODE " - execute_process(COMMAND /bin/sh \"${CMAKE_SOURCE_DIR}/macosx/make-app-bundle.sh\" - \"${CMAKE_SOURCE_DIR}/macosx\" - \"${CMAKE_INSTALL_PREFIX}\" - \"${CMAKE_BINARY_DIR}\" - \"${OPENTRACK_COMMIT}\") - ") -endif() -- cgit v1.2.3 From 2160e39a4f3d5198eafbb483671583a5a0b51eaa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 08:34:40 +0100 Subject: rename gui directory --- CMakeLists.txt | 2 +- facetracknoir/CMakeLists.txt | 62 -- facetracknoir/curve-config.cpp | 81 --- facetracknoir/curve-config.h | 18 - facetracknoir/facetracknoir.ico | Bin 67134 -> 0 bytes facetracknoir/facetracknoir.rc | 2 - facetracknoir/images/curves.png | Bin 3457 -> 0 bytes facetracknoir/images/facetracknoir.png | Bin 29485 -> 0 bytes facetracknoir/images/filter-16.png | Bin 642 -> 0 bytes facetracknoir/images/no-feed.png | Bin 4471 -> 0 bytes facetracknoir/images/settings16.png | Bin 711 -> 0 bytes facetracknoir/images/tools.png | Bin 3053 -> 0 bytes facetracknoir/keyboard.h | 50 -- facetracknoir/keyboard_listener.ui | 37 - facetracknoir/main.cpp | 71 -- facetracknoir/main.ui | 1255 -------------------------------- facetracknoir/mapping.ui | 391 ---------- facetracknoir/new_config.ui | 45 -- facetracknoir/new_file_dialog.h | 50 -- facetracknoir/options-dialog.cpp | 96 --- facetracknoir/options-dialog.hpp | 23 - facetracknoir/process_detector.cpp | 211 ------ facetracknoir/process_detector.h | 86 --- facetracknoir/process_widget.ui | 121 --- facetracknoir/settings.ui | 1109 ---------------------------- facetracknoir/ui-res.qrc | 10 - facetracknoir/ui.cpp | 567 --------------- facetracknoir/ui.h | 113 --- gui/CMakeLists.txt | 62 ++ gui/curve-config.cpp | 81 +++ gui/curve-config.h | 18 + gui/facetracknoir.ico | Bin 0 -> 67134 bytes gui/facetracknoir.rc | 2 + gui/images/curves.png | Bin 0 -> 3457 bytes gui/images/facetracknoir.png | Bin 0 -> 29485 bytes gui/images/filter-16.png | Bin 0 -> 642 bytes gui/images/no-feed.png | Bin 0 -> 4471 bytes gui/images/settings16.png | Bin 0 -> 711 bytes gui/images/tools.png | Bin 0 -> 3053 bytes gui/keyboard.h | 50 ++ gui/keyboard_listener.ui | 37 + gui/main.cpp | 71 ++ gui/main.ui | 1255 ++++++++++++++++++++++++++++++++ gui/mapping.ui | 391 ++++++++++ gui/new_config.ui | 45 ++ gui/new_file_dialog.h | 50 ++ gui/options-dialog.cpp | 96 +++ gui/options-dialog.hpp | 23 + gui/process_detector.cpp | 211 ++++++ gui/process_detector.h | 86 +++ gui/process_widget.ui | 121 +++ gui/settings.ui | 1109 ++++++++++++++++++++++++++++ gui/ui-res.qrc | 10 + gui/ui.cpp | 567 +++++++++++++++ gui/ui.h | 113 +++ 55 files changed, 4399 insertions(+), 4399 deletions(-) delete mode 100644 facetracknoir/CMakeLists.txt delete mode 100644 facetracknoir/curve-config.cpp delete mode 100644 facetracknoir/curve-config.h delete mode 100644 facetracknoir/facetracknoir.ico delete mode 100644 facetracknoir/facetracknoir.rc delete mode 100644 facetracknoir/images/curves.png delete mode 100644 facetracknoir/images/facetracknoir.png delete mode 100644 facetracknoir/images/filter-16.png delete mode 100644 facetracknoir/images/no-feed.png delete mode 100644 facetracknoir/images/settings16.png delete mode 100644 facetracknoir/images/tools.png delete mode 100644 facetracknoir/keyboard.h delete mode 100644 facetracknoir/keyboard_listener.ui delete mode 100644 facetracknoir/main.cpp delete mode 100644 facetracknoir/main.ui delete mode 100644 facetracknoir/mapping.ui delete mode 100644 facetracknoir/new_config.ui delete mode 100644 facetracknoir/new_file_dialog.h delete mode 100644 facetracknoir/options-dialog.cpp delete mode 100644 facetracknoir/options-dialog.hpp delete mode 100644 facetracknoir/process_detector.cpp delete mode 100644 facetracknoir/process_detector.h delete mode 100644 facetracknoir/process_widget.ui delete mode 100644 facetracknoir/settings.ui delete mode 100644 facetracknoir/ui-res.qrc delete mode 100644 facetracknoir/ui.cpp delete mode 100644 facetracknoir/ui.h create mode 100644 gui/CMakeLists.txt create mode 100644 gui/curve-config.cpp create mode 100644 gui/curve-config.h create mode 100644 gui/facetracknoir.ico create mode 100644 gui/facetracknoir.rc create mode 100644 gui/images/curves.png create mode 100644 gui/images/facetracknoir.png create mode 100644 gui/images/filter-16.png create mode 100644 gui/images/no-feed.png create mode 100644 gui/images/settings16.png create mode 100644 gui/images/tools.png create mode 100644 gui/keyboard.h create mode 100644 gui/keyboard_listener.ui create mode 100644 gui/main.cpp create mode 100644 gui/main.ui create mode 100644 gui/mapping.ui create mode 100644 gui/new_config.ui create mode 100644 gui/new_file_dialog.h create mode 100644 gui/options-dialog.cpp create mode 100644 gui/options-dialog.hpp create mode 100644 gui/process_detector.cpp create mode 100644 gui/process_detector.h create mode 100644 gui/process_widget.ui create mode 100644 gui/settings.ui create mode 100644 gui/ui-res.qrc create mode 100644 gui/ui.cpp create mode 100644 gui/ui.h (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b43189c..06634b06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ file(GLOB opentrack-subprojects "protocol-*/${C}" "filter-*/${C}" "opentrack*/${C}" - "facetracknoir/${C}" + "gui/${C}" "x-plane-plugin/${C}" "csv/${C}" "pose-widget/${C}" diff --git a/facetracknoir/CMakeLists.txt b/facetracknoir/CMakeLists.txt deleted file mode 100644 index 51d0cea3..00000000 --- a/facetracknoir/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -opentrack_boilerplate(opentrack NO-LIBRARY) - -if(UNIX OR APPLE) - target_include_directories(opentrack "${CMAKE_SOURCE_DIR}/qxt-mini") - if(APPLE) - set(qxt-plat mac) - else() - set(qxt-plat x11) - endif() - file(GLOB qxt-mini-c - ${CMAKE_SOURCE_DIR}/qxt-mini/*.h - ${CMAKE_SOURCE_DIR}/qxt-mini/qxtglobalshortcut.cpp - ${CMAKE_SOURCE_DIR}/qxt-mini/plat/qxtglobalshortcut_${qxt-plat}.cpp - ) - opentrack_qt(qxt-mini) - add_library(opentrack-qxt-mini STATIC ${qxt-mini-all}) - target_link_libraries(opentrack-qxt-mini ${MY_QT_LIBS}) - if(NOT APPLE) - target_link_libraries(opentrack-qxt-mini X11) - endif() -endif() - -if(WIN32) - SET(SDK_CONSOLE_DEBUG FALSE CACHE BOOL "Console window visible at runtime") -endif() - -if(WIN32 AND NOT SDK_CONSOLE_DEBUG) - set(opentrack-win32-executable WIN32) -else() - set(opentrack-win32-executable "") -endif() - -if(UNIX OR APPLE) - list(APPEND opentrack-c ${CMAKE_SOURCE_DIR}/qxt-mini/qxtglobalshortcut.h) -endif() -opentrack_qt(opentrack) -add_executable(opentrack ${opentrack-win32-executable} ${opentrack-all}) -opentrack_compat(opentrack) -if(NOT WIN32) - set_target_properties(opentrack PROPERTIES SUFFIX ".bin") -endif() -target_link_libraries(opentrack opentrack-api opentrack-version opentrack-pose-widget opentrack-spline-widget) -if(APPLE) - SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES LINK_FLAGS "-framework Carbon -framework CoreFoundation") -endif() -if(UNIX OR APPLE) - target_link_libraries(opentrack opentrack-qxt-mini) -endif() -link_with_dinput8(opentrack) -target_link_libraries(opentrack ${MY_QT_LIBS}) - -if(APPLE) - # for process detector - target_link_libraries(opentrack proc) -endif() - -if(LINUX) - # for process detector - target_link_libraries(opentrack procps) -endif() - -install(TARGETS opentrack DESTINATION .) diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp deleted file mode 100644 index 2e9065b4..00000000 --- a/facetracknoir/curve-config.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (c) 2014-2015, Stanislaw Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#include "curve-config.h" -#include "opentrack/main-settings.hpp" -MapWidget::MapWidget(Mappings& m, main_settings& s) : - m(m) -{ - ui.setupUi( this ); - - // rest of mapping settings taken care of by options::value - m.load_mappings(); - - { - struct { - QFunctionConfigurator* qfc; - Axis axis; - QCheckBox* checkbox; - bool altp; - } qfcs[] = - { - { ui.rxconfig, Yaw, nullptr, false }, - { ui.ryconfig, Pitch, nullptr, false }, - { ui.rzconfig, Roll, nullptr, false }, - { ui.txconfig, TX, nullptr, false }, - { ui.tyconfig, TY, nullptr, false }, - { ui.tzconfig, TZ, nullptr, false }, - - { ui.rxconfig_alt, Yaw, ui.rx_altp, true }, - { ui.ryconfig_alt, Pitch, ui.ry_altp, true }, - { ui.rzconfig_alt, Roll, ui.rz_altp, true }, - { ui.txconfig_alt, TX, ui.tx_altp, true }, - { ui.tyconfig_alt, TY, ui.ty_altp, true }, - { ui.tzconfig_alt, TZ, ui.tz_altp, true }, - { nullptr, Yaw, nullptr, false } - }; - - for (int i = 0; qfcs[i].qfc; i++) - { - const bool altp = qfcs[i].altp; - Mapping& axis = m(qfcs[i].axis); - Map* conf = altp ? &axis.curveAlt : &axis.curve; - const auto& name = qfcs[i].altp ? axis.name2 : axis.name1; - if (altp) - { - QFunctionConfigurator& qfc = *qfcs[i].qfc; - connect(qfcs[i].checkbox, &QCheckBox::toggled, - [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();}); - qfc.setEnabled(qfcs[i].checkbox->isChecked()); - qfc.force_redraw(); - } - qfcs[i].qfc->setConfig(conf, name); - } - } - - setFont(qApp->font()); - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - tie_setting(s.a_x.altp, ui.tx_altp); - tie_setting(s.a_y.altp, ui.ty_altp); - tie_setting(s.a_z.altp, ui.tz_altp); - tie_setting(s.a_yaw.altp, ui.rx_altp); - tie_setting(s.a_pitch.altp, ui.ry_altp); - tie_setting(s.a_roll.altp, ui.rz_altp); -} - -void MapWidget::doOK() { - m.save_mappings(); - this->close(); -} - -void MapWidget::doCancel() { - m.invalidate_unsaved(); - this->close(); -} diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h deleted file mode 100644 index 0cbc7055..00000000 --- a/facetracknoir/curve-config.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include -#include "opentrack/mappings.hpp" -#include "ui_mapping.h" - -class MapWidget: public QWidget -{ - Q_OBJECT -public: - MapWidget(Mappings &m, main_settings &s); -private: - Ui::UICCurveConfigurationDialog ui; - Mappings& m; - void closeEvent(QCloseEvent *) override { doCancel(); } -private slots: - void doOK(); - void doCancel(); -}; diff --git a/facetracknoir/facetracknoir.ico b/facetracknoir/facetracknoir.ico deleted file mode 100644 index 5cac8da1..00000000 Binary files a/facetracknoir/facetracknoir.ico and /dev/null differ diff --git a/facetracknoir/facetracknoir.rc b/facetracknoir/facetracknoir.rc deleted file mode 100644 index 020ffe97..00000000 --- a/facetracknoir/facetracknoir.rc +++ /dev/null @@ -1,2 +0,0 @@ -#include -IDI_ICON1 ICON "facetracknoir.ico" diff --git a/facetracknoir/images/curves.png b/facetracknoir/images/curves.png deleted file mode 100644 index 3f953a0a..00000000 Binary files a/facetracknoir/images/curves.png and /dev/null differ diff --git a/facetracknoir/images/facetracknoir.png b/facetracknoir/images/facetracknoir.png deleted file mode 100644 index 85c06df6..00000000 Binary files a/facetracknoir/images/facetracknoir.png and /dev/null differ diff --git a/facetracknoir/images/filter-16.png b/facetracknoir/images/filter-16.png deleted file mode 100644 index ecde6a10..00000000 Binary files a/facetracknoir/images/filter-16.png and /dev/null differ diff --git a/facetracknoir/images/no-feed.png b/facetracknoir/images/no-feed.png deleted file mode 100644 index 02aa227a..00000000 Binary files a/facetracknoir/images/no-feed.png and /dev/null differ diff --git a/facetracknoir/images/settings16.png b/facetracknoir/images/settings16.png deleted file mode 100644 index 3b31623b..00000000 Binary files a/facetracknoir/images/settings16.png and /dev/null differ diff --git a/facetracknoir/images/tools.png b/facetracknoir/images/tools.png deleted file mode 100644 index 2da8f9f5..00000000 Binary files a/facetracknoir/images/tools.png and /dev/null differ diff --git a/facetracknoir/keyboard.h b/facetracknoir/keyboard.h deleted file mode 100644 index 62a9ce20..00000000 --- a/facetracknoir/keyboard.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once -#include "ui_keyboard_listener.h" -#ifdef _WIN32 -#include "opentrack/win32-shortcuts.h" -#include "opentrack/shortcuts.h" -#endif -#include -#include -#include - -class KeyboardListener : public QLabel -{ - Q_OBJECT - Ui_keyboard_listener ui; -#ifdef _WIN32 - KeybindingWorker w; -#endif -public: - KeyboardListener(QWidget* parent = nullptr) : QLabel(parent) -#ifdef _WIN32 - , w([&](Key& k) - { - Qt::KeyboardModifiers m; - QKeySequence k_; - if (win_key::to_qt(k, k_, m)) - key_pressed(static_cast(k_).toInt() | m); - }, this->winId()) -#endif - { - ui.setupUi(this); - setFocusPolicy(Qt::StrongFocus); -#ifdef _WIN32 - w.start(); -#endif - } -#ifndef _WIN32 - void keyPressEvent(QKeyEvent* event) override - { - //qDebug() << "k" << (event->key() | event->modifiers()); - switch (event->key() | event->modifiers()) - { - default: - emit key_pressed(QKeySequence(event->key() | event->modifiers())); - break; - } - } -#endif -signals: - void key_pressed(QKeySequence k); -}; diff --git a/facetracknoir/keyboard_listener.ui b/facetracknoir/keyboard_listener.ui deleted file mode 100644 index b6977df0..00000000 --- a/facetracknoir/keyboard_listener.ui +++ /dev/null @@ -1,37 +0,0 @@ - - - keyboard_listener - - - Qt::ApplicationModal - - - - 0 - 0 - 224 - 33 - - - - - 0 - 0 - - - - Bind a shortcut - - - <html><head/><body><p>Press a key or close this window to remove the keybinding.</p></body></html> - - - Qt::RichText - - - 10 - - - - - diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp deleted file mode 100644 index a63fe54a..00000000 --- a/facetracknoir/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifdef _WIN32 -# include -#endif - -#include "ui.h" -#include "opentrack/options.hpp" -using namespace options; -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -// workaround QTBUG-38598, allow for launching from another directory -static void add_program_library_path() -{ - char* p = _pgmptr; - char path[MAX_PATH+1]; - strcpy(path, p); - char* ptr = strrchr(path, '\\'); - if (ptr) - { - *ptr = '\0'; - QCoreApplication::addLibraryPath(path); - } -} -#endif - -int main(int argc, char** argv) -{ -#ifdef _WIN32 - add_program_library_path(); -#elif !defined(__linux) - // workaround QTBUG-38598 - QCoreApplication::addLibraryPath("."); -#endif - -#if defined(_WIN32) || defined(__APPLE__) - // qt5 designer-made controls look like shit on 'doze -sh 20140921 - // also our OSX look leaves a lot to be desired -sh 20150726 - { - const QStringList preferred { "fusion", "windowsvista", "macintosh", "windowsxp" }; - for (const auto& style_name : preferred) - { - QStyle* s = QStyleFactory::create(style_name); - if (s) - { - QApplication::setStyle(s); - break; - } - } - } -#endif - - QApplication::setAttribute(Qt::AA_X11InitThreads, true); - QApplication app(argc, argv); - - auto w = std::make_shared(); - - w->show(); - app.exec(); - - // on MSVC crashes in atexit -#ifdef _MSC_VER - TerminateProcess(GetCurrentProcess(), 0); -#endif - return 0; -} diff --git a/facetracknoir/main.ui b/facetracknoir/main.ui deleted file mode 100644 index ab63e832..00000000 --- a/facetracknoir/main.ui +++ /dev/null @@ -1,1255 +0,0 @@ - - - Lovecraftian Octopus - OpentrackUI - - - - 0 - 0 - 707 - 494 - - - - - :/images/facetracknoir.png:/images/facetracknoir.png - - - #video_feed { border: 0; } - - - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Raised - - - 0 - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 480 - 360 - - - - - 480 - 360 - - - - - - 0 - 0 - 480 - 360 - - - - - 0 - 0 - - - - - - 0 - 0 - 480 - 360 - - - - - 0 - 0 - - - - - 480 - 360 - - - - - 480 - 360 - - - - - - - - - - - - - QFrame::NoFrame - - - 0 - - - - 12 - - - 6 - - - 12 - - - 8 - - - 4 - - - - - - 0 - 0 - - - - - 80 - 90 - - - - - - - - - 0 - 0 - - - - Raw tracker data - - - - 0 - - - 0 - - - 0 - - - 0 - - - 3 - - - 2 - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - yaw - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - roll - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TZ - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - pitch - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - TX - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TY - - - - - - - - - - - 0 - 0 - - - - Game data - - - - 0 - - - 0 - - - 0 - - - 0 - - - 3 - - - 2 - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TY - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - pitch - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - yaw - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - roll - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TZ - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - TX - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - - - - - - - - - - - 0 - 0 - - - - - 4 - - - 8 - - - 10 - - - 0 - - - 4 - - - 0 - - - - - - 4 - 0 - - - - Settings - - - true - - - - 3 - - - 4 - - - 2 - - - 0 - - - 6 - - - - - - 0 - 2 - - - - - 0 - - - 0 - - - 2 - - - 2 - - - - - true - - - - 0 - 0 - - - - Profile - - - QToolButton::InstantPopup - - - Qt::ToolButtonTextBesideIcon - - - true - - - Qt::DownArrow - - - - - - - - 0 - 0 - - - - 20 - - - - - - - - - - - 0 - 3 - - - - Mapping - - - - :/images/curves.png:/images/curves.png - - - - 80 - 24 - - - - - - - - - 0 - 3 - - - - Options - - - - :/images/tools.png:/images/tools.png - - - - 80 - 24 - - - - - - - - - - - - 3 - 0 - - - - Controls - - - true - - - - 8 - - - 0 - - - 8 - - - 0 - - - 9 - - - - - - 0 - 0 - - - - Start - - - - - - - false - - - - 0 - 0 - - - - Stop - - - - - - - - - - - 4 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 2 - - - 3 - - - 2 - - - 3 - - - 8 - - - - - Tracker - - - - 4 - - - 0 - - - 4 - - - 0 - - - 3 - - - 0 - - - - - - - - true - - - ... - - - false - - - - - - - - - - Protocol - - - - 4 - - - 0 - - - 4 - - - 0 - - - 3 - - - 0 - - - - - - - - true - - - ... - - - false - - - - - - - - - - Filter - - - - 4 - - - 0 - - - 4 - - - 0 - - - 3 - - - 0 - - - - - - - - true - - - ... - - - false - - - - - - - - - - - - - - - - - - - - - GLWidget - QWidget -
pose-widget/glwidget.h
-
-
- - btnStartTracker - btnStopTracker - iconcomboTrackerSource - btnShowEngineControls - iconcomboProtocol - btnShowServerControls - iconcomboFilter - btnShowFilterControls - profile_button - iconcomboProfile - btnEditCurves - btnShortcuts - - - - - -
diff --git a/facetracknoir/mapping.ui b/facetracknoir/mapping.ui deleted file mode 100644 index 75c32e27..00000000 --- a/facetracknoir/mapping.ui +++ /dev/null @@ -1,391 +0,0 @@ - - - UICCurveConfigurationDialog - - - - 0 - 0 - 970 - 664 - - - - - 0 - 0 - - - - - 970 - 664 - - - - - 970 - 664 - - - - Mapping properties - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - background-color: #ccc; - - - - - - - - - QTabWidget::North - - - 0 - - - - Yaw - - - - - - - 255 - 0 - 0 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 255 - 0 - 0 - - - - - 255 - 255 - 255 - - - - - - - - - Pitch - - - - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - - - Roll - - - - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - - - X - - - - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - - - Y - - - - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - - - Z - - - - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - - Asymmetric mapping below - - - - - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - QFunctionConfigurator - QWidget -
spline-widget/qfunctionconfigurator.h
-
-
- - ry_altp - rz_altp - tx_altp - ty_altp - tz_altp - tabWidget - buttonBox - rx_altp - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
diff --git a/facetracknoir/new_config.ui b/facetracknoir/new_config.ui deleted file mode 100644 index 27dce0f8..00000000 --- a/facetracknoir/new_config.ui +++ /dev/null @@ -1,45 +0,0 @@ - - - UI_new_config - - - Qt::ApplicationModal - - - - 0 - 0 - 269 - 67 - - - - Config filename - - - - images/facetracknoir.pngimages/facetracknoir.png - - - - - - New file name: - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - diff --git a/facetracknoir/new_file_dialog.h b/facetracknoir/new_file_dialog.h deleted file mode 100644 index 3a35cf71..00000000 --- a/facetracknoir/new_file_dialog.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include "ui_new_config.h" -#include "opentrack/options.hpp" -#include -#include -#include -#include - -class new_file_dialog : public QDialog -{ - Q_OBJECT -public: - new_file_dialog(QWidget* parent = 0) : QDialog(parent), ok(false) - { - ui.setupUi(this); - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(ok_clicked())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancel_clicked())); - setFixedSize(size()); - } - bool is_ok(QString& name_) - { - name_ = name; - return ok; - } -private: - Ui::UI_new_config ui; - bool ok; - QString name; -private slots: - void cancel_clicked() { close(); } - void ok_clicked() - { - QString text = ui.lineEdit->text(); - text = text.replace('/', ""); - text = text.replace('\\', ""); - if (text != "" && !text.endsWith(".ini")) - text += ".ini"; - if (text == "" || text == ".ini" || QFile(options::group::ini_directory() + "/" + text).exists()) - { - QMessageBox::warning(this, - "File exists", "This file already exists. Pick another name.", - QMessageBox::Ok, QMessageBox::NoButton); - return; - } - ok = true; - close(); - name = text; - } -}; diff --git a/facetracknoir/options-dialog.cpp b/facetracknoir/options-dialog.cpp deleted file mode 100644 index fef2b0ca..00000000 --- a/facetracknoir/options-dialog.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2015, Stanislaw Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#include "options-dialog.hpp" -#include "keyboard.h" -#include -#include - -OptionsDialog::OptionsDialog() -{ - ui.setupUi( this ); - - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - tie_setting(s.s_main.tray_enabled, ui.trayp); - - tie_setting(s.s_main.center_at_startup, ui.center_at_startup); - - tie_setting(s.s_main.tcomp_p, ui.tcomp_enable); - tie_setting(s.s_main.tcomp_tz, ui.tcomp_rz); - - tie_setting(s.s_main.a_x.zero, ui.pos_tx); - tie_setting(s.s_main.a_y.zero, ui.pos_ty); - tie_setting(s.s_main.a_z.zero, ui.pos_tz); - tie_setting(s.s_main.a_yaw.zero, ui.pos_rx); - tie_setting(s.s_main.a_pitch.zero, ui.pos_ry); - tie_setting(s.s_main.a_roll.zero, ui.pos_rz); - - tie_setting(s.s_main.a_yaw.invert, ui.invert_yaw); - tie_setting(s.s_main.a_pitch.invert, ui.invert_pitch); - tie_setting(s.s_main.a_roll.invert, ui.invert_roll); - tie_setting(s.s_main.a_x.invert, ui.invert_x); - tie_setting(s.s_main.a_y.invert, ui.invert_y); - tie_setting(s.s_main.a_z.invert, ui.invert_z); - - tie_setting(s.s_main.a_yaw.src, ui.src_yaw); - tie_setting(s.s_main.a_pitch.src, ui.src_pitch); - tie_setting(s.s_main.a_roll.src, ui.src_roll); - tie_setting(s.s_main.a_x.src, ui.src_x); - tie_setting(s.s_main.a_y.src, ui.src_y); - tie_setting(s.s_main.a_z.src, ui.src_z); - - tie_setting(s.s_main.camera_yaw, ui.camera_yaw); - tie_setting(s.s_main.camera_pitch, ui.camera_pitch); - tie_setting(s.s_main.camera_roll, ui.camera_roll); - - tie_setting(s.s_main.center_method, ui.center_method); - - connect(ui.bind_center, &QPushButton::pressed, [&]() -> void { bind_key(s.center.keycode, ui.center_text); }); - connect(ui.bind_zero, &QPushButton::pressed, [&]() -> void { bind_key(s.zero.keycode, ui.zero_text); }); - connect(ui.bind_toggle, &QPushButton::pressed, [&]() -> void { bind_key(s.toggle.keycode, ui.toggle_text); }); - - ui.center_text->setText(s.center.keycode == "" ? "None" : static_cast(s.center.keycode)); - ui.toggle_text->setText(s.toggle.keycode == "" ? "None" : static_cast(s.toggle.keycode)); - ui.zero_text->setText(s.zero.keycode == "" ? "None" : static_cast(s.zero.keycode)); -} - -void OptionsDialog::bind_key(value& ret, QLabel* label) -{ - ret = ""; - QDialog d; - auto l = new QHBoxLayout; - l->setMargin(0); - auto k = new KeyboardListener; - l->addWidget(k); - d.setLayout(l); - d.setFixedSize(QSize(500, 300)); - d.setWindowFlags(Qt::Dialog); - connect(k, &KeyboardListener::key_pressed, [&] (QKeySequence s) -> void { ret = s.toString(QKeySequence::PortableText); d.close(); }); - d.exec(); - label->setText(ret == "" ? "None" : static_cast(ret)); - delete k; - delete l; -} - -void OptionsDialog::doOK() { - s.b->save(); - s.s_main.b->save(); - ui.game_detector->save(); - this->close(); - emit reload(); -} - -void OptionsDialog::doCancel() { - s.b->reload(); - s.s_main.b->reload(); - ui.game_detector->revert(); - close(); -} - diff --git a/facetracknoir/options-dialog.hpp b/facetracknoir/options-dialog.hpp deleted file mode 100644 index 3ef99d06..00000000 --- a/facetracknoir/options-dialog.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include -#include -#include "ui_settings.h" -#include "opentrack/shortcuts.h" - -class OptionsDialog: public QWidget -{ - Q_OBJECT -signals: - void reload(); -public: - OptionsDialog(); -private: - Ui::UI_Settings ui; - Shortcuts::settings s; - void closeEvent(QCloseEvent *) override { doCancel(); } -private slots: - void doOK(); - void doCancel(); - void bind_key(value& ret, QLabel* label); -}; diff --git a/facetracknoir/process_detector.cpp b/facetracknoir/process_detector.cpp deleted file mode 100644 index 59a40f03..00000000 --- a/facetracknoir/process_detector.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright (c) 2015, Stanislaw Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#include "process_detector.h" -#include "facetracknoir/ui.h" -#include "opentrack-compat/process-list.hpp" -#include -#include -#include -#include -#include -#include - -void settings::set_game_list(const QString &game_list) -{ - QSettings settings(OPENTRACK_ORG); - settings.setValue("executable-list", game_list); -} - -QString settings::get_game_list() -{ - QSettings settings(OPENTRACK_ORG); - return settings.value("executable-list").toString(); -} - -bool settings::is_enabled() -{ - QSettings settings(OPENTRACK_ORG); - return settings.value("executable-detector-enabled", false).toBool(); -} - -void settings::set_is_enabled(bool enabled) -{ - QSettings settings(OPENTRACK_ORG); - settings.setValue("executable-detector-enabled", enabled); -} - -QHash settings::split_process_names() -{ - QHash ret; - QString str = get_game_list(); - QStringList pairs = str.split('|'); - for (auto pair : pairs) - { - QList tmp = pair.split(':'); - if (tmp.count() != 2) - continue; - ret[tmp[0]] = tmp[1]; - } - return ret; -} - -void BrowseButton::browse() -{ - QFileDialog dialog(this); - dialog.setFileMode(QFileDialog::ExistingFile); - QString dir_path = QFileInfo(group::ini_pathname()).absolutePath(); - QString filename = dialog.getOpenFileName( - this, - tr("Set executable name"), - dir_path, - tr("Executable (*.exe);;All Files (*)")); - MainWindow::set_working_directory(); - filename = QFileInfo(filename).fileName(); - if (!filename.isNull()) - twi->setText(filename); -} - -int process_detector::add_row(QString exe_name, QString profile) -{ - int i = ui.tableWidget->rowCount(); - ui.tableWidget->insertRow(i); - - QComboBox* cb = new QComboBox(); - cb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum); - cb->addItem(""); - cb->addItems(group::ini_list()); - ui.tableWidget->setCellWidget(i, 1, cb); - - QTableWidgetItem* twi = new QTableWidgetItem(exe_name); - ui.tableWidget->setItem(i, 0, twi); - - { - BrowseButton* b = new BrowseButton(twi); - b->setText("..."); - QObject::connect(b, SIGNAL(pressed()), b, SLOT(browse())); - ui.tableWidget->setCellWidget(i, 2, b); - } - - cb->setCurrentText(profile); - - return i; -} - -void process_detector::add_items() -{ - auto names = s.split_process_names(); - ui.tableWidget->clearContents(); - auto keys = names.keys(); - qSort(keys); - for (auto n : keys) - add_row(n, names[n]); -} - -process_detector::process_detector(QWidget* parent) : QWidget(parent) -{ - ui.setupUi(this); - setFixedSize(size()); - connect(ui.add, SIGNAL(pressed()), this, SLOT(add())); - connect(ui.remove, SIGNAL(pressed()), this, SLOT(remove())); - - add_items(); - - QResizeEvent e(ui.tableWidget->size(), ui.tableWidget->size()); - ui.tableWidget->resizeEvent(&e); - - settings s; - - ui.enabled->setChecked(s.is_enabled()); -} - -void process_detector::save() -{ - QString str; - - for (int i = 0; i < ui.tableWidget->rowCount(); i++) - { - auto exe = ui.tableWidget->item(i, 0)->text(); - auto profile = reinterpret_cast(ui.tableWidget->cellWidget(i, 1))->currentText(); - str += "|" + exe + ":" + profile; - } - - s.set_game_list(str); - s.set_is_enabled(ui.enabled->isChecked()); -} - -void process_detector::revert() -{ -} - -void process_detector::add() -{ - add_row(); -} - -void process_detector::remove() -{ - int r = ui.tableWidget->currentRow(); - if (r != -1) - ui.tableWidget->removeRow(r); -} - -bool process_detector_worker::should_stop() -{ - if (last_exe_name == "") - return false; - - settings s; - - if (!s.is_enabled()) - { - last_exe_name = ""; - return false; - } - - QStringList exe_list = get_all_executable_names(); - - if (exe_list.contains(last_exe_name)) - return false; - - last_exe_name = ""; - - return true; -} - -bool process_detector_worker::config_to_start(QString& str) -{ - settings s; - if (!s.is_enabled()) - { - last_exe_name = ""; - return false; - } - - auto filenames = s.split_process_names(); - QStringList exe_list = get_all_executable_names(); - - // assuming manual stop by user button click. - // don't automatically start again while the same process is running. - if (last_exe_name != "" && exe_list.contains(last_exe_name)) - return false; - // it's gone, we can start automatically again - last_exe_name = ""; - - for (auto& name : exe_list) - { - if (filenames.contains(name)) - { - last_exe_name = name; - str = filenames[name]; - return str != ""; - } - } - - return false; -} diff --git a/facetracknoir/process_detector.h b/facetracknoir/process_detector.h deleted file mode 100644 index f6497c90..00000000 --- a/facetracknoir/process_detector.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (c) 2015, Stanislaw Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#pragma once - -#include -#include -#include -#include - -#include "opentrack/options.hpp" -using namespace options; - -class FancyTable : public QTableWidget -{ - Q_OBJECT -public: - void resizeEvent(QResizeEvent* e) override - { - QTableView::resizeEvent(e); - int w = width(); - setColumnWidth(2, 32); - w -= 48; - setColumnWidth(0, w / 2); - setColumnWidth(1, w / 2); - } -public: - FancyTable(QWidget* parent = nullptr) : QTableWidget(parent) {} -}; - -struct settings -{ - QHash split_process_names(); - QString get_game_list(); - void set_game_list(const QString& game_list); - bool is_enabled(); - void set_is_enabled(bool enabled); -}; - -#include "ui_process_widget.h" - -class process_detector : public QWidget -{ - Q_OBJECT - - Ui_Dialog ui; - settings s; - - int add_row(QString exe_name = "...", QString profile = ""); - void add_items(); -public: - process_detector(QWidget* parent = nullptr); -public slots: - void save(); - void revert(); -private slots: - void add(); - void remove(); -}; - -class BrowseButton : public QPushButton -{ - Q_OBJECT - QTableWidgetItem* twi; -public: - BrowseButton(QTableWidgetItem* twi) : twi(twi) - {} -public slots: - void browse(); -}; - -class process_detector_worker : QObject -{ - Q_OBJECT - settings s; - QString last_exe_name; -public: - bool config_to_start(QString& s); - bool should_stop(); -}; - diff --git a/facetracknoir/process_widget.ui b/facetracknoir/process_widget.ui deleted file mode 100644 index 19fe39da..00000000 --- a/facetracknoir/process_widget.ui +++ /dev/null @@ -1,121 +0,0 @@ - - - Dialog - - - - 0 - 0 - 302 - 325 - - - - Game detector - - - - - - - 0 - 0 - - - - - Executable - - - - - Profile - - - - - - - - - - - - - - 0 - 0 - - - - border: 0; - - - - - - - 5 - - - - - - 0 - 0 - - - - - 14 - 75 - true - - - - + - - - - - - - - 0 - 0 - - - - - 14 - 75 - true - - - - - - - - - - - - - - - Start profiles from game executable names in this list - - - - - - - - FancyTable - QTableWidget -
facetracknoir/process_detector.h
-
-
- - -
diff --git a/facetracknoir/settings.ui b/facetracknoir/settings.ui deleted file mode 100644 index 92d275b6..00000000 --- a/facetracknoir/settings.ui +++ /dev/null @@ -1,1109 +0,0 @@ - - - UI_Settings - - - - 0 - 0 - 348 - 548 - - - - Options - - - - images/facetracknoir.pngimages/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - 0 - - - - Shortcuts - - - - - - Global shortcuts - - - - - - - 0 - 0 - - - - <html><head/><body><p><span style=" font-weight:600;">Center</span> - use current pose as looking perfectly forward.<br/><span style=" font-weight:600;">Toggle</span> - keep looking at same spot until toggle keypress.<br/><span style=" font-weight:600;">Zero</span> - keep looking forward while the key is pressed.<br/></p></body></html> - - - true - - - - - - - QGroupBox { border: 0; } - - - - - - - - - - - - - Center - - - false - - - - - - - - - - - - - - - - - - - - - Toggle - - - false - - - - - - - Zero - - - false - - - - - - - Bind - - - - - - - Bind - - - - - - - Bind - - - - - - - - - - - - - Centering method - - - - - - Method - - - - - - - - Relative (inertial device) - - - - - Absolute (camera device) - - - - - - - - Try changing this if centering doesn't perform correctly for your input device. - - - true - - - - - - - - - - Center at startup - - - - - - - Minimize to tray - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Camera - - - - - - Camera offset - - - - - - <html><head/><body><p>Specify an angle for off-center camera as a basis for which direction is which, avoiding axis interconnect. Also see <a href="https://github.com/opentrack/opentrack/wiki/choosing-camera-offset"><span style=" text-decoration: underline; color:#0000ff;">description on wiki</span></a>.</p></body></html> - - - Qt::AlignJustify|Qt::AlignVCenter - - - true - - - 2 - - - true - - - - - - - QGroupBox -{ - border: 0; -} - - - - - - Roll - - - - - - - - 80 - 0 - - - - -180 - - - 180 - - - - - - - - 80 - 0 - - - - -180 - - - 180 - - - - - - - Pitch - - - - - - - - 80 - 0 - - - - -180 - - - 180 - - - - - - - Yaw - - - - - - - - - - - - - Center pose offset - - - - - - Alter the centered position sent to games by a fixed amount. - - - true - - - 2 - - - - - - - QGroupBox { - border: 0; -} - - - - - - Qt::AlignCenter - - - false - - - false - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - TX - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RY - - - - - - - TY - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - TZ - - - - - - - RZ - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RX - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Output - - - - - - - 0 - 0 - - - - - - - Translation compensation - - - false - - - - - - With compensation on, translation is applied after rotation. For example, rotating +180 degrees yaw and moving backwards results in moving forward as a result of that rotation. - - - Qt::AlignJustify|Qt::AlignVCenter - - - true - - - 2 - - - - - - - - - - Enable - - - - - - - - - - Disable Z axis compensation - - - - - - - - - - - 65536 - 65536 - - - - - true - - - - Output remap - - - Qt::AlignCenter - - - false - - - false - - - - QLayout::SetMinAndMaxSize - - - 6 - - - - - Assign input axis to output axis. - - - Qt::AlignJustify|Qt::AlignVCenter - - - true - - - - - - - QGroupBox -{ - border: 0; -} - - - - - - - - - - - - - Roll - - - - - - - X - - - - - - - Invert - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - Pitch - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - - - - - - - Y - - - - - - - Destination - - - - - - - - - - - - - - Yaw - - - - - - - - - - - - - - Source - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - Z - - - - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - Disabled - - - - - - - - - - - - - label_15 - label_13 - label_14 - src_yaw - invert_yaw - label_7 - src_pitch - label_8 - invert_pitch - label_9 - src_roll - invert_roll - label_10 - src_x - invert_x - label_11 - src_y - invert_y - label_12 - src_z - invert_z - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Game detection - - - - - - Game detection - - - - - - - - - - 0 - 0 - - - - Start tracking automatically when a game starts with selected profile, and stop when the game exits. - - - true - - - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - process_detector - QWidget -
facetracknoir/process_detector.h
-
-
- - tabWidget - center_at_startup - trayp - camera_yaw - camera_pitch - camera_roll - pos_rx - pos_ry - pos_rz - pos_tx - pos_ty - pos_tz - tcomp_enable - tcomp_rz - src_yaw - invert_yaw - src_pitch - invert_pitch - src_roll - invert_roll - src_x - invert_x - src_y - invert_y - src_z - invert_z - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
diff --git a/facetracknoir/ui-res.qrc b/facetracknoir/ui-res.qrc deleted file mode 100644 index 030a6153..00000000 --- a/facetracknoir/ui-res.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - images/tools.png - images/settings16.png - images/curves.png - images/facetracknoir.png - images/no-feed.png - images/filter-16.png - - diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp deleted file mode 100644 index d0a5e93c..00000000 --- a/facetracknoir/ui.cpp +++ /dev/null @@ -1,567 +0,0 @@ -/* Copyright (c) 2013-2015, Stanislaw Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#include "ui.h" -#include "opentrack/tracker.h" -#include "opentrack/options.hpp" -#include "facetracknoir/new_file_dialog.h" -#include -#include - -#ifndef _WIN32 -# include -#else -# include -#endif - -MainWindow::MainWindow() : - pose_update_timer(this), - kbd_quit(QKeySequence("Ctrl+Q"), this), - no_feed_pixmap(":/images/no-feed.png"), - is_refreshing_profiles(false) -{ - ui.setupUi(this); - - setFixedSize(size()); - - updateButtonState(false, false); - ui.video_frame_label->setPixmap(no_feed_pixmap); - - connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); - connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(show_options_dialog())); - connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); - connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showProtocolSettings())); - connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterSettings())); - - modules.filters().push_front(std::make_shared("", dylib::Filter)); - - for (auto x : modules.trackers()) - ui.iconcomboTrackerSource->addItem(x->icon, x->name); - - for (auto x : modules.protocols()) - ui.iconcomboProtocol->addItem(x->icon, x->name); - - for (auto x : modules.filters()) - ui.iconcomboFilter->addItem(x->icon, x->name); - - refresh_config_list(); - connect(&config_list_timer, SIGNAL(timeout()), this, SLOT(refresh_config_list())); - config_list_timer.start(1000 * 3); - - tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); - tie_setting(s.protocol_dll, ui.iconcomboProtocol); - tie_setting(s.filter_dll, ui.iconcomboFilter); - - connect(ui.iconcomboTrackerSource, - &QComboBox::currentTextChanged, - [&](QString) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); }); - - connect(ui.iconcomboProtocol, - &QComboBox::currentTextChanged, - [&](QString) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); }); - - connect(ui.iconcomboFilter, - &QComboBox::currentTextChanged, - [&](QString) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); }); - - connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); - connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - connect(ui.iconcomboProfile, SIGNAL(currentTextChanged(QString)), this, SLOT(profileSelected(QString))); - - connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); - connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); - - save_timer.setSingleShot(true); - connect(&save_timer, SIGNAL(timeout()), this, SLOT(_save())); - - profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config())); - profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config())); - profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory())); - ui.profile_button->setMenu(&profile_menu); - - kbd_quit.setEnabled(true); - - connect(&det_timer, SIGNAL(timeout()), this, SLOT(maybe_start_profile_from_executable())); - det_timer.start(1000); - - ensure_tray(); - set_working_directory(); - - if (!QFile(group::ini_pathname()).exists()) - { - set_profile(OPENTRACK_DEFAULT_CONFIG); - const auto pathname = group::ini_pathname(); - if (!QFile(pathname).exists()) - { - QFile file(pathname); - (void) file.open(QFile::ReadWrite); - } - } - - if (group::ini_directory() == "") - QMessageBox::warning(this, - "Configuration not saved.", - "Can't create configuration directory! Expect major malfunction.", - QMessageBox::Ok, QMessageBox::NoButton); - - ui.btnStartTracker->setFocus(); -} - -bool MainWindow::get_new_config_name_from_dialog(QString& ret) -{ - new_file_dialog dlg; - dlg.exec(); - return dlg.is_ok(ret); -} - -MainWindow::~MainWindow() -{ - maybe_save(); - - if (tray) - tray->hide(); - stopTracker(); -} - -void MainWindow::set_working_directory() -{ - QDir::setCurrent(QCoreApplication::applicationDirPath()); -} - -void MainWindow::save_mappings() { - pose.save_mappings(); -} - -void MainWindow::save() -{ - save_timer.stop(); - save_timer.start(5000); -} - -void MainWindow::maybe_save() -{ - if (save_timer.isActive()) - { - save_timer.stop(); - _save(); - } -} - -void MainWindow::_save() { - s.b->save(); - save_mappings(); - mem settings = group::ini_file(); - settings->sync(); - -#if defined(__unix) || defined(__linux) - QString currentFile = group::ini_pathname(); - QByteArray bytes = QFile::encodeName(currentFile); - const char* filename_as_asciiz = bytes.constData(); - - if (access(filename_as_asciiz, R_OK | W_OK)) - { - QMessageBox::warning(this, "Something went wrong", "Check permissions and ownership for your .ini file!", QMessageBox::Ok, QMessageBox::NoButton); - } -#endif -} - -void MainWindow::load_mappings() { - pose.load_mappings(); -} - -void MainWindow::load_settings() { - s.b->reload(); - load_mappings(); -} - -void MainWindow::make_empty_config() -{ - QString name; - const QString dir = group::ini_directory(); - if (dir != "" && get_new_config_name_from_dialog(name)) - { - QFile filename(dir + "/" + name); - (void) filename.open(QFile::ReadWrite); - refresh_config_list(); - ui.iconcomboProfile->setCurrentText(name); - } -} - -void MainWindow::make_copied_config() -{ - const QString dir = group::ini_directory(); - const QString cur = group::ini_pathname(); - QString name; - if (cur != "" && dir != "" && get_new_config_name_from_dialog(name)) - { - const QString new_name = dir + "/" + name; - (void) QFile::remove(new_name); - (void) QFile::copy(cur, new_name); - refresh_config_list(); - ui.iconcomboProfile->setCurrentText(name); - } -} - -void MainWindow::open_config_directory() -{ - const QString path = group::ini_directory(); - if (path != "") - { - QDesktopServices::openUrl("file:///" + QDir::toNativeSeparators(path)); - } -} - -extern "C" const char* opentrack_version; - -void MainWindow::refresh_config_list() -{ - if (work) - return; - - if (group::ini_list().size() == 0) - { - QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); - (void) filename.open(QFile::ReadWrite); - } - - QStringList ini_list = group::ini_list(); - set_title(); - QString current = group::ini_filename(); - is_refreshing_profiles = true; - ui.iconcomboProfile->clear(); - for (auto x : ini_list) - ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), x); - is_refreshing_profiles = false; - ui.iconcomboProfile->setCurrentText(current); -} - -void MainWindow::updateButtonState(bool running, bool inertialp) -{ - bool not_running = !running; - ui.iconcomboProfile->setEnabled ( not_running ); - ui.btnStartTracker->setEnabled ( not_running ); - ui.btnStopTracker->setEnabled ( running ); - ui.iconcomboProtocol->setEnabled ( not_running ); - ui.iconcomboFilter->setEnabled ( not_running ); - ui.iconcomboTrackerSource->setEnabled(not_running); - ui.video_frame_label->setVisible(not_running || inertialp); - ui.profile_button->setEnabled(not_running); -} - -void MainWindow::reload_options() -{ - if (work) - work->reload_shortcuts(); - ensure_tray(); -} - -void MainWindow::startTracker() { - // tracker dtor needs run first - work = nullptr; - - libs = SelectedLibraries(ui.video_frame, current_tracker(), current_protocol(), current_filter()); - - { - double p[6] = {0,0,0, 0,0,0}; - display_pose(p, p); - } - - if (!libs.correct) - { - QMessageBox::warning(this, "Library load error", - "One of libraries failed to load. Check installation.", - QMessageBox::Ok, - QMessageBox::NoButton); - libs = SelectedLibraries(); - return; - } - - work = std::make_shared(s, pose, libs, this, winId()); - - reload_options(); - - if (pTrackerDialog) - pTrackerDialog->register_tracker(libs.pTracker.get()); - - if (pFilterDialog) - pFilterDialog->register_filter(libs.pFilter.get()); - - if (pProtocolDialog) - pProtocolDialog->register_protocol(libs.pProtocol.get()); - - pose_update_timer.start(50); - - // NB check valid since SelectedLibraries ctor called - // trackers take care of layout state updates - const bool is_inertial = ui.video_frame->layout() == nullptr; - updateButtonState(true, is_inertial); - - maybe_save(); - - ui.btnStopTracker->setFocus(); -} - -void MainWindow::stopTracker( ) { - //ui.game_name->setText("Not connected"); - - pose_update_timer.stop(); - ui.pose_display->rotateBy(0, 0, 0, 0, 0, 0); - - if (pTrackerDialog) - pTrackerDialog->unregister_tracker(); - - if (pProtocolDialog) - pProtocolDialog->unregister_protocol(); - - if (pFilterDialog) - pFilterDialog->unregister_filter(); - - maybe_save(); - - work = nullptr; - libs = SelectedLibraries(); - - { - double p[6] = {0,0,0, 0,0,0}; - display_pose(p, p); - } - updateButtonState(false, false); - - set_title(); - - ui.btnStartTracker->setFocus(); -} - -void MainWindow::display_pose(const double *mapped, const double *raw) -{ - ui.pose_display->rotateBy(mapped[Yaw], mapped[Pitch], mapped[Roll], - mapped[TX], mapped[TY], mapped[TZ]); - - if (mapping_widget) - mapping_widget->update(); - - double mapped_[6], raw_[6]; - - for (int i = 0; i < 6; i++) - { - mapped_[i] = (int) mapped[i]; - raw_[i] = (int) raw[i]; - } - - ui.raw_x->display(raw_[TX]); - ui.raw_y->display(raw_[TY]); - ui.raw_z->display(raw_[TZ]); - ui.raw_yaw->display(raw_[Yaw]); - ui.raw_pitch->display(raw_[Pitch]); - ui.raw_roll->display(raw_[Roll]); - - ui.pose_x->display(mapped_[TX]); - ui.pose_y->display(mapped_[TY]); - ui.pose_z->display(mapped_[TZ]); - ui.pose_yaw->display(mapped_[Yaw]); - ui.pose_pitch->display(mapped_[Pitch]); - ui.pose_roll->display(mapped_[Roll]); - - QString game_title; - if (libs.pProtocol) - game_title = libs.pProtocol->game_name(); - set_title(game_title); -} - -void MainWindow::set_title(const QString& game_title_) -{ - QString game_title; - if (game_title_ != "") - game_title = " :: " + game_title_; - QString current = group::ini_filename(); - setWindowTitle(opentrack_version + QStringLiteral(" :: ") + current + game_title); -} - -void MainWindow::showHeadPose() -{ - double mapped[6], raw[6]; - - work->tracker->get_raw_and_mapped_poses(mapped, raw); - - display_pose(mapped, raw); -} - -template -bool mk_dialog(mem lib, mem& orig) -{ - if (orig && orig->isVisible()) - { - orig->show(); - orig->raise(); - return false; - } - - if (lib && lib->Dialog) - { - auto dialog = mem(reinterpret_cast(lib->Dialog())); - dialog->setWindowFlags(Qt::Dialog); - dialog->setFixedSize(dialog->size()); - - orig = dialog; - dialog->show(); - dialog->raise(); - - QObject::connect(dialog.get(), &BaseDialog::closing, [&]() -> void { orig = nullptr; }); - - return true; - } - - return false; -} - -void MainWindow::showTrackerSettings() -{ - if (mk_dialog(current_tracker(), pTrackerDialog) && libs.pTracker) - pTrackerDialog->register_tracker(libs.pTracker.get()); -} - -void MainWindow::showProtocolSettings() { - if (mk_dialog(current_protocol(), pProtocolDialog) && libs.pProtocol) - pProtocolDialog->register_protocol(libs.pProtocol.get()); -} - -void MainWindow::showFilterSettings() { - if (mk_dialog(current_filter(), pFilterDialog) && libs.pFilter) - pFilterDialog->register_filter(libs.pFilter.get()); -} - -template -bool mk_window(mem* place, Args... params) -{ - if (*place && (*place)->isVisible()) - { - (*place)->show(); - (*place)->raise(); - return false; - } - else - { - *place = std::make_shared(params...); - (*place)->setWindowFlags(Qt::Dialog); - (*place)->show(); - (*place)->raise(); - return true; - } -} - -void MainWindow::show_options_dialog() { - if (mk_window(&options_widget)) - connect(options_widget.get(), SIGNAL(reload()), this, SLOT(reload_options())); -} - -void MainWindow::showCurveConfiguration() { - mk_window(&mapping_widget, pose, s); -} - -void MainWindow::exit() { - QCoreApplication::exit(0); -} - -void MainWindow::profileSelected(QString name) -{ - if (name == "" || is_refreshing_profiles) - return; - - const auto old_name = group::ini_filename(); - const auto new_name = name; - - if (old_name != new_name) - { - save(); - - { - QSettings settings(OPENTRACK_ORG); - settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, new_name); - } - - set_title(); - load_settings(); - } -} - -void MainWindow::shortcutRecentered() -{ - qDebug() << "Center"; - if (work) - work->tracker->center(); -} - -void MainWindow::shortcutToggled() -{ - qDebug() << "Toggle"; - if (work) - work->tracker->toggle_enabled(); -} - -void MainWindow::shortcutZeroed() -{ - qDebug() << "Zero"; - if (work) - work->tracker->zero(); -} - -void MainWindow::ensure_tray() -{ - if (tray) - tray->hide(); - tray = nullptr; - if (s.tray_enabled) - { - tray = std::make_shared(this); - tray->setIcon(QIcon(":/images/facetracknoir.png")); - tray->show(); - connect(tray.get(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - this, SLOT(restore_from_tray(QSystemTrayIcon::ActivationReason))); - } -} - -void MainWindow::restore_from_tray(QSystemTrayIcon::ActivationReason) -{ - show(); - setWindowState(Qt::WindowNoState); -} - -void MainWindow::changeEvent(QEvent* e) -{ - if (s.tray_enabled && e->type() == QEvent::WindowStateChange && (windowState() & Qt::WindowMinimized)) - { - if (!tray) - ensure_tray(); - hide(); - } - QMainWindow::changeEvent(e); -} - -void MainWindow::maybe_start_profile_from_executable() -{ - if (!work) - { - QString prof; - if (det.config_to_start(prof)) - { - ui.iconcomboProfile->setCurrentText(prof); - startTracker(); - } - } - else - { - if (det.should_stop()) - stopTracker(); - } -} - -void MainWindow::set_profile(const QString &profile) -{ - QSettings settings(OPENTRACK_ORG); - settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, profile); -} diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h deleted file mode 100644 index 91e4ebbf..00000000 --- a/facetracknoir/ui.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (c) 2014-2015, Stanislaw Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ui_main.h" - -#include "opentrack/options.hpp" -#include "opentrack/main-settings.hpp" -#include "opentrack/plugin-support.hpp" -#include "opentrack/tracker.h" -#include "opentrack/shortcuts.h" -#include "opentrack/work.hpp" -#include "opentrack/state.hpp" -#include "curve-config.h" -#include "options-dialog.hpp" -#include "process_detector.h" - -using namespace options; - -class MainWindow : public QMainWindow, private State -{ - Q_OBJECT - - Ui::OpentrackUI ui; - mem tray; - QTimer pose_update_timer; - QTimer det_timer; - QTimer config_list_timer; - mem options_widget; - mem mapping_widget; - QShortcut kbd_quit; - QPixmap no_feed_pixmap; - mem pFilterDialog; - mem pProtocolDialog; - mem pTrackerDialog; - process_detector_worker det; - QMenu profile_menu; - bool is_refreshing_profiles; - QTimer save_timer; - - mem current_tracker() - { - return modules.trackers().value(ui.iconcomboTrackerSource->currentIndex(), nullptr); - } - mem current_protocol() - { - return modules.protocols().value(ui.iconcomboProtocol->currentIndex(), nullptr); - } - mem current_filter() - { - return modules.filters().value(ui.iconcomboFilter->currentIndex(), nullptr); - } - - void changeEvent(QEvent* e) override; - - void load_settings(); - void updateButtonState(bool running, bool inertialp); - void display_pose(const double* mapped, const double* raw); - void ensure_tray(); - void set_title(const QString& game_title = QStringLiteral("")); - static bool get_new_config_name_from_dialog(QString &ret); - void set_profile(const QString& profile); - void maybe_save(); -private slots: - void _save(); - void save(); - void exit(); - void profileSelected(QString name); - - void showTrackerSettings(); - void showProtocolSettings(); - void showFilterSettings(); - void show_options_dialog(); - void showCurveConfiguration(); - void showHeadPose(); - - void restore_from_tray(QSystemTrayIcon::ActivationReason); - void maybe_start_profile_from_executable(); - - void make_empty_config(); - void make_copied_config(); - void open_config_directory(); - void refresh_config_list(); - - void startTracker(); - void stopTracker(); - void reload_options(); -public slots: - void shortcutRecentered(); - void shortcutToggled(); - void shortcutZeroed(); -public: - MainWindow(); - ~MainWindow(); - void save_mappings(); - void load_mappings(); - static void set_working_directory(); -}; diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt new file mode 100644 index 00000000..51d0cea3 --- /dev/null +++ b/gui/CMakeLists.txt @@ -0,0 +1,62 @@ +opentrack_boilerplate(opentrack NO-LIBRARY) + +if(UNIX OR APPLE) + target_include_directories(opentrack "${CMAKE_SOURCE_DIR}/qxt-mini") + if(APPLE) + set(qxt-plat mac) + else() + set(qxt-plat x11) + endif() + file(GLOB qxt-mini-c + ${CMAKE_SOURCE_DIR}/qxt-mini/*.h + ${CMAKE_SOURCE_DIR}/qxt-mini/qxtglobalshortcut.cpp + ${CMAKE_SOURCE_DIR}/qxt-mini/plat/qxtglobalshortcut_${qxt-plat}.cpp + ) + opentrack_qt(qxt-mini) + add_library(opentrack-qxt-mini STATIC ${qxt-mini-all}) + target_link_libraries(opentrack-qxt-mini ${MY_QT_LIBS}) + if(NOT APPLE) + target_link_libraries(opentrack-qxt-mini X11) + endif() +endif() + +if(WIN32) + SET(SDK_CONSOLE_DEBUG FALSE CACHE BOOL "Console window visible at runtime") +endif() + +if(WIN32 AND NOT SDK_CONSOLE_DEBUG) + set(opentrack-win32-executable WIN32) +else() + set(opentrack-win32-executable "") +endif() + +if(UNIX OR APPLE) + list(APPEND opentrack-c ${CMAKE_SOURCE_DIR}/qxt-mini/qxtglobalshortcut.h) +endif() +opentrack_qt(opentrack) +add_executable(opentrack ${opentrack-win32-executable} ${opentrack-all}) +opentrack_compat(opentrack) +if(NOT WIN32) + set_target_properties(opentrack PROPERTIES SUFFIX ".bin") +endif() +target_link_libraries(opentrack opentrack-api opentrack-version opentrack-pose-widget opentrack-spline-widget) +if(APPLE) + SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES LINK_FLAGS "-framework Carbon -framework CoreFoundation") +endif() +if(UNIX OR APPLE) + target_link_libraries(opentrack opentrack-qxt-mini) +endif() +link_with_dinput8(opentrack) +target_link_libraries(opentrack ${MY_QT_LIBS}) + +if(APPLE) + # for process detector + target_link_libraries(opentrack proc) +endif() + +if(LINUX) + # for process detector + target_link_libraries(opentrack procps) +endif() + +install(TARGETS opentrack DESTINATION .) diff --git a/gui/curve-config.cpp b/gui/curve-config.cpp new file mode 100644 index 00000000..2e9065b4 --- /dev/null +++ b/gui/curve-config.cpp @@ -0,0 +1,81 @@ +/* Copyright (c) 2014-2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#include "curve-config.h" +#include "opentrack/main-settings.hpp" +MapWidget::MapWidget(Mappings& m, main_settings& s) : + m(m) +{ + ui.setupUi( this ); + + // rest of mapping settings taken care of by options::value + m.load_mappings(); + + { + struct { + QFunctionConfigurator* qfc; + Axis axis; + QCheckBox* checkbox; + bool altp; + } qfcs[] = + { + { ui.rxconfig, Yaw, nullptr, false }, + { ui.ryconfig, Pitch, nullptr, false }, + { ui.rzconfig, Roll, nullptr, false }, + { ui.txconfig, TX, nullptr, false }, + { ui.tyconfig, TY, nullptr, false }, + { ui.tzconfig, TZ, nullptr, false }, + + { ui.rxconfig_alt, Yaw, ui.rx_altp, true }, + { ui.ryconfig_alt, Pitch, ui.ry_altp, true }, + { ui.rzconfig_alt, Roll, ui.rz_altp, true }, + { ui.txconfig_alt, TX, ui.tx_altp, true }, + { ui.tyconfig_alt, TY, ui.ty_altp, true }, + { ui.tzconfig_alt, TZ, ui.tz_altp, true }, + { nullptr, Yaw, nullptr, false } + }; + + for (int i = 0; qfcs[i].qfc; i++) + { + const bool altp = qfcs[i].altp; + Mapping& axis = m(qfcs[i].axis); + Map* conf = altp ? &axis.curveAlt : &axis.curve; + const auto& name = qfcs[i].altp ? axis.name2 : axis.name1; + if (altp) + { + QFunctionConfigurator& qfc = *qfcs[i].qfc; + connect(qfcs[i].checkbox, &QCheckBox::toggled, + [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();}); + qfc.setEnabled(qfcs[i].checkbox->isChecked()); + qfc.force_redraw(); + } + qfcs[i].qfc->setConfig(conf, name); + } + } + + setFont(qApp->font()); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + tie_setting(s.a_x.altp, ui.tx_altp); + tie_setting(s.a_y.altp, ui.ty_altp); + tie_setting(s.a_z.altp, ui.tz_altp); + tie_setting(s.a_yaw.altp, ui.rx_altp); + tie_setting(s.a_pitch.altp, ui.ry_altp); + tie_setting(s.a_roll.altp, ui.rz_altp); +} + +void MapWidget::doOK() { + m.save_mappings(); + this->close(); +} + +void MapWidget::doCancel() { + m.invalidate_unsaved(); + this->close(); +} diff --git a/gui/curve-config.h b/gui/curve-config.h new file mode 100644 index 00000000..0cbc7055 --- /dev/null +++ b/gui/curve-config.h @@ -0,0 +1,18 @@ +#pragma once +#include +#include "opentrack/mappings.hpp" +#include "ui_mapping.h" + +class MapWidget: public QWidget +{ + Q_OBJECT +public: + MapWidget(Mappings &m, main_settings &s); +private: + Ui::UICCurveConfigurationDialog ui; + Mappings& m; + void closeEvent(QCloseEvent *) override { doCancel(); } +private slots: + void doOK(); + void doCancel(); +}; diff --git a/gui/facetracknoir.ico b/gui/facetracknoir.ico new file mode 100644 index 00000000..5cac8da1 Binary files /dev/null and b/gui/facetracknoir.ico differ diff --git a/gui/facetracknoir.rc b/gui/facetracknoir.rc new file mode 100644 index 00000000..020ffe97 --- /dev/null +++ b/gui/facetracknoir.rc @@ -0,0 +1,2 @@ +#include +IDI_ICON1 ICON "facetracknoir.ico" diff --git a/gui/images/curves.png b/gui/images/curves.png new file mode 100644 index 00000000..3f953a0a Binary files /dev/null and b/gui/images/curves.png differ diff --git a/gui/images/facetracknoir.png b/gui/images/facetracknoir.png new file mode 100644 index 00000000..85c06df6 Binary files /dev/null and b/gui/images/facetracknoir.png differ diff --git a/gui/images/filter-16.png b/gui/images/filter-16.png new file mode 100644 index 00000000..ecde6a10 Binary files /dev/null and b/gui/images/filter-16.png differ diff --git a/gui/images/no-feed.png b/gui/images/no-feed.png new file mode 100644 index 00000000..02aa227a Binary files /dev/null and b/gui/images/no-feed.png differ diff --git a/gui/images/settings16.png b/gui/images/settings16.png new file mode 100644 index 00000000..3b31623b Binary files /dev/null and b/gui/images/settings16.png differ diff --git a/gui/images/tools.png b/gui/images/tools.png new file mode 100644 index 00000000..2da8f9f5 Binary files /dev/null and b/gui/images/tools.png differ diff --git a/gui/keyboard.h b/gui/keyboard.h new file mode 100644 index 00000000..62a9ce20 --- /dev/null +++ b/gui/keyboard.h @@ -0,0 +1,50 @@ +#pragma once +#include "ui_keyboard_listener.h" +#ifdef _WIN32 +#include "opentrack/win32-shortcuts.h" +#include "opentrack/shortcuts.h" +#endif +#include +#include +#include + +class KeyboardListener : public QLabel +{ + Q_OBJECT + Ui_keyboard_listener ui; +#ifdef _WIN32 + KeybindingWorker w; +#endif +public: + KeyboardListener(QWidget* parent = nullptr) : QLabel(parent) +#ifdef _WIN32 + , w([&](Key& k) + { + Qt::KeyboardModifiers m; + QKeySequence k_; + if (win_key::to_qt(k, k_, m)) + key_pressed(static_cast(k_).toInt() | m); + }, this->winId()) +#endif + { + ui.setupUi(this); + setFocusPolicy(Qt::StrongFocus); +#ifdef _WIN32 + w.start(); +#endif + } +#ifndef _WIN32 + void keyPressEvent(QKeyEvent* event) override + { + //qDebug() << "k" << (event->key() | event->modifiers()); + switch (event->key() | event->modifiers()) + { + default: + emit key_pressed(QKeySequence(event->key() | event->modifiers())); + break; + } + } +#endif +signals: + void key_pressed(QKeySequence k); +}; diff --git a/gui/keyboard_listener.ui b/gui/keyboard_listener.ui new file mode 100644 index 00000000..b6977df0 --- /dev/null +++ b/gui/keyboard_listener.ui @@ -0,0 +1,37 @@ + + + keyboard_listener + + + Qt::ApplicationModal + + + + 0 + 0 + 224 + 33 + + + + + 0 + 0 + + + + Bind a shortcut + + + <html><head/><body><p>Press a key or close this window to remove the keybinding.</p></body></html> + + + Qt::RichText + + + 10 + + + + + diff --git a/gui/main.cpp b/gui/main.cpp new file mode 100644 index 00000000..a63fe54a --- /dev/null +++ b/gui/main.cpp @@ -0,0 +1,71 @@ +#ifdef _WIN32 +# include +#endif + +#include "ui.h" +#include "opentrack/options.hpp" +using namespace options; +#include +#include +#include +#include +#include +#include +#include + +#ifdef _WIN32 +// workaround QTBUG-38598, allow for launching from another directory +static void add_program_library_path() +{ + char* p = _pgmptr; + char path[MAX_PATH+1]; + strcpy(path, p); + char* ptr = strrchr(path, '\\'); + if (ptr) + { + *ptr = '\0'; + QCoreApplication::addLibraryPath(path); + } +} +#endif + +int main(int argc, char** argv) +{ +#ifdef _WIN32 + add_program_library_path(); +#elif !defined(__linux) + // workaround QTBUG-38598 + QCoreApplication::addLibraryPath("."); +#endif + +#if defined(_WIN32) || defined(__APPLE__) + // qt5 designer-made controls look like shit on 'doze -sh 20140921 + // also our OSX look leaves a lot to be desired -sh 20150726 + { + const QStringList preferred { "fusion", "windowsvista", "macintosh", "windowsxp" }; + for (const auto& style_name : preferred) + { + QStyle* s = QStyleFactory::create(style_name); + if (s) + { + QApplication::setStyle(s); + break; + } + } + } +#endif + + QApplication::setAttribute(Qt::AA_X11InitThreads, true); + QApplication app(argc, argv); + + auto w = std::make_shared(); + + w->show(); + app.exec(); + + // on MSVC crashes in atexit +#ifdef _MSC_VER + TerminateProcess(GetCurrentProcess(), 0); +#endif + return 0; +} diff --git a/gui/main.ui b/gui/main.ui new file mode 100644 index 00000000..ab63e832 --- /dev/null +++ b/gui/main.ui @@ -0,0 +1,1255 @@ + + + Lovecraftian Octopus + OpentrackUI + + + + 0 + 0 + 707 + 494 + + + + + :/images/facetracknoir.png:/images/facetracknoir.png + + + #video_feed { border: 0; } + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Raised + + + 0 + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 480 + 360 + + + + + 480 + 360 + + + + + + 0 + 0 + 480 + 360 + + + + + 0 + 0 + + + + + + 0 + 0 + 480 + 360 + + + + + 0 + 0 + + + + + 480 + 360 + + + + + 480 + 360 + + + + + + + + + + + + + QFrame::NoFrame + + + 0 + + + + 12 + + + 6 + + + 12 + + + 8 + + + 4 + + + + + + 0 + 0 + + + + + 80 + 90 + + + + + + + + + 0 + 0 + + + + Raw tracker data + + + + 0 + + + 0 + + + 0 + + + 0 + + + 3 + + + 2 + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + yaw + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TZ + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TY + + + + + + + + + + + 0 + 0 + + + + Game data + + + + 0 + + + 0 + + + 0 + + + 0 + + + 3 + + + 2 + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TY + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + yaw + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TZ + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + + + + + + + + + + 0 + 0 + + + + + 4 + + + 8 + + + 10 + + + 0 + + + 4 + + + 0 + + + + + + 4 + 0 + + + + Settings + + + true + + + + 3 + + + 4 + + + 2 + + + 0 + + + 6 + + + + + + 0 + 2 + + + + + 0 + + + 0 + + + 2 + + + 2 + + + + + true + + + + 0 + 0 + + + + Profile + + + QToolButton::InstantPopup + + + Qt::ToolButtonTextBesideIcon + + + true + + + Qt::DownArrow + + + + + + + + 0 + 0 + + + + 20 + + + + + + + + + + + 0 + 3 + + + + Mapping + + + + :/images/curves.png:/images/curves.png + + + + 80 + 24 + + + + + + + + + 0 + 3 + + + + Options + + + + :/images/tools.png:/images/tools.png + + + + 80 + 24 + + + + + + + + + + + + 3 + 0 + + + + Controls + + + true + + + + 8 + + + 0 + + + 8 + + + 0 + + + 9 + + + + + + 0 + 0 + + + + Start + + + + + + + false + + + + 0 + 0 + + + + Stop + + + + + + + + + + + 4 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 2 + + + 3 + + + 2 + + + 3 + + + 8 + + + + + Tracker + + + + 4 + + + 0 + + + 4 + + + 0 + + + 3 + + + 0 + + + + + + + + true + + + ... + + + false + + + + + + + + + + Protocol + + + + 4 + + + 0 + + + 4 + + + 0 + + + 3 + + + 0 + + + + + + + + true + + + ... + + + false + + + + + + + + + + Filter + + + + 4 + + + 0 + + + 4 + + + 0 + + + 3 + + + 0 + + + + + + + + true + + + ... + + + false + + + + + + + + + + + + + + + + + + + + + GLWidget + QWidget +
pose-widget/glwidget.h
+
+
+ + btnStartTracker + btnStopTracker + iconcomboTrackerSource + btnShowEngineControls + iconcomboProtocol + btnShowServerControls + iconcomboFilter + btnShowFilterControls + profile_button + iconcomboProfile + btnEditCurves + btnShortcuts + + + + + +
diff --git a/gui/mapping.ui b/gui/mapping.ui new file mode 100644 index 00000000..75c32e27 --- /dev/null +++ b/gui/mapping.ui @@ -0,0 +1,391 @@ + + + UICCurveConfigurationDialog + + + + 0 + 0 + 970 + 664 + + + + + 0 + 0 + + + + + 970 + 664 + + + + + 970 + 664 + + + + Mapping properties + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + background-color: #ccc; + + + + + + + + + QTabWidget::North + + + 0 + + + + Yaw + + + + + + + 255 + 0 + 0 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 255 + 0 + 0 + + + + + 255 + 255 + 255 + + + + + + + + + Pitch + + + + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + + + Roll + + + + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + + + X + + + + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + + + Y + + + + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + + + Z + + + + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + + Asymmetric mapping below + + + + + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + QFunctionConfigurator + QWidget +
spline-widget/qfunctionconfigurator.h
+
+
+ + ry_altp + rz_altp + tx_altp + ty_altp + tz_altp + tabWidget + buttonBox + rx_altp + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/gui/new_config.ui b/gui/new_config.ui new file mode 100644 index 00000000..27dce0f8 --- /dev/null +++ b/gui/new_config.ui @@ -0,0 +1,45 @@ + + + UI_new_config + + + Qt::ApplicationModal + + + + 0 + 0 + 269 + 67 + + + + Config filename + + + + images/facetracknoir.pngimages/facetracknoir.png + + + + + + New file name: + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/gui/new_file_dialog.h b/gui/new_file_dialog.h new file mode 100644 index 00000000..3a35cf71 --- /dev/null +++ b/gui/new_file_dialog.h @@ -0,0 +1,50 @@ +#pragma once + +#include "ui_new_config.h" +#include "opentrack/options.hpp" +#include +#include +#include +#include + +class new_file_dialog : public QDialog +{ + Q_OBJECT +public: + new_file_dialog(QWidget* parent = 0) : QDialog(parent), ok(false) + { + ui.setupUi(this); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(ok_clicked())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancel_clicked())); + setFixedSize(size()); + } + bool is_ok(QString& name_) + { + name_ = name; + return ok; + } +private: + Ui::UI_new_config ui; + bool ok; + QString name; +private slots: + void cancel_clicked() { close(); } + void ok_clicked() + { + QString text = ui.lineEdit->text(); + text = text.replace('/', ""); + text = text.replace('\\', ""); + if (text != "" && !text.endsWith(".ini")) + text += ".ini"; + if (text == "" || text == ".ini" || QFile(options::group::ini_directory() + "/" + text).exists()) + { + QMessageBox::warning(this, + "File exists", "This file already exists. Pick another name.", + QMessageBox::Ok, QMessageBox::NoButton); + return; + } + ok = true; + close(); + name = text; + } +}; diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp new file mode 100644 index 00000000..fef2b0ca --- /dev/null +++ b/gui/options-dialog.cpp @@ -0,0 +1,96 @@ +/* Copyright (c) 2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#include "options-dialog.hpp" +#include "keyboard.h" +#include +#include + +OptionsDialog::OptionsDialog() +{ + ui.setupUi( this ); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + tie_setting(s.s_main.tray_enabled, ui.trayp); + + tie_setting(s.s_main.center_at_startup, ui.center_at_startup); + + tie_setting(s.s_main.tcomp_p, ui.tcomp_enable); + tie_setting(s.s_main.tcomp_tz, ui.tcomp_rz); + + tie_setting(s.s_main.a_x.zero, ui.pos_tx); + tie_setting(s.s_main.a_y.zero, ui.pos_ty); + tie_setting(s.s_main.a_z.zero, ui.pos_tz); + tie_setting(s.s_main.a_yaw.zero, ui.pos_rx); + tie_setting(s.s_main.a_pitch.zero, ui.pos_ry); + tie_setting(s.s_main.a_roll.zero, ui.pos_rz); + + tie_setting(s.s_main.a_yaw.invert, ui.invert_yaw); + tie_setting(s.s_main.a_pitch.invert, ui.invert_pitch); + tie_setting(s.s_main.a_roll.invert, ui.invert_roll); + tie_setting(s.s_main.a_x.invert, ui.invert_x); + tie_setting(s.s_main.a_y.invert, ui.invert_y); + tie_setting(s.s_main.a_z.invert, ui.invert_z); + + tie_setting(s.s_main.a_yaw.src, ui.src_yaw); + tie_setting(s.s_main.a_pitch.src, ui.src_pitch); + tie_setting(s.s_main.a_roll.src, ui.src_roll); + tie_setting(s.s_main.a_x.src, ui.src_x); + tie_setting(s.s_main.a_y.src, ui.src_y); + tie_setting(s.s_main.a_z.src, ui.src_z); + + tie_setting(s.s_main.camera_yaw, ui.camera_yaw); + tie_setting(s.s_main.camera_pitch, ui.camera_pitch); + tie_setting(s.s_main.camera_roll, ui.camera_roll); + + tie_setting(s.s_main.center_method, ui.center_method); + + connect(ui.bind_center, &QPushButton::pressed, [&]() -> void { bind_key(s.center.keycode, ui.center_text); }); + connect(ui.bind_zero, &QPushButton::pressed, [&]() -> void { bind_key(s.zero.keycode, ui.zero_text); }); + connect(ui.bind_toggle, &QPushButton::pressed, [&]() -> void { bind_key(s.toggle.keycode, ui.toggle_text); }); + + ui.center_text->setText(s.center.keycode == "" ? "None" : static_cast(s.center.keycode)); + ui.toggle_text->setText(s.toggle.keycode == "" ? "None" : static_cast(s.toggle.keycode)); + ui.zero_text->setText(s.zero.keycode == "" ? "None" : static_cast(s.zero.keycode)); +} + +void OptionsDialog::bind_key(value& ret, QLabel* label) +{ + ret = ""; + QDialog d; + auto l = new QHBoxLayout; + l->setMargin(0); + auto k = new KeyboardListener; + l->addWidget(k); + d.setLayout(l); + d.setFixedSize(QSize(500, 300)); + d.setWindowFlags(Qt::Dialog); + connect(k, &KeyboardListener::key_pressed, [&] (QKeySequence s) -> void { ret = s.toString(QKeySequence::PortableText); d.close(); }); + d.exec(); + label->setText(ret == "" ? "None" : static_cast(ret)); + delete k; + delete l; +} + +void OptionsDialog::doOK() { + s.b->save(); + s.s_main.b->save(); + ui.game_detector->save(); + this->close(); + emit reload(); +} + +void OptionsDialog::doCancel() { + s.b->reload(); + s.s_main.b->reload(); + ui.game_detector->revert(); + close(); +} + diff --git a/gui/options-dialog.hpp b/gui/options-dialog.hpp new file mode 100644 index 00000000..3ef99d06 --- /dev/null +++ b/gui/options-dialog.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include +#include +#include "ui_settings.h" +#include "opentrack/shortcuts.h" + +class OptionsDialog: public QWidget +{ + Q_OBJECT +signals: + void reload(); +public: + OptionsDialog(); +private: + Ui::UI_Settings ui; + Shortcuts::settings s; + void closeEvent(QCloseEvent *) override { doCancel(); } +private slots: + void doOK(); + void doCancel(); + void bind_key(value& ret, QLabel* label); +}; diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp new file mode 100644 index 00000000..f9fa4b59 --- /dev/null +++ b/gui/process_detector.cpp @@ -0,0 +1,211 @@ +/* Copyright (c) 2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#include "process_detector.h" +#include "ui.h" +#include "opentrack-compat/process-list.hpp" +#include +#include +#include +#include +#include +#include + +void settings::set_game_list(const QString &game_list) +{ + QSettings settings(OPENTRACK_ORG); + settings.setValue("executable-list", game_list); +} + +QString settings::get_game_list() +{ + QSettings settings(OPENTRACK_ORG); + return settings.value("executable-list").toString(); +} + +bool settings::is_enabled() +{ + QSettings settings(OPENTRACK_ORG); + return settings.value("executable-detector-enabled", false).toBool(); +} + +void settings::set_is_enabled(bool enabled) +{ + QSettings settings(OPENTRACK_ORG); + settings.setValue("executable-detector-enabled", enabled); +} + +QHash settings::split_process_names() +{ + QHash ret; + QString str = get_game_list(); + QStringList pairs = str.split('|'); + for (auto pair : pairs) + { + QList tmp = pair.split(':'); + if (tmp.count() != 2) + continue; + ret[tmp[0]] = tmp[1]; + } + return ret; +} + +void BrowseButton::browse() +{ + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::ExistingFile); + QString dir_path = QFileInfo(group::ini_pathname()).absolutePath(); + QString filename = dialog.getOpenFileName( + this, + tr("Set executable name"), + dir_path, + tr("Executable (*.exe);;All Files (*)")); + MainWindow::set_working_directory(); + filename = QFileInfo(filename).fileName(); + if (!filename.isNull()) + twi->setText(filename); +} + +int process_detector::add_row(QString exe_name, QString profile) +{ + int i = ui.tableWidget->rowCount(); + ui.tableWidget->insertRow(i); + + QComboBox* cb = new QComboBox(); + cb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum); + cb->addItem(""); + cb->addItems(group::ini_list()); + ui.tableWidget->setCellWidget(i, 1, cb); + + QTableWidgetItem* twi = new QTableWidgetItem(exe_name); + ui.tableWidget->setItem(i, 0, twi); + + { + BrowseButton* b = new BrowseButton(twi); + b->setText("..."); + QObject::connect(b, SIGNAL(pressed()), b, SLOT(browse())); + ui.tableWidget->setCellWidget(i, 2, b); + } + + cb->setCurrentText(profile); + + return i; +} + +void process_detector::add_items() +{ + auto names = s.split_process_names(); + ui.tableWidget->clearContents(); + auto keys = names.keys(); + qSort(keys); + for (auto n : keys) + add_row(n, names[n]); +} + +process_detector::process_detector(QWidget* parent) : QWidget(parent) +{ + ui.setupUi(this); + setFixedSize(size()); + connect(ui.add, SIGNAL(pressed()), this, SLOT(add())); + connect(ui.remove, SIGNAL(pressed()), this, SLOT(remove())); + + add_items(); + + QResizeEvent e(ui.tableWidget->size(), ui.tableWidget->size()); + ui.tableWidget->resizeEvent(&e); + + settings s; + + ui.enabled->setChecked(s.is_enabled()); +} + +void process_detector::save() +{ + QString str; + + for (int i = 0; i < ui.tableWidget->rowCount(); i++) + { + auto exe = ui.tableWidget->item(i, 0)->text(); + auto profile = reinterpret_cast(ui.tableWidget->cellWidget(i, 1))->currentText(); + str += "|" + exe + ":" + profile; + } + + s.set_game_list(str); + s.set_is_enabled(ui.enabled->isChecked()); +} + +void process_detector::revert() +{ +} + +void process_detector::add() +{ + add_row(); +} + +void process_detector::remove() +{ + int r = ui.tableWidget->currentRow(); + if (r != -1) + ui.tableWidget->removeRow(r); +} + +bool process_detector_worker::should_stop() +{ + if (last_exe_name == "") + return false; + + settings s; + + if (!s.is_enabled()) + { + last_exe_name = ""; + return false; + } + + QStringList exe_list = get_all_executable_names(); + + if (exe_list.contains(last_exe_name)) + return false; + + last_exe_name = ""; + + return true; +} + +bool process_detector_worker::config_to_start(QString& str) +{ + settings s; + if (!s.is_enabled()) + { + last_exe_name = ""; + return false; + } + + auto filenames = s.split_process_names(); + QStringList exe_list = get_all_executable_names(); + + // assuming manual stop by user button click. + // don't automatically start again while the same process is running. + if (last_exe_name != "" && exe_list.contains(last_exe_name)) + return false; + // it's gone, we can start automatically again + last_exe_name = ""; + + for (auto& name : exe_list) + { + if (filenames.contains(name)) + { + last_exe_name = name; + str = filenames[name]; + return str != ""; + } + } + + return false; +} diff --git a/gui/process_detector.h b/gui/process_detector.h new file mode 100644 index 00000000..f6497c90 --- /dev/null +++ b/gui/process_detector.h @@ -0,0 +1,86 @@ +/* Copyright (c) 2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#pragma once + +#include +#include +#include +#include + +#include "opentrack/options.hpp" +using namespace options; + +class FancyTable : public QTableWidget +{ + Q_OBJECT +public: + void resizeEvent(QResizeEvent* e) override + { + QTableView::resizeEvent(e); + int w = width(); + setColumnWidth(2, 32); + w -= 48; + setColumnWidth(0, w / 2); + setColumnWidth(1, w / 2); + } +public: + FancyTable(QWidget* parent = nullptr) : QTableWidget(parent) {} +}; + +struct settings +{ + QHash split_process_names(); + QString get_game_list(); + void set_game_list(const QString& game_list); + bool is_enabled(); + void set_is_enabled(bool enabled); +}; + +#include "ui_process_widget.h" + +class process_detector : public QWidget +{ + Q_OBJECT + + Ui_Dialog ui; + settings s; + + int add_row(QString exe_name = "...", QString profile = ""); + void add_items(); +public: + process_detector(QWidget* parent = nullptr); +public slots: + void save(); + void revert(); +private slots: + void add(); + void remove(); +}; + +class BrowseButton : public QPushButton +{ + Q_OBJECT + QTableWidgetItem* twi; +public: + BrowseButton(QTableWidgetItem* twi) : twi(twi) + {} +public slots: + void browse(); +}; + +class process_detector_worker : QObject +{ + Q_OBJECT + settings s; + QString last_exe_name; +public: + bool config_to_start(QString& s); + bool should_stop(); +}; + diff --git a/gui/process_widget.ui b/gui/process_widget.ui new file mode 100644 index 00000000..63ad9472 --- /dev/null +++ b/gui/process_widget.ui @@ -0,0 +1,121 @@ + + + Dialog + + + + 0 + 0 + 302 + 325 + + + + Game detector + + + + + + + 0 + 0 + + + + + Executable + + + + + Profile + + + + + + + + + + + + + + 0 + 0 + + + + border: 0; + + + + + + + 5 + + + + + + 0 + 0 + + + + + 14 + 75 + true + + + + + + + + + + + + + 0 + 0 + + + + + 14 + 75 + true + + + + - + + + + + + + + + + Start profiles from game executable names in this list + + + + + + + + FancyTable + QTableWidget +
process_detector.h
+
+
+ + +
diff --git a/gui/settings.ui b/gui/settings.ui new file mode 100644 index 00000000..e277b5d8 --- /dev/null +++ b/gui/settings.ui @@ -0,0 +1,1109 @@ + + + UI_Settings + + + + 0 + 0 + 348 + 548 + + + + Options + + + + images/facetracknoir.pngimages/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + 0 + + + + Shortcuts + + + + + + Global shortcuts + + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600;">Center</span> - use current pose as looking perfectly forward.<br/><span style=" font-weight:600;">Toggle</span> - keep looking at same spot until toggle keypress.<br/><span style=" font-weight:600;">Zero</span> - keep looking forward while the key is pressed.<br/></p></body></html> + + + true + + + + + + + QGroupBox { border: 0; } + + + + + + + + + + + + + Center + + + false + + + + + + + + + + + + + + + + + + + + + Toggle + + + false + + + + + + + Zero + + + false + + + + + + + Bind + + + + + + + Bind + + + + + + + Bind + + + + + + + + + + + + + Centering method + + + + + + Method + + + + + + + + Relative (inertial device) + + + + + Absolute (camera device) + + + + + + + + Try changing this if centering doesn't perform correctly for your input device. + + + true + + + + + + + + + + Center at startup + + + + + + + Minimize to tray + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Camera + + + + + + Camera offset + + + + + + <html><head/><body><p>Specify an angle for off-center camera as a basis for which direction is which, avoiding axis interconnect. Also see <a href="https://github.com/opentrack/opentrack/wiki/choosing-camera-offset"><span style=" text-decoration: underline; color:#0000ff;">description on wiki</span></a>.</p></body></html> + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + 2 + + + true + + + + + + + QGroupBox +{ + border: 0; +} + + + + + + Roll + + + + + + + + 80 + 0 + + + + -180 + + + 180 + + + + + + + + 80 + 0 + + + + -180 + + + 180 + + + + + + + Pitch + + + + + + + + 80 + 0 + + + + -180 + + + 180 + + + + + + + Yaw + + + + + + + + + + + + + Center pose offset + + + + + + Alter the centered position sent to games by a fixed amount. + + + true + + + 2 + + + + + + + QGroupBox { + border: 0; +} + + + + + + Qt::AlignCenter + + + false + + + false + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + TX + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RY + + + + + + + TY + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + TZ + + + + + + + RZ + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RX + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Output + + + + + + + 0 + 0 + + + + + + + Translation compensation + + + false + + + + + + With compensation on, translation is applied after rotation. For example, rotating +180 degrees yaw and moving backwards results in moving forward as a result of that rotation. + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + 2 + + + + + + + + + + Enable + + + + + + + + + + Disable Z axis compensation + + + + + + + + + + + 65536 + 65536 + + + + + true + + + + Output remap + + + Qt::AlignCenter + + + false + + + false + + + + QLayout::SetMinAndMaxSize + + + 6 + + + + + Assign input axis to output axis. + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + + + + + QGroupBox +{ + border: 0; +} + + + + + + + + + + + + + Roll + + + + + + + X + + + + + + + Invert + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + Pitch + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + + + + + + + Y + + + + + + + Destination + + + + + + + + + + + + + + Yaw + + + + + + + + + + + + + + Source + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + Z + + + + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + Disabled + + + + + + + + + + + + + label_15 + label_13 + label_14 + src_yaw + invert_yaw + label_7 + src_pitch + label_8 + invert_pitch + label_9 + src_roll + invert_roll + label_10 + src_x + invert_x + label_11 + src_y + invert_y + label_12 + src_z + invert_z + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Game detection + + + + + + Game detection + + + + + + + + + + 0 + 0 + + + + Start tracking automatically when a game starts with selected profile, and stop when the game exits. + + + true + + + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + process_detector + QWidget +
process_detector.h
+
+
+ + tabWidget + center_at_startup + trayp + camera_yaw + camera_pitch + camera_roll + pos_rx + pos_ry + pos_rz + pos_tx + pos_ty + pos_tz + tcomp_enable + tcomp_rz + src_yaw + invert_yaw + src_pitch + invert_pitch + src_roll + invert_roll + src_x + invert_x + src_y + invert_y + src_z + invert_z + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/gui/ui-res.qrc b/gui/ui-res.qrc new file mode 100644 index 00000000..030a6153 --- /dev/null +++ b/gui/ui-res.qrc @@ -0,0 +1,10 @@ + + + images/tools.png + images/settings16.png + images/curves.png + images/facetracknoir.png + images/no-feed.png + images/filter-16.png + + diff --git a/gui/ui.cpp b/gui/ui.cpp new file mode 100644 index 00000000..5ea5dbfa --- /dev/null +++ b/gui/ui.cpp @@ -0,0 +1,567 @@ +/* Copyright (c) 2013-2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#include "ui.h" +#include "opentrack/tracker.h" +#include "opentrack/options.hpp" +#include "new_file_dialog.h" +#include +#include + +#ifndef _WIN32 +# include +#else +# include +#endif + +MainWindow::MainWindow() : + pose_update_timer(this), + kbd_quit(QKeySequence("Ctrl+Q"), this), + no_feed_pixmap(":/images/no-feed.png"), + is_refreshing_profiles(false) +{ + ui.setupUi(this); + + setFixedSize(size()); + + updateButtonState(false, false); + ui.video_frame_label->setPixmap(no_feed_pixmap); + + connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); + connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(show_options_dialog())); + connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); + connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showProtocolSettings())); + connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterSettings())); + + modules.filters().push_front(std::make_shared("", dylib::Filter)); + + for (auto x : modules.trackers()) + ui.iconcomboTrackerSource->addItem(x->icon, x->name); + + for (auto x : modules.protocols()) + ui.iconcomboProtocol->addItem(x->icon, x->name); + + for (auto x : modules.filters()) + ui.iconcomboFilter->addItem(x->icon, x->name); + + refresh_config_list(); + connect(&config_list_timer, SIGNAL(timeout()), this, SLOT(refresh_config_list())); + config_list_timer.start(1000 * 3); + + tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); + tie_setting(s.protocol_dll, ui.iconcomboProtocol); + tie_setting(s.filter_dll, ui.iconcomboFilter); + + connect(ui.iconcomboTrackerSource, + &QComboBox::currentTextChanged, + [&](QString) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); }); + + connect(ui.iconcomboProtocol, + &QComboBox::currentTextChanged, + [&](QString) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); }); + + connect(ui.iconcomboFilter, + &QComboBox::currentTextChanged, + [&](QString) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); }); + + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); + connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); + connect(ui.iconcomboProfile, SIGNAL(currentTextChanged(QString)), this, SLOT(profileSelected(QString))); + + connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); + connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); + + save_timer.setSingleShot(true); + connect(&save_timer, SIGNAL(timeout()), this, SLOT(_save())); + + profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config())); + profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config())); + profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory())); + ui.profile_button->setMenu(&profile_menu); + + kbd_quit.setEnabled(true); + + connect(&det_timer, SIGNAL(timeout()), this, SLOT(maybe_start_profile_from_executable())); + det_timer.start(1000); + + ensure_tray(); + set_working_directory(); + + if (!QFile(group::ini_pathname()).exists()) + { + set_profile(OPENTRACK_DEFAULT_CONFIG); + const auto pathname = group::ini_pathname(); + if (!QFile(pathname).exists()) + { + QFile file(pathname); + (void) file.open(QFile::ReadWrite); + } + } + + if (group::ini_directory() == "") + QMessageBox::warning(this, + "Configuration not saved.", + "Can't create configuration directory! Expect major malfunction.", + QMessageBox::Ok, QMessageBox::NoButton); + + ui.btnStartTracker->setFocus(); +} + +bool MainWindow::get_new_config_name_from_dialog(QString& ret) +{ + new_file_dialog dlg; + dlg.exec(); + return dlg.is_ok(ret); +} + +MainWindow::~MainWindow() +{ + maybe_save(); + + if (tray) + tray->hide(); + stopTracker(); +} + +void MainWindow::set_working_directory() +{ + QDir::setCurrent(QCoreApplication::applicationDirPath()); +} + +void MainWindow::save_mappings() { + pose.save_mappings(); +} + +void MainWindow::save() +{ + save_timer.stop(); + save_timer.start(5000); +} + +void MainWindow::maybe_save() +{ + if (save_timer.isActive()) + { + save_timer.stop(); + _save(); + } +} + +void MainWindow::_save() { + s.b->save(); + save_mappings(); + mem settings = group::ini_file(); + settings->sync(); + +#if defined(__unix) || defined(__linux) + QString currentFile = group::ini_pathname(); + QByteArray bytes = QFile::encodeName(currentFile); + const char* filename_as_asciiz = bytes.constData(); + + if (access(filename_as_asciiz, R_OK | W_OK)) + { + QMessageBox::warning(this, "Something went wrong", "Check permissions and ownership for your .ini file!", QMessageBox::Ok, QMessageBox::NoButton); + } +#endif +} + +void MainWindow::load_mappings() { + pose.load_mappings(); +} + +void MainWindow::load_settings() { + s.b->reload(); + load_mappings(); +} + +void MainWindow::make_empty_config() +{ + QString name; + const QString dir = group::ini_directory(); + if (dir != "" && get_new_config_name_from_dialog(name)) + { + QFile filename(dir + "/" + name); + (void) filename.open(QFile::ReadWrite); + refresh_config_list(); + ui.iconcomboProfile->setCurrentText(name); + } +} + +void MainWindow::make_copied_config() +{ + const QString dir = group::ini_directory(); + const QString cur = group::ini_pathname(); + QString name; + if (cur != "" && dir != "" && get_new_config_name_from_dialog(name)) + { + const QString new_name = dir + "/" + name; + (void) QFile::remove(new_name); + (void) QFile::copy(cur, new_name); + refresh_config_list(); + ui.iconcomboProfile->setCurrentText(name); + } +} + +void MainWindow::open_config_directory() +{ + const QString path = group::ini_directory(); + if (path != "") + { + QDesktopServices::openUrl("file:///" + QDir::toNativeSeparators(path)); + } +} + +extern "C" const char* opentrack_version; + +void MainWindow::refresh_config_list() +{ + if (work) + return; + + if (group::ini_list().size() == 0) + { + QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); + (void) filename.open(QFile::ReadWrite); + } + + QStringList ini_list = group::ini_list(); + set_title(); + QString current = group::ini_filename(); + is_refreshing_profiles = true; + ui.iconcomboProfile->clear(); + for (auto x : ini_list) + ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), x); + is_refreshing_profiles = false; + ui.iconcomboProfile->setCurrentText(current); +} + +void MainWindow::updateButtonState(bool running, bool inertialp) +{ + bool not_running = !running; + ui.iconcomboProfile->setEnabled ( not_running ); + ui.btnStartTracker->setEnabled ( not_running ); + ui.btnStopTracker->setEnabled ( running ); + ui.iconcomboProtocol->setEnabled ( not_running ); + ui.iconcomboFilter->setEnabled ( not_running ); + ui.iconcomboTrackerSource->setEnabled(not_running); + ui.video_frame_label->setVisible(not_running || inertialp); + ui.profile_button->setEnabled(not_running); +} + +void MainWindow::reload_options() +{ + if (work) + work->reload_shortcuts(); + ensure_tray(); +} + +void MainWindow::startTracker() { + // tracker dtor needs run first + work = nullptr; + + libs = SelectedLibraries(ui.video_frame, current_tracker(), current_protocol(), current_filter()); + + { + double p[6] = {0,0,0, 0,0,0}; + display_pose(p, p); + } + + if (!libs.correct) + { + QMessageBox::warning(this, "Library load error", + "One of libraries failed to load. Check installation.", + QMessageBox::Ok, + QMessageBox::NoButton); + libs = SelectedLibraries(); + return; + } + + work = std::make_shared(s, pose, libs, this, winId()); + + reload_options(); + + if (pTrackerDialog) + pTrackerDialog->register_tracker(libs.pTracker.get()); + + if (pFilterDialog) + pFilterDialog->register_filter(libs.pFilter.get()); + + if (pProtocolDialog) + pProtocolDialog->register_protocol(libs.pProtocol.get()); + + pose_update_timer.start(50); + + // NB check valid since SelectedLibraries ctor called + // trackers take care of layout state updates + const bool is_inertial = ui.video_frame->layout() == nullptr; + updateButtonState(true, is_inertial); + + maybe_save(); + + ui.btnStopTracker->setFocus(); +} + +void MainWindow::stopTracker( ) { + //ui.game_name->setText("Not connected"); + + pose_update_timer.stop(); + ui.pose_display->rotateBy(0, 0, 0, 0, 0, 0); + + if (pTrackerDialog) + pTrackerDialog->unregister_tracker(); + + if (pProtocolDialog) + pProtocolDialog->unregister_protocol(); + + if (pFilterDialog) + pFilterDialog->unregister_filter(); + + maybe_save(); + + work = nullptr; + libs = SelectedLibraries(); + + { + double p[6] = {0,0,0, 0,0,0}; + display_pose(p, p); + } + updateButtonState(false, false); + + set_title(); + + ui.btnStartTracker->setFocus(); +} + +void MainWindow::display_pose(const double *mapped, const double *raw) +{ + ui.pose_display->rotateBy(mapped[Yaw], mapped[Pitch], mapped[Roll], + mapped[TX], mapped[TY], mapped[TZ]); + + if (mapping_widget) + mapping_widget->update(); + + double mapped_[6], raw_[6]; + + for (int i = 0; i < 6; i++) + { + mapped_[i] = (int) mapped[i]; + raw_[i] = (int) raw[i]; + } + + ui.raw_x->display(raw_[TX]); + ui.raw_y->display(raw_[TY]); + ui.raw_z->display(raw_[TZ]); + ui.raw_yaw->display(raw_[Yaw]); + ui.raw_pitch->display(raw_[Pitch]); + ui.raw_roll->display(raw_[Roll]); + + ui.pose_x->display(mapped_[TX]); + ui.pose_y->display(mapped_[TY]); + ui.pose_z->display(mapped_[TZ]); + ui.pose_yaw->display(mapped_[Yaw]); + ui.pose_pitch->display(mapped_[Pitch]); + ui.pose_roll->display(mapped_[Roll]); + + QString game_title; + if (libs.pProtocol) + game_title = libs.pProtocol->game_name(); + set_title(game_title); +} + +void MainWindow::set_title(const QString& game_title_) +{ + QString game_title; + if (game_title_ != "") + game_title = " :: " + game_title_; + QString current = group::ini_filename(); + setWindowTitle(opentrack_version + QStringLiteral(" :: ") + current + game_title); +} + +void MainWindow::showHeadPose() +{ + double mapped[6], raw[6]; + + work->tracker->get_raw_and_mapped_poses(mapped, raw); + + display_pose(mapped, raw); +} + +template +bool mk_dialog(mem lib, mem& orig) +{ + if (orig && orig->isVisible()) + { + orig->show(); + orig->raise(); + return false; + } + + if (lib && lib->Dialog) + { + auto dialog = mem(reinterpret_cast(lib->Dialog())); + dialog->setWindowFlags(Qt::Dialog); + dialog->setFixedSize(dialog->size()); + + orig = dialog; + dialog->show(); + dialog->raise(); + + QObject::connect(dialog.get(), &BaseDialog::closing, [&]() -> void { orig = nullptr; }); + + return true; + } + + return false; +} + +void MainWindow::showTrackerSettings() +{ + if (mk_dialog(current_tracker(), pTrackerDialog) && libs.pTracker) + pTrackerDialog->register_tracker(libs.pTracker.get()); +} + +void MainWindow::showProtocolSettings() { + if (mk_dialog(current_protocol(), pProtocolDialog) && libs.pProtocol) + pProtocolDialog->register_protocol(libs.pProtocol.get()); +} + +void MainWindow::showFilterSettings() { + if (mk_dialog(current_filter(), pFilterDialog) && libs.pFilter) + pFilterDialog->register_filter(libs.pFilter.get()); +} + +template +bool mk_window(mem* place, Args... params) +{ + if (*place && (*place)->isVisible()) + { + (*place)->show(); + (*place)->raise(); + return false; + } + else + { + *place = std::make_shared(params...); + (*place)->setWindowFlags(Qt::Dialog); + (*place)->show(); + (*place)->raise(); + return true; + } +} + +void MainWindow::show_options_dialog() { + if (mk_window(&options_widget)) + connect(options_widget.get(), SIGNAL(reload()), this, SLOT(reload_options())); +} + +void MainWindow::showCurveConfiguration() { + mk_window(&mapping_widget, pose, s); +} + +void MainWindow::exit() { + QCoreApplication::exit(0); +} + +void MainWindow::profileSelected(QString name) +{ + if (name == "" || is_refreshing_profiles) + return; + + const auto old_name = group::ini_filename(); + const auto new_name = name; + + if (old_name != new_name) + { + save(); + + { + QSettings settings(OPENTRACK_ORG); + settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, new_name); + } + + set_title(); + load_settings(); + } +} + +void MainWindow::shortcutRecentered() +{ + qDebug() << "Center"; + if (work) + work->tracker->center(); +} + +void MainWindow::shortcutToggled() +{ + qDebug() << "Toggle"; + if (work) + work->tracker->toggle_enabled(); +} + +void MainWindow::shortcutZeroed() +{ + qDebug() << "Zero"; + if (work) + work->tracker->zero(); +} + +void MainWindow::ensure_tray() +{ + if (tray) + tray->hide(); + tray = nullptr; + if (s.tray_enabled) + { + tray = std::make_shared(this); + tray->setIcon(QIcon(":/images/facetracknoir.png")); + tray->show(); + connect(tray.get(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), + this, SLOT(restore_from_tray(QSystemTrayIcon::ActivationReason))); + } +} + +void MainWindow::restore_from_tray(QSystemTrayIcon::ActivationReason) +{ + show(); + setWindowState(Qt::WindowNoState); +} + +void MainWindow::changeEvent(QEvent* e) +{ + if (s.tray_enabled && e->type() == QEvent::WindowStateChange && (windowState() & Qt::WindowMinimized)) + { + if (!tray) + ensure_tray(); + hide(); + } + QMainWindow::changeEvent(e); +} + +void MainWindow::maybe_start_profile_from_executable() +{ + if (!work) + { + QString prof; + if (det.config_to_start(prof)) + { + ui.iconcomboProfile->setCurrentText(prof); + startTracker(); + } + } + else + { + if (det.should_stop()) + stopTracker(); + } +} + +void MainWindow::set_profile(const QString &profile) +{ + QSettings settings(OPENTRACK_ORG); + settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, profile); +} diff --git a/gui/ui.h b/gui/ui.h new file mode 100644 index 00000000..91e4ebbf --- /dev/null +++ b/gui/ui.h @@ -0,0 +1,113 @@ +/* Copyright (c) 2014-2015, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ui_main.h" + +#include "opentrack/options.hpp" +#include "opentrack/main-settings.hpp" +#include "opentrack/plugin-support.hpp" +#include "opentrack/tracker.h" +#include "opentrack/shortcuts.h" +#include "opentrack/work.hpp" +#include "opentrack/state.hpp" +#include "curve-config.h" +#include "options-dialog.hpp" +#include "process_detector.h" + +using namespace options; + +class MainWindow : public QMainWindow, private State +{ + Q_OBJECT + + Ui::OpentrackUI ui; + mem tray; + QTimer pose_update_timer; + QTimer det_timer; + QTimer config_list_timer; + mem options_widget; + mem mapping_widget; + QShortcut kbd_quit; + QPixmap no_feed_pixmap; + mem pFilterDialog; + mem pProtocolDialog; + mem pTrackerDialog; + process_detector_worker det; + QMenu profile_menu; + bool is_refreshing_profiles; + QTimer save_timer; + + mem current_tracker() + { + return modules.trackers().value(ui.iconcomboTrackerSource->currentIndex(), nullptr); + } + mem current_protocol() + { + return modules.protocols().value(ui.iconcomboProtocol->currentIndex(), nullptr); + } + mem current_filter() + { + return modules.filters().value(ui.iconcomboFilter->currentIndex(), nullptr); + } + + void changeEvent(QEvent* e) override; + + void load_settings(); + void updateButtonState(bool running, bool inertialp); + void display_pose(const double* mapped, const double* raw); + void ensure_tray(); + void set_title(const QString& game_title = QStringLiteral("")); + static bool get_new_config_name_from_dialog(QString &ret); + void set_profile(const QString& profile); + void maybe_save(); +private slots: + void _save(); + void save(); + void exit(); + void profileSelected(QString name); + + void showTrackerSettings(); + void showProtocolSettings(); + void showFilterSettings(); + void show_options_dialog(); + void showCurveConfiguration(); + void showHeadPose(); + + void restore_from_tray(QSystemTrayIcon::ActivationReason); + void maybe_start_profile_from_executable(); + + void make_empty_config(); + void make_copied_config(); + void open_config_directory(); + void refresh_config_list(); + + void startTracker(); + void stopTracker(); + void reload_options(); +public slots: + void shortcutRecentered(); + void shortcutToggled(); + void shortcutZeroed(); +public: + MainWindow(); + ~MainWindow(); + void save_mappings(); + void load_mappings(); + static void set_working_directory(); +}; -- cgit v1.2.3