From ef3fd54e23228f4b75676189e9e2ad1faf726433 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 09:11:08 +0100 Subject: fix icon paths --- filter-accela/ftnoir_accela_filtercontrols.ui | 4 ++-- filter-kalman/ftnoir_kalman_filtercontrols.ui | 4 ++-- macosx/make-app-bundle.sh | 10 +++++----- protocol-ftn/ftnoir_ftncontrols.ui | 4 ++-- tracker-freepie-udp/freepie-udp-controls.ui | 2 +- tracker-joystick/ftnoir_tracker_joystick_controls.ui | 2 +- tracker-udp/ftnoir_ftnclientcontrols.ui | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/filter-accela/ftnoir_accela_filtercontrols.ui b/filter-accela/ftnoir_accela_filtercontrols.ui index 3ab9a78e..6ec6e751 100644 --- a/filter-accela/ftnoir_accela_filtercontrols.ui +++ b/filter-accela/ftnoir_accela_filtercontrols.ui @@ -17,7 +17,7 @@ Accela filter settings - + :/images/filter-16.png:/images/filter-16.png @@ -289,7 +289,7 @@ buttonBox - + diff --git a/filter-kalman/ftnoir_kalman_filtercontrols.ui b/filter-kalman/ftnoir_kalman_filtercontrols.ui index 69297102..df213815 100644 --- a/filter-kalman/ftnoir_kalman_filtercontrols.ui +++ b/filter-kalman/ftnoir_kalman_filtercontrols.ui @@ -23,7 +23,7 @@ Kalman settings - + :/images/filter-16.png:/images/filter-16.png @@ -88,7 +88,7 @@ - + diff --git a/macosx/make-app-bundle.sh b/macosx/make-app-bundle.sh index 1001af4a..d0afb790 100644 --- a/macosx/make-app-bundle.sh +++ b/macosx/make-app-bundle.sh @@ -24,11 +24,11 @@ mkdir "$tmp/$APPNAME.iconset" || exit 1 mkdir "$tmp/$APPNAME.app/Contents/Resources" || exit 1 cp "$dir"/opentrack.sh "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 -sips -z 16 16 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16.png" || exit 1 -sips -z 32 32 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16@2x.png" || exit 1 -sips -z 32 32 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_32x32.png" || exit 1 -sips -z 64 64 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_32x32@2x.png" || exit 1 -sips -z 128 128 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_128x128.png" || exit 1 +sips -z 16 16 "$dir/../gui/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16.png" || exit 1 +sips -z 32 32 "$dir/../gui/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16@2x.png" || exit 1 +sips -z 32 32 "$dir/../gui/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_32x32.png" || exit 1 +sips -z 64 64 "$dir/../gui/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_32x32@2x.png" || exit 1 +sips -z 128 128 "$dir/../gui/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_128x128.png" || exit 1 iconutil -c icns -o "$tmp/$APPNAME.app/Contents/Resources/$APPNAME.icns" "$tmp/$APPNAME.iconset" rm -r "$tmp/$APPNAME.iconset" diff --git a/protocol-ftn/ftnoir_ftncontrols.ui b/protocol-ftn/ftnoir_ftncontrols.ui index ca811e99..28f8ccdf 100644 --- a/protocol-ftn/ftnoir_ftncontrols.ui +++ b/protocol-ftn/ftnoir_ftncontrols.ui @@ -17,7 +17,7 @@ UDP protocol settings - + :/images/facetracknoir.png:/images/facetracknoir.png @@ -255,7 +255,7 @@ btnCancel - + diff --git a/tracker-freepie-udp/freepie-udp-controls.ui b/tracker-freepie-udp/freepie-udp-controls.ui index 74e5a6f1..c59b9781 100644 --- a/tracker-freepie-udp/freepie-udp-controls.ui +++ b/tracker-freepie-udp/freepie-udp-controls.ui @@ -18,7 +18,7 @@ - ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png + ../gui/images/facetracknoir.png../gui/images/facetracknoir.png diff --git a/tracker-joystick/ftnoir_tracker_joystick_controls.ui b/tracker-joystick/ftnoir_tracker_joystick_controls.ui index 88737023..ca41e35b 100644 --- a/tracker-joystick/ftnoir_tracker_joystick_controls.ui +++ b/tracker-joystick/ftnoir_tracker_joystick_controls.ui @@ -18,7 +18,7 @@ - ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png + ../gui/images/facetracknoir.png../gui/images/facetracknoir.png diff --git a/tracker-udp/ftnoir_ftnclientcontrols.ui b/tracker-udp/ftnoir_ftnclientcontrols.ui index cb9362ca..147c08e6 100644 --- a/tracker-udp/ftnoir_ftnclientcontrols.ui +++ b/tracker-udp/ftnoir_ftnclientcontrols.ui @@ -18,7 +18,7 @@ - ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png + ../gui/images/facetracknoir.png../gui/images/facetracknoir.png Qt::LeftToRight -- cgit v1.2.3 From 853a266b7ff8795771e56af72dc288ce4dd0d34d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 09:13:03 +0100 Subject: fix paths after rename --- protocol-fg/ftnoir_fgcontrols.ui | 7 ------- protocol-wine/CMakeLists.txt | 2 +- protocol-wine/ftnoir_protocol_wine.h | 2 +- protocol-wine/opentrack-wrapper-wine-main.cxx | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/protocol-fg/ftnoir_fgcontrols.ui b/protocol-fg/ftnoir_fgcontrols.ui index 575549d6..bd5b95c7 100644 --- a/protocol-fg/ftnoir_fgcontrols.ui +++ b/protocol-fg/ftnoir_fgcontrols.ui @@ -16,10 +16,6 @@ FlightGear protocol settings - - - :/images/filter-16.png:/images/filter-16.png - Qt::LeftToRight @@ -131,9 +127,6 @@ spinIPFourthNibble spinPortNumber - - - startEngineClicked() diff --git a/protocol-wine/CMakeLists.txt b/protocol-wine/CMakeLists.txt index 682e50de..db5eddb5 100644 --- a/protocol-wine/CMakeLists.txt +++ b/protocol-wine/CMakeLists.txt @@ -9,7 +9,7 @@ if(NOT WIN32) if(APPLE) set(my-rt) endif() - file(GLOB wine-deps ${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/*.cxx) + file(GLOB wine-deps ${CMAKE_SOURCE_DIR}/protocol-wine/*.cxx) add_custom_command( OUTPUT opentrack-wrapper-wine.exe.so DEPENDS ${wine-deps} diff --git a/protocol-wine/ftnoir_protocol_wine.h b/protocol-wine/ftnoir_protocol_wine.h index 2aeb4608..f1c556d9 100644 --- a/protocol-wine/ftnoir_protocol_wine.h +++ b/protocol-wine/ftnoir_protocol_wine.h @@ -10,7 +10,7 @@ #include #include "opentrack/plugin-api.hpp" #include "opentrack-compat/shm.h" -#include "ftnoir_protocol_wine/wine-shm.h" +#include "protocol-wine/wine-shm.h" class FTNoIR_Protocol : public IProtocol { diff --git a/protocol-wine/opentrack-wrapper-wine-main.cxx b/protocol-wine/opentrack-wrapper-wine-main.cxx index ffe8938d..875fc6ef 100644 --- a/protocol-wine/opentrack-wrapper-wine-main.cxx +++ b/protocol-wine/opentrack-wrapper-wine-main.cxx @@ -5,7 +5,7 @@ #endif #include #include "freetrackclient/fttypes.h" -#include "ftnoir_protocol_wine/wine-shm.h" +#include "protocol-wine/wine-shm.h" #include "opentrack-compat/export.hpp" enum Axis { -- cgit v1.2.3 From 05b2f05b72c706908e961eff8c0e4aa70dcadbd3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 09:14:39 +0100 Subject: fix paths harder --- protocol-wine/CMakeLists.txt | 2 +- protocol-wine/ftnoir_protocol_wine.h | 2 +- protocol-wine/opentrack-wrapper-wine-main.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol-wine/CMakeLists.txt b/protocol-wine/CMakeLists.txt index db5eddb5..bafcff8b 100644 --- a/protocol-wine/CMakeLists.txt +++ b/protocol-wine/CMakeLists.txt @@ -9,7 +9,7 @@ if(NOT WIN32) if(APPLE) set(my-rt) endif() - file(GLOB wine-deps ${CMAKE_SOURCE_DIR}/protocol-wine/*.cxx) + file(GLOB wine-deps ${PROJECT_SOURCE_DIR}/*.cxx) add_custom_command( OUTPUT opentrack-wrapper-wine.exe.so DEPENDS ${wine-deps} diff --git a/protocol-wine/ftnoir_protocol_wine.h b/protocol-wine/ftnoir_protocol_wine.h index f1c556d9..f78e1364 100644 --- a/protocol-wine/ftnoir_protocol_wine.h +++ b/protocol-wine/ftnoir_protocol_wine.h @@ -10,7 +10,7 @@ #include #include "opentrack/plugin-api.hpp" #include "opentrack-compat/shm.h" -#include "protocol-wine/wine-shm.h" +#include "wine-shm.h" class FTNoIR_Protocol : public IProtocol { diff --git a/protocol-wine/opentrack-wrapper-wine-main.cxx b/protocol-wine/opentrack-wrapper-wine-main.cxx index 875fc6ef..082e5dde 100644 --- a/protocol-wine/opentrack-wrapper-wine-main.cxx +++ b/protocol-wine/opentrack-wrapper-wine-main.cxx @@ -5,7 +5,7 @@ #endif #include #include "freetrackclient/fttypes.h" -#include "protocol-wine/wine-shm.h" +#include "wine-shm.h" #include "opentrack-compat/export.hpp" enum Axis { -- cgit v1.2.3 From 0739d5b595be9492c1e574192eba12174111e52c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 09:16:32 +0100 Subject: also rename protocol -> proto --- CMakeLists.txt | 2 +- proto-fg/CMakeLists.txt | 1 + proto-fg/fg-protocol.qrc | 5 + proto-fg/fgtypes.h | 27 +++ proto-fg/ftnoir_fgcontrols.ui | 136 +++++++++++ proto-fg/ftnoir_protocol_fg.cpp | 38 +++ proto-fg/ftnoir_protocol_fg.h | 69 ++++++ proto-fg/ftnoir_protocol_fg_dialog.cpp | 46 ++++ proto-fg/images/flightgear.png | Bin 0 -> 979 bytes proto-fsuipc/CMakeLists.txt | 11 + proto-fsuipc/fsuipc-protocol.qrc | 5 + proto-fsuipc/ftnoir_fsuipccontrols.ui | 134 +++++++++++ proto-fsuipc/ftnoir_protocol_fsuipc.cpp | 149 ++++++++++++ proto-fsuipc/ftnoir_protocol_fsuipc.h | 90 +++++++ proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp | 43 ++++ proto-fsuipc/images/fs9.png | Bin 0 -> 758 bytes proto-fsuipc/images/fs91.png | Bin 0 -> 1644 bytes proto-ft/CMakeLists.txt | 4 + proto-ft/ft-protocol.qrc | 5 + proto-ft/ftnoir_ftcontrols.ui | 182 ++++++++++++++ proto-ft/ftnoir_protocol_ft.cpp | 166 +++++++++++++ proto-ft/ftnoir_protocol_ft.h | 90 +++++++ proto-ft/ftnoir_protocol_ft_dialog.cpp | 60 +++++ proto-ft/images/freetrack.png | Bin 0 -> 1773 bytes proto-ftn/CMakeLists.txt | 1 + proto-ftn/ftnoir_ftncontrols.ui | 266 +++++++++++++++++++++ proto-ftn/ftnoir_protocol_ftn.cpp | 34 +++ proto-ftn/ftnoir_protocol_ftn.h | 69 ++++++ proto-ftn/ftnoir_protocol_ftn_dialog.cpp | 42 ++++ proto-libevdev/CMakeLists.txt | 10 + proto-libevdev/ftnoir_libevdev_controls.ui | 111 +++++++++ proto-libevdev/ftnoir_protocol_libevdev.cpp | 97 ++++++++ proto-libevdev/ftnoir_protocol_libevdev.h | 57 +++++ proto-libevdev/ftnoir_protocol_libevdev_dialog.cpp | 21 ++ proto-libevdev/images/linux.png | Bin 0 -> 668 bytes proto-libevdev/libevdev-protocol.qrc | 5 + proto-mouse/CMakeLists.txt | 3 + proto-mouse/ftnoir_mousecontrols.ui | 188 +++++++++++++++ proto-mouse/ftnoir_protocol_mouse.cpp | 54 +++++ proto-mouse/ftnoir_protocol_mouse.h | 59 +++++ proto-mouse/ftnoir_protocol_mouse_dialog.cpp | 24 ++ proto-mouse/images/mouse.png | Bin 0 -> 1169 bytes proto-mouse/win32-mouse-protocol.qrc | 5 + proto-sc/CMakeLists.txt | 3 + proto-sc/ftnoir-protocol-sc.rc | 4 + proto-sc/ftnoir_protocol_sc.cpp | 189 +++++++++++++++ proto-sc/ftnoir_protocol_sc.h | 108 +++++++++ proto-sc/ftnoir_protocol_sc_dialog.cpp | 35 +++ proto-sc/ftnoir_sccontrols.ui | 72 ++++++ proto-sc/images/fsx.png | Bin 0 -> 813 bytes proto-sc/images/fsx1.png | Bin 0 -> 1920 bytes proto-sc/sc-protocol.qrc | 5 + proto-sc/scserver.manifest | 13 + proto-sc/scserver_acceleration.manifest | 13 + proto-sc/scserver_sp2.manifest | 13 + proto-vjoy/CMakeLists.txt | 14 ++ proto-vjoy/ftnoir_protocol_vjoy.cpp | 33 +++ proto-vjoy/ftnoir_protocol_vjoy.h | 91 +++++++ proto-vjoy/ftnoir_protocol_vjoy_dialog.cpp | 22 ++ proto-vjoy/ftnoir_vjoy_controls.ui | 113 +++++++++ proto-vjoy/images/vjoy.png | Bin 0 -> 694 bytes proto-vjoy/vjoy-protocol.qrc | 5 + proto-vjoy/vjoy.def | 5 + proto-wine/CMakeLists.txt | 26 ++ proto-wine/ftnoir_protocol_wine.cpp | 59 +++++ proto-wine/ftnoir_protocol_wine.h | 57 +++++ proto-wine/ftnoir_protocol_wine_dialog.cpp | 19 ++ proto-wine/ftnoir_winecontrols.ui | 170 +++++++++++++ proto-wine/images/wine.png | Bin 0 -> 376 bytes proto-wine/opentrack-wrapper-wine-main.cxx | 80 +++++++ proto-wine/opentrack-wrapper-wine-posix.cxx | 7 + proto-wine/opentrack-wrapper-wine-windows.cxx | 40 ++++ proto-wine/wine-protocol.qrc | 5 + proto-wine/wine-shm.h | 20 ++ protocol-fg/CMakeLists.txt | 1 - protocol-fg/fg-protocol.qrc | 5 - protocol-fg/fgtypes.h | 27 --- protocol-fg/ftnoir_fgcontrols.ui | 136 ----------- protocol-fg/ftnoir_protocol_fg.cpp | 38 --- protocol-fg/ftnoir_protocol_fg.h | 69 ------ protocol-fg/ftnoir_protocol_fg_dialog.cpp | 46 ---- protocol-fg/images/flightgear.png | Bin 979 -> 0 bytes protocol-fsuipc/CMakeLists.txt | 11 - protocol-fsuipc/fsuipc-protocol.qrc | 5 - protocol-fsuipc/ftnoir_fsuipccontrols.ui | 134 ----------- protocol-fsuipc/ftnoir_protocol_fsuipc.cpp | 149 ------------ protocol-fsuipc/ftnoir_protocol_fsuipc.h | 90 ------- protocol-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp | 43 ---- protocol-fsuipc/images/fs9.png | Bin 758 -> 0 bytes protocol-fsuipc/images/fs91.png | Bin 1644 -> 0 bytes protocol-ft/CMakeLists.txt | 4 - protocol-ft/ft-protocol.qrc | 5 - protocol-ft/ftnoir_ftcontrols.ui | 182 -------------- protocol-ft/ftnoir_protocol_ft.cpp | 166 ------------- protocol-ft/ftnoir_protocol_ft.h | 90 ------- protocol-ft/ftnoir_protocol_ft_dialog.cpp | 60 ----- protocol-ft/images/freetrack.png | Bin 1773 -> 0 bytes protocol-ftn/CMakeLists.txt | 1 - protocol-ftn/ftnoir_ftncontrols.ui | 266 --------------------- protocol-ftn/ftnoir_protocol_ftn.cpp | 34 --- protocol-ftn/ftnoir_protocol_ftn.h | 69 ------ protocol-ftn/ftnoir_protocol_ftn_dialog.cpp | 42 ---- protocol-libevdev/CMakeLists.txt | 10 - protocol-libevdev/ftnoir_libevdev_controls.ui | 111 --------- protocol-libevdev/ftnoir_protocol_libevdev.cpp | 97 -------- protocol-libevdev/ftnoir_protocol_libevdev.h | 57 ----- .../ftnoir_protocol_libevdev_dialog.cpp | 21 -- protocol-libevdev/images/linux.png | Bin 668 -> 0 bytes protocol-libevdev/libevdev-protocol.qrc | 5 - protocol-mouse/CMakeLists.txt | 3 - protocol-mouse/ftnoir_mousecontrols.ui | 188 --------------- protocol-mouse/ftnoir_protocol_mouse.cpp | 54 ----- protocol-mouse/ftnoir_protocol_mouse.h | 59 ----- protocol-mouse/ftnoir_protocol_mouse_dialog.cpp | 24 -- protocol-mouse/images/mouse.png | Bin 1169 -> 0 bytes protocol-mouse/win32-mouse-protocol.qrc | 5 - protocol-sc/CMakeLists.txt | 3 - protocol-sc/ftnoir-protocol-sc.rc | 4 - protocol-sc/ftnoir_protocol_sc.cpp | 189 --------------- protocol-sc/ftnoir_protocol_sc.h | 108 --------- protocol-sc/ftnoir_protocol_sc_dialog.cpp | 35 --- protocol-sc/ftnoir_sccontrols.ui | 72 ------ protocol-sc/images/fsx.png | Bin 813 -> 0 bytes protocol-sc/images/fsx1.png | Bin 1920 -> 0 bytes protocol-sc/sc-protocol.qrc | 5 - protocol-sc/scserver.manifest | 13 - protocol-sc/scserver_acceleration.manifest | 13 - protocol-sc/scserver_sp2.manifest | 13 - protocol-vjoy/CMakeLists.txt | 14 -- protocol-vjoy/ftnoir_protocol_vjoy.cpp | 33 --- protocol-vjoy/ftnoir_protocol_vjoy.h | 91 ------- protocol-vjoy/ftnoir_protocol_vjoy_dialog.cpp | 22 -- protocol-vjoy/ftnoir_vjoy_controls.ui | 113 --------- protocol-vjoy/images/vjoy.png | Bin 694 -> 0 bytes protocol-vjoy/vjoy-protocol.qrc | 5 - protocol-vjoy/vjoy.def | 5 - protocol-wine/CMakeLists.txt | 26 -- protocol-wine/ftnoir_protocol_wine.cpp | 59 ----- protocol-wine/ftnoir_protocol_wine.h | 57 ----- protocol-wine/ftnoir_protocol_wine_dialog.cpp | 19 -- protocol-wine/ftnoir_winecontrols.ui | 170 ------------- protocol-wine/images/wine.png | Bin 376 -> 0 bytes protocol-wine/opentrack-wrapper-wine-main.cxx | 80 ------- protocol-wine/opentrack-wrapper-wine-posix.cxx | 7 - protocol-wine/opentrack-wrapper-wine-windows.cxx | 40 ---- protocol-wine/wine-protocol.qrc | 5 - protocol-wine/wine-shm.h | 20 -- 147 files changed, 3529 insertions(+), 3529 deletions(-) create mode 100644 proto-fg/CMakeLists.txt create mode 100644 proto-fg/fg-protocol.qrc create mode 100644 proto-fg/fgtypes.h create mode 100644 proto-fg/ftnoir_fgcontrols.ui create mode 100644 proto-fg/ftnoir_protocol_fg.cpp create mode 100644 proto-fg/ftnoir_protocol_fg.h create mode 100644 proto-fg/ftnoir_protocol_fg_dialog.cpp create mode 100644 proto-fg/images/flightgear.png create mode 100644 proto-fsuipc/CMakeLists.txt create mode 100644 proto-fsuipc/fsuipc-protocol.qrc create mode 100644 proto-fsuipc/ftnoir_fsuipccontrols.ui create mode 100644 proto-fsuipc/ftnoir_protocol_fsuipc.cpp create mode 100644 proto-fsuipc/ftnoir_protocol_fsuipc.h create mode 100644 proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp create mode 100644 proto-fsuipc/images/fs9.png create mode 100644 proto-fsuipc/images/fs91.png create mode 100644 proto-ft/CMakeLists.txt create mode 100644 proto-ft/ft-protocol.qrc create mode 100644 proto-ft/ftnoir_ftcontrols.ui create mode 100644 proto-ft/ftnoir_protocol_ft.cpp create mode 100644 proto-ft/ftnoir_protocol_ft.h create mode 100644 proto-ft/ftnoir_protocol_ft_dialog.cpp create mode 100644 proto-ft/images/freetrack.png create mode 100644 proto-ftn/CMakeLists.txt create mode 100644 proto-ftn/ftnoir_ftncontrols.ui create mode 100644 proto-ftn/ftnoir_protocol_ftn.cpp create mode 100644 proto-ftn/ftnoir_protocol_ftn.h create mode 100644 proto-ftn/ftnoir_protocol_ftn_dialog.cpp create mode 100644 proto-libevdev/CMakeLists.txt create mode 100644 proto-libevdev/ftnoir_libevdev_controls.ui create mode 100644 proto-libevdev/ftnoir_protocol_libevdev.cpp create mode 100644 proto-libevdev/ftnoir_protocol_libevdev.h create mode 100644 proto-libevdev/ftnoir_protocol_libevdev_dialog.cpp create mode 100644 proto-libevdev/images/linux.png create mode 100644 proto-libevdev/libevdev-protocol.qrc create mode 100644 proto-mouse/CMakeLists.txt create mode 100644 proto-mouse/ftnoir_mousecontrols.ui create mode 100644 proto-mouse/ftnoir_protocol_mouse.cpp create mode 100644 proto-mouse/ftnoir_protocol_mouse.h create mode 100644 proto-mouse/ftnoir_protocol_mouse_dialog.cpp create mode 100644 proto-mouse/images/mouse.png create mode 100644 proto-mouse/win32-mouse-protocol.qrc create mode 100644 proto-sc/CMakeLists.txt create mode 100644 proto-sc/ftnoir-protocol-sc.rc create mode 100644 proto-sc/ftnoir_protocol_sc.cpp create mode 100644 proto-sc/ftnoir_protocol_sc.h create mode 100644 proto-sc/ftnoir_protocol_sc_dialog.cpp create mode 100644 proto-sc/ftnoir_sccontrols.ui create mode 100644 proto-sc/images/fsx.png create mode 100644 proto-sc/images/fsx1.png create mode 100644 proto-sc/sc-protocol.qrc create mode 100644 proto-sc/scserver.manifest create mode 100644 proto-sc/scserver_acceleration.manifest create mode 100644 proto-sc/scserver_sp2.manifest create mode 100644 proto-vjoy/CMakeLists.txt create mode 100644 proto-vjoy/ftnoir_protocol_vjoy.cpp create mode 100644 proto-vjoy/ftnoir_protocol_vjoy.h create mode 100644 proto-vjoy/ftnoir_protocol_vjoy_dialog.cpp create mode 100644 proto-vjoy/ftnoir_vjoy_controls.ui create mode 100644 proto-vjoy/images/vjoy.png create mode 100644 proto-vjoy/vjoy-protocol.qrc create mode 100644 proto-vjoy/vjoy.def create mode 100644 proto-wine/CMakeLists.txt create mode 100644 proto-wine/ftnoir_protocol_wine.cpp create mode 100644 proto-wine/ftnoir_protocol_wine.h create mode 100644 proto-wine/ftnoir_protocol_wine_dialog.cpp create mode 100644 proto-wine/ftnoir_winecontrols.ui create mode 100644 proto-wine/images/wine.png create mode 100644 proto-wine/opentrack-wrapper-wine-main.cxx create mode 100644 proto-wine/opentrack-wrapper-wine-posix.cxx create mode 100644 proto-wine/opentrack-wrapper-wine-windows.cxx create mode 100644 proto-wine/wine-protocol.qrc create mode 100644 proto-wine/wine-shm.h delete mode 100644 protocol-fg/CMakeLists.txt delete mode 100644 protocol-fg/fg-protocol.qrc delete mode 100644 protocol-fg/fgtypes.h delete mode 100644 protocol-fg/ftnoir_fgcontrols.ui delete mode 100644 protocol-fg/ftnoir_protocol_fg.cpp delete mode 100644 protocol-fg/ftnoir_protocol_fg.h delete mode 100644 protocol-fg/ftnoir_protocol_fg_dialog.cpp delete mode 100644 protocol-fg/images/flightgear.png delete mode 100644 protocol-fsuipc/CMakeLists.txt delete mode 100644 protocol-fsuipc/fsuipc-protocol.qrc delete mode 100644 protocol-fsuipc/ftnoir_fsuipccontrols.ui delete mode 100644 protocol-fsuipc/ftnoir_protocol_fsuipc.cpp delete mode 100644 protocol-fsuipc/ftnoir_protocol_fsuipc.h delete mode 100644 protocol-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp delete mode 100644 protocol-fsuipc/images/fs9.png delete mode 100644 protocol-fsuipc/images/fs91.png delete mode 100644 protocol-ft/CMakeLists.txt delete mode 100644 protocol-ft/ft-protocol.qrc delete mode 100644 protocol-ft/ftnoir_ftcontrols.ui delete mode 100644 protocol-ft/ftnoir_protocol_ft.cpp delete mode 100644 protocol-ft/ftnoir_protocol_ft.h delete mode 100644 protocol-ft/ftnoir_protocol_ft_dialog.cpp delete mode 100644 protocol-ft/images/freetrack.png delete mode 100644 protocol-ftn/CMakeLists.txt delete mode 100644 protocol-ftn/ftnoir_ftncontrols.ui delete mode 100644 protocol-ftn/ftnoir_protocol_ftn.cpp delete mode 100644 protocol-ftn/ftnoir_protocol_ftn.h delete mode 100644 protocol-ftn/ftnoir_protocol_ftn_dialog.cpp delete mode 100644 protocol-libevdev/CMakeLists.txt delete mode 100644 protocol-libevdev/ftnoir_libevdev_controls.ui delete mode 100644 protocol-libevdev/ftnoir_protocol_libevdev.cpp delete mode 100644 protocol-libevdev/ftnoir_protocol_libevdev.h delete mode 100644 protocol-libevdev/ftnoir_protocol_libevdev_dialog.cpp delete mode 100644 protocol-libevdev/images/linux.png delete mode 100644 protocol-libevdev/libevdev-protocol.qrc delete mode 100644 protocol-mouse/CMakeLists.txt delete mode 100644 protocol-mouse/ftnoir_mousecontrols.ui delete mode 100644 protocol-mouse/ftnoir_protocol_mouse.cpp delete mode 100644 protocol-mouse/ftnoir_protocol_mouse.h delete mode 100644 protocol-mouse/ftnoir_protocol_mouse_dialog.cpp delete mode 100644 protocol-mouse/images/mouse.png delete mode 100644 protocol-mouse/win32-mouse-protocol.qrc delete mode 100644 protocol-sc/CMakeLists.txt delete mode 100644 protocol-sc/ftnoir-protocol-sc.rc delete mode 100644 protocol-sc/ftnoir_protocol_sc.cpp delete mode 100644 protocol-sc/ftnoir_protocol_sc.h delete mode 100644 protocol-sc/ftnoir_protocol_sc_dialog.cpp delete mode 100644 protocol-sc/ftnoir_sccontrols.ui delete mode 100644 protocol-sc/images/fsx.png delete mode 100644 protocol-sc/images/fsx1.png delete mode 100644 protocol-sc/sc-protocol.qrc delete mode 100644 protocol-sc/scserver.manifest delete mode 100644 protocol-sc/scserver_acceleration.manifest delete mode 100644 protocol-sc/scserver_sp2.manifest delete mode 100644 protocol-vjoy/CMakeLists.txt delete mode 100644 protocol-vjoy/ftnoir_protocol_vjoy.cpp delete mode 100644 protocol-vjoy/ftnoir_protocol_vjoy.h delete mode 100644 protocol-vjoy/ftnoir_protocol_vjoy_dialog.cpp delete mode 100644 protocol-vjoy/ftnoir_vjoy_controls.ui delete mode 100644 protocol-vjoy/images/vjoy.png delete mode 100644 protocol-vjoy/vjoy-protocol.qrc delete mode 100644 protocol-vjoy/vjoy.def delete mode 100644 protocol-wine/CMakeLists.txt delete mode 100644 protocol-wine/ftnoir_protocol_wine.cpp delete mode 100644 protocol-wine/ftnoir_protocol_wine.h delete mode 100644 protocol-wine/ftnoir_protocol_wine_dialog.cpp delete mode 100644 protocol-wine/ftnoir_winecontrols.ui delete mode 100644 protocol-wine/images/wine.png delete mode 100644 protocol-wine/opentrack-wrapper-wine-main.cxx delete mode 100644 protocol-wine/opentrack-wrapper-wine-posix.cxx delete mode 100644 protocol-wine/opentrack-wrapper-wine-windows.cxx delete mode 100644 protocol-wine/wine-protocol.qrc delete mode 100644 protocol-wine/wine-shm.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 06634b06..aa6f988e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include(opentrack-install) set(C CMakeLists.txt) file(GLOB opentrack-subprojects "tracker-*/${C}" - "protocol-*/${C}" + "proto-*/${C}" "filter-*/${C}" "opentrack*/${C}" "gui/${C}" diff --git a/proto-fg/CMakeLists.txt b/proto-fg/CMakeLists.txt new file mode 100644 index 00000000..151b30ee --- /dev/null +++ b/proto-fg/CMakeLists.txt @@ -0,0 +1 @@ +opentrack_boilerplate(opentrack-proto-fgfs) diff --git a/proto-fg/fg-protocol.qrc b/proto-fg/fg-protocol.qrc new file mode 100644 index 00000000..1c685437 --- /dev/null +++ b/proto-fg/fg-protocol.qrc @@ -0,0 +1,5 @@ + + + images/flightgear.png + + diff --git a/proto-fg/fgtypes.h b/proto-fg/fgtypes.h new file mode 100644 index 00000000..2e493f46 --- /dev/null +++ b/proto-fg/fgtypes.h @@ -0,0 +1,27 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* Type definitions for the FlightGear server. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FGTYPES_H +#define INCLUDED_FGTYPES_H + +// +// x,y,z position in metres, heading, pitch and roll in degrees... +// +#pragma pack(push, 2) +struct TFlightGearData { + double x, y, z, h, p, r; + int status; +}; +#pragma pack(pop) + +#endif//INCLUDED_FGTYPES_H diff --git a/proto-fg/ftnoir_fgcontrols.ui b/proto-fg/ftnoir_fgcontrols.ui new file mode 100644 index 00000000..bd5b95c7 --- /dev/null +++ b/proto-fg/ftnoir_fgcontrols.ui @@ -0,0 +1,136 @@ + + + UICFGControls + + + Qt::NonModal + + + + 0 + 0 + 415 + 112 + + + + FlightGear protocol settings + + + Qt::LeftToRight + + + false + + + + + + IP-address remote PC + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/proto-fg/ftnoir_protocol_fg.cpp b/proto-fg/ftnoir_protocol_fg.cpp new file mode 100644 index 00000000..660a7352 --- /dev/null +++ b/proto-fg/ftnoir_protocol_fg.cpp @@ -0,0 +1,38 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ftnoir_protocol_fg.h" +#include "opentrack/plugin-api.hpp" + +// For Todd and Arda Kutlu + +void FTNoIR_Protocol::pose(const double* headpose) { + FlightData.x = headpose[TX] * 1e-2; + FlightData.y = headpose[TY] * 1e-2; + FlightData.z = headpose[TZ] * 1e-2; + FlightData.p = headpose[Pitch]; + FlightData.h = headpose[Yaw]; + FlightData.r = headpose[Roll]; + FlightData.status = 1; + QHostAddress destIP(QString("%1.%2.%3.%4").arg( + QString::number(static_cast(s.ip1)), + QString::number(static_cast(s.ip2)), + QString::number(static_cast(s.ip3)), + QString::number(static_cast(s.ip4)))); + int destPort = s.port; + (void) outSocket.writeDatagram(reinterpret_cast(&FlightData), sizeof(FlightData), destIP, static_cast(destPort)); +} + +bool FTNoIR_Protocol::correct() +{ + return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FGControls, FTNoIR_ProtocolDll) diff --git a/proto-fg/ftnoir_protocol_fg.h b/proto-fg/ftnoir_protocol_fg.h new file mode 100644 index 00000000..de528270 --- /dev/null +++ b/proto-fg/ftnoir_protocol_fg.h @@ -0,0 +1,69 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ui_ftnoir_fgcontrols.h" +#include "fgtypes.h" +#include +#include +#include +#include "opentrack/plugin-api.hpp" +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value ip1, ip2, ip3, ip4; + value port; + settings() : + opts("flightgear-proto"), + ip1(b, "ip1", 192), + ip2(b, "ip2", 168), + ip3(b, "ip3", 0), + ip4(b, "ip4", 2), + port(b, "port", 5542) + {} +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: + bool correct(); + void pose(const double *headpose); + QString game_name() { + return "FlightGear"; + } +private: + settings s; + TFlightGearData FlightData; + QUdpSocket outSocket; +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FGControls: public IProtocolDialog +{ + Q_OBJECT +public: + FGControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} +private: + Ui::UICFGControls ui; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("FlightGear"); } + QIcon icon() { return QIcon(":/images/flightgear.png"); } +}; diff --git a/proto-fg/ftnoir_protocol_fg_dialog.cpp b/proto-fg/ftnoir_protocol_fg_dialog.cpp new file mode 100644 index 00000000..1d583115 --- /dev/null +++ b/proto-fg/ftnoir_protocol_fg_dialog.cpp @@ -0,0 +1,46 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ftnoir_protocol_fg.h" +#include +#include +#include "opentrack/plugin-api.hpp" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FGControls::FGControls() +{ + ui.setupUi( this ); + + tie_setting(s.ip1, ui.spinIPFirstNibble); + tie_setting(s.ip2, ui.spinIPSecondNibble); + tie_setting(s.ip3, ui.spinIPThirdNibble); + tie_setting(s.ip4, ui.spinIPFourthNibble); + tie_setting(s.port, ui.spinPortNumber); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); +} + +void FGControls::doOK() { + s.b->save(); + this->close(); +} + +void FGControls::doCancel() { + s.b->reload(); + this->close(); +} + diff --git a/proto-fg/images/flightgear.png b/proto-fg/images/flightgear.png new file mode 100644 index 00000000..2a546642 Binary files /dev/null and b/proto-fg/images/flightgear.png differ diff --git a/proto-fsuipc/CMakeLists.txt b/proto-fsuipc/CMakeLists.txt new file mode 100644 index 00000000..ec897ae8 --- /dev/null +++ b/proto-fsuipc/CMakeLists.txt @@ -0,0 +1,11 @@ +if(WIN32) + set(SDK_FSUIPC "" CACHE PATH "FSUIPC for older MS FSX path") + if(SDK_FSUIPC) + opentrack_boilerplate(opentrack-proto-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() + endif() +endif() diff --git a/proto-fsuipc/fsuipc-protocol.qrc b/proto-fsuipc/fsuipc-protocol.qrc new file mode 100644 index 00000000..34756f84 --- /dev/null +++ b/proto-fsuipc/fsuipc-protocol.qrc @@ -0,0 +1,5 @@ + + + images/fs9.png + + diff --git a/proto-fsuipc/ftnoir_fsuipccontrols.ui b/proto-fsuipc/ftnoir_fsuipccontrols.ui new file mode 100644 index 00000000..637e4dba --- /dev/null +++ b/proto-fsuipc/ftnoir_fsuipccontrols.ui @@ -0,0 +1,134 @@ + + + UICFSUIPCControls + + + Qt::NonModal + + + + 0 + 0 + 512 + 100 + + + + FSUIPC settings FaceTrackNoIR + + + + images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + 230 + 0 + + + + Location of FSUIPC.dll + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + Location of FSUIPC.dll + + + + + + + The DLL should be located in the Modules/ directory of MS FS 2004 + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 35 + 16777215 + + + + ... + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/proto-fsuipc/ftnoir_protocol_fsuipc.cpp b/proto-fsuipc/ftnoir_protocol_fsuipc.cpp new file mode 100644 index 00000000..702a92d4 --- /dev/null +++ b/proto-fsuipc/ftnoir_protocol_fsuipc.cpp @@ -0,0 +1,149 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ftnoir_protocol_fsuipc.h" +#include "opentrack/plugin-api.hpp" + +FTNoIR_Protocol::FTNoIR_Protocol() +{ + prevPosX = 0.0f; + prevPosY = 0.0f; + prevPosZ = 0.0f; + prevRotX = 0.0f; + prevRotY = 0.0f; + prevRotZ = 0.0f; +} + +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + FSUIPC_Close(); + FSUIPCLib.unload(); +} + +int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { +double y; +double local_x; + + local_x = x; + if (local_x > max_x) { + local_x = max_x; + } + if (local_x < min_x) { + local_x = min_x; + } + y = ( 16383 * local_x ) / max_x; + + return (int) y; +} + +void FTNoIR_Protocol::pose(const double *headpose ) { + DWORD result; + TFSState pitch; + TFSState yaw; + TFSState roll; + WORD FSZoom; + + float virtPosX; + float virtPosY; + float virtPosZ; + + float virtRotX; + float virtRotY; + float virtRotZ; + +// qDebug() << "FSUIPCServer::run() says: started!"; + + virtRotX = -headpose[Pitch]; // degrees + virtRotY = headpose[Yaw]; + virtRotZ = headpose[Roll]; + + virtPosX = 0.0f; // cm, X and Y are not working for FS2002/2004! + virtPosY = 0.0f; + virtPosZ = headpose[TZ]; + + // + // Init. the FSUIPC offsets (derived from Free-track...) + // + pitch.Control = 66503; + yaw.Control = 66504; + roll.Control = 66505; + + // + // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. + // + if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || + (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { + // + // Open the connection + // + FSUIPC_Open(SIM_ANY, &result); + + // + // Check the FS-version + // + if (((result == FSUIPC_ERR_OK) || (result == FSUIPC_ERR_OPEN)) && + ((FSUIPC_FS_Version == SIM_FS2K2) || (FSUIPC_FS_Version == SIM_FS2K4))) { +// qDebug() << "FSUIPCServer::run() says: FSUIPC opened succesfully"; + // + // Write the 4! DOF-data to FS. Only rotations and zoom are possible. + // + pitch.Value = scale2AnalogLimits(virtRotX, -180, 180); + FSUIPC_Write(0x3110, 8, &pitch, &result); + + yaw.Value = scale2AnalogLimits(virtRotY, -180, 180); + FSUIPC_Write(0x3110, 8, &yaw, &result); + + roll.Value = scale2AnalogLimits(virtRotZ, -180, 180); + FSUIPC_Write(0x3110, 8, &roll, &result); + + FSZoom = (WORD) (64/50) * virtPosZ + 64; + FSUIPC_Write(0x832E, 2, &FSZoom, &result); + + // + // Write the data, in one go! + // + FSUIPC_Process(&result); + if (result == FSUIPC_ERR_SENDMSG) { + // FSUIPC checks for already open connections and returns FSUIPC_ERR_OPEN in that case + // the connection scope is global for the process. this is why above code doesn't + // leak resources or have logic errors. see: http://www.purebasic.fr/english/viewtopic.php?t=31112 + FSUIPC_Close(); + } + } + } + + prevPosX = virtPosX; + prevPosY = virtPosY; + prevPosZ = virtPosZ; + prevRotX = virtRotX; + prevRotY = virtRotY; + prevRotZ = virtRotZ; +} + +bool FTNoIR_Protocol::correct() +{ + qDebug() << "correct says: Starting Function"; + + // + // Load the DLL. + // + FSUIPCLib.setFileName( s.LocationOfDLL ); + if (FSUIPCLib.load() != true) { + qDebug() << "correct says: Error loading FSUIPC DLL"; + return false; + } + else { + qDebug() << "correct says: FSUIPC DLL loaded."; + } + + return true; +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FSUIPCControls, FTNoIR_ProtocolDll) diff --git a/proto-fsuipc/ftnoir_protocol_fsuipc.h b/proto-fsuipc/ftnoir_protocol_fsuipc.h new file mode 100644 index 00000000..c8e91a42 --- /dev/null +++ b/proto-fsuipc/ftnoir_protocol_fsuipc.h @@ -0,0 +1,90 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 +#ifndef INCLUDED_FSUIPCSERVER_H +#define INCLUDED_FSUIPCSERVER_H + +#include +#include +#include "FSUIPC_User.h" +#include "opentrack/plugin-api.hpp" +#include "ui_ftnoir_fsuipccontrols.h" +#include +#include +#include +#include +#include +#include +#include +#include "opentrack/options.hpp" +using namespace options; + +#define FSUIPC_FILENAME "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll" + +struct settings : opts { + value LocationOfDLL; + settings() : + opts("proto-fsuipc"), + LocationOfDLL(b, "dll-location", FSUIPC_FILENAME) + {} +}; + +#pragma pack(push,1) // All fields in structure must be byte aligned. +typedef struct +{ + int Control; // Control identifier + int Value; // Value of DOF +} TFSState; +#pragma pack(pop) + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol() override; + bool correct(); + void pose(const double* headpose); + QString game_name() { + return "Microsoft Flight Simulator X"; + } +private: + QLibrary FSUIPCLib; + double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; + static int scale2AnalogLimits( float x, float min_x, float max_x ); + settings s; +}; + +class FSUIPCControls: public IProtocolDialog +{ + Q_OBJECT +public: + FSUIPCControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} +private: + Ui::UICFSUIPCControls ui; + settings s; +private slots: + void doOK(); + void doCancel(); + void getLocationOfDLL(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("FSUIPC -- Microsoft FS2002/FS2004"); } + QIcon icon() { return QIcon(":/images/fs9.png"); } +}; + + +#endif//INCLUDED_FSUIPCSERVER_H +//END diff --git a/proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp new file mode 100644 index 00000000..d573420a --- /dev/null +++ b/proto-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -0,0 +1,43 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ftnoir_protocol_fsuipc.h" +#include "opentrack/plugin-api.hpp" + +FSUIPCControls::FSUIPCControls() +{ + ui.setupUi( this ); + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); + + tie_setting(s.LocationOfDLL, ui.txtLocationOfDLL); +} + +void FSUIPCControls::doOK() { + s.b->save(); + this->close(); +} + +void FSUIPCControls::doCancel() { + s.b->reload(); + close(); +} + +void FSUIPCControls::getLocationOfDLL() +{ + QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), + ui.txtLocationOfDLL->text(), + tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); + if (!fileName.isEmpty()) { + s.LocationOfDLL = fileName; + } +} + diff --git a/proto-fsuipc/images/fs9.png b/proto-fsuipc/images/fs9.png new file mode 100644 index 00000000..914c9dcb Binary files /dev/null and b/proto-fsuipc/images/fs9.png differ diff --git a/proto-fsuipc/images/fs91.png b/proto-fsuipc/images/fs91.png new file mode 100644 index 00000000..f9540d1d Binary files /dev/null and b/proto-fsuipc/images/fs91.png differ diff --git a/proto-ft/CMakeLists.txt b/proto-ft/CMakeLists.txt new file mode 100644 index 00000000..44f95ba3 --- /dev/null +++ b/proto-ft/CMakeLists.txt @@ -0,0 +1,4 @@ +if(WIN32) + opentrack_boilerplate(opentrack-proto-freetrack) + target_link_libraries(opentrack-proto-freetrack opentrack-csv opentrack-compat) +endif() diff --git a/proto-ft/ft-protocol.qrc b/proto-ft/ft-protocol.qrc new file mode 100644 index 00000000..c04959f0 --- /dev/null +++ b/proto-ft/ft-protocol.qrc @@ -0,0 +1,5 @@ + + + images/freetrack.png + + diff --git a/proto-ft/ftnoir_ftcontrols.ui b/proto-ft/ftnoir_ftcontrols.ui new file mode 100644 index 00000000..5356d2e5 --- /dev/null +++ b/proto-ft/ftnoir_ftcontrols.ui @@ -0,0 +1,182 @@ + + + UICFTControls + + + Qt::NonModal + + + true + + + + 0 + 0 + 422 + 305 + + + + + 0 + 0 + + + + + 0 + 0 + + + + freetrack protocol settings + + + + :/images/freetrack.png:/images/freetrack.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + TIRViews + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Qt::RightToLeft + + + Memory hacks + + + + + + + Only for very old and buggy old games such as CFS3. + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + + + + + 0 + 0 + + + + Repair NPClient location + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Locate DLL + + + + + + + Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically. + + + true + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + 0 + 0 + + + + Select interface + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + + + + Disable one of the protocols if game is confused by presence of both at the same time. + + + true + + + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp new file mode 100644 index 00000000..05253174 --- /dev/null +++ b/proto-ft/ftnoir_protocol_ft.cpp @@ -0,0 +1,166 @@ +/* Copyright (c) 2013-2015 Stanislaw Halik + * Copyright (c) 2015 Wim Vriend + * + * 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 "ftnoir_protocol_ft.h" +#include "csv/csv.h" + +FTNoIR_Protocol::FTNoIR_Protocol() : + shm(FREETRACK_HEAP, FREETRACK_MUTEX, sizeof(FTHeap)), + pMemData((FTHeap*) shm.ptr()), + viewsStart(nullptr), + viewsStop(nullptr), + intGameID(0) +{ +} + +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + if (viewsStop != NULL) { + viewsStop(); + FTIRViewsLib.unload(); + } + dummyTrackIR.terminate(); + dummyTrackIR.kill(); + dummyTrackIR.waitForFinished(50); +} + +void FTNoIR_Protocol::pose(const double* headpose) { + float yaw = -getRadsFromDegrees(headpose[Yaw]); + float pitch = -getRadsFromDegrees(headpose[Pitch]); + float roll = getRadsFromDegrees(headpose[Roll]); + float tx = headpose[TX] * 10.f; + float ty = headpose[TY] * 10.f; + float tz = headpose[TZ] * 10.f; + + FTHeap* ft = pMemData; + FTData* data = &ft->data; + + data->RawX = 0; + data->RawY = 0; + data->RawZ = 0; + data->RawPitch = 0; + data->RawYaw = 0; + data->RawRoll = 0; + + data->X = tx; + data->Y = ty; + data->Z = tz; + data->Yaw = yaw; + data->Pitch = pitch; + data->Roll = roll; + + data->X1 = data->DataID; + data->X2 = 0; + data->X3 = 0; + data->X4 = 0; + data->Y1 = 0; + data->Y2 = 0; + data->Y3 = 0; + data->Y4 = 0; + + int32_t id = ft->GameID; + + if (intGameID != id) + { + QString gamename; + { + unsigned char table[8]; + if (CSV::getGameData(id, table, gamename)) + for (int i = 0; i < 8; i++) pMemData->table[i] = table[i]; + } + ft->GameID2 = id; + intGameID = id; + QMutexLocker foo(&this->game_name_mutex); + connected_game = gamename; + } + + data->DataID += 1; +} + +void FTNoIR_Protocol::start_tirviews() { + QString aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; + if ( QFile::exists( aFileName )) { + FTIRViewsLib.setFileName(aFileName); + FTIRViewsLib.load(); + + viewsStart = (importTIRViewsStart) FTIRViewsLib.resolve("TIRViewsStart"); + if (viewsStart == NULL) { + qDebug() << "FTServer::run() says: TIRViewsStart function not found in DLL!"; + } + else { + qDebug() << "FTServer::run() says: TIRViewsStart executed!"; + viewsStart(); + } + + // + // Load the Stop function from TIRViews.dll. Call it when terminating the thread. + // + viewsStop = (importTIRViewsStop) FTIRViewsLib.resolve("TIRViewsStop"); + if (viewsStop == NULL) { + qDebug() << "FTServer::run() says: TIRViewsStop function not found in DLL!"; + } + } +} + +void FTNoIR_Protocol::start_dummy() { + + + QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe"; + dummyTrackIR.setProgram("\"" + program + "\""); + dummyTrackIR.start(); +} + +bool FTNoIR_Protocol::correct() +{ + // Registry settings (in HK_USER) + QSettings settings("Freetrack", "FreetrackClient"); + QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); + + if (!shm.success()) + return false; + + QString aLocation = QCoreApplication::applicationDirPath() + "/"; + + switch (s.intUsedInterface) { + case 0: + // Use both interfaces + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , aLocation ); + break; + case 1: + // Use FreeTrack, disable TrackIR + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , "" ); + break; + case 2: + // Use TrackIR, disable FreeTrack + settings.setValue( "Path" , "" ); + settingsTIR.setValue( "Path" , aLocation ); + break; + default: + break; + } + + if (s.useTIRViews) { + start_tirviews(); + } + + // more games need the dummy executable than previously thought + start_dummy(); + + pMemData->data.DataID = 1; + pMemData->data.CamWidth = 100; + pMemData->data.CamHeight = 250; + pMemData->GameID2 = 0; + for (int i = 0; i < 8; i++) + pMemData->table[i] = 0; + + return true; +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FTControls, FTNoIR_ProtocolDll) diff --git a/proto-ft/ftnoir_protocol_ft.h b/proto-ft/ftnoir_protocol_ft.h new file mode 100644 index 00000000..8e50f1cb --- /dev/null +++ b/proto-ft/ftnoir_protocol_ft.h @@ -0,0 +1,90 @@ +/* Copyright (c) 2013-2015 Stanislaw Halik + * Copyright (c) 2015 Wim Vriend + * + * 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 "ui_ftnoir_ftcontrols.h" +#include "opentrack/plugin-api.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "opentrack-compat/shm.h" +#include "opentrack/options.hpp" +#include "freetrackclient/fttypes.h" +using namespace options; + +struct settings : opts { + value intUsedInterface; + value useTIRViews; + settings() : + opts("proto-freetrack"), + intUsedInterface(b, "used-interfaces", 0), + useTIRViews(b, "use-memory-hacks", false) + {} +}; + +typedef void (__stdcall *importTIRViewsStart)(void); +typedef void (__stdcall *importTIRViewsStop)(void); + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol() override; + bool correct(); + void pose( const double *headpose ); + QString game_name() override { + QMutexLocker foo(&game_name_mutex); + return connected_game; + } +private: + settings s; + PortableLockedShm shm; + FTHeap *pMemData; + + QLibrary FTIRViewsLib; + QProcess dummyTrackIR; + importTIRViewsStart viewsStart; + importTIRViewsStop viewsStop; + + int intGameID; + QString connected_game; + QMutex game_name_mutex; + + static inline double getRadsFromDegrees(double degrees) { return degrees * 0.017453; } + void start_tirviews(); + void start_dummy(); +}; + +class FTControls: public IProtocolDialog +{ + Q_OBJECT +public: + FTControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} +private: + Ui::UICFTControls ui; + settings s; +private slots: + void selectDLL(); + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("freetrack 2.0 Enhanced"); } + QIcon icon() { return QIcon(":/images/freetrack.png"); } +}; diff --git a/proto-ft/ftnoir_protocol_ft_dialog.cpp b/proto-ft/ftnoir_protocol_ft_dialog.cpp new file mode 100644 index 00000000..25f3a4cb --- /dev/null +++ b/proto-ft/ftnoir_protocol_ft_dialog.cpp @@ -0,0 +1,60 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ftnoir_protocol_ft.h" +#include +#include + +FTControls::FTControls() +{ + ui.setupUi( this ); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); + + tie_setting(s.useTIRViews, ui.chkTIRViews); + + ui.cbxSelectInterface->addItem("Enable both"); + ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); + ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); + + tie_setting(s.intUsedInterface, ui.cbxSelectInterface); + + QFile memhacks_pathname(QCoreApplication::applicationDirPath() + "/TIRViews.dll"); + if (!memhacks_pathname.exists()) { + ui.chkTIRViews->setChecked( false ); + ui.chkTIRViews->setEnabled ( false ); + } + else { + ui.chkTIRViews->setEnabled ( true ); + } +} + +void FTControls::doOK() { + s.b->save(); + this->close(); +} + +void FTControls::doCancel() { + s.b->reload(); + this->close(); +} + +void FTControls::selectDLL() { + QString filename = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)")); + + if (! filename.isEmpty() ) { + QSettings node("NaturalPoint", "NATURALPOINT\\NPClient Location"); + QFileInfo dllname(filename); + node.setValue( "Path" , dllname.dir().path() ); + } +} + diff --git a/proto-ft/images/freetrack.png b/proto-ft/images/freetrack.png new file mode 100644 index 00000000..c184dc88 Binary files /dev/null and b/proto-ft/images/freetrack.png differ diff --git a/proto-ftn/CMakeLists.txt b/proto-ftn/CMakeLists.txt new file mode 100644 index 00000000..a0b74d9c --- /dev/null +++ b/proto-ftn/CMakeLists.txt @@ -0,0 +1 @@ +opentrack_boilerplate(opentrack-proto-udp) diff --git a/proto-ftn/ftnoir_ftncontrols.ui b/proto-ftn/ftnoir_ftncontrols.ui new file mode 100644 index 00000000..28f8ccdf --- /dev/null +++ b/proto-ftn/ftnoir_ftncontrols.ui @@ -0,0 +1,266 @@ + + + UICFTNControls + + + Qt::NonModal + + + + 0 + 0 + 411 + 169 + + + + UDP protocol settings + + + + :/images/facetracknoir.png:/images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + IP-address remote PC + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Enter IP-address and port-number for the remote PC. + + + true + + + + + + + Remember: you may have to change firewall-settings too! + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + btnOK + btnCancel + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/proto-ftn/ftnoir_protocol_ftn.cpp b/proto-ftn/ftnoir_protocol_ftn.cpp new file mode 100644 index 00000000..db852f55 --- /dev/null +++ b/proto-ftn/ftnoir_protocol_ftn.cpp @@ -0,0 +1,34 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ftnoir_protocol_ftn.h" +#include +#include "opentrack/plugin-api.hpp" + +FTNoIR_Protocol::FTNoIR_Protocol() +{ +} + +void FTNoIR_Protocol::pose(const double *headpose) { + int destPort = s.port; + QHostAddress destIP(QString("%1.%2.%3.%4").arg( + QString::number(static_cast(s.ip1)), + QString::number(static_cast(s.ip2)), + QString::number(static_cast(s.ip3)), + QString::number(static_cast(s.ip4)))); + outSocket.writeDatagram((const char *) headpose, sizeof( double[6] ), destIP, destPort); +} + +bool FTNoIR_Protocol::correct() +{ + return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FTNControls, FTNoIR_ProtocolDll) diff --git a/proto-ftn/ftnoir_protocol_ftn.h b/proto-ftn/ftnoir_protocol_ftn.h new file mode 100644 index 00000000..7fe6c225 --- /dev/null +++ b/proto-ftn/ftnoir_protocol_ftn.h @@ -0,0 +1,69 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ui_ftnoir_ftncontrols.h" +#include +#include +#include +#include +#include "opentrack/plugin-api.hpp" +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value ip1, ip2, ip3, ip4, port; + settings() : + opts("udp-proto"), + ip1(b, "ip1", 192), + ip2(b, "ip2", 168), + ip3(b, "ip3", 0), + ip4(b, "ip4", 2), + port(b, "port", 4242) + {} +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + bool correct(); + void pose(const double *headpose); + QString game_name() { + return "UDP Tracker"; + } +private: + QUdpSocket outSocket; + settings s; +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FTNControls: public IProtocolDialog +{ + Q_OBJECT +public: + FTNControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} +private: + Ui::UICFTNControls ui; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("UDP receiver"); } + QIcon icon() { return QIcon(":/images/facetracknoir.png"); } +}; diff --git a/proto-ftn/ftnoir_protocol_ftn_dialog.cpp b/proto-ftn/ftnoir_protocol_ftn_dialog.cpp new file mode 100644 index 00000000..77a1508a --- /dev/null +++ b/proto-ftn/ftnoir_protocol_ftn_dialog.cpp @@ -0,0 +1,42 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ftnoir_protocol_ftn.h" +#include "opentrack/plugin-api.hpp" + +FTNControls::FTNControls() +{ + ui.setupUi( this ); + + tie_setting(s.ip1, ui.spinIPFirstNibble); + tie_setting(s.ip2, ui.spinIPSecondNibble); + tie_setting(s.ip3, ui.spinIPThirdNibble); + tie_setting(s.ip4, ui.spinIPFourthNibble); + tie_setting(s.port, ui.spinPortNumber); + + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); +} + +// +// OK clicked on server-dialog +// +void FTNControls::doOK() { + s.b->save(); + this->close(); +} + +// +// Cancel clicked on server-dialog +// +void FTNControls::doCancel() { + s.b->reload(); + this->close(); +} diff --git a/proto-libevdev/CMakeLists.txt b/proto-libevdev/CMakeLists.txt new file mode 100644 index 00000000..960a1271 --- /dev/null +++ b/proto-libevdev/CMakeLists.txt @@ -0,0 +1,10 @@ +if(LINUX OR APPLE) + set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support") + if(SDK_ENABLE_LIBEVDEV) + include(FindPkgConfig) + opentrack_boilerplate(opentrack-proto-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() +endif() diff --git a/proto-libevdev/ftnoir_libevdev_controls.ui b/proto-libevdev/ftnoir_libevdev_controls.ui new file mode 100644 index 00000000..d2b86445 --- /dev/null +++ b/proto-libevdev/ftnoir_libevdev_controls.ui @@ -0,0 +1,111 @@ + + + UICLibevdevControls + + + Qt::NonModal + + + + 0 + 0 + 228 + 69 + + + + VJoy + + + + :/images/vjoy.png:/images/vjoy.png + + + Qt::LeftToRight + + + false + + + + + + Make sure rw for /dev/input/uinput! + + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + + + btnOK + btnCancel + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/proto-libevdev/ftnoir_protocol_libevdev.cpp b/proto-libevdev/ftnoir_protocol_libevdev.cpp new file mode 100644 index 00000000..96805b39 --- /dev/null +++ b/proto-libevdev/ftnoir_protocol_libevdev.cpp @@ -0,0 +1,97 @@ +#include "ftnoir_protocol_libevdev.h" +#include "opentrack/plugin-api.hpp" +#include +#include + +#include +#include + +#define CHECK_LIBEVDEV(expr) if ((error = (expr)) != 0) goto error; + +static const int max_input = 65535; +static const int mid_input = 32767; +static const int min_input = 0; + +FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) +{ + int error = 0; + + dev = libevdev_new(); + + if (!dev) + goto error; + + CHECK_LIBEVDEV(libevdev_enable_property(dev, INPUT_PROP_BUTTONPAD)); + + libevdev_set_name(dev, "opentrack headpose"); + + struct input_absinfo absinfo; + + absinfo.minimum = min_input; + absinfo.maximum = max_input; + absinfo.resolution = 1; + absinfo.value = mid_input; + absinfo.flat = 1; + absinfo.fuzz = 0; + + CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_ABS)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_X, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Y, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Z, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RX, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RY, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RZ, &absinfo)); + + /* do not remove next 3 lines or udev scripts won't assign 0664 permissions -sh */ + CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_KEY)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_KEY, BTN_JOYSTICK, NULL)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_KEY, BTN_TRIGGER, NULL)); + + CHECK_LIBEVDEV(libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &uidev)); + + return; +error: + if (uidev) + libevdev_uinput_destroy(uidev); + if (dev) + libevdev_free(dev); + if (error) + fprintf(stderr, "libevdev error: %d\n", error); + uidev = NULL; + dev = NULL; +} + +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + if (uidev) + libevdev_uinput_destroy(uidev); + if (dev) + libevdev_free(dev); +} + +void FTNoIR_Protocol::pose(const double* headpose) { + static const int axes[] = { + /* translation goes first */ + ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ + }; + + static const int max_value[] = { + 100, + 100, + 100, + 180, + 90, + 180 + }; + + for (int i = 0; i < 6; i++) + { + int value = headpose[i] * mid_input / max_value[i] + mid_input; + int normalized = std::max(std::min(max_input, value), min_input); + (void) libevdev_uinput_write_event(uidev, EV_ABS, axes[i], normalized); + } + + (void) libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0); +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, LibevdevControls, FTNoIR_ProtocolDll) diff --git a/proto-libevdev/ftnoir_protocol_libevdev.h b/proto-libevdev/ftnoir_protocol_libevdev.h new file mode 100644 index 00000000..ecb3b201 --- /dev/null +++ b/proto-libevdev/ftnoir_protocol_libevdev.h @@ -0,0 +1,57 @@ +/* Copyright (c) 2013 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 "ui_ftnoir_libevdev_controls.h" + +#include +#include "opentrack/plugin-api.hpp" + +extern "C" { +# include +# include +} + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol() override; + bool correct() { + return dev != NULL; + } + void pose(const double *headpose); + QString game_name() { + return "Virtual joystick for Linux"; + } +private: + struct libevdev* dev; + struct libevdev_uinput* uidev; +}; + +class LibevdevControls: public IProtocolDialog +{ + Q_OBJECT +public: + LibevdevControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} + +private: + Ui::UICLibevdevControls ui; + void save(); + +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("libevdev joystick receiver"); } + QIcon icon() { return QIcon(":/images/linux.png"); } +}; diff --git a/proto-libevdev/ftnoir_protocol_libevdev_dialog.cpp b/proto-libevdev/ftnoir_protocol_libevdev_dialog.cpp new file mode 100644 index 00000000..70495a8f --- /dev/null +++ b/proto-libevdev/ftnoir_protocol_libevdev_dialog.cpp @@ -0,0 +1,21 @@ +#include "ftnoir_protocol_libevdev.h" +#include "opentrack/plugin-api.hpp" + +LibevdevControls::LibevdevControls() +{ + ui.setupUi( this ); + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); +} + +void LibevdevControls::doOK() { + save(); + this->close(); +} + +void LibevdevControls::doCancel() { + this->close(); +} + +void LibevdevControls::save() { +} diff --git a/proto-libevdev/images/linux.png b/proto-libevdev/images/linux.png new file mode 100644 index 00000000..8836c0e2 Binary files /dev/null and b/proto-libevdev/images/linux.png differ diff --git a/proto-libevdev/libevdev-protocol.qrc b/proto-libevdev/libevdev-protocol.qrc new file mode 100644 index 00000000..70bb415f --- /dev/null +++ b/proto-libevdev/libevdev-protocol.qrc @@ -0,0 +1,5 @@ + + + images/linux.png + + diff --git a/proto-mouse/CMakeLists.txt b/proto-mouse/CMakeLists.txt new file mode 100644 index 00000000..b221c79c --- /dev/null +++ b/proto-mouse/CMakeLists.txt @@ -0,0 +1,3 @@ +if(WIN32) + opentrack_boilerplate(opentrack-proto-win32-mouse) +endif() diff --git a/proto-mouse/ftnoir_mousecontrols.ui b/proto-mouse/ftnoir_mousecontrols.ui new file mode 100644 index 00000000..b1f4bcf8 --- /dev/null +++ b/proto-mouse/ftnoir_mousecontrols.ui @@ -0,0 +1,188 @@ + + + UICMOUSEControls + + + Qt::NonModal + + + + 0 + 0 + 280 + 106 + + + + Mouse protocol settings + + + + :/images/mouse.png:/images/mouse.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + Map mouse X to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + None + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + None + + + + + X + + + + + Y + + + + + Z + + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + 0 + 0 + + + + Map mouse Y to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/proto-mouse/ftnoir_protocol_mouse.cpp b/proto-mouse/ftnoir_protocol_mouse.cpp new file mode 100644 index 00000000..c0a0a868 --- /dev/null +++ b/proto-mouse/ftnoir_protocol_mouse.cpp @@ -0,0 +1,54 @@ +/* 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 "ftnoir_protocol_mouse.h" +#include "opentrack/plugin-api.hpp" +#include + +#ifndef MOUSEEVENTF_MOVE_NOCOALESCE +# define MOUSEEVENTF_MOVE_NOCOALESCE 0x2000 +#endif + +void FTNoIR_Protocol::pose(const double *headpose ) { + RECT desktop; + const HWND hDesktop = GetDesktopWindow(); + if (hDesktop != NULL && GetWindowRect(hDesktop, &desktop)) { + // XXX TODO remove axis selector, use mapping window's + // axis selection. Mention in UI axis used. -sh 20140920 + int axis_x = s.Mouse_X; + int axis_y = s.Mouse_Y; + + int mouse_x = 0, mouse_y = 0; + + if (axis_x > 0 && axis_x <= 6) + mouse_x = headpose[axis_x-1] / (axis_x <= 3 ? 100 : 180) * 10 * desktop.right/2; + + if (axis_y > 0 && axis_y <= 6) + mouse_y = headpose[axis_y-1] / (axis_y <= 3 ? 100 : 180) * 10 * desktop.bottom/2; + + MOUSEINPUT mi; + mi.dx = mouse_x - last_x; + mi.dy = mouse_y - last_y; + mi.mouseData = 0; + mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_MOVE_NOCOALESCE; + mi.time = 0; + mi.dwExtraInfo = 0; + INPUT input; + input.type = INPUT_MOUSE; + input.mi = mi; + (void) SendInput(1, &input, sizeof(INPUT)); + + last_x = mouse_x; + last_y = mouse_y; + } +} + +bool FTNoIR_Protocol::correct() +{ + return true; +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, MOUSEControls, FTNoIR_ProtocolDll) diff --git a/proto-mouse/ftnoir_protocol_mouse.h b/proto-mouse/ftnoir_protocol_mouse.h new file mode 100644 index 00000000..595be393 --- /dev/null +++ b/proto-mouse/ftnoir_protocol_mouse.h @@ -0,0 +1,59 @@ +/* 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 "ui_ftnoir_mousecontrols.h" +#include +#include "opentrack/plugin-api.hpp" +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value Mouse_X, Mouse_Y; + settings() : + opts("mouse-proto"), + Mouse_X(b, "mouse-x", 0), + Mouse_Y(b, "mouse-y", 0) + {} +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol() : last_x(0), last_y(0) {} + bool correct(); + void pose( const double *headpose); + QString game_name() { + return "Mouse tracker"; + } + int last_x, last_y; +private: + struct settings s; +}; + +class MOUSEControls: public IProtocolDialog +{ + Q_OBJECT +public: + MOUSEControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} +private: + Ui::UICMOUSEControls ui; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("mouse emulation"); } + QIcon icon() { return QIcon(":/images/mouse.png"); } +}; diff --git a/proto-mouse/ftnoir_protocol_mouse_dialog.cpp b/proto-mouse/ftnoir_protocol_mouse_dialog.cpp new file mode 100644 index 00000000..bb5fe3b8 --- /dev/null +++ b/proto-mouse/ftnoir_protocol_mouse_dialog.cpp @@ -0,0 +1,24 @@ +#include "ftnoir_protocol_mouse.h" +#include "opentrack/plugin-api.hpp" + +MOUSEControls::MOUSEControls() +{ + ui.setupUi( this ); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + tie_setting(s.Mouse_X, ui.cbxSelectMouse_X); + tie_setting(s.Mouse_Y, ui.cbxSelectMouse_Y); +} + +void MOUSEControls::doOK() { + s.b->save(); + this->close(); +} + +void MOUSEControls::doCancel() { + s.b->reload(); + this->close(); +} + diff --git a/proto-mouse/images/mouse.png b/proto-mouse/images/mouse.png new file mode 100644 index 00000000..c6f9ea26 Binary files /dev/null and b/proto-mouse/images/mouse.png differ diff --git a/proto-mouse/win32-mouse-protocol.qrc b/proto-mouse/win32-mouse-protocol.qrc new file mode 100644 index 00000000..ed6a71be --- /dev/null +++ b/proto-mouse/win32-mouse-protocol.qrc @@ -0,0 +1,5 @@ + + + images/mouse.png + + diff --git a/proto-sc/CMakeLists.txt b/proto-sc/CMakeLists.txt new file mode 100644 index 00000000..bd83e944 --- /dev/null +++ b/proto-sc/CMakeLists.txt @@ -0,0 +1,3 @@ +if(WIN32) + opentrack_boilerplate(opentrack-proto-simconnect) +endif() diff --git a/proto-sc/ftnoir-protocol-sc.rc b/proto-sc/ftnoir-protocol-sc.rc new file mode 100644 index 00000000..c89eb9a7 --- /dev/null +++ b/proto-sc/ftnoir-protocol-sc.rc @@ -0,0 +1,4 @@ +#include +142 RT_MANIFEST scserver.manifest +143 RT_MANIFEST scserver_sp2.manifest +144 RT_MANIFEST scserver_acceleration.manifest \ No newline at end of file diff --git a/proto-sc/ftnoir_protocol_sc.cpp b/proto-sc/ftnoir_protocol_sc.cpp new file mode 100644 index 00000000..0c6cb486 --- /dev/null +++ b/proto-sc/ftnoir_protocol_sc.cpp @@ -0,0 +1,189 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend + * Copyright (c) 2014, 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 "ftnoir_protocol_sc.h" +#include "opentrack/plugin-api.hpp" + +FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr) +{ +} + +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + should_stop = true; + wait(); +} + +void FTNoIR_Protocol::run() +{ + HANDLE event = CreateEvent(NULL, FALSE, FALSE, nullptr); + + if (event == nullptr) + { + qDebug() << "simconnect: event create" << GetLastError(); + return; + } + + while (!should_stop) + { + if (SUCCEEDED(simconnect_open(&hSimConnect, "opentrack", NULL, 0, event, 0))) + { + simconnect_subscribetosystemevent(hSimConnect, 0, "Frame"); + + while (!should_stop) + { + if (WaitForSingleObject(event, 10) == WAIT_OBJECT_0) + { + if (FAILED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast(this)))) + break; + } + } + + (void) simconnect_close(hSimConnect); + } + + if (!should_stop) + Sleep(100); + } + + CloseHandle(event); +} + +void FTNoIR_Protocol::pose( const double *headpose ) { + virtSCRotX = -headpose[Pitch]; // degrees + virtSCRotY = headpose[Yaw]; + virtSCRotZ = headpose[Roll]; + + virtSCPosX = headpose[TX]/100.f; // cm to meters + virtSCPosY = headpose[TY]/100.f; + virtSCPosZ = -headpose[TZ]/100.f; +} + +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +class ActivationContext { +public: + ActivationContext(const int resid) : ok(false) { + hactctx = INVALID_HANDLE_VALUE; + actctx_cookie = 0; + ACTCTXA actx = {0}; + actx.cbSize = sizeof(ACTCTXA); + actx.lpResourceName = MAKEINTRESOURCEA(resid); + actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; +#ifdef _MSC_VER +# define PREFIX "" +#else +# define PREFIX "lib" +#endif + QString path = QCoreApplication::applicationDirPath() + "/" PREFIX "opentrack-proto-simconnect.dll"; + QByteArray name = QFile::encodeName(path); + actx.lpSource = name.constData(); + hactctx = CreateActCtxA(&actx); + actctx_cookie = 0; + if (hactctx != INVALID_HANDLE_VALUE) { + if (!ActivateActCtx(hactctx, &actctx_cookie)) { + qDebug() << "SC: can't set win32 activation context" << GetLastError(); + ReleaseActCtx(hactctx); + hactctx = INVALID_HANDLE_VALUE; + } + else + ok = true; + } else { + qDebug() << "SC: can't create win32 activation context" << GetLastError(); + } + } + ~ActivationContext() { + if (hactctx != INVALID_HANDLE_VALUE) + { + DeactivateActCtx(0, actctx_cookie); + ReleaseActCtx(hactctx); + } + } + bool is_ok() { return ok; } +private: + ULONG_PTR actctx_cookie; + HANDLE hactctx; + bool ok; +}; + +bool FTNoIR_Protocol::correct() +{ + if (!SCClientLib.isLoaded()) + { + ActivationContext ctx(142 + static_cast(s.sxs_manifest)); + + if (ctx.is_ok()) + { + SCClientLib.setFileName("SimConnect.dll"); + if (!SCClientLib.load()) { + qDebug() << "SC load" << SCClientLib.errorString(); + return false; + } + } + else + return false; + } + + simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open"); + if (simconnect_open == NULL) { + qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_Open function not found in DLL!"; + return false; + } + simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF"); + if (simconnect_set6DOF == NULL) { + qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_CameraSetRelative6DOF function not found in DLL!"; + return false; + } + simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close"); + if (simconnect_close == NULL) { + qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_Close function not found in DLL!"; + return false; + } + + simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch"); + if (simconnect_calldispatch == NULL) { + qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_CallDispatch function not found in DLL!"; + return false; + } + + simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent"); + if (simconnect_subscribetosystemevent == NULL) { + qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_SubscribeToSystemEvent function not found in DLL!"; + return false; + } + + start(); + + return true; +} + +void FTNoIR_Protocol::handle() +{ + (void) simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY); +} + +void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD, void *self_) +{ + FTNoIR_Protocol& self = *reinterpret_cast(self_); + + switch(pData->dwID) + { + default: + break; + case SIMCONNECT_RECV_ID_EVENT_FRAME: + self.handle(); + break; + } +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, SCControls, FTNoIR_ProtocolDll) diff --git a/proto-sc/ftnoir_protocol_sc.h b/proto-sc/ftnoir_protocol_sc.h new file mode 100644 index 00000000..671a3500 --- /dev/null +++ b/proto-sc/ftnoir_protocol_sc.h @@ -0,0 +1,108 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * Copyright (c) 2014, 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 "opentrack/plugin-api.hpp" + +#include "ui_ftnoir_sccontrols.h" +#include +#include +#include +#include +#include +#include +#include +#include "opentrack/options.hpp" +using namespace options; +#include + +struct settings : opts { + value sxs_manifest; + settings() : + opts("proto-simconnect"), + sxs_manifest(b, "sxs-manifest-version", 0) + {} +}; + +class FTNoIR_Protocol : public IProtocol, private QThread +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol() override; + bool correct(); + void pose(const double* headpose); + void handle(); + QString game_name() { + return "FS2004/FSX"; + } +private: + enum { SIMCONNECT_RECV_ID_EVENT_FRAME = 7 }; + + #pragma pack(push, 1) + struct SIMCONNECT_RECV + { + DWORD dwSize; + DWORD dwVersion; + DWORD dwID; + }; + #pragma pack(pop) + + typedef void (CALLBACK *DispatchProc)(SIMCONNECT_RECV*, DWORD, void*); + + typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); + typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); + typedef HRESULT (WINAPI *importSimConnect_CameraSetRelative6DOF)(HANDLE hSimConnect, float fDeltaX, float fDeltaY, float fDeltaZ, float fPitchDeg, float fBankDeg, float fHeadingDeg); + typedef HRESULT (WINAPI *importSimConnect_CallDispatch)(HANDLE hSimConnect, DispatchProc pfcnDispatch, void * pContext); + typedef HRESULT (WINAPI *importSimConnect_SubscribeToSystemEvent)(HANDLE hSimConnect, DWORD EventID, const char * SystemEventName); + + void run() override; + volatile bool should_stop; + + volatile float virtSCPosX; + volatile float virtSCPosY; + volatile float virtSCPosZ; + volatile float virtSCRotX; + volatile float virtSCRotY; + volatile float virtSCRotZ; + + importSimConnect_Open simconnect_open; + importSimConnect_Close simconnect_close; + importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; + importSimConnect_CallDispatch simconnect_calldispatch; + importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; + + HANDLE hSimConnect; + static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); + settings s; + QLibrary SCClientLib; +}; + +class SCControls: public IProtocolDialog +{ + Q_OBJECT +public: + SCControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} +private: + Ui::UICSCControls ui; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("Microsoft FSX SimConnect"); } + QIcon icon() { return QIcon(":/images/fsx.png"); } +}; diff --git a/proto-sc/ftnoir_protocol_sc_dialog.cpp b/proto-sc/ftnoir_protocol_sc_dialog.cpp new file mode 100644 index 00000000..7c2ecfd4 --- /dev/null +++ b/proto-sc/ftnoir_protocol_sc_dialog.cpp @@ -0,0 +1,35 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ftnoir_protocol_sc.h" +#include +#include "opentrack/plugin-api.hpp" + +SCControls::SCControls() +{ + ui.setupUi( this ); + + // Connect Qt signals to member-functions + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + tie_setting(s.sxs_manifest, ui.comboBox); +} + +void SCControls::doOK() { + s.b->save(); + this->close(); +} + +void SCControls::doCancel() { + s.b->reload(); + close(); +} + diff --git a/proto-sc/ftnoir_sccontrols.ui b/proto-sc/ftnoir_sccontrols.ui new file mode 100644 index 00000000..5b2fd291 --- /dev/null +++ b/proto-sc/ftnoir_sccontrols.ui @@ -0,0 +1,72 @@ + + + UICSCControls + + + Qt::NonModal + + + + 0 + 0 + 290 + 79 + + + + SimConnect settings FaceTrackNoIR + + + + images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + + Qt::LeftToRight + + + false + + + + + + FSX version + + + + + + + + SP1 + + + + + SP2 + + + + + Acceleration + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/proto-sc/images/fsx.png b/proto-sc/images/fsx.png new file mode 100644 index 00000000..16b072a1 Binary files /dev/null and b/proto-sc/images/fsx.png differ diff --git a/proto-sc/images/fsx1.png b/proto-sc/images/fsx1.png new file mode 100644 index 00000000..a1f0f188 Binary files /dev/null and b/proto-sc/images/fsx1.png differ diff --git a/proto-sc/sc-protocol.qrc b/proto-sc/sc-protocol.qrc new file mode 100644 index 00000000..127d5180 --- /dev/null +++ b/proto-sc/sc-protocol.qrc @@ -0,0 +1,5 @@ + + + images/fsx.png + + diff --git a/proto-sc/scserver.manifest b/proto-sc/scserver.manifest new file mode 100644 index 00000000..d342cfda --- /dev/null +++ b/proto-sc/scserver.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/proto-sc/scserver_acceleration.manifest b/proto-sc/scserver_acceleration.manifest new file mode 100644 index 00000000..06459587 --- /dev/null +++ b/proto-sc/scserver_acceleration.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/proto-sc/scserver_sp2.manifest b/proto-sc/scserver_sp2.manifest new file mode 100644 index 00000000..3020d16c --- /dev/null +++ b/proto-sc/scserver_sp2.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/proto-vjoy/CMakeLists.txt b/proto-vjoy/CMakeLists.txt new file mode 100644 index 00000000..22678c32 --- /dev/null +++ b/proto-vjoy/CMakeLists.txt @@ -0,0 +1,14 @@ +if(WIN32) + set(SDK_VJOY "" CACHE PATH "VJoy SDK path") + if(SDK_VJOY) + opentrack_boilerplate(opentrack-proto-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}) + install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION . ${opentrack-perms}) + endif() +endif() diff --git a/proto-vjoy/ftnoir_protocol_vjoy.cpp b/proto-vjoy/ftnoir_protocol_vjoy.cpp new file mode 100644 index 00000000..24148c63 --- /dev/null +++ b/proto-vjoy/ftnoir_protocol_vjoy.cpp @@ -0,0 +1,33 @@ +#include "ftnoir_protocol_vjoy.h" +#include "opentrack/plugin-api.hpp" + +FTNoIR_Protocol::FTNoIR_Protocol() +{ + static char meh[1] = {0}; + VJoy_Initialize(meh, meh); +} + +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + VJoy_Shutdown(); +} + +void FTNoIR_Protocol::pose( const double *headpose ) { +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + JOYSTICK_STATE state[2] = { 0 }; + + state[0].POV = (4 << 12) | (4 << 8) | (4 << 4) | 4; + + state[0].XAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Yaw] * VJOY_AXIS_MAX / 180.0)); + state[0].YAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Pitch] * VJOY_AXIS_MAX / 180.0)); + state[0].ZAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Roll] * VJOY_AXIS_MAX / 180.0)); + state[0].XRotation = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[TX] * VJOY_AXIS_MAX / 100.0)); + state[0].YRotation = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[TY] * VJOY_AXIS_MAX / 100.0)); + state[0].ZRotation = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[TZ] * VJOY_AXIS_MAX / 100.0)); + + VJoy_UpdateJoyState(0, state); +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, VJoyControls, FTNoIR_ProtocolDll) diff --git a/proto-vjoy/ftnoir_protocol_vjoy.h b/proto-vjoy/ftnoir_protocol_vjoy.h new file mode 100644 index 00000000..118306b5 --- /dev/null +++ b/proto-vjoy/ftnoir_protocol_vjoy.h @@ -0,0 +1,91 @@ +/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * + * * + * ISC License (ISC) * + * * + * Copyright (c) 2015, Wim Vriend * + * * + * 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 "ui_ftnoir_vjoy_controls.h" +#include +#include "opentrack/plugin-api.hpp" + +#define FT_PROGRAMID "FT_ProgramID" + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol() override; + bool correct() { + return true; + } + void pose( const double *headpose ); + QString game_name() { + return "Virtual joystick"; + } +private: +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class VJoyControls: public IProtocolDialog +{ + Q_OBJECT +public: + + explicit VJoyControls(); + void register_protocol(IProtocol *) {} + void unregister_protocol() {} + +private: + Ui::UICVJoyControls ui; + void save(); + +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() { return QString("Joystick emulation -- VJoy"); } + QIcon icon() { return QIcon(":/images/vjoy.png"); } +}; + +#define VJOY_AXIS_MIN -32768 +#define VJOY_AXIS_NIL 0 +#define VJOY_AXIS_MAX 32767 + +#include + +#include + +typedef struct _JOYSTICK_STATE +{ + UCHAR ReportId; // Report Id + SHORT XAxis; // X Axis + SHORT YAxis; // Y Axis + SHORT ZAxis; // Z Axis + SHORT XRotation; // X Rotation + SHORT YRotation; // Y Rotation + SHORT ZRotation; // Z Rotation + SHORT Slider; // Slider + SHORT Dial; // Dial + USHORT POV; // POV + UINT32 Buttons; // 32 Buttons +} JOYSTICK_STATE, * PJOYSTICK_STATE; + +#ifndef _MSC_VER +EXTERN_C BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); +EXTERN_C VOID __stdcall VJoy_Shutdown(); +EXTERN_C BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); +#else +#define VJOY_API __declspec(dllimport) +VJOY_API BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); +VJOY_API VOID __stdcall VJoy_Shutdown(); +VJOY_API BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); +#endif diff --git a/proto-vjoy/ftnoir_protocol_vjoy_dialog.cpp b/proto-vjoy/ftnoir_protocol_vjoy_dialog.cpp new file mode 100644 index 00000000..08c65558 --- /dev/null +++ b/proto-vjoy/ftnoir_protocol_vjoy_dialog.cpp @@ -0,0 +1,22 @@ +#include "ftnoir_protocol_vjoy.h" +#include "opentrack/plugin-api.hpp" + +VJoyControls::VJoyControls() +{ + ui.setupUi( this ); + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); +} + +void VJoyControls::doOK() { + save(); + this->close(); +} + +void VJoyControls::doCancel() { + this->close(); +} + +void VJoyControls::save() { +} + diff --git a/proto-vjoy/ftnoir_vjoy_controls.ui b/proto-vjoy/ftnoir_vjoy_controls.ui new file mode 100644 index 00000000..2214b887 --- /dev/null +++ b/proto-vjoy/ftnoir_vjoy_controls.ui @@ -0,0 +1,113 @@ + + + UICVJoyControls + + + Qt::NonModal + + + + 0 + 0 + 228 + 69 + + + + VJoy + + + + :/images/vjoy.png:/images/vjoy.png + + + Qt::LeftToRight + + + false + + + + + + No settings necessary + + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + + + btnOK + btnCancel + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/proto-vjoy/images/vjoy.png b/proto-vjoy/images/vjoy.png new file mode 100644 index 00000000..8eb14be8 Binary files /dev/null and b/proto-vjoy/images/vjoy.png differ diff --git a/proto-vjoy/vjoy-protocol.qrc b/proto-vjoy/vjoy-protocol.qrc new file mode 100644 index 00000000..7b3741f1 --- /dev/null +++ b/proto-vjoy/vjoy-protocol.qrc @@ -0,0 +1,5 @@ + + + images/vjoy.png + + diff --git a/proto-vjoy/vjoy.def b/proto-vjoy/vjoy.def new file mode 100644 index 00000000..aea590a4 --- /dev/null +++ b/proto-vjoy/vjoy.def @@ -0,0 +1,5 @@ +LIBRARY vjoy.dll +IMPORTS +VJoy_Initialize = _VJoy_Initialize +VJoy_Shutdown = _VJoy_Shutdown +VJoy_UpdateJoyState = _VJoy_UpdateJoyState diff --git a/proto-wine/CMakeLists.txt b/proto-wine/CMakeLists.txt new file mode 100644 index 00000000..bafcff8b --- /dev/null +++ b/proto-wine/CMakeLists.txt @@ -0,0 +1,26 @@ +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") + if(SDK_WINE_PREFIX) + opentrack_boilerplate(opentrack-proto-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 ${PROJECT_SOURCE_DIR}/*.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) + install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" DESTINATION .) + endif() + endif() +endif() diff --git a/proto-wine/ftnoir_protocol_wine.cpp b/proto-wine/ftnoir_protocol_wine.cpp new file mode 100644 index 00000000..99ad30a2 --- /dev/null +++ b/proto-wine/ftnoir_protocol_wine.cpp @@ -0,0 +1,59 @@ +#include "ftnoir_protocol_wine.h" +#include +#include +#include /* For mode constants */ +#include /* For O_* constants */ +#include "csv/csv.h" + +FTNoIR_Protocol::FTNoIR_Protocol() : lck_shm(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)), shm(NULL), gameid(0) +{ + if (lck_shm.success()) { + shm = (WineSHM*) lck_shm.ptr(); + memset(shm, 0, sizeof(*shm)); + } + wrapper.start("wine", QStringList() << (QCoreApplication::applicationDirPath() + "/opentrack-wrapper-wine.exe.so")); +} + +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + if (shm) { + shm->stop = true; + wrapper.waitForFinished(100); + } + wrapper.terminate(); + if (!wrapper.waitForFinished(100)) + { + wrapper.kill(); + wrapper.waitForFinished(42); + } + //shm_unlink("/" WINE_SHM_NAME); +} + +void FTNoIR_Protocol::pose( const double *headpose ) { + if (shm) + { + lck_shm.lock(); + for (int i = 3; i < 6; i++) + shm->data[i] = headpose[i] / 57.295781; + for (int i = 0; i < 3; i++) + shm->data[i] = headpose[i] * 10; + if (shm->gameid != gameid) + { + QString gamename; + QMutexLocker foo(&game_name_mutex); + /* only EZCA for FSX requires dummy process, and FSX doesn't work on Linux */ + /* memory-hacks DLL can't be loaded into a Linux process, either */ + CSV::getGameData(shm->gameid, shm->table, gamename); + gameid = shm->gameid2 = shm->gameid; + connected_game = gamename; + } + lck_shm.unlock(); + } +} + +bool FTNoIR_Protocol::correct() +{ + return lck_shm.success(); +} + +OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FTControls, FTNoIR_ProtocolDll) diff --git a/proto-wine/ftnoir_protocol_wine.h b/proto-wine/ftnoir_protocol_wine.h new file mode 100644 index 00000000..f78e1364 --- /dev/null +++ b/proto-wine/ftnoir_protocol_wine.h @@ -0,0 +1,57 @@ +#pragma once + +#include "ui_ftnoir_winecontrols.h" +#include +#include +#include +#include +#include +#include +#include +#include "opentrack/plugin-api.hpp" +#include "opentrack-compat/shm.h" +#include "wine-shm.h" + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol() override; + + bool correct() override; + void pose(const double* headpose) override; + QString game_name() override { + QMutexLocker foo(&game_name_mutex); + return connected_game; + } +private: + PortableLockedShm lck_shm; + WineSHM* shm; + QProcess wrapper; + int gameid; + QString connected_game; + QMutex game_name_mutex; +}; + +class FTControls: public IProtocolDialog +{ + Q_OBJECT +public: + FTControls(); + void register_protocol(IProtocol *) override {} + void unregister_protocol() override {} + +private: + Ui::UICFTControls ui; + +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_ProtocolDll : public Metadata +{ +public: + QString name() override { return QString("Wine -- Windows layer for Unix"); } + QIcon icon() override { return QIcon(":/images/wine.png"); } +}; diff --git a/proto-wine/ftnoir_protocol_wine_dialog.cpp b/proto-wine/ftnoir_protocol_wine_dialog.cpp new file mode 100644 index 00000000..e4027c73 --- /dev/null +++ b/proto-wine/ftnoir_protocol_wine_dialog.cpp @@ -0,0 +1,19 @@ +#include "ftnoir_protocol_wine.h" +#include +#include "opentrack/plugin-api.hpp" + +FTControls::FTControls() +{ + ui.setupUi( this ); + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); +} + +void FTControls::doOK() { + this->close(); +} + +void FTControls::doCancel() { + this->close(); +} + diff --git a/proto-wine/ftnoir_winecontrols.ui b/proto-wine/ftnoir_winecontrols.ui new file mode 100644 index 00000000..9356c448 --- /dev/null +++ b/proto-wine/ftnoir_winecontrols.ui @@ -0,0 +1,170 @@ + + + UICFTControls + + + Qt::NonModal + + + + 0 + 0 + 409 + 110 + + + + FreeTrack settings FaceTrackNoIR + + + + images/freetrack.pngimages/freetrack.png + + + Qt::LeftToRight + + + false + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + There are no settings necessary for the Wine protocol. + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/proto-wine/images/wine.png b/proto-wine/images/wine.png new file mode 100644 index 00000000..bcf3a012 Binary files /dev/null and b/proto-wine/images/wine.png differ diff --git a/proto-wine/opentrack-wrapper-wine-main.cxx b/proto-wine/opentrack-wrapper-wine-main.cxx new file mode 100644 index 00000000..082e5dde --- /dev/null +++ b/proto-wine/opentrack-wrapper-wine-main.cxx @@ -0,0 +1,80 @@ +#include +// OSX sdk 10.8 build error otherwise +#ifdef _LIBCPP_MSVCRT +# undef _LIBCPP_MSVCRT +#endif +#include +#include "freetrackclient/fttypes.h" +#include "wine-shm.h" +#include "opentrack-compat/export.hpp" + +enum Axis { + TX = 0, TY, TZ, Yaw, Pitch, Roll +}; + +#include "opentrack-compat/shm.h" + +void create_registry_key(void); + +class ShmPosix { +public: + ShmPosix(const char *shmName, const char *mutexName, int mapSize); + ~ShmPosix(); + void lock(); + void unlock(); + bool success(); + inline void* ptr() { return mem; } +private: + void* mem; + int fd, size; +}; + +class ShmWine { +public: + ShmWine(const char *shmName, const char *mutexName, int mapSize); + ~ShmWine(); + void lock(); + void unlock(); + bool success(); + inline void* ptr() { return mem; } +private: + void* mem; + void *hMutex, *hMapFile; +}; +#include + +int main(void) +{ + ShmPosix lck_posix(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)); + ShmWine lck_wine("FT_SharedMem", "FT_Mutext", sizeof(FTHeap)); + if(!lck_posix.success()) { + printf("Can't open posix map: %d\n", errno); + return 1; + } + if(!lck_wine.success()) { + printf("Can't open Wine map\n"); + return 1; + } + WineSHM* shm_posix = (WineSHM*) lck_posix.ptr(); + FTHeap* shm_wine = (FTHeap*) lck_wine.ptr(); + FTData* data = &shm_wine->data; + create_registry_key(); + while (1) { + if (shm_posix->stop) + break; + data->Yaw = -shm_posix->data[Yaw]; + data->Pitch = -shm_posix->data[Pitch]; + data->Roll = shm_posix->data[Roll]; + data->X = shm_posix->data[TX]; + data->Y = shm_posix->data[TY]; + data->Z = shm_posix->data[TZ]; + data->DataID++; + data->CamWidth = 250; + data->CamHeight = 100; + shm_wine->GameID2 = shm_posix->gameid2; + shm_posix->gameid = shm_wine->GameID; + for (int i = 0; i < 8; i++) + shm_wine->table[i] = shm_posix->table[i]; + (void) Sleep(4); + } +} diff --git a/proto-wine/opentrack-wrapper-wine-posix.cxx b/proto-wine/opentrack-wrapper-wine-posix.cxx new file mode 100644 index 00000000..50cce728 --- /dev/null +++ b/proto-wine/opentrack-wrapper-wine-posix.cxx @@ -0,0 +1,7 @@ +#ifdef _WIN32 +# undef _WIN32 +#endif + +#define PortableLockedShm ShmPosix +#include "opentrack-compat/shm.h" +#include "opentrack-compat/shm.cpp" diff --git a/proto-wine/opentrack-wrapper-wine-windows.cxx b/proto-wine/opentrack-wrapper-wine-windows.cxx new file mode 100644 index 00000000..19ee8ffd --- /dev/null +++ b/proto-wine/opentrack-wrapper-wine-windows.cxx @@ -0,0 +1,40 @@ +#ifndef __WIN32 +# error "bad cross" +#endif + +#define PortableLockedShm ShmWine +#include "opentrack-compat/shm.h" +#include "opentrack-compat/shm.cpp" +#include "wine-shm.h" + +static void write_path(const char* key, const char* subkey) +{ + char dir[8192]; + + if (GetCurrentDirectoryA(8192, dir) < 8190) + { + HKEY hkpath; + if (RegCreateKeyExA(HKEY_CURRENT_USER, + key, + 0, + NULL, + 0, + KEY_ALL_ACCESS, + NULL, + &hkpath, + NULL) == ERROR_SUCCESS) + { + for (int i = 0; dir[i]; i++) + if (dir[i] == '\\') + dir[i] = '/'; + strcat(dir, "/"); + (void) RegSetValueExA(hkpath, subkey, 0, REG_SZ, (BYTE*) dir, strlen(dir) + 1); + RegCloseKey(hkpath); + } + } +} + +void create_registry_key(void) { + write_path("Software\\NaturalPoint\\NATURALPOINT\\NPClient Location", "Path"); + write_path("Software\\Freetrack\\FreeTrackClient", "Path"); +} diff --git a/proto-wine/wine-protocol.qrc b/proto-wine/wine-protocol.qrc new file mode 100644 index 00000000..af81caea --- /dev/null +++ b/proto-wine/wine-protocol.qrc @@ -0,0 +1,5 @@ + + + images/wine.png + + diff --git a/proto-wine/wine-shm.h b/proto-wine/wine-shm.h new file mode 100644 index 00000000..c7e29abb --- /dev/null +++ b/proto-wine/wine-shm.h @@ -0,0 +1,20 @@ +#pragma once + +#define WINE_SHM_NAME "facetracknoir-wine-shm" +#define WINE_MTX_NAME "facetracknoir-wine-mtx" + +// OSX sdk 10.8 build error otherwise +#ifdef _LIBCPP_MSVCRT +# undef _LIBCPP_MSVCRT +#endif + +#include + +template using ptr = std::shared_ptr; + +struct WineSHM { + double data[6]; + int gameid, gameid2; + unsigned char table[8]; + bool stop; +}; diff --git a/protocol-fg/CMakeLists.txt b/protocol-fg/CMakeLists.txt deleted file mode 100644 index 151b30ee..00000000 --- a/protocol-fg/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -opentrack_boilerplate(opentrack-proto-fgfs) diff --git a/protocol-fg/fg-protocol.qrc b/protocol-fg/fg-protocol.qrc deleted file mode 100644 index 1c685437..00000000 --- a/protocol-fg/fg-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/flightgear.png - - diff --git a/protocol-fg/fgtypes.h b/protocol-fg/fgtypes.h deleted file mode 100644 index 2e493f46..00000000 --- a/protocol-fg/fgtypes.h +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* Type definitions for the FlightGear server. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FGTYPES_H -#define INCLUDED_FGTYPES_H - -// -// x,y,z position in metres, heading, pitch and roll in degrees... -// -#pragma pack(push, 2) -struct TFlightGearData { - double x, y, z, h, p, r; - int status; -}; -#pragma pack(pop) - -#endif//INCLUDED_FGTYPES_H diff --git a/protocol-fg/ftnoir_fgcontrols.ui b/protocol-fg/ftnoir_fgcontrols.ui deleted file mode 100644 index bd5b95c7..00000000 --- a/protocol-fg/ftnoir_fgcontrols.ui +++ /dev/null @@ -1,136 +0,0 @@ - - - UICFGControls - - - Qt::NonModal - - - - 0 - 0 - 415 - 112 - - - - FlightGear protocol settings - - - Qt::LeftToRight - - - false - - - - - - IP-address remote PC - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - spinIPFirstNibble - spinIPSecondNibble - spinIPThirdNibble - spinIPFourthNibble - spinPortNumber - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/protocol-fg/ftnoir_protocol_fg.cpp b/protocol-fg/ftnoir_protocol_fg.cpp deleted file mode 100644 index 660a7352..00000000 --- a/protocol-fg/ftnoir_protocol_fg.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ftnoir_protocol_fg.h" -#include "opentrack/plugin-api.hpp" - -// For Todd and Arda Kutlu - -void FTNoIR_Protocol::pose(const double* headpose) { - FlightData.x = headpose[TX] * 1e-2; - FlightData.y = headpose[TY] * 1e-2; - FlightData.z = headpose[TZ] * 1e-2; - FlightData.p = headpose[Pitch]; - FlightData.h = headpose[Yaw]; - FlightData.r = headpose[Roll]; - FlightData.status = 1; - QHostAddress destIP(QString("%1.%2.%3.%4").arg( - QString::number(static_cast(s.ip1)), - QString::number(static_cast(s.ip2)), - QString::number(static_cast(s.ip3)), - QString::number(static_cast(s.ip4)))); - int destPort = s.port; - (void) outSocket.writeDatagram(reinterpret_cast(&FlightData), sizeof(FlightData), destIP, static_cast(destPort)); -} - -bool FTNoIR_Protocol::correct() -{ - return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FGControls, FTNoIR_ProtocolDll) diff --git a/protocol-fg/ftnoir_protocol_fg.h b/protocol-fg/ftnoir_protocol_fg.h deleted file mode 100644 index de528270..00000000 --- a/protocol-fg/ftnoir_protocol_fg.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ui_ftnoir_fgcontrols.h" -#include "fgtypes.h" -#include -#include -#include -#include "opentrack/plugin-api.hpp" -#include "opentrack/options.hpp" -using namespace options; - -struct settings : opts { - value ip1, ip2, ip3, ip4; - value port; - settings() : - opts("flightgear-proto"), - ip1(b, "ip1", 192), - ip2(b, "ip2", 168), - ip3(b, "ip3", 0), - ip4(b, "ip4", 2), - port(b, "port", 5542) - {} -}; - -class FTNoIR_Protocol : public IProtocol -{ -public: - bool correct(); - void pose(const double *headpose); - QString game_name() { - return "FlightGear"; - } -private: - settings s; - TFlightGearData FlightData; - QUdpSocket outSocket; -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FGControls: public IProtocolDialog -{ - Q_OBJECT -public: - FGControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} -private: - Ui::UICFGControls ui; - settings s; -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() { return QString("FlightGear"); } - QIcon icon() { return QIcon(":/images/flightgear.png"); } -}; diff --git a/protocol-fg/ftnoir_protocol_fg_dialog.cpp b/protocol-fg/ftnoir_protocol_fg_dialog.cpp deleted file mode 100644 index 1d583115..00000000 --- a/protocol-fg/ftnoir_protocol_fg_dialog.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ftnoir_protocol_fg.h" -#include -#include -#include "opentrack/plugin-api.hpp" - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FGControls::FGControls() -{ - ui.setupUi( this ); - - tie_setting(s.ip1, ui.spinIPFirstNibble); - tie_setting(s.ip2, ui.spinIPSecondNibble); - tie_setting(s.ip3, ui.spinIPThirdNibble); - tie_setting(s.ip4, ui.spinIPFourthNibble); - tie_setting(s.port, ui.spinPortNumber); - - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); -} - -void FGControls::doOK() { - s.b->save(); - this->close(); -} - -void FGControls::doCancel() { - s.b->reload(); - this->close(); -} - diff --git a/protocol-fg/images/flightgear.png b/protocol-fg/images/flightgear.png deleted file mode 100644 index 2a546642..00000000 Binary files a/protocol-fg/images/flightgear.png and /dev/null differ diff --git a/protocol-fsuipc/CMakeLists.txt b/protocol-fsuipc/CMakeLists.txt deleted file mode 100644 index ec897ae8..00000000 --- a/protocol-fsuipc/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -if(WIN32) - set(SDK_FSUIPC "" CACHE PATH "FSUIPC for older MS FSX path") - if(SDK_FSUIPC) - opentrack_boilerplate(opentrack-proto-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() - endif() -endif() diff --git a/protocol-fsuipc/fsuipc-protocol.qrc b/protocol-fsuipc/fsuipc-protocol.qrc deleted file mode 100644 index 34756f84..00000000 --- a/protocol-fsuipc/fsuipc-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/fs9.png - - diff --git a/protocol-fsuipc/ftnoir_fsuipccontrols.ui b/protocol-fsuipc/ftnoir_fsuipccontrols.ui deleted file mode 100644 index 637e4dba..00000000 --- a/protocol-fsuipc/ftnoir_fsuipccontrols.ui +++ /dev/null @@ -1,134 +0,0 @@ - - - UICFSUIPCControls - - - Qt::NonModal - - - - 0 - 0 - 512 - 100 - - - - FSUIPC settings FaceTrackNoIR - - - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - 230 - 0 - - - - Location of FSUIPC.dll - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - Location of FSUIPC.dll - - - - - - - The DLL should be located in the Modules/ directory of MS FS 2004 - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 35 - 16777215 - - - - ... - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/protocol-fsuipc/ftnoir_protocol_fsuipc.cpp b/protocol-fsuipc/ftnoir_protocol_fsuipc.cpp deleted file mode 100644 index 702a92d4..00000000 --- a/protocol-fsuipc/ftnoir_protocol_fsuipc.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ftnoir_protocol_fsuipc.h" -#include "opentrack/plugin-api.hpp" - -FTNoIR_Protocol::FTNoIR_Protocol() -{ - prevPosX = 0.0f; - prevPosY = 0.0f; - prevPosZ = 0.0f; - prevRotX = 0.0f; - prevRotY = 0.0f; - prevRotZ = 0.0f; -} - -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - FSUIPC_Close(); - FSUIPCLib.unload(); -} - -int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { -double y; -double local_x; - - local_x = x; - if (local_x > max_x) { - local_x = max_x; - } - if (local_x < min_x) { - local_x = min_x; - } - y = ( 16383 * local_x ) / max_x; - - return (int) y; -} - -void FTNoIR_Protocol::pose(const double *headpose ) { - DWORD result; - TFSState pitch; - TFSState yaw; - TFSState roll; - WORD FSZoom; - - float virtPosX; - float virtPosY; - float virtPosZ; - - float virtRotX; - float virtRotY; - float virtRotZ; - -// qDebug() << "FSUIPCServer::run() says: started!"; - - virtRotX = -headpose[Pitch]; // degrees - virtRotY = headpose[Yaw]; - virtRotZ = headpose[Roll]; - - virtPosX = 0.0f; // cm, X and Y are not working for FS2002/2004! - virtPosY = 0.0f; - virtPosZ = headpose[TZ]; - - // - // Init. the FSUIPC offsets (derived from Free-track...) - // - pitch.Control = 66503; - yaw.Control = 66504; - roll.Control = 66505; - - // - // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. - // - if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || - (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { - // - // Open the connection - // - FSUIPC_Open(SIM_ANY, &result); - - // - // Check the FS-version - // - if (((result == FSUIPC_ERR_OK) || (result == FSUIPC_ERR_OPEN)) && - ((FSUIPC_FS_Version == SIM_FS2K2) || (FSUIPC_FS_Version == SIM_FS2K4))) { -// qDebug() << "FSUIPCServer::run() says: FSUIPC opened succesfully"; - // - // Write the 4! DOF-data to FS. Only rotations and zoom are possible. - // - pitch.Value = scale2AnalogLimits(virtRotX, -180, 180); - FSUIPC_Write(0x3110, 8, &pitch, &result); - - yaw.Value = scale2AnalogLimits(virtRotY, -180, 180); - FSUIPC_Write(0x3110, 8, &yaw, &result); - - roll.Value = scale2AnalogLimits(virtRotZ, -180, 180); - FSUIPC_Write(0x3110, 8, &roll, &result); - - FSZoom = (WORD) (64/50) * virtPosZ + 64; - FSUIPC_Write(0x832E, 2, &FSZoom, &result); - - // - // Write the data, in one go! - // - FSUIPC_Process(&result); - if (result == FSUIPC_ERR_SENDMSG) { - // FSUIPC checks for already open connections and returns FSUIPC_ERR_OPEN in that case - // the connection scope is global for the process. this is why above code doesn't - // leak resources or have logic errors. see: http://www.purebasic.fr/english/viewtopic.php?t=31112 - FSUIPC_Close(); - } - } - } - - prevPosX = virtPosX; - prevPosY = virtPosY; - prevPosZ = virtPosZ; - prevRotX = virtRotX; - prevRotY = virtRotY; - prevRotZ = virtRotZ; -} - -bool FTNoIR_Protocol::correct() -{ - qDebug() << "correct says: Starting Function"; - - // - // Load the DLL. - // - FSUIPCLib.setFileName( s.LocationOfDLL ); - if (FSUIPCLib.load() != true) { - qDebug() << "correct says: Error loading FSUIPC DLL"; - return false; - } - else { - qDebug() << "correct says: FSUIPC DLL loaded."; - } - - return true; -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FSUIPCControls, FTNoIR_ProtocolDll) diff --git a/protocol-fsuipc/ftnoir_protocol_fsuipc.h b/protocol-fsuipc/ftnoir_protocol_fsuipc.h deleted file mode 100644 index c8e91a42..00000000 --- a/protocol-fsuipc/ftnoir_protocol_fsuipc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 -#ifndef INCLUDED_FSUIPCSERVER_H -#define INCLUDED_FSUIPCSERVER_H - -#include -#include -#include "FSUIPC_User.h" -#include "opentrack/plugin-api.hpp" -#include "ui_ftnoir_fsuipccontrols.h" -#include -#include -#include -#include -#include -#include -#include -#include "opentrack/options.hpp" -using namespace options; - -#define FSUIPC_FILENAME "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll" - -struct settings : opts { - value LocationOfDLL; - settings() : - opts("proto-fsuipc"), - LocationOfDLL(b, "dll-location", FSUIPC_FILENAME) - {} -}; - -#pragma pack(push,1) // All fields in structure must be byte aligned. -typedef struct -{ - int Control; // Control identifier - int Value; // Value of DOF -} TFSState; -#pragma pack(pop) - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol() override; - bool correct(); - void pose(const double* headpose); - QString game_name() { - return "Microsoft Flight Simulator X"; - } -private: - QLibrary FSUIPCLib; - double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; - static int scale2AnalogLimits( float x, float min_x, float max_x ); - settings s; -}; - -class FSUIPCControls: public IProtocolDialog -{ - Q_OBJECT -public: - FSUIPCControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} -private: - Ui::UICFSUIPCControls ui; - settings s; -private slots: - void doOK(); - void doCancel(); - void getLocationOfDLL(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() { return QString("FSUIPC -- Microsoft FS2002/FS2004"); } - QIcon icon() { return QIcon(":/images/fs9.png"); } -}; - - -#endif//INCLUDED_FSUIPCSERVER_H -//END diff --git a/protocol-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/protocol-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp deleted file mode 100644 index d573420a..00000000 --- a/protocol-fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ftnoir_protocol_fsuipc.h" -#include "opentrack/plugin-api.hpp" - -FSUIPCControls::FSUIPCControls() -{ - ui.setupUi( this ); - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); - - tie_setting(s.LocationOfDLL, ui.txtLocationOfDLL); -} - -void FSUIPCControls::doOK() { - s.b->save(); - this->close(); -} - -void FSUIPCControls::doCancel() { - s.b->reload(); - close(); -} - -void FSUIPCControls::getLocationOfDLL() -{ - QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), - ui.txtLocationOfDLL->text(), - tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); - if (!fileName.isEmpty()) { - s.LocationOfDLL = fileName; - } -} - diff --git a/protocol-fsuipc/images/fs9.png b/protocol-fsuipc/images/fs9.png deleted file mode 100644 index 914c9dcb..00000000 Binary files a/protocol-fsuipc/images/fs9.png and /dev/null differ diff --git a/protocol-fsuipc/images/fs91.png b/protocol-fsuipc/images/fs91.png deleted file mode 100644 index f9540d1d..00000000 Binary files a/protocol-fsuipc/images/fs91.png and /dev/null differ diff --git a/protocol-ft/CMakeLists.txt b/protocol-ft/CMakeLists.txt deleted file mode 100644 index 44f95ba3..00000000 --- a/protocol-ft/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -if(WIN32) - opentrack_boilerplate(opentrack-proto-freetrack) - target_link_libraries(opentrack-proto-freetrack opentrack-csv opentrack-compat) -endif() diff --git a/protocol-ft/ft-protocol.qrc b/protocol-ft/ft-protocol.qrc deleted file mode 100644 index c04959f0..00000000 --- a/protocol-ft/ft-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/freetrack.png - - diff --git a/protocol-ft/ftnoir_ftcontrols.ui b/protocol-ft/ftnoir_ftcontrols.ui deleted file mode 100644 index 5356d2e5..00000000 --- a/protocol-ft/ftnoir_ftcontrols.ui +++ /dev/null @@ -1,182 +0,0 @@ - - - UICFTControls - - - Qt::NonModal - - - true - - - - 0 - 0 - 422 - 305 - - - - - 0 - 0 - - - - - 0 - 0 - - - - freetrack protocol settings - - - - :/images/freetrack.png:/images/freetrack.png - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - TIRViews - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - Qt::RightToLeft - - - Memory hacks - - - - - - - Only for very old and buggy old games such as CFS3. - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - - - - - 0 - 0 - - - - Repair NPClient location - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - Locate DLL - - - - - - - Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically. - - - true - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - 0 - 0 - - - - Select interface - - - Qt::AlignJustify|Qt::AlignTop - - - false - - - - - - - - - Disable one of the protocols if game is confused by presence of both at the same time. - - - true - - - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/protocol-ft/ftnoir_protocol_ft.cpp b/protocol-ft/ftnoir_protocol_ft.cpp deleted file mode 100644 index 05253174..00000000 --- a/protocol-ft/ftnoir_protocol_ft.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* Copyright (c) 2013-2015 Stanislaw Halik - * Copyright (c) 2015 Wim Vriend - * - * 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 "ftnoir_protocol_ft.h" -#include "csv/csv.h" - -FTNoIR_Protocol::FTNoIR_Protocol() : - shm(FREETRACK_HEAP, FREETRACK_MUTEX, sizeof(FTHeap)), - pMemData((FTHeap*) shm.ptr()), - viewsStart(nullptr), - viewsStop(nullptr), - intGameID(0) -{ -} - -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - if (viewsStop != NULL) { - viewsStop(); - FTIRViewsLib.unload(); - } - dummyTrackIR.terminate(); - dummyTrackIR.kill(); - dummyTrackIR.waitForFinished(50); -} - -void FTNoIR_Protocol::pose(const double* headpose) { - float yaw = -getRadsFromDegrees(headpose[Yaw]); - float pitch = -getRadsFromDegrees(headpose[Pitch]); - float roll = getRadsFromDegrees(headpose[Roll]); - float tx = headpose[TX] * 10.f; - float ty = headpose[TY] * 10.f; - float tz = headpose[TZ] * 10.f; - - FTHeap* ft = pMemData; - FTData* data = &ft->data; - - data->RawX = 0; - data->RawY = 0; - data->RawZ = 0; - data->RawPitch = 0; - data->RawYaw = 0; - data->RawRoll = 0; - - data->X = tx; - data->Y = ty; - data->Z = tz; - data->Yaw = yaw; - data->Pitch = pitch; - data->Roll = roll; - - data->X1 = data->DataID; - data->X2 = 0; - data->X3 = 0; - data->X4 = 0; - data->Y1 = 0; - data->Y2 = 0; - data->Y3 = 0; - data->Y4 = 0; - - int32_t id = ft->GameID; - - if (intGameID != id) - { - QString gamename; - { - unsigned char table[8]; - if (CSV::getGameData(id, table, gamename)) - for (int i = 0; i < 8; i++) pMemData->table[i] = table[i]; - } - ft->GameID2 = id; - intGameID = id; - QMutexLocker foo(&this->game_name_mutex); - connected_game = gamename; - } - - data->DataID += 1; -} - -void FTNoIR_Protocol::start_tirviews() { - QString aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; - if ( QFile::exists( aFileName )) { - FTIRViewsLib.setFileName(aFileName); - FTIRViewsLib.load(); - - viewsStart = (importTIRViewsStart) FTIRViewsLib.resolve("TIRViewsStart"); - if (viewsStart == NULL) { - qDebug() << "FTServer::run() says: TIRViewsStart function not found in DLL!"; - } - else { - qDebug() << "FTServer::run() says: TIRViewsStart executed!"; - viewsStart(); - } - - // - // Load the Stop function from TIRViews.dll. Call it when terminating the thread. - // - viewsStop = (importTIRViewsStop) FTIRViewsLib.resolve("TIRViewsStop"); - if (viewsStop == NULL) { - qDebug() << "FTServer::run() says: TIRViewsStop function not found in DLL!"; - } - } -} - -void FTNoIR_Protocol::start_dummy() { - - - QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe"; - dummyTrackIR.setProgram("\"" + program + "\""); - dummyTrackIR.start(); -} - -bool FTNoIR_Protocol::correct() -{ - // Registry settings (in HK_USER) - QSettings settings("Freetrack", "FreetrackClient"); - QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); - - if (!shm.success()) - return false; - - QString aLocation = QCoreApplication::applicationDirPath() + "/"; - - switch (s.intUsedInterface) { - case 0: - // Use both interfaces - settings.setValue( "Path" , aLocation ); - settingsTIR.setValue( "Path" , aLocation ); - break; - case 1: - // Use FreeTrack, disable TrackIR - settings.setValue( "Path" , aLocation ); - settingsTIR.setValue( "Path" , "" ); - break; - case 2: - // Use TrackIR, disable FreeTrack - settings.setValue( "Path" , "" ); - settingsTIR.setValue( "Path" , aLocation ); - break; - default: - break; - } - - if (s.useTIRViews) { - start_tirviews(); - } - - // more games need the dummy executable than previously thought - start_dummy(); - - pMemData->data.DataID = 1; - pMemData->data.CamWidth = 100; - pMemData->data.CamHeight = 250; - pMemData->GameID2 = 0; - for (int i = 0; i < 8; i++) - pMemData->table[i] = 0; - - return true; -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FTControls, FTNoIR_ProtocolDll) diff --git a/protocol-ft/ftnoir_protocol_ft.h b/protocol-ft/ftnoir_protocol_ft.h deleted file mode 100644 index 8e50f1cb..00000000 --- a/protocol-ft/ftnoir_protocol_ft.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (c) 2013-2015 Stanislaw Halik - * Copyright (c) 2015 Wim Vriend - * - * 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 "ui_ftnoir_ftcontrols.h" -#include "opentrack/plugin-api.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "opentrack-compat/shm.h" -#include "opentrack/options.hpp" -#include "freetrackclient/fttypes.h" -using namespace options; - -struct settings : opts { - value intUsedInterface; - value useTIRViews; - settings() : - opts("proto-freetrack"), - intUsedInterface(b, "used-interfaces", 0), - useTIRViews(b, "use-memory-hacks", false) - {} -}; - -typedef void (__stdcall *importTIRViewsStart)(void); -typedef void (__stdcall *importTIRViewsStop)(void); - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol() override; - bool correct(); - void pose( const double *headpose ); - QString game_name() override { - QMutexLocker foo(&game_name_mutex); - return connected_game; - } -private: - settings s; - PortableLockedShm shm; - FTHeap *pMemData; - - QLibrary FTIRViewsLib; - QProcess dummyTrackIR; - importTIRViewsStart viewsStart; - importTIRViewsStop viewsStop; - - int intGameID; - QString connected_game; - QMutex game_name_mutex; - - static inline double getRadsFromDegrees(double degrees) { return degrees * 0.017453; } - void start_tirviews(); - void start_dummy(); -}; - -class FTControls: public IProtocolDialog -{ - Q_OBJECT -public: - FTControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} -private: - Ui::UICFTControls ui; - settings s; -private slots: - void selectDLL(); - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() { return QString("freetrack 2.0 Enhanced"); } - QIcon icon() { return QIcon(":/images/freetrack.png"); } -}; diff --git a/protocol-ft/ftnoir_protocol_ft_dialog.cpp b/protocol-ft/ftnoir_protocol_ft_dialog.cpp deleted file mode 100644 index 25f3a4cb..00000000 --- a/protocol-ft/ftnoir_protocol_ft_dialog.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ftnoir_protocol_ft.h" -#include -#include - -FTControls::FTControls() -{ - ui.setupUi( this ); - - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); - - tie_setting(s.useTIRViews, ui.chkTIRViews); - - ui.cbxSelectInterface->addItem("Enable both"); - ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); - ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); - - tie_setting(s.intUsedInterface, ui.cbxSelectInterface); - - QFile memhacks_pathname(QCoreApplication::applicationDirPath() + "/TIRViews.dll"); - if (!memhacks_pathname.exists()) { - ui.chkTIRViews->setChecked( false ); - ui.chkTIRViews->setEnabled ( false ); - } - else { - ui.chkTIRViews->setEnabled ( true ); - } -} - -void FTControls::doOK() { - s.b->save(); - this->close(); -} - -void FTControls::doCancel() { - s.b->reload(); - this->close(); -} - -void FTControls::selectDLL() { - QString filename = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)")); - - if (! filename.isEmpty() ) { - QSettings node("NaturalPoint", "NATURALPOINT\\NPClient Location"); - QFileInfo dllname(filename); - node.setValue( "Path" , dllname.dir().path() ); - } -} - diff --git a/protocol-ft/images/freetrack.png b/protocol-ft/images/freetrack.png deleted file mode 100644 index c184dc88..00000000 Binary files a/protocol-ft/images/freetrack.png and /dev/null differ diff --git a/protocol-ftn/CMakeLists.txt b/protocol-ftn/CMakeLists.txt deleted file mode 100644 index a0b74d9c..00000000 --- a/protocol-ftn/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -opentrack_boilerplate(opentrack-proto-udp) diff --git a/protocol-ftn/ftnoir_ftncontrols.ui b/protocol-ftn/ftnoir_ftncontrols.ui deleted file mode 100644 index 28f8ccdf..00000000 --- a/protocol-ftn/ftnoir_ftncontrols.ui +++ /dev/null @@ -1,266 +0,0 @@ - - - UICFTNControls - - - Qt::NonModal - - - - 0 - 0 - 411 - 169 - - - - UDP protocol settings - - - - :/images/facetracknoir.png:/images/facetracknoir.png - - - Qt::LeftToRight - - - false - - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - IP-address remote PC - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Enter IP-address and port-number for the remote PC. - - - true - - - - - - - Remember: you may have to change firewall-settings too! - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - spinIPFirstNibble - spinIPSecondNibble - spinIPThirdNibble - spinIPFourthNibble - spinPortNumber - btnOK - btnCancel - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/protocol-ftn/ftnoir_protocol_ftn.cpp b/protocol-ftn/ftnoir_protocol_ftn.cpp deleted file mode 100644 index db852f55..00000000 --- a/protocol-ftn/ftnoir_protocol_ftn.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ftnoir_protocol_ftn.h" -#include -#include "opentrack/plugin-api.hpp" - -FTNoIR_Protocol::FTNoIR_Protocol() -{ -} - -void FTNoIR_Protocol::pose(const double *headpose) { - int destPort = s.port; - QHostAddress destIP(QString("%1.%2.%3.%4").arg( - QString::number(static_cast(s.ip1)), - QString::number(static_cast(s.ip2)), - QString::number(static_cast(s.ip3)), - QString::number(static_cast(s.ip4)))); - outSocket.writeDatagram((const char *) headpose, sizeof( double[6] ), destIP, destPort); -} - -bool FTNoIR_Protocol::correct() -{ - return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FTNControls, FTNoIR_ProtocolDll) diff --git a/protocol-ftn/ftnoir_protocol_ftn.h b/protocol-ftn/ftnoir_protocol_ftn.h deleted file mode 100644 index 7fe6c225..00000000 --- a/protocol-ftn/ftnoir_protocol_ftn.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ui_ftnoir_ftncontrols.h" -#include -#include -#include -#include -#include "opentrack/plugin-api.hpp" -#include "opentrack/options.hpp" -using namespace options; - -struct settings : opts { - value ip1, ip2, ip3, ip4, port; - settings() : - opts("udp-proto"), - ip1(b, "ip1", 192), - ip2(b, "ip2", 168), - ip3(b, "ip3", 0), - ip4(b, "ip4", 2), - port(b, "port", 4242) - {} -}; - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - bool correct(); - void pose(const double *headpose); - QString game_name() { - return "UDP Tracker"; - } -private: - QUdpSocket outSocket; - settings s; -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FTNControls: public IProtocolDialog -{ - Q_OBJECT -public: - FTNControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} -private: - Ui::UICFTNControls ui; - settings s; -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() { return QString("UDP receiver"); } - QIcon icon() { return QIcon(":/images/facetracknoir.png"); } -}; diff --git a/protocol-ftn/ftnoir_protocol_ftn_dialog.cpp b/protocol-ftn/ftnoir_protocol_ftn_dialog.cpp deleted file mode 100644 index 77a1508a..00000000 --- a/protocol-ftn/ftnoir_protocol_ftn_dialog.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ftnoir_protocol_ftn.h" -#include "opentrack/plugin-api.hpp" - -FTNControls::FTNControls() -{ - ui.setupUi( this ); - - tie_setting(s.ip1, ui.spinIPFirstNibble); - tie_setting(s.ip2, ui.spinIPSecondNibble); - tie_setting(s.ip3, ui.spinIPThirdNibble); - tie_setting(s.ip4, ui.spinIPFourthNibble); - tie_setting(s.port, ui.spinPortNumber); - - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); -} - -// -// OK clicked on server-dialog -// -void FTNControls::doOK() { - s.b->save(); - this->close(); -} - -// -// Cancel clicked on server-dialog -// -void FTNControls::doCancel() { - s.b->reload(); - this->close(); -} diff --git a/protocol-libevdev/CMakeLists.txt b/protocol-libevdev/CMakeLists.txt deleted file mode 100644 index 960a1271..00000000 --- a/protocol-libevdev/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -if(LINUX OR APPLE) - set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support") - if(SDK_ENABLE_LIBEVDEV) - include(FindPkgConfig) - opentrack_boilerplate(opentrack-proto-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() -endif() diff --git a/protocol-libevdev/ftnoir_libevdev_controls.ui b/protocol-libevdev/ftnoir_libevdev_controls.ui deleted file mode 100644 index d2b86445..00000000 --- a/protocol-libevdev/ftnoir_libevdev_controls.ui +++ /dev/null @@ -1,111 +0,0 @@ - - - UICLibevdevControls - - - Qt::NonModal - - - - 0 - 0 - 228 - 69 - - - - VJoy - - - - :/images/vjoy.png:/images/vjoy.png - - - Qt::LeftToRight - - - false - - - - - - Make sure rw for /dev/input/uinput! - - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - - - btnOK - btnCancel - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/protocol-libevdev/ftnoir_protocol_libevdev.cpp b/protocol-libevdev/ftnoir_protocol_libevdev.cpp deleted file mode 100644 index 96805b39..00000000 --- a/protocol-libevdev/ftnoir_protocol_libevdev.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "ftnoir_protocol_libevdev.h" -#include "opentrack/plugin-api.hpp" -#include -#include - -#include -#include - -#define CHECK_LIBEVDEV(expr) if ((error = (expr)) != 0) goto error; - -static const int max_input = 65535; -static const int mid_input = 32767; -static const int min_input = 0; - -FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) -{ - int error = 0; - - dev = libevdev_new(); - - if (!dev) - goto error; - - CHECK_LIBEVDEV(libevdev_enable_property(dev, INPUT_PROP_BUTTONPAD)); - - libevdev_set_name(dev, "opentrack headpose"); - - struct input_absinfo absinfo; - - absinfo.minimum = min_input; - absinfo.maximum = max_input; - absinfo.resolution = 1; - absinfo.value = mid_input; - absinfo.flat = 1; - absinfo.fuzz = 0; - - CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_ABS)); - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_X, &absinfo)); - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Y, &absinfo)); - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Z, &absinfo)); - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RX, &absinfo)); - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RY, &absinfo)); - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RZ, &absinfo)); - - /* do not remove next 3 lines or udev scripts won't assign 0664 permissions -sh */ - CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_KEY)); - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_KEY, BTN_JOYSTICK, NULL)); - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_KEY, BTN_TRIGGER, NULL)); - - CHECK_LIBEVDEV(libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &uidev)); - - return; -error: - if (uidev) - libevdev_uinput_destroy(uidev); - if (dev) - libevdev_free(dev); - if (error) - fprintf(stderr, "libevdev error: %d\n", error); - uidev = NULL; - dev = NULL; -} - -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - if (uidev) - libevdev_uinput_destroy(uidev); - if (dev) - libevdev_free(dev); -} - -void FTNoIR_Protocol::pose(const double* headpose) { - static const int axes[] = { - /* translation goes first */ - ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ - }; - - static const int max_value[] = { - 100, - 100, - 100, - 180, - 90, - 180 - }; - - for (int i = 0; i < 6; i++) - { - int value = headpose[i] * mid_input / max_value[i] + mid_input; - int normalized = std::max(std::min(max_input, value), min_input); - (void) libevdev_uinput_write_event(uidev, EV_ABS, axes[i], normalized); - } - - (void) libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0); -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, LibevdevControls, FTNoIR_ProtocolDll) diff --git a/protocol-libevdev/ftnoir_protocol_libevdev.h b/protocol-libevdev/ftnoir_protocol_libevdev.h deleted file mode 100644 index ecb3b201..00000000 --- a/protocol-libevdev/ftnoir_protocol_libevdev.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) 2013 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 "ui_ftnoir_libevdev_controls.h" - -#include -#include "opentrack/plugin-api.hpp" - -extern "C" { -# include -# include -} - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol() override; - bool correct() { - return dev != NULL; - } - void pose(const double *headpose); - QString game_name() { - return "Virtual joystick for Linux"; - } -private: - struct libevdev* dev; - struct libevdev_uinput* uidev; -}; - -class LibevdevControls: public IProtocolDialog -{ - Q_OBJECT -public: - LibevdevControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} - -private: - Ui::UICLibevdevControls ui; - void save(); - -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() { return QString("libevdev joystick receiver"); } - QIcon icon() { return QIcon(":/images/linux.png"); } -}; diff --git a/protocol-libevdev/ftnoir_protocol_libevdev_dialog.cpp b/protocol-libevdev/ftnoir_protocol_libevdev_dialog.cpp deleted file mode 100644 index 70495a8f..00000000 --- a/protocol-libevdev/ftnoir_protocol_libevdev_dialog.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ftnoir_protocol_libevdev.h" -#include "opentrack/plugin-api.hpp" - -LibevdevControls::LibevdevControls() -{ - ui.setupUi( this ); - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); -} - -void LibevdevControls::doOK() { - save(); - this->close(); -} - -void LibevdevControls::doCancel() { - this->close(); -} - -void LibevdevControls::save() { -} diff --git a/protocol-libevdev/images/linux.png b/protocol-libevdev/images/linux.png deleted file mode 100644 index 8836c0e2..00000000 Binary files a/protocol-libevdev/images/linux.png and /dev/null differ diff --git a/protocol-libevdev/libevdev-protocol.qrc b/protocol-libevdev/libevdev-protocol.qrc deleted file mode 100644 index 70bb415f..00000000 --- a/protocol-libevdev/libevdev-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/linux.png - - diff --git a/protocol-mouse/CMakeLists.txt b/protocol-mouse/CMakeLists.txt deleted file mode 100644 index b221c79c..00000000 --- a/protocol-mouse/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -if(WIN32) - opentrack_boilerplate(opentrack-proto-win32-mouse) -endif() diff --git a/protocol-mouse/ftnoir_mousecontrols.ui b/protocol-mouse/ftnoir_mousecontrols.ui deleted file mode 100644 index b1f4bcf8..00000000 --- a/protocol-mouse/ftnoir_mousecontrols.ui +++ /dev/null @@ -1,188 +0,0 @@ - - - UICMOUSEControls - - - Qt::NonModal - - - - 0 - 0 - 280 - 106 - - - - Mouse protocol settings - - - - :/images/mouse.png:/images/mouse.png - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - Map mouse X to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - None - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - None - - - - - X - - - - - Y - - - - - Z - - - - - Yaw - - - - - Pitch - - - - - Roll - - - - - - - - - 0 - 0 - - - - Map mouse Y to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/protocol-mouse/ftnoir_protocol_mouse.cpp b/protocol-mouse/ftnoir_protocol_mouse.cpp deleted file mode 100644 index c0a0a868..00000000 --- a/protocol-mouse/ftnoir_protocol_mouse.cpp +++ /dev/null @@ -1,54 +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 "ftnoir_protocol_mouse.h" -#include "opentrack/plugin-api.hpp" -#include - -#ifndef MOUSEEVENTF_MOVE_NOCOALESCE -# define MOUSEEVENTF_MOVE_NOCOALESCE 0x2000 -#endif - -void FTNoIR_Protocol::pose(const double *headpose ) { - RECT desktop; - const HWND hDesktop = GetDesktopWindow(); - if (hDesktop != NULL && GetWindowRect(hDesktop, &desktop)) { - // XXX TODO remove axis selector, use mapping window's - // axis selection. Mention in UI axis used. -sh 20140920 - int axis_x = s.Mouse_X; - int axis_y = s.Mouse_Y; - - int mouse_x = 0, mouse_y = 0; - - if (axis_x > 0 && axis_x <= 6) - mouse_x = headpose[axis_x-1] / (axis_x <= 3 ? 100 : 180) * 10 * desktop.right/2; - - if (axis_y > 0 && axis_y <= 6) - mouse_y = headpose[axis_y-1] / (axis_y <= 3 ? 100 : 180) * 10 * desktop.bottom/2; - - MOUSEINPUT mi; - mi.dx = mouse_x - last_x; - mi.dy = mouse_y - last_y; - mi.mouseData = 0; - mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_MOVE_NOCOALESCE; - mi.time = 0; - mi.dwExtraInfo = 0; - INPUT input; - input.type = INPUT_MOUSE; - input.mi = mi; - (void) SendInput(1, &input, sizeof(INPUT)); - - last_x = mouse_x; - last_y = mouse_y; - } -} - -bool FTNoIR_Protocol::correct() -{ - return true; -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, MOUSEControls, FTNoIR_ProtocolDll) diff --git a/protocol-mouse/ftnoir_protocol_mouse.h b/protocol-mouse/ftnoir_protocol_mouse.h deleted file mode 100644 index 595be393..00000000 --- a/protocol-mouse/ftnoir_protocol_mouse.h +++ /dev/null @@ -1,59 +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 "ui_ftnoir_mousecontrols.h" -#include -#include "opentrack/plugin-api.hpp" -#include "opentrack/options.hpp" -using namespace options; - -struct settings : opts { - value Mouse_X, Mouse_Y; - settings() : - opts("mouse-proto"), - Mouse_X(b, "mouse-x", 0), - Mouse_Y(b, "mouse-y", 0) - {} -}; - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol() : last_x(0), last_y(0) {} - bool correct(); - void pose( const double *headpose); - QString game_name() { - return "Mouse tracker"; - } - int last_x, last_y; -private: - struct settings s; -}; - -class MOUSEControls: public IProtocolDialog -{ - Q_OBJECT -public: - MOUSEControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} -private: - Ui::UICMOUSEControls ui; - settings s; -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() { return QString("mouse emulation"); } - QIcon icon() { return QIcon(":/images/mouse.png"); } -}; diff --git a/protocol-mouse/ftnoir_protocol_mouse_dialog.cpp b/protocol-mouse/ftnoir_protocol_mouse_dialog.cpp deleted file mode 100644 index bb5fe3b8..00000000 --- a/protocol-mouse/ftnoir_protocol_mouse_dialog.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "ftnoir_protocol_mouse.h" -#include "opentrack/plugin-api.hpp" - -MOUSEControls::MOUSEControls() -{ - ui.setupUi( this ); - - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - tie_setting(s.Mouse_X, ui.cbxSelectMouse_X); - tie_setting(s.Mouse_Y, ui.cbxSelectMouse_Y); -} - -void MOUSEControls::doOK() { - s.b->save(); - this->close(); -} - -void MOUSEControls::doCancel() { - s.b->reload(); - this->close(); -} - diff --git a/protocol-mouse/images/mouse.png b/protocol-mouse/images/mouse.png deleted file mode 100644 index c6f9ea26..00000000 Binary files a/protocol-mouse/images/mouse.png and /dev/null differ diff --git a/protocol-mouse/win32-mouse-protocol.qrc b/protocol-mouse/win32-mouse-protocol.qrc deleted file mode 100644 index ed6a71be..00000000 --- a/protocol-mouse/win32-mouse-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/mouse.png - - diff --git a/protocol-sc/CMakeLists.txt b/protocol-sc/CMakeLists.txt deleted file mode 100644 index bd83e944..00000000 --- a/protocol-sc/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -if(WIN32) - opentrack_boilerplate(opentrack-proto-simconnect) -endif() diff --git a/protocol-sc/ftnoir-protocol-sc.rc b/protocol-sc/ftnoir-protocol-sc.rc deleted file mode 100644 index c89eb9a7..00000000 --- a/protocol-sc/ftnoir-protocol-sc.rc +++ /dev/null @@ -1,4 +0,0 @@ -#include -142 RT_MANIFEST scserver.manifest -143 RT_MANIFEST scserver_sp2.manifest -144 RT_MANIFEST scserver_acceleration.manifest \ No newline at end of file diff --git a/protocol-sc/ftnoir_protocol_sc.cpp b/protocol-sc/ftnoir_protocol_sc.cpp deleted file mode 100644 index 0c6cb486..00000000 --- a/protocol-sc/ftnoir_protocol_sc.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend - * Copyright (c) 2014, 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 "ftnoir_protocol_sc.h" -#include "opentrack/plugin-api.hpp" - -FTNoIR_Protocol::FTNoIR_Protocol() : should_stop(false), hSimConnect(nullptr) -{ -} - -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - should_stop = true; - wait(); -} - -void FTNoIR_Protocol::run() -{ - HANDLE event = CreateEvent(NULL, FALSE, FALSE, nullptr); - - if (event == nullptr) - { - qDebug() << "simconnect: event create" << GetLastError(); - return; - } - - while (!should_stop) - { - if (SUCCEEDED(simconnect_open(&hSimConnect, "opentrack", NULL, 0, event, 0))) - { - simconnect_subscribetosystemevent(hSimConnect, 0, "Frame"); - - while (!should_stop) - { - if (WaitForSingleObject(event, 10) == WAIT_OBJECT_0) - { - if (FAILED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, reinterpret_cast(this)))) - break; - } - } - - (void) simconnect_close(hSimConnect); - } - - if (!should_stop) - Sleep(100); - } - - CloseHandle(event); -} - -void FTNoIR_Protocol::pose( const double *headpose ) { - virtSCRotX = -headpose[Pitch]; // degrees - virtSCRotY = headpose[Yaw]; - virtSCRotZ = headpose[Roll]; - - virtSCPosX = headpose[TX]/100.f; // cm to meters - virtSCPosY = headpose[TY]/100.f; - virtSCPosZ = -headpose[TZ]/100.f; -} - -#ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif - -class ActivationContext { -public: - ActivationContext(const int resid) : ok(false) { - hactctx = INVALID_HANDLE_VALUE; - actctx_cookie = 0; - ACTCTXA actx = {0}; - actx.cbSize = sizeof(ACTCTXA); - actx.lpResourceName = MAKEINTRESOURCEA(resid); - actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; -#ifdef _MSC_VER -# define PREFIX "" -#else -# define PREFIX "lib" -#endif - QString path = QCoreApplication::applicationDirPath() + "/" PREFIX "opentrack-proto-simconnect.dll"; - QByteArray name = QFile::encodeName(path); - actx.lpSource = name.constData(); - hactctx = CreateActCtxA(&actx); - actctx_cookie = 0; - if (hactctx != INVALID_HANDLE_VALUE) { - if (!ActivateActCtx(hactctx, &actctx_cookie)) { - qDebug() << "SC: can't set win32 activation context" << GetLastError(); - ReleaseActCtx(hactctx); - hactctx = INVALID_HANDLE_VALUE; - } - else - ok = true; - } else { - qDebug() << "SC: can't create win32 activation context" << GetLastError(); - } - } - ~ActivationContext() { - if (hactctx != INVALID_HANDLE_VALUE) - { - DeactivateActCtx(0, actctx_cookie); - ReleaseActCtx(hactctx); - } - } - bool is_ok() { return ok; } -private: - ULONG_PTR actctx_cookie; - HANDLE hactctx; - bool ok; -}; - -bool FTNoIR_Protocol::correct() -{ - if (!SCClientLib.isLoaded()) - { - ActivationContext ctx(142 + static_cast(s.sxs_manifest)); - - if (ctx.is_ok()) - { - SCClientLib.setFileName("SimConnect.dll"); - if (!SCClientLib.load()) { - qDebug() << "SC load" << SCClientLib.errorString(); - return false; - } - } - else - return false; - } - - simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open"); - if (simconnect_open == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_Open function not found in DLL!"; - return false; - } - simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF"); - if (simconnect_set6DOF == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_CameraSetRelative6DOF function not found in DLL!"; - return false; - } - simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close"); - if (simconnect_close == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_Close function not found in DLL!"; - return false; - } - - simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch"); - if (simconnect_calldispatch == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_CallDispatch function not found in DLL!"; - return false; - } - - simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::correct() says: SimConnect_SubscribeToSystemEvent function not found in DLL!"; - return false; - } - - start(); - - return true; -} - -void FTNoIR_Protocol::handle() -{ - (void) simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY); -} - -void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD, void *self_) -{ - FTNoIR_Protocol& self = *reinterpret_cast(self_); - - switch(pData->dwID) - { - default: - break; - case SIMCONNECT_RECV_ID_EVENT_FRAME: - self.handle(); - break; - } -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, SCControls, FTNoIR_ProtocolDll) diff --git a/protocol-sc/ftnoir_protocol_sc.h b/protocol-sc/ftnoir_protocol_sc.h deleted file mode 100644 index 671a3500..00000000 --- a/protocol-sc/ftnoir_protocol_sc.h +++ /dev/null @@ -1,108 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * Copyright (c) 2014, 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 "opentrack/plugin-api.hpp" - -#include "ui_ftnoir_sccontrols.h" -#include -#include -#include -#include -#include -#include -#include -#include "opentrack/options.hpp" -using namespace options; -#include - -struct settings : opts { - value sxs_manifest; - settings() : - opts("proto-simconnect"), - sxs_manifest(b, "sxs-manifest-version", 0) - {} -}; - -class FTNoIR_Protocol : public IProtocol, private QThread -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol() override; - bool correct(); - void pose(const double* headpose); - void handle(); - QString game_name() { - return "FS2004/FSX"; - } -private: - enum { SIMCONNECT_RECV_ID_EVENT_FRAME = 7 }; - - #pragma pack(push, 1) - struct SIMCONNECT_RECV - { - DWORD dwSize; - DWORD dwVersion; - DWORD dwID; - }; - #pragma pack(pop) - - typedef void (CALLBACK *DispatchProc)(SIMCONNECT_RECV*, DWORD, void*); - - typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); - typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); - typedef HRESULT (WINAPI *importSimConnect_CameraSetRelative6DOF)(HANDLE hSimConnect, float fDeltaX, float fDeltaY, float fDeltaZ, float fPitchDeg, float fBankDeg, float fHeadingDeg); - typedef HRESULT (WINAPI *importSimConnect_CallDispatch)(HANDLE hSimConnect, DispatchProc pfcnDispatch, void * pContext); - typedef HRESULT (WINAPI *importSimConnect_SubscribeToSystemEvent)(HANDLE hSimConnect, DWORD EventID, const char * SystemEventName); - - void run() override; - volatile bool should_stop; - - volatile float virtSCPosX; - volatile float virtSCPosY; - volatile float virtSCPosZ; - volatile float virtSCRotX; - volatile float virtSCRotY; - volatile float virtSCRotZ; - - importSimConnect_Open simconnect_open; - importSimConnect_Close simconnect_close; - importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; - importSimConnect_CallDispatch simconnect_calldispatch; - importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; - - HANDLE hSimConnect; - static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); - settings s; - QLibrary SCClientLib; -}; - -class SCControls: public IProtocolDialog -{ - Q_OBJECT -public: - SCControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} -private: - Ui::UICSCControls ui; - settings s; -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() { return QString("Microsoft FSX SimConnect"); } - QIcon icon() { return QIcon(":/images/fsx.png"); } -}; diff --git a/protocol-sc/ftnoir_protocol_sc_dialog.cpp b/protocol-sc/ftnoir_protocol_sc_dialog.cpp deleted file mode 100644 index 7c2ecfd4..00000000 --- a/protocol-sc/ftnoir_protocol_sc_dialog.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ftnoir_protocol_sc.h" -#include -#include "opentrack/plugin-api.hpp" - -SCControls::SCControls() -{ - ui.setupUi( this ); - - // Connect Qt signals to member-functions - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - tie_setting(s.sxs_manifest, ui.comboBox); -} - -void SCControls::doOK() { - s.b->save(); - this->close(); -} - -void SCControls::doCancel() { - s.b->reload(); - close(); -} - diff --git a/protocol-sc/ftnoir_sccontrols.ui b/protocol-sc/ftnoir_sccontrols.ui deleted file mode 100644 index 5b2fd291..00000000 --- a/protocol-sc/ftnoir_sccontrols.ui +++ /dev/null @@ -1,72 +0,0 @@ - - - UICSCControls - - - Qt::NonModal - - - - 0 - 0 - 290 - 79 - - - - SimConnect settings FaceTrackNoIR - - - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png - - - Qt::LeftToRight - - - false - - - - - - FSX version - - - - - - - - SP1 - - - - - SP2 - - - - - Acceleration - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/protocol-sc/images/fsx.png b/protocol-sc/images/fsx.png deleted file mode 100644 index 16b072a1..00000000 Binary files a/protocol-sc/images/fsx.png and /dev/null differ diff --git a/protocol-sc/images/fsx1.png b/protocol-sc/images/fsx1.png deleted file mode 100644 index a1f0f188..00000000 Binary files a/protocol-sc/images/fsx1.png and /dev/null differ diff --git a/protocol-sc/sc-protocol.qrc b/protocol-sc/sc-protocol.qrc deleted file mode 100644 index 127d5180..00000000 --- a/protocol-sc/sc-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/fsx.png - - diff --git a/protocol-sc/scserver.manifest b/protocol-sc/scserver.manifest deleted file mode 100644 index d342cfda..00000000 --- a/protocol-sc/scserver.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/protocol-sc/scserver_acceleration.manifest b/protocol-sc/scserver_acceleration.manifest deleted file mode 100644 index 06459587..00000000 --- a/protocol-sc/scserver_acceleration.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/protocol-sc/scserver_sp2.manifest b/protocol-sc/scserver_sp2.manifest deleted file mode 100644 index 3020d16c..00000000 --- a/protocol-sc/scserver_sp2.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/protocol-vjoy/CMakeLists.txt b/protocol-vjoy/CMakeLists.txt deleted file mode 100644 index 22678c32..00000000 --- a/protocol-vjoy/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -if(WIN32) - set(SDK_VJOY "" CACHE PATH "VJoy SDK path") - if(SDK_VJOY) - opentrack_boilerplate(opentrack-proto-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}) - install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION . ${opentrack-perms}) - endif() -endif() diff --git a/protocol-vjoy/ftnoir_protocol_vjoy.cpp b/protocol-vjoy/ftnoir_protocol_vjoy.cpp deleted file mode 100644 index 24148c63..00000000 --- a/protocol-vjoy/ftnoir_protocol_vjoy.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "ftnoir_protocol_vjoy.h" -#include "opentrack/plugin-api.hpp" - -FTNoIR_Protocol::FTNoIR_Protocol() -{ - static char meh[1] = {0}; - VJoy_Initialize(meh, meh); -} - -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - VJoy_Shutdown(); -} - -void FTNoIR_Protocol::pose( const double *headpose ) { -#ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif - JOYSTICK_STATE state[2] = { 0 }; - - state[0].POV = (4 << 12) | (4 << 8) | (4 << 4) | 4; - - state[0].XAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Yaw] * VJOY_AXIS_MAX / 180.0)); - state[0].YAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Pitch] * VJOY_AXIS_MAX / 180.0)); - state[0].ZAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Roll] * VJOY_AXIS_MAX / 180.0)); - state[0].XRotation = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[TX] * VJOY_AXIS_MAX / 100.0)); - state[0].YRotation = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[TY] * VJOY_AXIS_MAX / 100.0)); - state[0].ZRotation = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[TZ] * VJOY_AXIS_MAX / 100.0)); - - VJoy_UpdateJoyState(0, state); -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, VJoyControls, FTNoIR_ProtocolDll) diff --git a/protocol-vjoy/ftnoir_protocol_vjoy.h b/protocol-vjoy/ftnoir_protocol_vjoy.h deleted file mode 100644 index 118306b5..00000000 --- a/protocol-vjoy/ftnoir_protocol_vjoy.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Homepage http://facetracknoir.sourceforge.net/home/default.htm * - * * - * ISC License (ISC) * - * * - * Copyright (c) 2015, Wim Vriend * - * * - * 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 "ui_ftnoir_vjoy_controls.h" -#include -#include "opentrack/plugin-api.hpp" - -#define FT_PROGRAMID "FT_ProgramID" - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol() override; - bool correct() { - return true; - } - void pose( const double *headpose ); - QString game_name() { - return "Virtual joystick"; - } -private: -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class VJoyControls: public IProtocolDialog -{ - Q_OBJECT -public: - - explicit VJoyControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} - -private: - Ui::UICVJoyControls ui; - void save(); - -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() { return QString("Joystick emulation -- VJoy"); } - QIcon icon() { return QIcon(":/images/vjoy.png"); } -}; - -#define VJOY_AXIS_MIN -32768 -#define VJOY_AXIS_NIL 0 -#define VJOY_AXIS_MAX 32767 - -#include - -#include - -typedef struct _JOYSTICK_STATE -{ - UCHAR ReportId; // Report Id - SHORT XAxis; // X Axis - SHORT YAxis; // Y Axis - SHORT ZAxis; // Z Axis - SHORT XRotation; // X Rotation - SHORT YRotation; // Y Rotation - SHORT ZRotation; // Z Rotation - SHORT Slider; // Slider - SHORT Dial; // Dial - USHORT POV; // POV - UINT32 Buttons; // 32 Buttons -} JOYSTICK_STATE, * PJOYSTICK_STATE; - -#ifndef _MSC_VER -EXTERN_C BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); -EXTERN_C VOID __stdcall VJoy_Shutdown(); -EXTERN_C BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); -#else -#define VJOY_API __declspec(dllimport) -VJOY_API BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); -VJOY_API VOID __stdcall VJoy_Shutdown(); -VJOY_API BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); -#endif diff --git a/protocol-vjoy/ftnoir_protocol_vjoy_dialog.cpp b/protocol-vjoy/ftnoir_protocol_vjoy_dialog.cpp deleted file mode 100644 index 08c65558..00000000 --- a/protocol-vjoy/ftnoir_protocol_vjoy_dialog.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ftnoir_protocol_vjoy.h" -#include "opentrack/plugin-api.hpp" - -VJoyControls::VJoyControls() -{ - ui.setupUi( this ); - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); -} - -void VJoyControls::doOK() { - save(); - this->close(); -} - -void VJoyControls::doCancel() { - this->close(); -} - -void VJoyControls::save() { -} - diff --git a/protocol-vjoy/ftnoir_vjoy_controls.ui b/protocol-vjoy/ftnoir_vjoy_controls.ui deleted file mode 100644 index 2214b887..00000000 --- a/protocol-vjoy/ftnoir_vjoy_controls.ui +++ /dev/null @@ -1,113 +0,0 @@ - - - UICVJoyControls - - - Qt::NonModal - - - - 0 - 0 - 228 - 69 - - - - VJoy - - - - :/images/vjoy.png:/images/vjoy.png - - - Qt::LeftToRight - - - false - - - - - - No settings necessary - - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - - - btnOK - btnCancel - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/protocol-vjoy/images/vjoy.png b/protocol-vjoy/images/vjoy.png deleted file mode 100644 index 8eb14be8..00000000 Binary files a/protocol-vjoy/images/vjoy.png and /dev/null differ diff --git a/protocol-vjoy/vjoy-protocol.qrc b/protocol-vjoy/vjoy-protocol.qrc deleted file mode 100644 index 7b3741f1..00000000 --- a/protocol-vjoy/vjoy-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/vjoy.png - - diff --git a/protocol-vjoy/vjoy.def b/protocol-vjoy/vjoy.def deleted file mode 100644 index aea590a4..00000000 --- a/protocol-vjoy/vjoy.def +++ /dev/null @@ -1,5 +0,0 @@ -LIBRARY vjoy.dll -IMPORTS -VJoy_Initialize = _VJoy_Initialize -VJoy_Shutdown = _VJoy_Shutdown -VJoy_UpdateJoyState = _VJoy_UpdateJoyState diff --git a/protocol-wine/CMakeLists.txt b/protocol-wine/CMakeLists.txt deleted file mode 100644 index bafcff8b..00000000 --- a/protocol-wine/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -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") - if(SDK_WINE_PREFIX) - opentrack_boilerplate(opentrack-proto-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 ${PROJECT_SOURCE_DIR}/*.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) - install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" DESTINATION .) - endif() - endif() -endif() diff --git a/protocol-wine/ftnoir_protocol_wine.cpp b/protocol-wine/ftnoir_protocol_wine.cpp deleted file mode 100644 index 99ad30a2..00000000 --- a/protocol-wine/ftnoir_protocol_wine.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "ftnoir_protocol_wine.h" -#include -#include -#include /* For mode constants */ -#include /* For O_* constants */ -#include "csv/csv.h" - -FTNoIR_Protocol::FTNoIR_Protocol() : lck_shm(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)), shm(NULL), gameid(0) -{ - if (lck_shm.success()) { - shm = (WineSHM*) lck_shm.ptr(); - memset(shm, 0, sizeof(*shm)); - } - wrapper.start("wine", QStringList() << (QCoreApplication::applicationDirPath() + "/opentrack-wrapper-wine.exe.so")); -} - -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - if (shm) { - shm->stop = true; - wrapper.waitForFinished(100); - } - wrapper.terminate(); - if (!wrapper.waitForFinished(100)) - { - wrapper.kill(); - wrapper.waitForFinished(42); - } - //shm_unlink("/" WINE_SHM_NAME); -} - -void FTNoIR_Protocol::pose( const double *headpose ) { - if (shm) - { - lck_shm.lock(); - for (int i = 3; i < 6; i++) - shm->data[i] = headpose[i] / 57.295781; - for (int i = 0; i < 3; i++) - shm->data[i] = headpose[i] * 10; - if (shm->gameid != gameid) - { - QString gamename; - QMutexLocker foo(&game_name_mutex); - /* only EZCA for FSX requires dummy process, and FSX doesn't work on Linux */ - /* memory-hacks DLL can't be loaded into a Linux process, either */ - CSV::getGameData(shm->gameid, shm->table, gamename); - gameid = shm->gameid2 = shm->gameid; - connected_game = gamename; - } - lck_shm.unlock(); - } -} - -bool FTNoIR_Protocol::correct() -{ - return lck_shm.success(); -} - -OPENTRACK_DECLARE_PROTOCOL(FTNoIR_Protocol, FTControls, FTNoIR_ProtocolDll) diff --git a/protocol-wine/ftnoir_protocol_wine.h b/protocol-wine/ftnoir_protocol_wine.h deleted file mode 100644 index f78e1364..00000000 --- a/protocol-wine/ftnoir_protocol_wine.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include "ui_ftnoir_winecontrols.h" -#include -#include -#include -#include -#include -#include -#include -#include "opentrack/plugin-api.hpp" -#include "opentrack-compat/shm.h" -#include "wine-shm.h" - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol() override; - - bool correct() override; - void pose(const double* headpose) override; - QString game_name() override { - QMutexLocker foo(&game_name_mutex); - return connected_game; - } -private: - PortableLockedShm lck_shm; - WineSHM* shm; - QProcess wrapper; - int gameid; - QString connected_game; - QMutex game_name_mutex; -}; - -class FTControls: public IProtocolDialog -{ - Q_OBJECT -public: - FTControls(); - void register_protocol(IProtocol *) override {} - void unregister_protocol() override {} - -private: - Ui::UICFTControls ui; - -private slots: - void doOK(); - void doCancel(); -}; - -class FTNoIR_ProtocolDll : public Metadata -{ -public: - QString name() override { return QString("Wine -- Windows layer for Unix"); } - QIcon icon() override { return QIcon(":/images/wine.png"); } -}; diff --git a/protocol-wine/ftnoir_protocol_wine_dialog.cpp b/protocol-wine/ftnoir_protocol_wine_dialog.cpp deleted file mode 100644 index e4027c73..00000000 --- a/protocol-wine/ftnoir_protocol_wine_dialog.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "ftnoir_protocol_wine.h" -#include -#include "opentrack/plugin-api.hpp" - -FTControls::FTControls() -{ - ui.setupUi( this ); - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); -} - -void FTControls::doOK() { - this->close(); -} - -void FTControls::doCancel() { - this->close(); -} - diff --git a/protocol-wine/ftnoir_winecontrols.ui b/protocol-wine/ftnoir_winecontrols.ui deleted file mode 100644 index 9356c448..00000000 --- a/protocol-wine/ftnoir_winecontrols.ui +++ /dev/null @@ -1,170 +0,0 @@ - - - UICFTControls - - - Qt::NonModal - - - - 0 - 0 - 409 - 110 - - - - FreeTrack settings FaceTrackNoIR - - - - images/freetrack.pngimages/freetrack.png - - - Qt::LeftToRight - - - false - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - There are no settings necessary for the Wine protocol. - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/protocol-wine/images/wine.png b/protocol-wine/images/wine.png deleted file mode 100644 index bcf3a012..00000000 Binary files a/protocol-wine/images/wine.png and /dev/null differ diff --git a/protocol-wine/opentrack-wrapper-wine-main.cxx b/protocol-wine/opentrack-wrapper-wine-main.cxx deleted file mode 100644 index 082e5dde..00000000 --- a/protocol-wine/opentrack-wrapper-wine-main.cxx +++ /dev/null @@ -1,80 +0,0 @@ -#include -// OSX sdk 10.8 build error otherwise -#ifdef _LIBCPP_MSVCRT -# undef _LIBCPP_MSVCRT -#endif -#include -#include "freetrackclient/fttypes.h" -#include "wine-shm.h" -#include "opentrack-compat/export.hpp" - -enum Axis { - TX = 0, TY, TZ, Yaw, Pitch, Roll -}; - -#include "opentrack-compat/shm.h" - -void create_registry_key(void); - -class ShmPosix { -public: - ShmPosix(const char *shmName, const char *mutexName, int mapSize); - ~ShmPosix(); - void lock(); - void unlock(); - bool success(); - inline void* ptr() { return mem; } -private: - void* mem; - int fd, size; -}; - -class ShmWine { -public: - ShmWine(const char *shmName, const char *mutexName, int mapSize); - ~ShmWine(); - void lock(); - void unlock(); - bool success(); - inline void* ptr() { return mem; } -private: - void* mem; - void *hMutex, *hMapFile; -}; -#include - -int main(void) -{ - ShmPosix lck_posix(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)); - ShmWine lck_wine("FT_SharedMem", "FT_Mutext", sizeof(FTHeap)); - if(!lck_posix.success()) { - printf("Can't open posix map: %d\n", errno); - return 1; - } - if(!lck_wine.success()) { - printf("Can't open Wine map\n"); - return 1; - } - WineSHM* shm_posix = (WineSHM*) lck_posix.ptr(); - FTHeap* shm_wine = (FTHeap*) lck_wine.ptr(); - FTData* data = &shm_wine->data; - create_registry_key(); - while (1) { - if (shm_posix->stop) - break; - data->Yaw = -shm_posix->data[Yaw]; - data->Pitch = -shm_posix->data[Pitch]; - data->Roll = shm_posix->data[Roll]; - data->X = shm_posix->data[TX]; - data->Y = shm_posix->data[TY]; - data->Z = shm_posix->data[TZ]; - data->DataID++; - data->CamWidth = 250; - data->CamHeight = 100; - shm_wine->GameID2 = shm_posix->gameid2; - shm_posix->gameid = shm_wine->GameID; - for (int i = 0; i < 8; i++) - shm_wine->table[i] = shm_posix->table[i]; - (void) Sleep(4); - } -} diff --git a/protocol-wine/opentrack-wrapper-wine-posix.cxx b/protocol-wine/opentrack-wrapper-wine-posix.cxx deleted file mode 100644 index 50cce728..00000000 --- a/protocol-wine/opentrack-wrapper-wine-posix.cxx +++ /dev/null @@ -1,7 +0,0 @@ -#ifdef _WIN32 -# undef _WIN32 -#endif - -#define PortableLockedShm ShmPosix -#include "opentrack-compat/shm.h" -#include "opentrack-compat/shm.cpp" diff --git a/protocol-wine/opentrack-wrapper-wine-windows.cxx b/protocol-wine/opentrack-wrapper-wine-windows.cxx deleted file mode 100644 index 19ee8ffd..00000000 --- a/protocol-wine/opentrack-wrapper-wine-windows.cxx +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __WIN32 -# error "bad cross" -#endif - -#define PortableLockedShm ShmWine -#include "opentrack-compat/shm.h" -#include "opentrack-compat/shm.cpp" -#include "wine-shm.h" - -static void write_path(const char* key, const char* subkey) -{ - char dir[8192]; - - if (GetCurrentDirectoryA(8192, dir) < 8190) - { - HKEY hkpath; - if (RegCreateKeyExA(HKEY_CURRENT_USER, - key, - 0, - NULL, - 0, - KEY_ALL_ACCESS, - NULL, - &hkpath, - NULL) == ERROR_SUCCESS) - { - for (int i = 0; dir[i]; i++) - if (dir[i] == '\\') - dir[i] = '/'; - strcat(dir, "/"); - (void) RegSetValueExA(hkpath, subkey, 0, REG_SZ, (BYTE*) dir, strlen(dir) + 1); - RegCloseKey(hkpath); - } - } -} - -void create_registry_key(void) { - write_path("Software\\NaturalPoint\\NATURALPOINT\\NPClient Location", "Path"); - write_path("Software\\Freetrack\\FreeTrackClient", "Path"); -} diff --git a/protocol-wine/wine-protocol.qrc b/protocol-wine/wine-protocol.qrc deleted file mode 100644 index af81caea..00000000 --- a/protocol-wine/wine-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/wine.png - - diff --git a/protocol-wine/wine-shm.h b/protocol-wine/wine-shm.h deleted file mode 100644 index c7e29abb..00000000 --- a/protocol-wine/wine-shm.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#define WINE_SHM_NAME "facetracknoir-wine-shm" -#define WINE_MTX_NAME "facetracknoir-wine-mtx" - -// OSX sdk 10.8 build error otherwise -#ifdef _LIBCPP_MSVCRT -# undef _LIBCPP_MSVCRT -#endif - -#include - -template using ptr = std::shared_ptr; - -struct WineSHM { - double data[6]; - int gameid, gameid2; - unsigned char table[8]; - bool stop; -}; -- cgit v1.2.3 From 8318ee4d821a4826b8e80369f499b3758abe8f4c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 10:07:13 +0100 Subject: cmake: lessen logspam with no opencv --- filter-kalman/CMakeLists.txt | 10 ++++++---- tracker-aruco/CMakeLists.txt | 2 +- tracker-ht/CMakeLists.txt | 2 +- tracker-pt/CMakeLists.txt | 12 +++++++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/filter-kalman/CMakeLists.txt b/filter-kalman/CMakeLists.txt index 666a35db..e2796c11 100644 --- a/filter-kalman/CMakeLists.txt +++ b/filter-kalman/CMakeLists.txt @@ -1,4 +1,6 @@ -find_package(OpenCV 3.0) -opentrack_boilerplate(opentrack-filter-kalman) -target_link_libraries(opentrack-filter-kalman ${OpenCV_LIBS}) -target_include_directories(opentrack-filter-kalman SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) +find_package(OpenCV 3.0 QUIET) +if(OpenCV_FOUND) + opentrack_boilerplate(opentrack-filter-kalman) + target_link_libraries(opentrack-filter-kalman ${OpenCV_LIBS}) + target_include_directories(opentrack-filter-kalman SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) +endif() diff --git a/tracker-aruco/CMakeLists.txt b/tracker-aruco/CMakeLists.txt index ed52eee6..70d742ee 100644 --- a/tracker-aruco/CMakeLists.txt +++ b/tracker-aruco/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(OpenCV 3.0) +find_package(OpenCV 3.0 QUIET) set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Aruco paper marker tracker static library path") if(SDK_ARUCO_LIBPATH) opentrack_boilerplate(opentrack-tracker-aruco) diff --git a/tracker-ht/CMakeLists.txt b/tracker-ht/CMakeLists.txt index 74fd9056..248a113e 100644 --- a/tracker-ht/CMakeLists.txt +++ b/tracker-ht/CMakeLists.txt @@ -1,6 +1,6 @@ set(SDK_HT "" CACHE FILEPATH "Path to headtracker library") set(SDK_HT_FLANDMARK "" CACHE FILEPATH "Path to flandmark library for headtracker") -find_package(OpenCV 3.0) +find_package(OpenCV 3.0 QUIET) if(OpenCV_FOUND) if(SDK_HT AND SDK_HT_FLANDMARK) opentrack_boilerplate(opentrack-tracker-ht) diff --git a/tracker-pt/CMakeLists.txt b/tracker-pt/CMakeLists.txt index 94b04437..36710ecf 100644 --- a/tracker-pt/CMakeLists.txt +++ b/tracker-pt/CMakeLists.txt @@ -1,5 +1,7 @@ -find_package(OpenCV 3.0) -opentrack_boilerplate(opentrack-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) +find_package(OpenCV 3.0 QUIET) +if(OpenCV_FOUND) + opentrack_boilerplate(opentrack-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) +endif() -- cgit v1.2.3 From 48c30a3d75d18e87e39c18cb52961bb37ab6055e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 Oct 2015 10:07:42 +0100 Subject: qxt: fix unix build --- cmake/opentrack-macros.cmake | 4 +- gui/CMakeLists.txt | 33 ++-- qxt-mini/plat/qxtglobalshortcut_mac.cpp | 268 ------------------------------- qxt-mini/plat/qxtglobalshortcut_x11.cpp | 235 --------------------------- qxt-mini/qxtglobal.h | 4 +- qxt-mini/qxtglobalshortcut.cpp | 1 + qxt-mini/qxtglobalshortcut_mac.cpp | 271 ++++++++++++++++++++++++++++++++ qxt-mini/qxtglobalshortcut_x11.cpp | 238 ++++++++++++++++++++++++++++ 8 files changed, 523 insertions(+), 531 deletions(-) delete mode 100644 qxt-mini/plat/qxtglobalshortcut_mac.cpp delete mode 100644 qxt-mini/plat/qxtglobalshortcut_x11.cpp create mode 100644 qxt-mini/qxtglobalshortcut_mac.cpp create mode 100644 qxt-mini/qxtglobalshortcut_x11.cpp diff --git a/cmake/opentrack-macros.cmake b/cmake/opentrack-macros.cmake index a9fa5bc7..df19ddf0 100644 --- a/cmake/opentrack-macros.cmake +++ b/cmake/opentrack-macros.cmake @@ -32,7 +32,7 @@ endfunction() macro(opentrack_library n dir) cmake_parse_arguments(opentrack-foolib - "NO-LIBRARY;STATIC;NO-COMPAT" + "NO-LIBRARY;STATIC;NO-COMPAT;NO-LINKER-SCRIPT" "LINK;COMPILE;GNU-LINK;GNU-COMPILE" "" ${ARGN} @@ -52,7 +52,7 @@ macro(opentrack_library n dir) if(NOT opentrack-foolib_NO-COMPAT) target_link_libraries(${n} opentrack-api ${MY_QT_LIBS} opentrack-compat) endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND NOT NO-LINKER-SCRIPT) SET_TARGET_PROPERTIES(${n} PROPERTIES LINK_FLAGS "${opentrack-foolib_LINK} ${opentrack-foolib_GNU-LINK} -Wl,--as-needed -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack-compat/${version-script}-version-script.txt\"" COMPILE_FLAGS "${opentrack-foolib_COMPILE} ${opentrack-foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden" diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 51d0cea3..b2540a68 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -1,25 +1,5 @@ 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() @@ -30,12 +10,19 @@ 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(UNIX OR APPLE) + target_include_directories(opentrack PRIVATE "${CMAKE_SOURCE_DIR}/qxt-mini") + opentrack_library(opentrack-qxt-mini ${CMAKE_SOURCE_DIR}/qxt-mini NO-LINKER-SCRIPT STATIC) + if(NOT APPLE) + target_link_libraries(opentrack-qxt-mini X11) + endif() +endif() + if(NOT WIN32) set_target_properties(opentrack PROPERTIES SUFFIX ".bin") endif() diff --git a/qxt-mini/plat/qxtglobalshortcut_mac.cpp b/qxt-mini/plat/qxtglobalshortcut_mac.cpp deleted file mode 100644 index 1181b293..00000000 --- a/qxt-mini/plat/qxtglobalshortcut_mac.cpp +++ /dev/null @@ -1,268 +0,0 @@ -#include -/**************************************************************************** -** Copyright (c) 2006 - 2011, the LibQxt project. -** See the Qxt AUTHORS file for a list of authors and copyright holders. -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the LibQxt project nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -** -*****************************************************************************/ - -#pragma GCC diagnostic ignored "-Wfour-char-constants" -#pragma GCC diagnostic ignored "-Wunused-parameter" - -#include "qxtglobalshortcut_p.h" -#include -#include -#include -#include - -typedef QPair Identifier; -static QMap keyRefs; -static QHash keyIDs; -static quint32 hotKeySerial = 0; -static bool qxt_mac_handler_installed = false; - -OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) -{ - Q_UNUSED(nextHandler); - Q_UNUSED(data); - if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) - { - EventHotKeyID keyID; - GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); - Identifier id = keyIDs.key(keyID.id); - if(id != Identifier()) - QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); - } - return noErr; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= shiftKey; - if (modifiers & Qt::ControlModifier) - native |= cmdKey; - if (modifiers & Qt::AltModifier) - native |= optionKey; - if (modifiers & Qt::MetaModifier) - native |= controlKey; - if (modifiers & Qt::KeypadModifier) - native |= kEventKeyModifierNumLockMask; - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - UTF16Char ch; - // Constants found in NSEvent.h from AppKit.framework - switch (key) - { - case Qt::Key_Return: - return kVK_Return; - case Qt::Key_Enter: - return kVK_ANSI_KeypadEnter; - case Qt::Key_Tab: - return kVK_Tab; - case Qt::Key_Space: - return kVK_Space; - case Qt::Key_Backspace: - return kVK_Delete; - case Qt::Key_Control: - return kVK_Command; - case Qt::Key_Shift: - return kVK_Shift; - case Qt::Key_CapsLock: - return kVK_CapsLock; - case Qt::Key_Option: - return kVK_Option; - case Qt::Key_Meta: - return kVK_Control; - case Qt::Key_F17: - return kVK_F17; - case Qt::Key_VolumeUp: - return kVK_VolumeUp; - case Qt::Key_VolumeDown: - return kVK_VolumeDown; - case Qt::Key_F18: - return kVK_F18; - case Qt::Key_F19: - return kVK_F19; - case Qt::Key_F20: - return kVK_F20; - case Qt::Key_F5: - return kVK_F5; - case Qt::Key_F6: - return kVK_F6; - case Qt::Key_F7: - return kVK_F7; - case Qt::Key_F3: - return kVK_F3; - case Qt::Key_F8: - return kVK_F8; - case Qt::Key_F9: - return kVK_F9; - case Qt::Key_F11: - return kVK_F11; - case Qt::Key_F13: - return kVK_F13; - case Qt::Key_F16: - return kVK_F16; - case Qt::Key_F14: - return kVK_F14; - case Qt::Key_F10: - return kVK_F10; - case Qt::Key_F12: - return kVK_F12; - case Qt::Key_F15: - return kVK_F15; - case Qt::Key_Help: - return kVK_Help; - case Qt::Key_Home: - return kVK_Home; - case Qt::Key_PageUp: - return kVK_PageUp; - case Qt::Key_Delete: - return kVK_ForwardDelete; - case Qt::Key_F4: - return kVK_F4; - case Qt::Key_End: - return kVK_End; - case Qt::Key_F2: - return kVK_F2; - case Qt::Key_PageDown: - return kVK_PageDown; - case Qt::Key_F1: - return kVK_F1; - case Qt::Key_Left: - return kVK_LeftArrow; - case Qt::Key_Right: - return kVK_RightArrow; - case Qt::Key_Down: - return kVK_DownArrow; - case Qt::Key_Up: - return kVK_UpArrow; - default: - ; - } - - if (key == Qt::Key_Escape) ch = 27; - else if (key == Qt::Key_Return) ch = 13; - else if (key == Qt::Key_Enter) ch = 3; - else if (key == Qt::Key_Tab) ch = 9; - else ch = key; - - CFDataRef currentLayoutData; - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); - - if (currentKeyboard == NULL) - return 0; - - currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); - CFRelease(currentKeyboard); - if (currentLayoutData == NULL) - return 0; - - UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); - UCKeyboardTypeHeader* table = header->keyboardTypeList; - - uint8_t *data = (uint8_t*)header; - // God, would a little documentation for this shit kill you... - for (quint32 i=0; i < header->keyboardTypeCount; i++) - { - UCKeyStateRecordsIndex* stateRec = 0; - if (table[i].keyStateRecordsIndexOffset != 0) - { - stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); - if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; - } - - UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); - if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; - - for (quint32 j=0; j < charTable->keyToCharTableCount; j++) - { - UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); - for (quint32 k=0; k < charTable->keyToCharTableSize; k++) - { - if (keyToChar[k] & kUCKeyOutputTestForIndexMask) - { - long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; - if (stateRec && idx < stateRec->keyStateRecordCount) - { - UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); - if (rec->stateZeroCharData == ch) return k; - } - } - else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) - { - if (keyToChar[k] == ch) return k; - } - } // for k - } // for j - } // for i - return 0; -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - if (!qxt_mac_handler_installed) - { - qxt_mac_handler_installed = true; - EventTypeSpec t; - t.eventClass = kEventClassKeyboard; - t.eventKind = kEventHotKeyPressed; - InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); - } - - EventHotKeyID keyID; - keyID.signature = 'cute'; - keyID.id = ++hotKeySerial; - - EventHotKeyRef ref = 0; - bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); - if (rv) - { - keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); - keyRefs.insert(keyID.id, ref); - } - return rv; -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Identifier id(nativeMods, nativeKey); - if (!keyIDs.contains(id)) return false; - - EventHotKeyRef ref = keyRefs.take(keyIDs[id]); - keyIDs.remove(id); - return !UnregisterEventHotKey(ref); -} -bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, - void *message, long *result) -{ - return false; -} diff --git a/qxt-mini/plat/qxtglobalshortcut_x11.cpp b/qxt-mini/plat/qxtglobalshortcut_x11.cpp deleted file mode 100644 index f18f86db..00000000 --- a/qxt-mini/plat/qxtglobalshortcut_x11.cpp +++ /dev/null @@ -1,235 +0,0 @@ -#include "../qxtglobalshortcut_p.h" -/**************************************************************************** -** Copyright (c) 2006 - 2011, the LibQxt project. -** See the Qxt AUTHORS file for a list of authors and copyright holders. -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the LibQxt project nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -** -*****************************************************************************/ - -#include -#include -// include private header for great justice -sh 20131015 -#include -#include -#include "qplatformnativeinterface.h" - -namespace { - -const QVector maskModifiers = QVector() - << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask); - -typedef int (*X11ErrorHandler)(Display *display, XErrorEvent *event); - -class QxtX11ErrorHandler { -public: - static bool error; - - static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) - { - Q_UNUSED(display); - switch (event->error_code) - { - case BadAccess: - case BadValue: - case BadWindow: - if (event->request_code == 33 /* X_GrabKey */ || - event->request_code == 34 /* X_UngrabKey */) - { - error = true; - //TODO: - //char errstr[256]; - //XGetErrorText(dpy, err->error_code, errstr, 256); - } - } - return 0; - } - - QxtX11ErrorHandler() - { - error = false; - m_previousErrorHandler = XSetErrorHandler(qxtX11ErrorHandler); - } - - ~QxtX11ErrorHandler() - { - XSetErrorHandler(m_previousErrorHandler); - } - -private: - X11ErrorHandler m_previousErrorHandler; -}; - -bool QxtX11ErrorHandler::error = false; - -class QxtX11Data { -public: - QxtX11Data() - { -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) - m_display = QX11Info::display(); -#else - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - void *display = native->nativeResourceForScreen(QByteArray("display"), - QGuiApplication::primaryScreen()); - m_display = reinterpret_cast(display); -#endif - } - - bool isValid() - { - return m_display != 0; - } - - Display *display() - { - Q_ASSERT(isValid()); - return m_display; - } - - Window rootWindow() - { - return DefaultRootWindow(display()); - } - - bool grabKey(quint32 keycode, quint32 modifiers, Window window) - { - QxtX11ErrorHandler errorHandler; - - for (int i = 0; !errorHandler.error && i < maskModifiers.size(); ++i) { - XGrabKey(display(), keycode, modifiers | maskModifiers[i], window, True, - GrabModeAsync, GrabModeAsync); - } - - if (errorHandler.error) { - ungrabKey(keycode, modifiers, window); - return false; - } - - return true; - } - - bool ungrabKey(quint32 keycode, quint32 modifiers, Window window) - { - QxtX11ErrorHandler errorHandler; - - foreach (quint32 maskMods, maskModifiers) { - XUngrabKey(display(), keycode, modifiers | maskMods, window); - } - - return !errorHandler.error; - } - -private: - Display *m_display; -}; - -} // namespace - -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) -bool QxtGlobalShortcutPrivate::eventFilter(void *message) -{ - XEvent *event = static_cast(message); - if (event->type == KeyPress) - { - XKeyEvent *key = reinterpret_cast(event); - unsigned int keycode = key->keycode; - unsigned int keystate = key->state; -#else -bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, - void *message, long *result) -{ - Q_UNUSED(result); - - xcb_key_press_event_t *kev = 0; - if (eventType == "xcb_generic_event_t") { - xcb_generic_event_t *ev = static_cast(message); - if ((ev->response_type & 127) == XCB_KEY_PRESS) - kev = static_cast(message); - } - - if (kev != 0) { - unsigned int keycode = kev->detail; - unsigned int keystate = 0; - if(kev->state & XCB_MOD_MASK_1) - keystate |= Mod1Mask; - if(kev->state & XCB_MOD_MASK_CONTROL) - keystate |= ControlMask; - if(kev->state & XCB_MOD_MASK_4) - keystate |= Mod4Mask; - if(kev->state & XCB_MOD_MASK_SHIFT) - keystate |= ShiftMask; -#endif - activateShortcut(keycode, - // Mod1Mask == Alt, Mod4Mask == Meta - keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); - } - return false; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= ShiftMask; - if (modifiers & Qt::ControlModifier) - native |= ControlMask; - if (modifiers & Qt::AltModifier) - native |= Mod1Mask; - if (modifiers & Qt::MetaModifier) - native |= Mod4Mask; - - // TODO: resolve these? - //if (modifiers & Qt::MetaModifier) - //if (modifiers & Qt::KeypadModifier) - //if (modifiers & Qt::GroupSwitchModifier) - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - QxtX11Data x11; - if (!x11.isValid()) - return 0; - - KeySym keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); - if (keysym == NoSymbol) - keysym = static_cast(key); - - return XKeysymToKeycode(x11.display(), keysym); -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - QxtX11Data x11; - return x11.isValid() && x11.grabKey(nativeKey, nativeMods, x11.rootWindow()); -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - QxtX11Data x11; - return x11.isValid() && x11.ungrabKey(nativeKey, nativeMods, x11.rootWindow()); -} diff --git a/qxt-mini/qxtglobal.h b/qxt-mini/qxtglobal.h index fa592181..574482ae 100644 --- a/qxt-mini/qxtglobal.h +++ b/qxt-mini/qxtglobal.h @@ -51,9 +51,7 @@ #define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE -#define QXT_STATIC - -#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) +#ifdef QXT_BUILD # if defined(BUILD_QXT_CORE) # define QXT_CORE_EXPORT Q_DECL_EXPORT # else diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp index 45576d37..4b400a72 100644 --- a/qxt-mini/qxtglobalshortcut.cpp +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -1,3 +1,4 @@ +#define QXT_BUILD #include "qxtglobalshortcut.h" /**************************************************************************** ** Copyright (c) 2006 - 2011, the LibQxt project. diff --git a/qxt-mini/qxtglobalshortcut_mac.cpp b/qxt-mini/qxtglobalshortcut_mac.cpp new file mode 100644 index 00000000..34de694e --- /dev/null +++ b/qxt-mini/qxtglobalshortcut_mac.cpp @@ -0,0 +1,271 @@ +#ifdef __APPLE__ +#define QXT_BUILD +#include +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#pragma GCC diagnostic ignored "-Wfour-char-constants" +#pragma GCC diagnostic ignored "-Wunused-parameter" + +#include "qxtglobalshortcut_p.h" +#include +#include +#include +#include + +typedef QPair Identifier; +static QMap keyRefs; +static QHash keyIDs; +static quint32 hotKeySerial = 0; +static bool qxt_mac_handler_installed = false; + +OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) +{ + Q_UNUSED(nextHandler); + Q_UNUSED(data); + if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) + { + EventHotKeyID keyID; + GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); + Identifier id = keyIDs.key(keyID.id); + if(id != Identifier()) + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); + } + return noErr; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= shiftKey; + if (modifiers & Qt::ControlModifier) + native |= cmdKey; + if (modifiers & Qt::AltModifier) + native |= optionKey; + if (modifiers & Qt::MetaModifier) + native |= controlKey; + if (modifiers & Qt::KeypadModifier) + native |= kEventKeyModifierNumLockMask; + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + UTF16Char ch; + // Constants found in NSEvent.h from AppKit.framework + switch (key) + { + case Qt::Key_Return: + return kVK_Return; + case Qt::Key_Enter: + return kVK_ANSI_KeypadEnter; + case Qt::Key_Tab: + return kVK_Tab; + case Qt::Key_Space: + return kVK_Space; + case Qt::Key_Backspace: + return kVK_Delete; + case Qt::Key_Control: + return kVK_Command; + case Qt::Key_Shift: + return kVK_Shift; + case Qt::Key_CapsLock: + return kVK_CapsLock; + case Qt::Key_Option: + return kVK_Option; + case Qt::Key_Meta: + return kVK_Control; + case Qt::Key_F17: + return kVK_F17; + case Qt::Key_VolumeUp: + return kVK_VolumeUp; + case Qt::Key_VolumeDown: + return kVK_VolumeDown; + case Qt::Key_F18: + return kVK_F18; + case Qt::Key_F19: + return kVK_F19; + case Qt::Key_F20: + return kVK_F20; + case Qt::Key_F5: + return kVK_F5; + case Qt::Key_F6: + return kVK_F6; + case Qt::Key_F7: + return kVK_F7; + case Qt::Key_F3: + return kVK_F3; + case Qt::Key_F8: + return kVK_F8; + case Qt::Key_F9: + return kVK_F9; + case Qt::Key_F11: + return kVK_F11; + case Qt::Key_F13: + return kVK_F13; + case Qt::Key_F16: + return kVK_F16; + case Qt::Key_F14: + return kVK_F14; + case Qt::Key_F10: + return kVK_F10; + case Qt::Key_F12: + return kVK_F12; + case Qt::Key_F15: + return kVK_F15; + case Qt::Key_Help: + return kVK_Help; + case Qt::Key_Home: + return kVK_Home; + case Qt::Key_PageUp: + return kVK_PageUp; + case Qt::Key_Delete: + return kVK_ForwardDelete; + case Qt::Key_F4: + return kVK_F4; + case Qt::Key_End: + return kVK_End; + case Qt::Key_F2: + return kVK_F2; + case Qt::Key_PageDown: + return kVK_PageDown; + case Qt::Key_F1: + return kVK_F1; + case Qt::Key_Left: + return kVK_LeftArrow; + case Qt::Key_Right: + return kVK_RightArrow; + case Qt::Key_Down: + return kVK_DownArrow; + case Qt::Key_Up: + return kVK_UpArrow; + default: + ; + } + + if (key == Qt::Key_Escape) ch = 27; + else if (key == Qt::Key_Return) ch = 13; + else if (key == Qt::Key_Enter) ch = 3; + else if (key == Qt::Key_Tab) ch = 9; + else ch = key; + + CFDataRef currentLayoutData; + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + + if (currentKeyboard == NULL) + return 0; + + currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + CFRelease(currentKeyboard); + if (currentLayoutData == NULL) + return 0; + + UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); + UCKeyboardTypeHeader* table = header->keyboardTypeList; + + uint8_t *data = (uint8_t*)header; + // God, would a little documentation for this shit kill you... + for (quint32 i=0; i < header->keyboardTypeCount; i++) + { + UCKeyStateRecordsIndex* stateRec = 0; + if (table[i].keyStateRecordsIndexOffset != 0) + { + stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); + if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; + } + + UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); + if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; + + for (quint32 j=0; j < charTable->keyToCharTableCount; j++) + { + UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); + for (quint32 k=0; k < charTable->keyToCharTableSize; k++) + { + if (keyToChar[k] & kUCKeyOutputTestForIndexMask) + { + long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; + if (stateRec && idx < stateRec->keyStateRecordCount) + { + UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); + if (rec->stateZeroCharData == ch) return k; + } + } + else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) + { + if (keyToChar[k] == ch) return k; + } + } // for k + } // for j + } // for i + return 0; +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + if (!qxt_mac_handler_installed) + { + qxt_mac_handler_installed = true; + EventTypeSpec t; + t.eventClass = kEventClassKeyboard; + t.eventKind = kEventHotKeyPressed; + InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); + } + + EventHotKeyID keyID; + keyID.signature = 'cute'; + keyID.id = ++hotKeySerial; + + EventHotKeyRef ref = 0; + bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); + if (rv) + { + keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); + keyRefs.insert(keyID.id, ref); + } + return rv; +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Identifier id(nativeMods, nativeKey); + if (!keyIDs.contains(id)) return false; + + EventHotKeyRef ref = keyRefs.take(keyIDs[id]); + keyIDs.remove(id); + return !UnregisterEventHotKey(ref); +} +bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, + void *message, long *result) +{ + return false; +} +#endif diff --git a/qxt-mini/qxtglobalshortcut_x11.cpp b/qxt-mini/qxtglobalshortcut_x11.cpp new file mode 100644 index 00000000..b13770a2 --- /dev/null +++ b/qxt-mini/qxtglobalshortcut_x11.cpp @@ -0,0 +1,238 @@ +#ifndef __APPLE_ +#define QXT_BUILD +#include "qxtglobalshortcut_p.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include +#include +// include private header for great justice -sh 20131015 +#include +#include +#include "qplatformnativeinterface.h" + +namespace { + +const QVector maskModifiers = QVector() + << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask); + +typedef int (*X11ErrorHandler)(Display *display, XErrorEvent *event); + +class QxtX11ErrorHandler { +public: + static bool error; + + static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) + { + Q_UNUSED(display); + switch (event->error_code) + { + case BadAccess: + case BadValue: + case BadWindow: + if (event->request_code == 33 /* X_GrabKey */ || + event->request_code == 34 /* X_UngrabKey */) + { + error = true; + //TODO: + //char errstr[256]; + //XGetErrorText(dpy, err->error_code, errstr, 256); + } + } + return 0; + } + + QxtX11ErrorHandler() + { + error = false; + m_previousErrorHandler = XSetErrorHandler(qxtX11ErrorHandler); + } + + ~QxtX11ErrorHandler() + { + XSetErrorHandler(m_previousErrorHandler); + } + +private: + X11ErrorHandler m_previousErrorHandler; +}; + +bool QxtX11ErrorHandler::error = false; + +class QxtX11Data { +public: + QxtX11Data() + { +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + m_display = QX11Info::display(); +#else + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + void *display = native->nativeResourceForScreen(QByteArray("display"), + QGuiApplication::primaryScreen()); + m_display = reinterpret_cast(display); +#endif + } + + bool isValid() + { + return m_display != 0; + } + + Display *display() + { + Q_ASSERT(isValid()); + return m_display; + } + + Window rootWindow() + { + return DefaultRootWindow(display()); + } + + bool grabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + for (int i = 0; !errorHandler.error && i < maskModifiers.size(); ++i) { + XGrabKey(display(), keycode, modifiers | maskModifiers[i], window, True, + GrabModeAsync, GrabModeAsync); + } + + if (errorHandler.error) { + ungrabKey(keycode, modifiers, window); + return false; + } + + return true; + } + + bool ungrabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + foreach (quint32 maskMods, maskModifiers) { + XUngrabKey(display(), keycode, modifiers | maskMods, window); + } + + return !errorHandler.error; + } + +private: + Display *m_display; +}; + +} // namespace + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +bool QxtGlobalShortcutPrivate::eventFilter(void *message) +{ + XEvent *event = static_cast(message); + if (event->type == KeyPress) + { + XKeyEvent *key = reinterpret_cast(event); + unsigned int keycode = key->keycode; + unsigned int keystate = key->state; +#else +bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, + void *message, long *result) +{ + Q_UNUSED(result); + + xcb_key_press_event_t *kev = 0; + if (eventType == "xcb_generic_event_t") { + xcb_generic_event_t *ev = static_cast(message); + if ((ev->response_type & 127) == XCB_KEY_PRESS) + kev = static_cast(message); + } + + if (kev != 0) { + unsigned int keycode = kev->detail; + unsigned int keystate = 0; + if(kev->state & XCB_MOD_MASK_1) + keystate |= Mod1Mask; + if(kev->state & XCB_MOD_MASK_CONTROL) + keystate |= ControlMask; + if(kev->state & XCB_MOD_MASK_4) + keystate |= Mod4Mask; + if(kev->state & XCB_MOD_MASK_SHIFT) + keystate |= ShiftMask; +#endif + activateShortcut(keycode, + // Mod1Mask == Alt, Mod4Mask == Meta + keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); + } + return false; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= ShiftMask; + if (modifiers & Qt::ControlModifier) + native |= ControlMask; + if (modifiers & Qt::AltModifier) + native |= Mod1Mask; + if (modifiers & Qt::MetaModifier) + native |= Mod4Mask; + + // TODO: resolve these? + //if (modifiers & Qt::MetaModifier) + //if (modifiers & Qt::KeypadModifier) + //if (modifiers & Qt::GroupSwitchModifier) + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + QxtX11Data x11; + if (!x11.isValid()) + return 0; + + KeySym keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); + if (keysym == NoSymbol) + keysym = static_cast(key); + + return XKeysymToKeycode(x11.display(), keysym); +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.grabKey(nativeKey, nativeMods, x11.rootWindow()); +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.ungrabKey(nativeKey, nativeMods, x11.rootWindow()); +} +#endif -- cgit v1.2.3