summaryrefslogtreecommitdiffhomepage
path: root/freetrackclient
diff options
context:
space:
mode:
Diffstat (limited to 'freetrackclient')
-rw-r--r--freetrackclient/build-msvc.sh33
-rw-r--r--freetrackclient/freetrackclient.c39
-rw-r--r--freetrackclient/fttypes.h69
3 files changed, 87 insertions, 54 deletions
diff --git a/freetrackclient/build-msvc.sh b/freetrackclient/build-msvc.sh
deleted file mode 100644
index 4fd303a0..00000000
--- a/freetrackclient/build-msvc.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-export PATH="/bin:/usr/bin:$PATH"
-
-case "$(uname -s 2>/dev/null)" in
-*CYG*|*MING*|'') wrap= ;;
-*) wrap=wine ;;
-esac
-
-c_src=".\\freetrackclient.c"
-c_bin="..\\facetracknoir\\clientfiles\\freetrackclient.dll"
-opt_link="-nologo -LTCG -SAFESEH:NO -OPT:REF,ICF"
-opt_cl="
--nologo -arch:SSE2 -fp:fast -EHc -EH- -GL -GR- -GS- -Gw -LD -MT -O1
--Ob2 -Og -Oi -Ot -Oy -QIfist -volatile:iso -Ze -Fe\"${c_bin}\"
-"
-
-MSVC="VS140COMNTOOLS"
-
-test -z "$MSVC" && {
- echo "uh-oh, no MSVC" >&2
- exit 1
-}
-
-sep="\&"
-
-cd "$(dirname "$0")"
-
-$wrap cmd.exe /C $(echo "
- del /F /Q $c_bin $sep
- call %${MSVC}%/vsvars32.bat 2>nul >nul $sep
- cl $opt_cl $c_src -link $opt_link
- " | tr '\n' ' ')
diff --git a/freetrackclient/freetrackclient.c b/freetrackclient/freetrackclient.c
index 4bc39d67..8e6c2b7f 100644
--- a/freetrackclient/freetrackclient.c
+++ b/freetrackclient/freetrackclient.c
@@ -27,13 +27,12 @@
#define NP_AXIS_MAX 16383
-#include <stdbool.h>
#include <string.h>
#include <windows.h>
-#include "../ftnoir_protocol_ft/fttypes.h"
+#include "fttypes.h"
-#define FT_EXPORT(t) __declspec(dllexport) t __stdcall
+#define FT_EXPORT(t) t __stdcall
#if 0
# include <stdio.h>
@@ -49,10 +48,10 @@ static HANDLE ipc_mutex = 0;
static const char* dllVersion = "1.0.0.0";
static const char* dllProvider = "FreeTrack";
-static bool impl_create_mapping(void)
+static BOOL impl_create_mapping(void)
{
if (ipc_heap != NULL)
- return true;
+ return TRUE;
hFTMemMap = CreateFileMappingA(INVALID_HANDLE_VALUE,
NULL,
@@ -62,29 +61,26 @@ static bool impl_create_mapping(void)
(LPCSTR) FREETRACK_HEAP);
if (hFTMemMap == NULL)
- return (ipc_heap = NULL), false;
+ return (ipc_heap = NULL), FALSE;
ipc_heap = (FTHeap*) MapViewOfFile(hFTMemMap, FILE_MAP_WRITE, 0, 0, sizeof(FTHeap));
- ipc_mutex = CreateMutexA(NULL, false, FREETRACK_MUTEX);
+ ipc_mutex = CreateMutexA(NULL, FALSE, FREETRACK_MUTEX);
- return true;
+ return TRUE;
}
-#pragma comment (linker, "/export:FTGetData")
-FT_EXPORT(bool) FTGetData(FTData* data)
+FT_EXPORT(BOOL) FTGetData(FTData* data)
{
- if (impl_create_mapping() == false)
- return false;
+ if (impl_create_mapping() == FALSE)
+ return FALSE;
if (ipc_mutex && WaitForSingleObject(ipc_mutex, 16) == WAIT_OBJECT_0) {
- if (ipc_heap) {
- if (ipc_heap->data.DataID > (1 << 29))
- ipc_heap->data.DataID = 0;
- data->DataID = ipc_heap->data.DataID;
- }
+ memcpy(data, &ipc_heap->data, sizeof(FTData));
+ if (ipc_heap->data.DataID > (1 << 29))
+ ipc_heap->data.DataID = 0;
ReleaseMutex(ipc_mutex);
}
- return true;
+ return TRUE;
}
/*
@@ -92,23 +88,24 @@ FT_EXPORT(bool) FTGetData(FTData* data)
// The Delphi-code from the FreeTrack repo suggest a char * as argument, so it cost me an afternoon to figure it out (and keep ArmA2 from crashing).
// Thanks guys!
*/
-#pragma comment (linker, "/export:FTReportName")
FT_EXPORT(void) FTReportName( int name )
{
dbg_report("FTReportName request (ID = %d).\n", name);
}
-#pragma comment (linker, "/export:FTGetDllVersion")
FT_EXPORT(const char*) FTGetDllVersion(void)
{
dbg_report("FTGetDllVersion request.\n");
return dllVersion;
}
-#pragma comment (linker, "/export:FTProvider")
FT_EXPORT(const char*) FTProvider(void)
{
dbg_report("FTProvider request.\n");
return dllProvider;
}
+#pragma comment (linker, "/export:FTReportName=_FTReportName@4")
+#pragma comment (linker, "/export:FTGetDllVersion=_FTGetDllVersion@0")
+#pragma comment (linker, "/export:FTProvider=_FTProvider@0")
+#pragma comment (linker, "/export:FTGetData=_FTGetData@4")
diff --git a/freetrackclient/fttypes.h b/freetrackclient/fttypes.h
new file mode 100644
index 00000000..ad974110
--- /dev/null
+++ b/freetrackclient/fttypes.h
@@ -0,0 +1,69 @@
+/************************************************************************************
+ * * FTTypes FTTypes contains the specific type definitions for the *
+ * * FreeTrack protocol. *
+ * * It was loosely translated from FTTypes.pas *
+ * * which was created by the FreeTrack-team. *
+ * * *
+ * * Wim Vriend (Developing) *
+ * * Ron Hendriks (Testing and Research) *
+ * * *
+ * * Homepage <http://facetracknoir.sourceforge.net/home/default.htm> *
+ * * *
+ * * 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. *
+ * * *
+ * * The FTTypes sources were translated from the original Delphi sources *
+ * * created by the FreeTrack developers. *
+ */
+
+#pragma once
+
+#ifndef _MSC_VER
+# include <inttypes.h>
+#else
+typedef unsigned __int32 uint32_t;
+typedef __int32 int32_t;
+#endif
+
+#define FREETRACK_HEAP "FT_SharedMem"
+#define FREETRACK_MUTEX "FT_Mutext"
+
+/* only 6 headpose floats and the data id are filled -sh */
+typedef struct __FTData {
+ int DataID;
+ int CamWidth;
+ int CamHeight;
+ /* virtual pose */
+ float Yaw; /* positive yaw to the left */
+ float Pitch; /* positive pitch up */
+ float Roll; /* positive roll to the left */
+ float X;
+ float Y;
+ float Z;
+ /* raw pose with no smoothing, sensitivity, response curve etc. */
+ float RawYaw;
+ float RawPitch;
+ float RawRoll;
+ float RawX;
+ float RawY;
+ float RawZ;
+ /* raw points, sorted by Y, origin top left corner */
+ float X1;
+ float Y1;
+ float X2;
+ float Y2;
+ float X3;
+ float Y3;
+ float X4;
+ float Y4;
+} FTData;
+
+/* we add some shit at the end for other legacy proto, sadly */
+
+typedef struct __FTHeap {
+ FTData data;
+ int32_t GameID;
+ unsigned char table[8];
+ int32_t GameID2;
+} FTHeap;