summaryrefslogtreecommitdiffhomepage
path: root/Stars45/NPClient.h
blob: bf7925bbceba94cd03d89171834aa00f16ec23d9 (plain)
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// *******************************************************************************
// *
// * Module Name:
// *   NPClient.h
// *
// * Doyle Nickless -- 13 Jan, 2003 -- for Eye Control Technology.
// *
// * Abstract:
// *   Header for NaturalPoint Game Client API.
// *
// * Environment:
// *   Microsoft Windows -- User mode
// *
// *******************************************************************************

#ifndef _NPCLIENT_H_DEFINED_
#define _NPCLIENT_H_DEFINED_

#pragma pack( push, npclient_h ) // Save current pack value
#pragma pack(1)

//////////////////
/// Defines //////////////////////////////////////////////////////////////////////
/////////////////
#define         VERSION_MAJOR           1
#define         VERSION_MINOR           0
#define         VERSION_BUILD           1

// magic to get the preprocessor to do what we want
#define        lita(arg) #arg
#define        xlita(arg) lita(arg)
#define        cat3(w,x,z) w##.##x##.##z##\000
#define        xcat3(w,x,z) cat3(w,x,z)
#define        VERSION_STRING xlita(xcat3(VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD))
//
// Versioning hasn't been worked out yet...
//
// The following is the previous spec definition of versioning info -- I can probably do
// something very similar to this -- will keep you posted.
//
// request version information using 2 messages, they cannot be expected to arrive in a specific order - so always parse using the High byte
// the messages have a NPCONTROL byte in the first parameter, and the second parameter has packed bytes.
//   Message 1) (first parameter)NPCONTROL : (second parameter) (High Byte)NPVERSIONMAJOR (Low Byte) major version number data
//   Message 2) (first parameter)NPCONTROL : (second parameter) (High Byte)NPVERSIONMINOR (Low Byte) minor version number data

#define    NPQUERYVERSION    1040

#define    NPSTATUS_REMOTEACTIVE    0
#define    NPSTATUS_REMOTEDISABLED    1

// CONTROL DATA SUBFIELDS
#define    NPVERSIONMAJOR    1
#define    NPVERSIONMINOR    2

// DATA FIELDS
#define    NPControl        8    // indicates a control data field
// the second parameter of a message bearing control data information contains a packed data format.
// The High byte indicates what the data is, and the Low byte contains the actual data
// roll, pitch, yaw
#define    NPRoll        1    // +/- 16383 (representing +/- 180) [data = input - 16383]
#define    NPPitch        2    // +/- 16383 (representing +/- 180) [data = input - 16383]
#define    NPYaw        4    // +/- 16383 (representing +/- 180) [data = input - 16383]

// x, y, z - remaining 6dof coordinates
#define    NPX            16    // +/- 16383 [data = input - 16383]
#define    NPY            32    // +/- 16383 [data = input - 16383]
#define    NPZ            64    // +/- 16383 [data = input - 16383]

// raw object position from imager
#define    NPRawX        128    // 0..25600 (actual value is multiplied x 100 to pass two decimal places of precision)  [data = input / 100]
#define    NPRawY        256  // 0..25600 (actual value is multiplied x 100 to pass two decimal places of precision)  [data = input / 100]
#define    NPRawZ        512  // 0..25600 (actual value is multiplied x 100 to pass two decimal places of precision)  [data = input / 100]

// x, y, z deltas from raw imager position
#define    NPDeltaX        1024 // +/- 2560 (actual value is multiplied x 10 to pass two decimal places of precision)  [data = (input / 10) - 256]
#define    NPDeltaY        2048 // +/- 2560 (actual value is multiplied x 10 to pass two decimal places of precision)  [data = (input / 10) - 256]
#define    NPDeltaZ        4096 // +/- 2560 (actual value is multiplied x 10 to pass two decimal places of precision)  [data = (input / 10) - 256]

// raw object position from imager
#define    NPSmoothX        8192      // 0..32766 (actual value is multiplied x 10 to pass one decimal place of precision) [data = input / 10]
#define    NPSmoothY        16384  // 0..32766 (actual value is multiplied x 10 to pass one decimal place of precision) [data = input / 10]
#define    NPSmoothZ        32768  // 0..32766 (actual value is multiplied x 10 to pass one decimal place of precision) [data = input / 10]


//////////////////
/// Typedefs /////////////////////////////////////////////////////////////////////
/////////////////

// NPESULT values are returned from the Game Client API functions.
//
typedef enum tagNPResult
{
    NP_OK = 0,
    NP_ERR_DEVICE_NOT_PRESENT,
    NP_ERR_UNSUPPORTED_OS,
    NP_ERR_INVALID_ARG,
    NP_ERR_DLL_NOT_FOUND,
    NP_ERR_NO_DATA,
    NP_ERR_INTERNAL_DATA

} NPRESULT;

typedef struct tagTrackIRSignature
{
    char DllSignature[200];
    char AppSignature[200];

} SIGNATUREDATA, *LPTRACKIRSIGNATURE;

typedef struct tagTrackIRData
{
    unsigned short wNPStatus;
    unsigned short wPFrameSignature;
    unsigned long  dwNPIOData;

    float fNPRoll;
    float fNPPitch;
    float fNPYaw;
    float fNPX;
    float fNPY;
    float fNPZ;
    float fNPRawX;
    float fNPRawY;
    float fNPRawZ;
    float fNPDeltaX;
    float fNPDeltaY;
    float fNPDeltaZ;
    float fNPSmoothX;
    float fNPSmoothY;
    float fNPSmoothZ;

} TRACKIRDATA, *LPTRACKIRDATA;


//
// Typedef for pointer to the notify callback function that is implemented within
// the client -- this function receives head tracker reports from the game client API
//
typedef NPRESULT (__stdcall *PF_NOTIFYCALLBACK)( unsigned short, unsigned short );

// Typedefs for game client API functions (useful for declaring pointers to these
// functions within the client for use during GetProcAddress() ops)
//
typedef NPRESULT (__stdcall *PF_NP_REGISTERWINDOWHANDLE)( HWND );
typedef NPRESULT (__stdcall *PF_NP_UNREGISTERWINDOWHANDLE)( void );
typedef NPRESULT (__stdcall *PF_NP_REGISTERPROGRAMPROFILEID)( unsigned short );
typedef NPRESULT (__stdcall *PF_NP_QUERYVERSION)( unsigned short* );
typedef NPRESULT (__stdcall *PF_NP_REQUESTDATA)( unsigned short );
typedef NPRESULT (__stdcall *PF_NP_GETSIGNATURE)( LPTRACKIRSIGNATURE );
typedef NPRESULT (__stdcall *PF_NP_GETDATA)( LPTRACKIRDATA );
typedef NPRESULT (__stdcall *PF_NP_REGISTERNOTIFY)( PF_NOTIFYCALLBACK );
typedef NPRESULT (__stdcall *PF_NP_UNREGISTERNOTIFY)( void );
typedef NPRESULT (__stdcall *PF_NP_STARTCURSOR)( void );
typedef NPRESULT (__stdcall *PF_NP_STOPCURSOR)( void );
typedef NPRESULT (__stdcall *PF_NP_RECENTER)( void );
typedef NPRESULT (__stdcall *PF_NP_STARTDATATRANSMISSION)( void );
typedef NPRESULT (__stdcall *PF_NP_STOPDATATRANSMISSION)( void );

//// Function Prototypes ///////////////////////////////////////////////
//
// Functions exported from game client API DLL ( note __stdcall calling convention
// is used for ease of interface to clients of differing implementations including
// C, C++, Pascal (Delphi) and VB. )
//
NPRESULT __stdcall NP_RegisterWindowHandle( HWND hWnd  );
NPRESULT __stdcall NP_UnregisterWindowHandle( void );
NPRESULT __stdcall NP_RegisterProgramProfileID( unsigned short wPPID );
NPRESULT __stdcall NP_QueryVersion( unsigned short* pwVersion );
NPRESULT __stdcall NP_RequestData( unsigned short wDataReq );
NPRESULT __stdcall NP_GetSignature( LPTRACKIRSIGNATURE pSignature );
NPRESULT __stdcall NP_GetData( LPTRACKIRDATA pTID );
NPRESULT __stdcall NP_RegisterNotify( PF_NOTIFYCALLBACK pfNotify );
NPRESULT __stdcall NP_UnregisterNotify( void );
NPRESULT __stdcall NP_StartCursor( void );
NPRESULT __stdcall NP_StopCursor( void );
NPRESULT __stdcall NP_ReCenter( void );
NPRESULT __stdcall NP_StartDataTransmission( void );
NPRESULT __stdcall NP_StopDataTransmission( void );

/////////////////////////////////////////////////////////////////////////

#pragma pack( pop, npclient_h ) // Ensure previous pack value is restored

#endif // #ifdef NPCLIENT_H_DEFINED_

//
// *** End of file: NPClient.h ***
//