From 602e4770360fb125ebdb129a6b777fe08a433370 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Fri, 11 Jun 2010 12:03:58 +0000 Subject: PPJoy files git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@9 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/PPJIoctl.h | 32 +++++++++++ FaceTrackNoIR/PPJoyServer.cpp | 74 ++++++++++++++++++++++++ FaceTrackNoIR/PPJoyServer.h | 91 ++++++++++++++++++++++++++++++ FaceTrackNoIR/Readme_Upgrade_20100607.txt | 30 ++++++++++ FaceTrackNoIR/images/PPJoy.ico | Bin 0 -> 5166 bytes 5 files changed, 227 insertions(+) create mode 100644 FaceTrackNoIR/PPJIoctl.h create mode 100644 FaceTrackNoIR/PPJoyServer.cpp create mode 100644 FaceTrackNoIR/PPJoyServer.h create mode 100644 FaceTrackNoIR/Readme_Upgrade_20100607.txt create mode 100644 FaceTrackNoIR/images/PPJoy.ico diff --git a/FaceTrackNoIR/PPJIoctl.h b/FaceTrackNoIR/PPJIoctl.h new file mode 100644 index 00000000..c406224f --- /dev/null +++ b/FaceTrackNoIR/PPJIoctl.h @@ -0,0 +1,32 @@ +#ifndef __PPJIOCTL_H__ +#define __PPJIOCTL_H__ + +#include "Windows.h" + +/* Define to use byte-size values for joystick axes, else dword size */ +#undef UCHAR_AXES + +#define PPJOY_AXIS_MIN 1 +#ifdef UCHAR_AXES +#define PPJOY_AXIS_MAX 127 +#else +#define PPJOY_AXIS_MAX 32767 +#endif + +#define FILE_DEVICE_PPORTJOY FILE_DEVICE_UNKNOWN + +#define PPORTJOY_IOCTL(_index_) \ + CTL_CODE (FILE_DEVICE_PPORTJOY, _index_, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_PPORTJOY_SET_STATE PPORTJOY_IOCTL (0x0) + +#define JOYSTICK_STATE_V1 0x53544143 + +typedef struct +{ + unsigned long Version; + unsigned char Data[1]; +} JOYSTICK_SET_STATE, *PJOYSTICK_SET_STATE; + + +#endif diff --git a/FaceTrackNoIR/PPJoyServer.cpp b/FaceTrackNoIR/PPJoyServer.cpp new file mode 100644 index 00000000..59c6f675 --- /dev/null +++ b/FaceTrackNoIR/PPJoyServer.cpp @@ -0,0 +1,74 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay for * +* head-tracking. * +* * +* Copyright (C) 2010 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 . * +* * +* PPJoyServer PPJoyServer is the Class, that communicates headpose-data * +* to the Virtual Joystick, created by Deon van der Westhuysen.* +********************************************************************************/ +#include +#include +#include "PPJoyServer.h" +#include "Tracker.h" +#include + +/** constructor **/ +PPJoyServer::PPJoyServer( Tracker *parent ) { + + // Save the parent + headTracker = parent; + + // Create events + m_StopThread = CreateEvent(0, TRUE, FALSE, 0); + m_WaitThread = CreateEvent(0, TRUE, FALSE, 0); +} + +/** QThread run @override **/ +void PPJoyServer::run() { + + //// Init. the data + //TestData.x = 0.0f; + //TestData.y = 0.0f; + //TestData.z = 0.0f; + //TestData.h = 0.0f; + //TestData.p = 0.0f; + //TestData.r = 0.0f; + //TestData.status = 0; + //fg_cmd = 0; + + // Create UDP-sockets + //inSocket = new QUdpSocket(); + //outSocket = new QUdpSocket(); + + //// Connect the inSocket to the port, to receive readyRead messages + //inSocket->bind(QHostAddress::LocalHost, 5551); + + // // Connect the inSocket to the member-function, to read FlightGear commands + //connect(inSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()), Qt::DirectConnection); + exec(); // Exec only returns, when the thread terminates... +} + +/** QThread terminate @override **/ +void PPJoyServer::terminate() { + +} + +//END diff --git a/FaceTrackNoIR/PPJoyServer.h b/FaceTrackNoIR/PPJoyServer.h new file mode 100644 index 00000000..f6c9b66f --- /dev/null +++ b/FaceTrackNoIR/PPJoyServer.h @@ -0,0 +1,91 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay for * +* head-tracking. * +* * +* Copyright (C) 2010 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 . * +* * +* PPJoyServer PPJoyServer is the Class, that communicates headpose-data * +* to the Virtual Joystick, created by Deon van der Westhuysen.* +********************************************************************************/ +#pragma once +#ifndef INCLUDED_PPJOYSERVER_H +#define INCLUDED_PPJOYSERVER_H + +#include "PPJIoctl.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +class Tracker; // pre-define parent-class to avoid circular includes + +class PPJoyServer : public QThread { + Q_OBJECT + +public: + + // public member methods + PPJoyServer( Tracker *parent ); + virtual ~PPJoyServer() {}; + + // protected member methods +protected: + void run(); + void terminate(); + +private slots: +// void readPendingDatagrams(); + +private: + // Handles to neatly terminate thread... + HANDLE m_StopThread; + HANDLE m_WaitThread; + + Tracker *headTracker; // For upstream messages... + + /** member variables for saving the head pose **/ + float virtPosX; + float virtPosY; + float virtPosZ; + + float virtRotX; + float virtRotY; + float virtRotZ; + +public: + void setVirtRotX(float rot) { virtRotX = rot; } + void setVirtRotY(float rot) { virtRotY = rot; } + void setVirtRotZ(float rot) { virtRotZ = rot; } + void setVirtPosX(float pos) { virtPosX = pos; } + void setVirtPosY(float pos) { virtPosY = pos; } + void setVirtPosZ(float pos) { virtPosZ = pos; } + +}; + + +#endif//INCLUDED_PPJOYSERVER_H +//END diff --git a/FaceTrackNoIR/Readme_Upgrade_20100607.txt b/FaceTrackNoIR/Readme_Upgrade_20100607.txt new file mode 100644 index 00000000..fb7a4ac9 --- /dev/null +++ b/FaceTrackNoIR/Readme_Upgrade_20100607.txt @@ -0,0 +1,30 @@ +FaceTrackNoIR (v. 1.0.1). + +The following upgrades have been applied: + + ‘=’ is center view + + ‘BACKSPACE’ = start (+center)/stop tracking. A messagebeep is generated when tracking is resumed and the + headpose-data is valid again (faceAPI has 'locked on'... + + Checkbox ‘use EWMA filter’: Ticking this checkbox will make FaceTrackNoIR filter the raw data with + a so-called 'Exponentially Weighed Moving Average'. This technique was adopted from FlightGear, where + Melchior Franz had 'invented' it. If the filter is active, the factor for each of the 6 DOF's are used. + These factor determine the weight that is given to previous measurements and goes from 0 - 1 (in the GUI + this setting is 0 - 100). + + Some timing-issues with the faceAPI were resolved, so now the scanning-frequency can be higher that 20Hz. + We do not know yet, how this influences performance of both FaceTrackNoIR and your CPU. + + + +Please let us know what you think of our little gadget. Posts can be made on the FaceTrackNoIR forum on SourceForge +(http://sourceforge.net/projects/facetracknoir/forums/forum/1150910) or on the various game-forums. + + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + diff --git a/FaceTrackNoIR/images/PPJoy.ico b/FaceTrackNoIR/images/PPJoy.ico new file mode 100644 index 00000000..321e5888 Binary files /dev/null and b/FaceTrackNoIR/images/PPJoy.ico differ -- cgit v1.2.3