From dbb5ab72d1f16ce864567dad84a7bf2a586fd0ff Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 29 Apr 2013 20:16:26 +0200 Subject: VJoy protocol --- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | 37 +++++++ ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 97 ++++++++++++++++++ .../ftnoir_protocol_vjoy_dialog.cpp | 41 ++++++++ ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp | 16 +++ ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui | 110 +++++++++++++++++++++ ftnoir_protocol_vjoy/images/vjoy.png | Bin 0 -> 694 bytes ftnoir_protocol_vjoy/vjoy-protocol.qrc | 5 + 7 files changed, 306 insertions(+) create mode 100644 ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp create mode 100644 ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h create mode 100644 ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp create mode 100644 ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dll.cpp create mode 100644 ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui create mode 100644 ftnoir_protocol_vjoy/images/vjoy.png create mode 100644 ftnoir_protocol_vjoy/vjoy-protocol.qrc (limited to 'ftnoir_protocol_vjoy') 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 + +/** 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(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[RX] * VJOY_AXIS_MAX / 180.0)); + state[0].YAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[RY] * VJOY_AXIS_MAX / 180.0)); + state[0].ZAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[RZ] * VJOY_AXIS_MAX / 180.0)); + state[0].XRotation = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[TX] * VJOY_AXIS_MAX / 100.0)); + state[0].YRotation = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[TY] * VJOY_AXIS_MAX / 100.0)); + state[0].ZRotation = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[TZ] * VJOY_AXIS_MAX / 100.0)); + + VJoy_UpdateJoyState(0, state); +} + +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 . * +* * +* 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 +#include +#include +#include +#include +#include +#include +#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 +#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 @@ + + + UICVJoyControls + + + + 0 + 0 + 228 + 64 + + + + VJoy + + + + :/images/vjoy.png:/images/vjoy.png + + + Qt::LeftToRight + + + false + + + + + + No settings necessary + + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + + + btnOK + btnCancel + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_vjoy/images/vjoy.png b/ftnoir_protocol_vjoy/images/vjoy.png new file mode 100644 index 00000000..8eb14be8 Binary files /dev/null and b/ftnoir_protocol_vjoy/images/vjoy.png differ 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 @@ + + + images/vjoy.png + + -- cgit v1.2.3