From 0739d5b595be9492c1e574192eba12174111e52c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik <sthalik@misaki.pl> 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 @@ +<RCC> + <qresource prefix="/"> + <file>images/flightgear.png</file> + </qresource> +</RCC> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICFGControls</class> + <widget class="QWidget" name="UICFGControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>415</width> + <height>112</height> + </rect> + </property> + <property name="windowTitle"> + <string>FlightGear protocol settings</string> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>IP-address remote PC</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="spinIPFirstNibble"> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QSpinBox" name="spinIPSecondNibble"> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QSpinBox" name="spinIPThirdNibble"> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QSpinBox" name="spinIPFourthNibble"> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Port-number</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="spinPortNumber"> + <property name="minimum"> + <number>1000</number> + </property> + <property name="maximum"> + <number>10000</number> + </property> + </widget> + </item> + <item row="2" column="2" colspan="3"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>spinIPFirstNibble</tabstop> + <tabstop>spinIPSecondNibble</tabstop> + <tabstop>spinIPThirdNibble</tabstop> + <tabstop>spinIPFourthNibble</tabstop> + <tabstop>spinPortNumber</tabstop> + </tabstops> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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<int>(s.ip1)), + QString::number(static_cast<int>(s.ip2)), + QString::number(static_cast<int>(s.ip3)), + QString::number(static_cast<int>(s.ip4)))); + int destPort = s.port; + (void) outSocket.writeDatagram(reinterpret_cast<const char*>(&FlightData), sizeof(FlightData), destIP, static_cast<quint16>(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 <QThread> +#include <QUdpSocket> +#include <QMessageBox> +#include "opentrack/plugin-api.hpp" +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value<int> ip1, ip2, ip3, ip4; + value<int> 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 <QObject> +#include <QFile> +#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 @@ +<RCC> + <qresource prefix="/"> + <file>images/fs9.png</file> + </qresource> +</RCC> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICFSUIPCControls</class> + <widget class="QWidget" name="UICFSUIPCControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>512</width> + <height>100</height> + </rect> + </property> + <property name="windowTitle"> + <string>FSUIPC settings FaceTrackNoIR</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="2" column="1"> + <widget class="QPushButton" name="btnCancel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="txtLocationOfDLL"> + <property name="minimumSize"> + <size> + <width>230</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Location of FSUIPC.dll</string> + </property> + <property name="frameShape"> + <enum>QFrame::Box</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + <property name="text"> + <string>Location of FSUIPC.dll</string> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>The DLL should be located in the Modules/ directory of MS FS 2004</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QPushButton" name="btnOK"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>OK</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="btnFindDLL"> + <property name="maximumSize"> + <size> + <width>35</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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 <windows.h> +#include <stdlib.h> +#include "FSUIPC_User.h" +#include "opentrack/plugin-api.hpp" +#include "ui_ftnoir_fsuipccontrols.h" +#include <QMessageBox> +#include <QSettings> +#include <QLibrary> +#include <QProcess> +#include <QDebug> +#include <QFile> +#include <QFileDialog> +#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<QString> 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 @@ +<RCC> + <qresource prefix="/"> + <file>images/freetrack.png</file> + </qresource> +</RCC> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICFTControls</class> + <widget class="QWidget" name="UICFTControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>422</width> + <height>305</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="windowTitle"> + <string>freetrack protocol settings</string> + </property> + <property name="windowIcon"> + <iconset resource="ft-protocol.qrc"> + <normaloff>:/images/freetrack.png</normaloff>:/images/freetrack.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>TIRViews</string> + </property> + <property name="alignment"> + <set>Qt::AlignJustify|Qt::AlignTop</set> + </property> + <property name="flat"> + <bool>false</bool> + </property> + <layout class="QFormLayout" name="formLayout_2"> + <item row="0" column="0"> + <widget class="QCheckBox" name="chkTIRViews"> + <property name="layoutDirection"> + <enum>Qt::RightToLeft</enum> + </property> + <property name="text"> + <string>Memory hacks</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Only for very old and buggy old games such as CFS3.</string> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="0"> + <widget class="QGroupBox" name="groupBox_4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Repair NPClient location</string> + </property> + <property name="alignment"> + <set>Qt::AlignJustify|Qt::AlignTop</set> + </property> + <property name="flat"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QPushButton" name="bntLocateNPClient"> + <property name="text"> + <string>Locate DLL</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="3" column="0"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="groupBox_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Select interface</string> + </property> + <property name="alignment"> + <set>Qt::AlignJustify|Qt::AlignTop</set> + </property> + <property name="flat"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> + <widget class="QComboBox" name="cbxSelectInterface"/> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Disable one of the protocols if game is confused by presence of both at the same time.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="ft-protocol.qrc"/> + </resources> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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 <sthalik@misaki.pl> + * 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 <sthalik@misaki.pl> + * 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 <QMessageBox> +#include <QSettings> +#include <QLibrary> +#include <QProcess> +#include <QDebug> +#include <QFile> +#include <QString> +#include <QMutex> +#include <QMutexLocker> +#include "opentrack-compat/shm.h" +#include "opentrack/options.hpp" +#include "freetrackclient/fttypes.h" +using namespace options; + +struct settings : opts { + value<int> intUsedInterface; + value<bool> 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 <QDebug> +#include <QFileDialog> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICFTNControls</class> + <widget class="QWidget" name="UICFTNControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>411</width> + <height>169</height> + </rect> + </property> + <property name="windowTitle"> + <string>UDP protocol settings</string> + </property> + <property name="windowIcon"> + <iconset resource="../gui/main-facetracknoir.qrc"> + <normaloff>:/images/facetracknoir.png</normaloff>:/images/facetracknoir.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QVBoxLayout" name="_vertical_layout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="4"> + <widget class="QSpinBox" name="spinIPFourthNibble"> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="spinIPFirstNibble"> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QSpinBox" name="spinIPSecondNibble"> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QSpinBox" name="spinIPThirdNibble"> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="singleStep"> + <number>1</number> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>IP-address remote PC</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Port-number</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="spinPortNumber"> + <property name="minimum"> + <number>1000</number> + </property> + <property name="maximum"> + <number>10000</number> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Enter IP-address and port-number for the remote PC.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Remember: you may have to change firewall-settings too!</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="sizeConstraint"> + <enum>QLayout::SetDefaultConstraint</enum> + </property> + <item> + <widget class="QPushButton" name="btnOK"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>OK</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btnCancel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <tabstops> + <tabstop>spinIPFirstNibble</tabstop> + <tabstop>spinIPSecondNibble</tabstop> + <tabstop>spinIPThirdNibble</tabstop> + <tabstop>spinIPFourthNibble</tabstop> + <tabstop>spinPortNumber</tabstop> + <tabstop>btnOK</tabstop> + <tabstop>btnCancel</tabstop> + </tabstops> + <resources> + <include location="../gui/main-facetracknoir.qrc"/> + </resources> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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 <QFile> +#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<int>(s.ip1)), + QString::number(static_cast<int>(s.ip2)), + QString::number(static_cast<int>(s.ip3)), + QString::number(static_cast<int>(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 <QThread> +#include <QUdpSocket> +#include <QMessageBox> +#include <cmath> +#include "opentrack/plugin-api.hpp" +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value<int> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICLibevdevControls</class> + <widget class="QWidget" name="UICLibevdevControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>228</width> + <height>69</height> + </rect> + </property> + <property name="windowTitle"> + <string>VJoy</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>:/images/vjoy.png</normaloff>:/images/vjoy.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QVBoxLayout" name="_vertical_layout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Make sure rw for /dev/input/uinput!</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="sizeConstraint"> + <enum>QLayout::SetDefaultConstraint</enum> + </property> + <item> + <widget class="QPushButton" name="btnOK"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>OK</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btnCancel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <tabstops> + <tabstop>btnOK</tabstop> + <tabstop>btnCancel</tabstop> + </tabstops> + <resources/> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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 <cstdio> +#include <algorithm> + +#include <sys/types.h> +#include <sys/stat.h> + +#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 <sthalik@misaki.pl> + * + * 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 <QMessageBox> +#include "opentrack/plugin-api.hpp" + +extern "C" { +# include <libevdev/libevdev.h> +# include <libevdev/libevdev-uinput.h> +} + +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 @@ +<RCC> + <qresource prefix="/"> + <file>images/linux.png</file> + </qresource> +</RCC> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICMOUSEControls</class> + <widget class="QWidget" name="UICMOUSEControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>280</width> + <height>106</height> + </rect> + </property> + <property name="windowTitle"> + <string>Mouse protocol settings</string> + </property> + <property name="windowIcon"> + <iconset resource="win32-mouse-protocol.qrc"> + <normaloff>:/images/mouse.png</normaloff>:/images/mouse.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="textLabel2_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Map mouse X to:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1" colspan="2"> + <widget class="QComboBox" name="cbxSelectMouse_X"> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + <property name="toolTip"> + <string>Select Number</string> + </property> + <property name="insertPolicy"> + <enum>QComboBox::InsertAlphabetically</enum> + </property> + <item> + <property name="text"> + <string>None</string> + </property> + </item> + <item> + <property name="text"> + <string>X</string> + </property> + </item> + <item> + <property name="text"> + <string>Y</string> + </property> + </item> + <item> + <property name="text"> + <string>Z</string> + </property> + </item> + <item> + <property name="text"> + <string>Yaw</string> + </property> + </item> + <item> + <property name="text"> + <string>Pitch</string> + </property> + </item> + <item> + <property name="text"> + <string>Roll</string> + </property> + </item> + </widget> + </item> + <item row="1" column="1" colspan="2"> + <widget class="QComboBox" name="cbxSelectMouse_Y"> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + <property name="toolTip"> + <string>Select Number</string> + </property> + <property name="insertPolicy"> + <enum>QComboBox::InsertAlphabetically</enum> + </property> + <item> + <property name="text"> + <string>None</string> + </property> + </item> + <item> + <property name="text"> + <string>X</string> + </property> + </item> + <item> + <property name="text"> + <string>Y</string> + </property> + </item> + <item> + <property name="text"> + <string>Z</string> + </property> + </item> + <item> + <property name="text"> + <string>Yaw</string> + </property> + </item> + <item> + <property name="text"> + <string>Pitch</string> + </property> + </item> + <item> + <property name="text"> + <string>Roll</string> + </property> + </item> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="textLabel2_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Map mouse Y to:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="win32-mouse-protocol.qrc"/> + </resources> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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 <sthalik@misaki.pl> + * + * 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 <windows.h> + +#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 <sthalik@misaki.pl> + * + * 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 <QDebug> +#include "opentrack/plugin-api.hpp" +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value<int> 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 @@ +<RCC> + <qresource prefix="/"> + <file>images/mouse.png</file> + </qresource> +</RCC> 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 <winuser.h> +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 <sthalik@misaki.pl> + * * + * 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<void*>(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<int>(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<FTNoIR_Protocol*>(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 <QThread> +#include <QMessageBox> +#include <QSettings> +#include <QLibrary> +#include <QProcess> +#include <QDebug> +#include <QFile> +#include "opentrack/options.hpp" +using namespace options; +#include <windows.h> + +struct settings : opts { + value<int> 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 <QDebug> +#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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICSCControls</class> + <widget class="QWidget" name="UICSCControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>290</width> + <height>79</height> + </rect> + </property> + <property name="windowTitle"> + <string>SimConnect settings FaceTrackNoIR</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>FSX version</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="comboBox"> + <item> + <property name="text"> + <string>SP1</string> + </property> + </item> + <item> + <property name="text"> + <string>SP2</string> + </property> + </item> + <item> + <property name="text"> + <string>Acceleration</string> + </property> + </item> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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 @@ +<RCC> + <qresource prefix="/"> + <file>images/fsx.png</file> + </qresource> +</RCC> 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 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='10.0.61259.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> + </dependentAssembly> + </dependency> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> + </dependentAssembly> + </dependency> +</assembly> 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 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect ' version='10.0.61242.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> + </dependentAssembly> + </dependency> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> + </dependentAssembly> + </dependency> +</assembly> 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 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect ' version='10.0.60905.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> + </dependentAssembly> + </dependency> + <dependency> + <dependentAssembly> + <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> + </dependentAssembly> + </dependency> +</assembly> 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<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[Yaw] * VJOY_AXIS_MAX / 180.0)); + state[0].YAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[Pitch] * VJOY_AXIS_MAX / 180.0)); + state[0].ZAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[Roll] * VJOY_AXIS_MAX / 180.0)); + state[0].XRotation = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[TX] * VJOY_AXIS_MAX / 100.0)); + state[0].YRotation = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[TY] * VJOY_AXIS_MAX / 100.0)); + state[0].ZRotation = std::min<int>(VJOY_AXIS_MAX, std::max<int>(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 <cmath> +#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 <windows.h> + +#include <pshpack1.h> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICVJoyControls</class> + <widget class="QWidget" name="UICVJoyControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>228</width> + <height>69</height> + </rect> + </property> + <property name="windowTitle"> + <string>VJoy</string> + </property> + <property name="windowIcon"> + <iconset resource="vjoy-protocol.qrc"> + <normaloff>:/images/vjoy.png</normaloff>:/images/vjoy.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QVBoxLayout" name="_vertical_layout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>No settings necessary</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="sizeConstraint"> + <enum>QLayout::SetDefaultConstraint</enum> + </property> + <item> + <widget class="QPushButton" name="btnOK"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>OK</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btnCancel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <tabstops> + <tabstop>btnOK</tabstop> + <tabstop>btnCancel</tabstop> + </tabstops> + <resources> + <include location="vjoy-protocol.qrc"/> + </resources> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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 @@ +<RCC> + <qresource prefix="/"> + <file>images/vjoy.png</file> + </qresource> +</RCC> 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 <string.h> +#include <sys/mman.h> +#include <sys/stat.h> /* For mode constants */ +#include <fcntl.h> /* 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 <QMessageBox> +#include <QLibrary> +#include <QProcess> +#include <QDebug> +#include <QMutex> +#include <QMutexLocker> +#include <QFile> +#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 <QDebug> +#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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICFTControls</class> + <widget class="QWidget" name="UICFTControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>409</width> + <height>110</height> + </rect> + </property> + <property name="windowTitle"> + <string>FreeTrack settings FaceTrackNoIR</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>images/freetrack.png</normaloff>images/freetrack.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QVBoxLayout" name="_vertical_layout"> + <item> + <layout class="QHBoxLayout"> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>There are no settings necessary for the Wine protocol.</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="sizeConstraint"> + <enum>QLayout::SetDefaultConstraint</enum> + </property> + <item> + <widget class="QPushButton" name="btnOK"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>OK</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btnCancel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> 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 <cerrno> +// OSX sdk 10.8 build error otherwise +#ifdef _LIBCPP_MSVCRT +# undef _LIBCPP_MSVCRT +#endif +#include <cstdio> +#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 <windows.h> + +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 @@ +<RCC> + <qresource prefix="/"> + <file>images/wine.png</file> + </qresource> +</RCC> 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 <memory> + +template<typename t> using ptr = std::shared_ptr<t>; + +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 @@ -<RCC> - <qresource prefix="/"> - <file>images/flightgear.png</file> - </qresource> -</RCC> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICFGControls</class> - <widget class="QWidget" name="UICFGControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>415</width> - <height>112</height> - </rect> - </property> - <property name="windowTitle"> - <string>FlightGear protocol settings</string> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>IP-address remote PC</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="spinIPFirstNibble"> - <property name="maximumSize"> - <size> - <width>60</width> - <height>16777215</height> - </size> - </property> - <property name="maximum"> - <number>255</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QSpinBox" name="spinIPSecondNibble"> - <property name="maximumSize"> - <size> - <width>60</width> - <height>16777215</height> - </size> - </property> - <property name="maximum"> - <number>255</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QSpinBox" name="spinIPThirdNibble"> - <property name="maximumSize"> - <size> - <width>60</width> - <height>16777215</height> - </size> - </property> - <property name="maximum"> - <number>255</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - </widget> - </item> - <item row="0" column="4"> - <widget class="QSpinBox" name="spinIPFourthNibble"> - <property name="maximumSize"> - <size> - <width>60</width> - <height>16777215</height> - </size> - </property> - <property name="maximum"> - <number>255</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Port-number</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="spinPortNumber"> - <property name="minimum"> - <number>1000</number> - </property> - <property name="maximum"> - <number>10000</number> - </property> - </widget> - </item> - <item row="2" column="2" colspan="3"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <tabstops> - <tabstop>spinIPFirstNibble</tabstop> - <tabstop>spinIPSecondNibble</tabstop> - <tabstop>spinIPThirdNibble</tabstop> - <tabstop>spinIPFourthNibble</tabstop> - <tabstop>spinPortNumber</tabstop> - </tabstops> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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<int>(s.ip1)), - QString::number(static_cast<int>(s.ip2)), - QString::number(static_cast<int>(s.ip3)), - QString::number(static_cast<int>(s.ip4)))); - int destPort = s.port; - (void) outSocket.writeDatagram(reinterpret_cast<const char*>(&FlightData), sizeof(FlightData), destIP, static_cast<quint16>(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 <QThread> -#include <QUdpSocket> -#include <QMessageBox> -#include "opentrack/plugin-api.hpp" -#include "opentrack/options.hpp" -using namespace options; - -struct settings : opts { - value<int> ip1, ip2, ip3, ip4; - value<int> 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 <QObject> -#include <QFile> -#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 @@ -<RCC> - <qresource prefix="/"> - <file>images/fs9.png</file> - </qresource> -</RCC> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICFSUIPCControls</class> - <widget class="QWidget" name="UICFSUIPCControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>512</width> - <height>100</height> - </rect> - </property> - <property name="windowTitle"> - <string>FSUIPC settings FaceTrackNoIR</string> - </property> - <property name="windowIcon"> - <iconset> - <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="1"> - <widget class="QPushButton" name="btnCancel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="txtLocationOfDLL"> - <property name="minimumSize"> - <size> - <width>230</width> - <height>0</height> - </size> - </property> - <property name="toolTip"> - <string>Location of FSUIPC.dll</string> - </property> - <property name="frameShape"> - <enum>QFrame::Box</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Sunken</enum> - </property> - <property name="lineWidth"> - <number>1</number> - </property> - <property name="text"> - <string>Location of FSUIPC.dll</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>The DLL should be located in the Modules/ directory of MS FS 2004</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QPushButton" name="btnOK"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QPushButton" name="btnFindDLL"> - <property name="maximumSize"> - <size> - <width>35</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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 <windows.h> -#include <stdlib.h> -#include "FSUIPC_User.h" -#include "opentrack/plugin-api.hpp" -#include "ui_ftnoir_fsuipccontrols.h" -#include <QMessageBox> -#include <QSettings> -#include <QLibrary> -#include <QProcess> -#include <QDebug> -#include <QFile> -#include <QFileDialog> -#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<QString> 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 @@ -<RCC> - <qresource prefix="/"> - <file>images/freetrack.png</file> - </qresource> -</RCC> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICFTControls</class> - <widget class="QWidget" name="UICFTControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>422</width> - <height>305</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="windowTitle"> - <string>freetrack protocol settings</string> - </property> - <property name="windowIcon"> - <iconset resource="ft-protocol.qrc"> - <normaloff>:/images/freetrack.png</normaloff>:/images/freetrack.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QGroupBox" name="groupBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>TIRViews</string> - </property> - <property name="alignment"> - <set>Qt::AlignJustify|Qt::AlignTop</set> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <layout class="QFormLayout" name="formLayout_2"> - <item row="0" column="0"> - <widget class="QCheckBox" name="chkTIRViews"> - <property name="layoutDirection"> - <enum>Qt::RightToLeft</enum> - </property> - <property name="text"> - <string>Memory hacks</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Only for very old and buggy old games such as CFS3.</string> - </property> - <property name="scaledContents"> - <bool>false</bool> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="2" column="0"> - <widget class="QGroupBox" name="groupBox_4"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Repair NPClient location</string> - </property> - <property name="alignment"> - <set>Qt::AlignJustify|Qt::AlignTop</set> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QPushButton" name="bntLocateNPClient"> - <property name="text"> - <string>Locate DLL</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="label_10"> - <property name="text"> - <string>Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="3" column="0"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QGroupBox" name="groupBox_3"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Select interface</string> - </property> - <property name="alignment"> - <set>Qt::AlignJustify|Qt::AlignTop</set> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QComboBox" name="cbxSelectInterface"/> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Disable one of the protocols if game is confused by presence of both at the same time.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="ft-protocol.qrc"/> - </resources> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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 <sthalik@misaki.pl> - * 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 <sthalik@misaki.pl> - * 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 <QMessageBox> -#include <QSettings> -#include <QLibrary> -#include <QProcess> -#include <QDebug> -#include <QFile> -#include <QString> -#include <QMutex> -#include <QMutexLocker> -#include "opentrack-compat/shm.h" -#include "opentrack/options.hpp" -#include "freetrackclient/fttypes.h" -using namespace options; - -struct settings : opts { - value<int> intUsedInterface; - value<bool> 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 <QDebug> -#include <QFileDialog> - -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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICFTNControls</class> - <widget class="QWidget" name="UICFTNControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>411</width> - <height>169</height> - </rect> - </property> - <property name="windowTitle"> - <string>UDP protocol settings</string> - </property> - <property name="windowIcon"> - <iconset resource="../gui/main-facetracknoir.qrc"> - <normaloff>:/images/facetracknoir.png</normaloff>:/images/facetracknoir.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="_vertical_layout"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="4"> - <widget class="QSpinBox" name="spinIPFourthNibble"> - <property name="maximumSize"> - <size> - <width>60</width> - <height>16777215</height> - </size> - </property> - <property name="maximum"> - <number>255</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="spinIPFirstNibble"> - <property name="maximumSize"> - <size> - <width>60</width> - <height>16777215</height> - </size> - </property> - <property name="maximum"> - <number>255</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QSpinBox" name="spinIPSecondNibble"> - <property name="maximumSize"> - <size> - <width>60</width> - <height>16777215</height> - </size> - </property> - <property name="maximum"> - <number>255</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QSpinBox" name="spinIPThirdNibble"> - <property name="maximumSize"> - <size> - <width>60</width> - <height>16777215</height> - </size> - </property> - <property name="maximum"> - <number>255</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>IP-address remote PC</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Port-number</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QSpinBox" name="spinPortNumber"> - <property name="minimum"> - <number>1000</number> - </property> - <property name="maximum"> - <number>10000</number> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Enter IP-address and port-number for the remote PC.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Remember: you may have to change firewall-settings too!</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> - </property> - <item> - <widget class="QPushButton" name="btnOK"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="btnCancel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>10</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <tabstops> - <tabstop>spinIPFirstNibble</tabstop> - <tabstop>spinIPSecondNibble</tabstop> - <tabstop>spinIPThirdNibble</tabstop> - <tabstop>spinIPFourthNibble</tabstop> - <tabstop>spinPortNumber</tabstop> - <tabstop>btnOK</tabstop> - <tabstop>btnCancel</tabstop> - </tabstops> - <resources> - <include location="../gui/main-facetracknoir.qrc"/> - </resources> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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 <QFile> -#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<int>(s.ip1)), - QString::number(static_cast<int>(s.ip2)), - QString::number(static_cast<int>(s.ip3)), - QString::number(static_cast<int>(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 <QThread> -#include <QUdpSocket> -#include <QMessageBox> -#include <cmath> -#include "opentrack/plugin-api.hpp" -#include "opentrack/options.hpp" -using namespace options; - -struct settings : opts { - value<int> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICLibevdevControls</class> - <widget class="QWidget" name="UICLibevdevControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>228</width> - <height>69</height> - </rect> - </property> - <property name="windowTitle"> - <string>VJoy</string> - </property> - <property name="windowIcon"> - <iconset> - <normaloff>:/images/vjoy.png</normaloff>:/images/vjoy.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="_vertical_layout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Make sure rw for /dev/input/uinput!</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> - </property> - <item> - <widget class="QPushButton" name="btnOK"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="btnCancel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <tabstops> - <tabstop>btnOK</tabstop> - <tabstop>btnCancel</tabstop> - </tabstops> - <resources/> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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 <cstdio> -#include <algorithm> - -#include <sys/types.h> -#include <sys/stat.h> - -#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 <sthalik@misaki.pl> - * - * 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 <QMessageBox> -#include "opentrack/plugin-api.hpp" - -extern "C" { -# include <libevdev/libevdev.h> -# include <libevdev/libevdev-uinput.h> -} - -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 @@ -<RCC> - <qresource prefix="/"> - <file>images/linux.png</file> - </qresource> -</RCC> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICMOUSEControls</class> - <widget class="QWidget" name="UICMOUSEControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>280</width> - <height>106</height> - </rect> - </property> - <property name="windowTitle"> - <string>Mouse protocol settings</string> - </property> - <property name="windowIcon"> - <iconset resource="win32-mouse-protocol.qrc"> - <normaloff>:/images/mouse.png</normaloff>:/images/mouse.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="textLabel2_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Map mouse X to:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="0" column="1" colspan="2"> - <widget class="QComboBox" name="cbxSelectMouse_X"> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - <property name="toolTip"> - <string>Select Number</string> - </property> - <property name="insertPolicy"> - <enum>QComboBox::InsertAlphabetically</enum> - </property> - <item> - <property name="text"> - <string>None</string> - </property> - </item> - <item> - <property name="text"> - <string>X</string> - </property> - </item> - <item> - <property name="text"> - <string>Y</string> - </property> - </item> - <item> - <property name="text"> - <string>Z</string> - </property> - </item> - <item> - <property name="text"> - <string>Yaw</string> - </property> - </item> - <item> - <property name="text"> - <string>Pitch</string> - </property> - </item> - <item> - <property name="text"> - <string>Roll</string> - </property> - </item> - </widget> - </item> - <item row="1" column="1" colspan="2"> - <widget class="QComboBox" name="cbxSelectMouse_Y"> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - <property name="toolTip"> - <string>Select Number</string> - </property> - <property name="insertPolicy"> - <enum>QComboBox::InsertAlphabetically</enum> - </property> - <item> - <property name="text"> - <string>None</string> - </property> - </item> - <item> - <property name="text"> - <string>X</string> - </property> - </item> - <item> - <property name="text"> - <string>Y</string> - </property> - </item> - <item> - <property name="text"> - <string>Z</string> - </property> - </item> - <item> - <property name="text"> - <string>Yaw</string> - </property> - </item> - <item> - <property name="text"> - <string>Pitch</string> - </property> - </item> - <item> - <property name="text"> - <string>Roll</string> - </property> - </item> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="textLabel2_3"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Map mouse Y to:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="win32-mouse-protocol.qrc"/> - </resources> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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 <sthalik@misaki.pl> - * - * 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 <windows.h> - -#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 <sthalik@misaki.pl> - * - * 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 <QDebug> -#include "opentrack/plugin-api.hpp" -#include "opentrack/options.hpp" -using namespace options; - -struct settings : opts { - value<int> 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 @@ -<RCC> - <qresource prefix="/"> - <file>images/mouse.png</file> - </qresource> -</RCC> 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 <winuser.h> -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 <sthalik@misaki.pl> - * * - * 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<void*>(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<int>(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<FTNoIR_Protocol*>(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 <QThread> -#include <QMessageBox> -#include <QSettings> -#include <QLibrary> -#include <QProcess> -#include <QDebug> -#include <QFile> -#include "opentrack/options.hpp" -using namespace options; -#include <windows.h> - -struct settings : opts { - value<int> 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 <QDebug> -#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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICSCControls</class> - <widget class="QWidget" name="UICSCControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>290</width> - <height>79</height> - </rect> - </property> - <property name="windowTitle"> - <string>SimConnect settings FaceTrackNoIR</string> - </property> - <property name="windowIcon"> - <iconset> - <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>FSX version</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="comboBox"> - <item> - <property name="text"> - <string>SP1</string> - </property> - </item> - <item> - <property name="text"> - <string>SP2</string> - </property> - </item> - <item> - <property name="text"> - <string>Acceleration</string> - </property> - </item> - </widget> - </item> - <item row="1" column="1"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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 @@ -<RCC> - <qresource prefix="/"> - <file>images/fsx.png</file> - </qresource> -</RCC> 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 @@ -<?xml version='1.0' encoding='UTF-8' standalone='yes'?> -<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect' version='10.0.61259.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> - </dependentAssembly> - </dependency> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> - </dependentAssembly> - </dependency> -</assembly> 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 @@ -<?xml version='1.0' encoding='UTF-8' standalone='yes'?> -<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect ' version='10.0.61242.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> - </dependentAssembly> - </dependency> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> - </dependentAssembly> - </dependency> -</assembly> 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 @@ -<?xml version='1.0' encoding='UTF-8' standalone='yes'?> -<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.FlightSimulator.SimConnect ' version='10.0.60905.0' processorArchitecture='x86' publicKeyToken='67c7c14424d61b5b' /> - </dependentAssembly> - </dependency> - <dependency> - <dependentAssembly> - <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' /> - </dependentAssembly> - </dependency> -</assembly> 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<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[Yaw] * VJOY_AXIS_MAX / 180.0)); - state[0].YAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[Pitch] * VJOY_AXIS_MAX / 180.0)); - state[0].ZAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[Roll] * VJOY_AXIS_MAX / 180.0)); - state[0].XRotation = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[TX] * VJOY_AXIS_MAX / 100.0)); - state[0].YRotation = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[TY] * VJOY_AXIS_MAX / 100.0)); - state[0].ZRotation = std::min<int>(VJOY_AXIS_MAX, std::max<int>(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 <cmath> -#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 <windows.h> - -#include <pshpack1.h> - -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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICVJoyControls</class> - <widget class="QWidget" name="UICVJoyControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>228</width> - <height>69</height> - </rect> - </property> - <property name="windowTitle"> - <string>VJoy</string> - </property> - <property name="windowIcon"> - <iconset resource="vjoy-protocol.qrc"> - <normaloff>:/images/vjoy.png</normaloff>:/images/vjoy.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="_vertical_layout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>No settings necessary</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> - </property> - <item> - <widget class="QPushButton" name="btnOK"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="btnCancel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <tabstops> - <tabstop>btnOK</tabstop> - <tabstop>btnCancel</tabstop> - </tabstops> - <resources> - <include location="vjoy-protocol.qrc"/> - </resources> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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 @@ -<RCC> - <qresource prefix="/"> - <file>images/vjoy.png</file> - </qresource> -</RCC> 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 <string.h> -#include <sys/mman.h> -#include <sys/stat.h> /* For mode constants */ -#include <fcntl.h> /* 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 <QMessageBox> -#include <QLibrary> -#include <QProcess> -#include <QDebug> -#include <QMutex> -#include <QMutexLocker> -#include <QFile> -#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 <QDebug> -#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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UICFTControls</class> - <widget class="QWidget" name="UICFTControls"> - <property name="windowModality"> - <enum>Qt::NonModal</enum> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>409</width> - <height>110</height> - </rect> - </property> - <property name="windowTitle"> - <string>FreeTrack settings FaceTrackNoIR</string> - </property> - <property name="windowIcon"> - <iconset> - <normaloff>images/freetrack.png</normaloff>images/freetrack.png</iconset> - </property> - <property name="layoutDirection"> - <enum>Qt::LeftToRight</enum> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="_vertical_layout"> - <item> - <layout class="QHBoxLayout"> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>There are no settings necessary for the Wine protocol.</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> - </property> - <item> - <widget class="QPushButton" name="btnOK"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="btnCancel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>100</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>10</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> - <slots> - <slot>startEngineClicked()</slot> - <slot>stopEngineClicked()</slot> - <slot>cameraSettingsClicked()</slot> - </slots> -</ui> 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 <cerrno> -// OSX sdk 10.8 build error otherwise -#ifdef _LIBCPP_MSVCRT -# undef _LIBCPP_MSVCRT -#endif -#include <cstdio> -#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 <windows.h> - -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 @@ -<RCC> - <qresource prefix="/"> - <file>images/wine.png</file> - </qresource> -</RCC> 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 <memory> - -template<typename t> using ptr = std::shared_ptr<t>; - -struct WineSHM { - double data[6]; - int gameid, gameid2; - unsigned char table[8]; - bool stop; -}; -- cgit v1.2.3