diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-29 20:16:26 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-29 20:16:26 +0200 |
commit | dbb5ab72d1f16ce864567dad84a7bf2a586fd0ff (patch) | |
tree | ec5aeca433f6fab2619834dd0c1edc1c8c46ff13 /ftnoir_protocol_vjoy | |
parent | c05fc771558a62ebdcd16dfb2f8459ae2a12fb88 (diff) |
VJoy protocol
Diffstat (limited to 'ftnoir_protocol_vjoy')
-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 |
7 files changed, 306 insertions, 0 deletions
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> |