File: trackirpublic.h

package info (click to toggle)
freespace2 3.7.4%2Brepack-1.1
  • links: PTS, VCS
  • area: non-free
  • in suites: bullseye
  • size: 22,268 kB
  • sloc: cpp: 393,535; ansic: 4,106; makefile: 1,091; xml: 181; sh: 137
file content (170 lines) | stat: -rw-r--r-- 3,444 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#ifndef TRACKIRPUBLIC_H_INCLUDED_
#define TRACKIRPUBLIC_H_INCLUDED_

#include "external_dll/externalcode.h"
#include "globalincs/pstypes.h"

#define TRACKIRBRIDGEDLLNAME "scptrackir.dll"

#define SCP_INITRESULT_SUCCESS 0
#define SCP_INITRESULT_BADKEY 1
#define SCP_INITRESULT_BADPATH 2
#define SCP_INITRESULT_PATHTOOLONG 3
#define SCP_INITRESULT_NODLL 4
#define SCP_INITRESULT_BADSIGNATURE 5
#define SCP_INITRESULT_UNABLETOREGISTER 6
#define SCP_INITRESULT_BADDATAFIELDS 7
#define SCP_INITRESULT_BADREGISTRATION 8
#define SCP_INITRESULT_BADTRANSMISSION 9

/* Exported functions */
/* HWND comes from externalcode.h */
/* These are function pointer prototypes provided for library loading */

/* Only one function doesn't return an int or a float */
typedef int ( SCP_EXT_CALLCONV *SCPTRACKIR_PFINIT )( HWND );

/* All other trackir functions return an int or a float
 *  and take no parameters
 */
typedef int ( SCP_EXT_CALLCONV *SCPTRACKIR_PFINTVOID )( );
typedef float ( SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID )( );

class TrackIRDLL : public SCP_ExternalCode
{
public:
	TrackIRDLL( )
	{
		/* Load the DLL and functions 
		 * If this is done globally, we'll be found by MSPDBDEBUGGING :)
		 */

		Reset( );

		if ( !LoadExternal( TRACKIRBRIDGEDLLNAME ) )
			return;

		m_Init = (SCPTRACKIR_PFINIT)LoadFunction( "SCPTIR_Init" );
		m_Close = (SCPTRACKIR_PFINTVOID)LoadFunction( "SCPTIR_Close" );
		m_Query = (SCPTRACKIR_PFINTVOID)LoadFunction( "SCPTIR_Query" );

		m_GetX = (SCPTRACKIR_PFFLOATVOID)LoadFunction( "SCPTIR_GetX" );
		m_GetY = (SCPTRACKIR_PFFLOATVOID)LoadFunction( "SCPTIR_GetY" );
		m_GetZ = (SCPTRACKIR_PFFLOATVOID)LoadFunction( "SCPTIR_GetZ" );
		m_GetRoll = (SCPTRACKIR_PFFLOATVOID)LoadFunction( "SCPTIR_GetRoll" );
		m_GetPitch = (SCPTRACKIR_PFFLOATVOID)LoadFunction( "SCPTIR_GetPitch" );
		m_GetYaw = (SCPTRACKIR_PFFLOATVOID)LoadFunction( "SCPTIR_GetYaw" );
		m_enabled = true;
	}

	bool Enabled( )
	{
		return m_enabled;
	}

	virtual ~TrackIRDLL( )
	{
		/* Prevent further use of the DLL */
		Reset( );
	}

	void Reset( )
	{
		m_Init = NULL;
		m_Close = NULL; 
		m_Query = NULL;
		m_GetX = NULL;
		m_GetY = NULL;
		m_GetZ = NULL;
		m_GetPitch = NULL;
		m_GetRoll = NULL;
		m_GetYaw = NULL;
		m_enabled = false;
	}

	/* Returns 0 on success */
	int Init( HWND hwnd )
	{
		if ( m_Init )
			return m_Init( hwnd );
		return 0;
	}

	int Close( )
	{
		if ( m_Close )
			return m_Close( );
		return 0;
	}

	int Query( )
	{
		if ( m_Query )
			return m_Query( );
		return 0;
	}


	float GetX( )
	{
		if ( m_GetX )
			return m_GetX( );
		return 0.0f;
	}

	float GetY( )
	{
		if ( m_GetY )
			return m_GetY( );
		return 0.0f;
	}

	float GetZ( )
	{
		if ( m_GetZ )
			return m_GetZ( );
		return 0.0f;
	}

	float GetPitch( )
	{
		if ( m_GetPitch )
			return m_GetPitch( );
		return 0.0f;
	}

	float GetRoll( )
	{
		if ( m_GetRoll )
			return m_GetRoll( );
		return 0.0f;
	}

	float GetYaw( )
	{
		if ( m_GetYaw )
			return m_GetYaw( );
		return 0.0f;
	}
private:
	/* Functions */
	SCPTRACKIR_PFINIT m_Init;
	SCPTRACKIR_PFINTVOID m_Close;
	SCPTRACKIR_PFINTVOID m_Query;

	SCPTRACKIR_PFFLOATVOID m_GetX;
	SCPTRACKIR_PFFLOATVOID m_GetY;
	SCPTRACKIR_PFFLOATVOID m_GetZ;
	SCPTRACKIR_PFFLOATVOID m_GetPitch;
	SCPTRACKIR_PFFLOATVOID m_GetRoll;
	SCPTRACKIR_PFFLOATVOID m_GetYaw;

	bool m_enabled;
};

/* Added to trackirpublic.h */
#ifndef SCPDLL_EXTERNAL_LIB
extern TrackIRDLL gTirDll_TrackIR;
#endif

#endif /* TRACKIRPUBLIC_H_INCLUDED_ */