diff options
-rw-r--r-- | CMakeLists.txt | 29 | ||||
-rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | 37 | ||||
-rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 97 | ||||
-rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp | 41 | ||||
-rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp | 16 | ||||
-rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui | 110 | ||||
-rw-r--r-- | ftnoir_protocol_vjoy/images/vjoy.png | bin | 0 -> 694 bytes | |||
-rw-r--r-- | ftnoir_protocol_vjoy/vjoy-protocol.qrc | 5 |
8 files changed, 334 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 34212a77..84b20df0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,8 @@ endif() IF(WIN32) SET(SDK_SM_FACEAPI_PATH "" CACHE PATH "SeeingMachines FaceAPI SDK path") - SET(SDK_RIFT "" CACHE PATH "libOVR path") + SET(SDK_RIFT "" CACHE PATH "libOVR path") + SET(SDK_VJOY "" CACHE PATH "VJoy SDK path") ENDIF() file(GLOB opentrack-faceapi-wrapper-c "faceapi/*.cpp") @@ -210,6 +211,14 @@ if(NOT SDK_FACEAPI_ONLY) QT4_WRAP_UI(opentrack-proto-simconnect-uih ${opentrack-proto-simconnect-ui}) QT4_ADD_RESOURCES(opentrack-proto-simconnect-rcc ${opentrack-proto-simconnect-rc}) + file(GLOB opentrack-proto-vjoy-c "ftnoir_protocol_vjoy/*.cpp") + file(GLOB opentrack-proto-vjoy-h "ftnoir_protocol_vjoy/*.h") + QT4_WRAP_CPP(opentrack-proto-vjoy-moc ${opentrack-proto-vjoy-h}) + file(GLOB opentrack-proto-vjoy-ui "ftnoir_protocol_vjoy/*.ui") + file(GLOB opentrack-proto-vjoy-rc "ftnoir_protocol_vjoy/*.qrc") + QT4_WRAP_UI(opentrack-proto-vjoy-uih ${opentrack-proto-vjoy-ui}) + QT4_ADD_RESOURCES(opentrack-proto-vjoy-rcc ${opentrack-proto-vjoy-rc}) + # trackers file(GLOB opentrack-tracker-ht-c "ftnoir_tracker_ht/*.cpp") @@ -342,6 +351,16 @@ endif() PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() + if(WIN32 AND SDK_VJOY) + include_directories(${SDK_VJOY}) + add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) + target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/vjoy.lib") + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-proto-vjoy + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + endif() + endif() + if(WIN32) if(SDK_FSUIPC) add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-moc} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) @@ -547,6 +566,14 @@ if(NOT SDK_FACEAPI_ONLY) NAMELINK_SKIP ) + if(SDK_VJOY) + install(TARGETS opentrack-proto-vjoy + RUNTIME DESTINATION . + LIBRARY DESTINATION . + NAMELINK_SKIP) + install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION .) + endif() + if(SDK_HILLCREST) install( TARGETS opentrack-tracker-hillcrest diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp new file mode 100644 index 00000000..6fea845c --- /dev/null +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp @@ -0,0 +1,37 @@ +#include "ftnoir_protocol_vjoy.h" +#include "facetracknoir/global-settings.h" +#include <ftnoir_tracker_base/ftnoir_tracker_types.h> + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + VJoy_Initialize("", ""); +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + VJoy_Shutdown(); +} + +void FTNoIR_Protocol::Initialize() +{ +} + +void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { + JOYSTICK_STATE state[2] = { 0 }; + + state[0].XAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[RX] * VJOY_AXIS_MAX / 180.0)); + state[0].YAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[RY] * VJOY_AXIS_MAX / 180.0)); + state[0].ZAxis = std::min<int>(VJOY_AXIS_MAX, std::max<int>(VJOY_AXIS_MIN, headpose[RZ] * 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); +} + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h new file mode 100644 index 00000000..d90a6124 --- /dev/null +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -0,0 +1,97 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see <http://www.gnu.org/licenses/>. * +* * +* FGServer FGServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +#pragma once +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ui_ftnoir_vjoy_controls.h" +#include <Windows.h> +#include <VJoy.h> +#include <QThread> +#include <QUdpSocket> +#include <QMessageBox> +#include <QSettings> +#include <math.h> +#include "facetracknoir/global-settings.h" + +#define FT_PROGRAMID "FT_ProgramID" + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + + void Initialize(); + + bool checkServerInstallationOK() { + return true; + } + void sendHeadposeToGame( double *headpose, double *rawheadpose ); +private: + QString getGameName() { + return "Virtual joystick"; + } +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class VJoyControls: public QWidget, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit VJoyControls(); + virtual ~VJoyControls(); + void showEvent ( QShowEvent *) {} + + void Initialize(QWidget *); + void registerProtocol(IProtocol *l) {} + void unRegisterProtocol() {} + +private: + Ui::UICVJoyControls ui; + void save(); + +private slots: + void doOK(); + void doCancel(); +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public Metadata +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("VJoy"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("VJoy"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("VJoy"); } + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/vjoy.png"); } +}; diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp new file mode 100644 index 00000000..0009553b --- /dev/null +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp @@ -0,0 +1,41 @@ +#include "ftnoir_protocol_vjoy.h" +#include "facetracknoir/global-settings.h" + +VJoyControls::VJoyControls() : QWidget() +{ + ui.setupUi( this ); + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); +} + +VJoyControls::~VJoyControls() { +} + +// +// Initialize tracker-client-dialog +// +void VJoyControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +void VJoyControls::doOK() { + save(); + this->close(); +} + +void VJoyControls::doCancel() { + this->close(); +} + +void VJoyControls::save() { +} + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +{ + return new VJoyControls; +} diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp new file mode 100644 index 00000000..5cb5ef05 --- /dev/null +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp @@ -0,0 +1,16 @@ +#include "ftnoir_protocol_vjoy.h" +#include <QDebug> +#include "facetracknoir/global-settings.h" + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui b/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui new file mode 100644 index 00000000..1a244410 --- /dev/null +++ b/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui @@ -0,0 +1,110 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UICVJoyControls</class> + <widget class="QWidget" name="UICVJoyControls"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>228</width> + <height>64</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/ftnoir_protocol_vjoy/images/vjoy.png b/ftnoir_protocol_vjoy/images/vjoy.png Binary files differnew file mode 100644 index 00000000..8eb14be8 --- /dev/null +++ b/ftnoir_protocol_vjoy/images/vjoy.png diff --git a/ftnoir_protocol_vjoy/vjoy-protocol.qrc b/ftnoir_protocol_vjoy/vjoy-protocol.qrc new file mode 100644 index 00000000..7b3741f1 --- /dev/null +++ b/ftnoir_protocol_vjoy/vjoy-protocol.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>images/vjoy.png</file> + </qresource> +</RCC> |