summaryrefslogtreecommitdiffhomepage
path: root/StarsEx/NPClientWraps.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-01 21:23:39 +0200
committerAki <please@ignore.pl>2022-04-01 21:23:39 +0200
commit3c487c5cd69c53d6fea948643c0a76df03516605 (patch)
tree72730c7b8b26a5ef8fc9a987ec4c16129efd5aac /StarsEx/NPClientWraps.cpp
parent8f353abd0bfe18baddd8a8250ab7c4f2d1c83a6e (diff)
downloadstarshatter-3c487c5cd69c53d6fea948643c0a76df03516605.zip
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.gz
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.bz2
Moved Stars45 to StarsEx
Diffstat (limited to 'StarsEx/NPClientWraps.cpp')
-rw-r--r--StarsEx/NPClientWraps.cpp256
1 files changed, 256 insertions, 0 deletions
diff --git a/StarsEx/NPClientWraps.cpp b/StarsEx/NPClientWraps.cpp
new file mode 100644
index 0000000..0705696
--- /dev/null
+++ b/StarsEx/NPClientWraps.cpp
@@ -0,0 +1,256 @@
+// *******************************************************************************
+// *
+// * Module Name:
+// * NPClientWraps.cpp
+// *
+// * Software Engineer:
+// * Doyle Nickless - GoFlight Inc., for Eye Control Technology.
+// *
+// * Abstract:
+// * This module implements the wrapper code for interfacing to the NaturalPoint
+// * Game Client API. Developers of client apps can include this module into
+// * their projects to simplify communication with the NaturalPoint software.
+// *
+// * This is necessary since the NPClient DLL is run-time linked rather than
+// * load-time linked, avoiding the need to link a static library into the
+// * client program (only this module is needed, and can be supplied in source
+// * form.)
+// *
+// * Environment:
+// * User mode
+// *
+// *******************************************************************************
+//
+#include "Game.h"
+#include "Text.h"
+
+#include "NPClient.h"
+#include "NPClientWraps.h"
+
+/////////////
+// Defines ///////////////////////////////////////////////////////////////////////
+/////////////
+//
+
+/////////////////
+// Global Data ///////////////////////////////////////////////////////////////////
+/////////////////
+//
+PF_NP_REGISTERWINDOWHANDLE gpfNP_RegisterWindowHandle = NULL;
+PF_NP_UNREGISTERWINDOWHANDLE gpfNP_UnregisterWindowHandle = NULL;
+PF_NP_REGISTERPROGRAMPROFILEID gpfNP_RegisterProgramProfileID = NULL;
+PF_NP_QUERYVERSION gpfNP_QueryVersion = NULL;
+PF_NP_REQUESTDATA gpfNP_RequestData = NULL;
+PF_NP_GETSIGNATURE gpfNP_GetSignature = NULL;
+PF_NP_GETDATA gpfNP_GetData = NULL;
+PF_NP_STARTCURSOR gpfNP_StartCursor = NULL;
+PF_NP_STOPCURSOR gpfNP_StopCursor = NULL;
+PF_NP_RECENTER gpfNP_ReCenter = NULL;
+PF_NP_STARTDATATRANSMISSION gpfNP_StartDataTransmission = NULL;
+PF_NP_STOPDATATRANSMISSION gpfNP_StopDataTransmission = NULL;
+
+HMODULE ghNPClientDLL = (HMODULE)NULL;
+
+////////////////////////////////////////////////////
+// NaturalPoint Game Client API function wrappers /////////////////////////////
+////////////////////////////////////////////////////
+//
+NPRESULT __stdcall NP_RegisterWindowHandle( HWND hWnd )
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_RegisterWindowHandle )
+ result = (*gpfNP_RegisterWindowHandle)( hWnd );
+
+ return result;
+} // NP_RegisterWindowHandle()
+
+
+NPRESULT __stdcall NP_UnregisterWindowHandle()
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_UnregisterWindowHandle )
+ result = (*gpfNP_UnregisterWindowHandle)();
+
+ return result;
+} // NP_UnregisterWindowHandle()
+
+
+NPRESULT __stdcall NP_RegisterProgramProfileID( unsigned short wPPID )
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_RegisterProgramProfileID )
+ result = (*gpfNP_RegisterProgramProfileID)( wPPID );
+
+ return result;
+} // NP_RegisterProgramProfileID()
+
+
+NPRESULT __stdcall NP_QueryVersion( unsigned short* pwVersion )
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_QueryVersion )
+ result = (*gpfNP_QueryVersion)( pwVersion );
+
+ return result;
+} // NP_QueryVersion()
+
+
+NPRESULT __stdcall NP_RequestData( unsigned short wDataReq )
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_RequestData )
+ result = (*gpfNP_RequestData)( wDataReq );
+
+ return result;
+} // NP_RequestData()
+
+NPRESULT __stdcall NP_GetSignature( LPTRACKIRSIGNATURE pSignature )
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_GetSignature )
+ result = (*gpfNP_GetSignature)( pSignature );
+
+ return result;
+} // NP_GetSignature()
+
+
+NPRESULT __stdcall NP_GetData( LPTRACKIRDATA pTID )
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_GetData )
+ result = (*gpfNP_GetData)( pTID );
+
+ return result;
+} // NP_GetData()
+
+
+NPRESULT __stdcall NP_StartCursor()
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_StartCursor )
+ result = (*gpfNP_StartCursor)();
+
+ return result;
+} // NP_StartCursor()
+
+
+NPRESULT __stdcall NP_StopCursor()
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_StopCursor )
+ result = (*gpfNP_StopCursor)();
+
+ return result;
+} // NP_StopCursor()
+
+
+NPRESULT __stdcall NP_ReCenter()
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_ReCenter )
+ result = (*gpfNP_ReCenter)();
+
+ return result;
+} // NP_ReCenter()
+
+
+NPRESULT __stdcall NP_StartDataTransmission()
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_StartDataTransmission )
+ result = (*gpfNP_StartDataTransmission)();
+
+ return result;
+} // NP_StartDataTransmission()
+
+
+NPRESULT __stdcall NP_StopDataTransmission()
+{
+ NPRESULT result = NP_ERR_DLL_NOT_FOUND;
+
+ if( NULL != gpfNP_StopDataTransmission )
+ result = (*gpfNP_StopDataTransmission)();
+
+ return result;
+} // NP_StopDataTransmission()
+
+
+//////////////////////////////////////////////////////////////////////////////
+// NPClientInit() -- Loads the DLL and retrieves pointers to all exports
+//
+NPRESULT NPClient_Init( const char* csDLLPath )
+{
+ NPRESULT result = NP_OK;
+
+ Text csNPClientDLLFullPath;
+
+ if (csDLLPath && *csDLLPath)
+ csNPClientDLLFullPath = Text(csDLLPath) + "\\";
+ csNPClientDLLFullPath += "NPClient.dll";
+
+ ghNPClientDLL = ::LoadLibrary( csNPClientDLLFullPath.data() );
+
+ if (NULL != ghNPClientDLL) {
+ // verify the dll signature
+ gpfNP_GetSignature = (PF_NP_GETSIGNATURE)::GetProcAddress( ghNPClientDLL, "NP_GetSignature" );
+
+ SIGNATUREDATA pSignature;
+ SIGNATUREDATA verifySignature;
+ // init the signatures
+ strcpy_s(verifySignature.DllSignature, "precise head tracking\n put your head into the game\n now go look around\n\n Copyright EyeControl Technologies");
+ strcpy_s(verifySignature.AppSignature, "hardware camera\n software processing data\n track user movement\n\n Copyright EyeControl Technologies");
+ // query the dll and compare the results
+ NPRESULT vresult = NP_GetSignature( &pSignature );
+ if( vresult == NP_OK )
+ {
+ if ((strcmp(verifySignature.DllSignature,pSignature.DllSignature)==0)
+ && (strcmp(verifySignature.AppSignature,pSignature.AppSignature)==0))
+ {
+ result = NP_OK;
+
+ // Get addresses of all exported functions
+ gpfNP_RegisterWindowHandle = (PF_NP_REGISTERWINDOWHANDLE)::GetProcAddress( ghNPClientDLL, "NP_RegisterWindowHandle" );
+ gpfNP_UnregisterWindowHandle = (PF_NP_UNREGISTERWINDOWHANDLE)::GetProcAddress( ghNPClientDLL, "NP_UnregisterWindowHandle" );
+ gpfNP_RegisterProgramProfileID = (PF_NP_REGISTERPROGRAMPROFILEID)::GetProcAddress( ghNPClientDLL, "NP_RegisterProgramProfileID" );
+ gpfNP_QueryVersion = (PF_NP_QUERYVERSION)::GetProcAddress( ghNPClientDLL, "NP_QueryVersion" );
+ gpfNP_RequestData = (PF_NP_REQUESTDATA)::GetProcAddress( ghNPClientDLL, "NP_RequestData" );
+ gpfNP_GetData = (PF_NP_GETDATA)::GetProcAddress( ghNPClientDLL, "NP_GetData" );
+ gpfNP_StartCursor = (PF_NP_STARTCURSOR)::GetProcAddress( ghNPClientDLL, "NP_StartCursor" );
+ gpfNP_StopCursor = (PF_NP_STOPCURSOR)::GetProcAddress( ghNPClientDLL, "NP_StopCursor" );
+ gpfNP_ReCenter = (PF_NP_RECENTER)::GetProcAddress( ghNPClientDLL, "NP_ReCenter" );
+ gpfNP_StartDataTransmission = (PF_NP_STARTDATATRANSMISSION)::GetProcAddress( ghNPClientDLL, "NP_StartDataTransmission" );
+ gpfNP_StopDataTransmission = (PF_NP_STOPDATATRANSMISSION)::GetProcAddress( ghNPClientDLL, "NP_StopDataTransmission" );
+ }
+ else
+ {
+ result = NP_ERR_DLL_NOT_FOUND;
+ }
+ }
+ else
+ {
+ result = NP_ERR_DLL_NOT_FOUND;
+ }
+ }
+ else
+ result = NP_ERR_DLL_NOT_FOUND;
+
+ return result;
+
+} // NPClient_Init()
+
+//////////////////////////////////////////////////////////////////////////////
+
+
+
+