diff options
| author | Donovan Baarda <abo@minkirri.apana.org.au> | 2014-06-12 14:53:43 +1000 | 
|---|---|---|
| committer | Donovan Baarda <abo@minkirri.apana.org.au> | 2014-06-12 14:53:43 +1000 | 
| commit | 0669a40347ffa233bc6042b0f65d244509a61394 (patch) | |
| tree | 36a4577bdaa1ed28ca1ad222a54777012dd2dda8 /ftnoir_protocol_vjoy | |
| parent | 72540e0a96a3120a5d02271e714aba29e136ab78 (diff) | |
| parent | 7454496476ba17ea622781d280606161581c9544 (diff) | |
Merge branch 'master' of https://github.com/opentrack/opentrack into dev/ewma2
Resolved conflicts manually in files:
	ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
	ftnoir_filter_ewma2/ftnoir_filter_ewma2.h
Diffstat (limited to 'ftnoir_protocol_vjoy')
| -rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | 4 | ||||
| -rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 49 | ||||
| -rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp | 15 | ||||
| -rw-r--r-- | ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui | 5 | ||||
| -rw-r--r-- | ftnoir_protocol_vjoy/vjoy.def | 5 | 
5 files changed, 52 insertions, 26 deletions
| diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp index 50a7bf97..a3a5cb5f 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp @@ -14,8 +14,10 @@ FTNoIR_Protocol::~FTNoIR_Protocol()      VJoy_Shutdown();  } -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) {      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)); diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 5c260d2e..873b4e3c 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -28,14 +28,13 @@  #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" +#include <windows.h>  #define FT_PROGRAMID "FT_ProgramID" @@ -43,15 +42,15 @@ class FTNoIR_Protocol : public IProtocol  {  public:  	FTNoIR_Protocol(); -	~FTNoIR_Protocol(); +    virtual ~FTNoIR_Protocol();      bool checkServerInstallationOK() {          return true;      } -    void sendHeadposeToGame( double *headpose, double *rawheadpose ); -private: +    void sendHeadposeToGame( const double *headpose );      QString getGameName() {          return "Virtual joystick";      } +private:  };  // Widget that has controls for FTNoIR protocol client-settings. @@ -61,10 +60,6 @@ class VJoyControls: public QWidget, public IProtocolDialog  public:  	explicit VJoyControls(); -    virtual ~VJoyControls(); -    void showEvent ( QShowEvent *) {} - -    void Initialize(QWidget *);      void registerProtocol(IProtocol *l) {}  	void unRegisterProtocol() {} @@ -92,3 +87,39 @@ public:      void getIcon(QIcon *icon) { *icon = QIcon(":/images/vjoy.png"); }  }; + +#define VJOY_AXIS_MIN   -32768 +#define VJOY_AXIS_NIL   0 +#define VJOY_AXIS_MAX   32767 + +#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; + +#include <poppack.h> + +#undef EXTERN_C +#if _MSC_VER +#	define EXTERN_C +#else +#	define EXTERN_C extern "C" +#endif +#if _MSC_VER +#	pragma comment(linker, "/implib:vjoy.def") +#endif +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); diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp index 0009553b..febb7b18 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp @@ -8,21 +8,6 @@ VJoyControls::VJoyControls() : QWidget()  	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(); diff --git a/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui b/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui index 1a244410..2214b887 100644 --- a/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui +++ b/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui @@ -2,12 +2,15 @@  <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>64</height> +    <height>69</height>     </rect>    </property>    <property name="windowTitle"> diff --git a/ftnoir_protocol_vjoy/vjoy.def b/ftnoir_protocol_vjoy/vjoy.def new file mode 100644 index 00000000..aea590a4 --- /dev/null +++ b/ftnoir_protocol_vjoy/vjoy.def @@ -0,0 +1,5 @@ +LIBRARY vjoy.dll +IMPORTS +VJoy_Initialize = _VJoy_Initialize +VJoy_Shutdown = _VJoy_Shutdown +VJoy_UpdateJoyState = _VJoy_UpdateJoyState | 
