@irsdk-node/native 4.0.2 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -46
- package/binding.gyp +28 -19
- package/dist/INativeSDK.d.ts +28 -0
- package/dist/INativeSDK.js +2 -0
- package/dist/MockSdk.d.ts +43 -0
- package/dist/MockSdk.js +70 -0
- package/dist/mock-data/loader.d.ts +3 -0
- package/dist/mock-data/loader.js +41 -0
- package/dist/mock-data/session.json +4305 -0
- package/dist/mock-data/telemetry.json +4986 -0
- package/{src/index.d.ts → index.d.ts} +5 -35
- package/index.js +36 -0
- package/lib/irsdk_client.cpp +495 -495
- package/lib/irsdk_client.h +139 -139
- package/lib/irsdk_defines.h +528 -528
- package/{src → lib}/irsdk_node.cc +404 -375
- package/{src → lib}/irsdk_node.h +49 -50
- package/lib/irsdk_node_mocked.cc +226 -0
- package/lib/irsdk_utils.cpp +377 -377
- package/lib/yaml_parser.cpp +176 -176
- package/lib/yaml_parser.h +34 -34
- package/package.json +37 -29
- package/prebuilds/darwin-arm64/@irsdk-node+native.node +0 -0
- package/prebuilds/linux-x64/@irsdk-node+native.node +0 -0
- package/prebuilds/win32-x64/@irsdk-node+native.node +0 -0
- package/build/Debug/irsdk_node.exp +0 -0
- package/build/Debug/irsdk_node.lib +0 -0
- package/build/Debug/irsdk_node.node +0 -0
- package/build/Debug/irsdk_node.pdb +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.node.recipe +0 -11
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/CL.command.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/CL.read.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/CL.write.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/Cl.items.tlog +0 -4
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/irsdk_node.lastbuildstate +0 -2
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.command.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.read.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.secondary.1.tlog +0 -3
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.write.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/lib/irsdk_utils.obj +0 -0
- package/build/Debug/obj/irsdk_node/lib/yaml_parser.obj +0 -0
- package/build/Debug/obj/irsdk_node/src/irsdk_node.obj +0 -0
- package/build/Debug/obj/irsdk_node/vcpkg.applocal.log +0 -1
- package/build/Debug/obj/irsdk_node/win_delay_load_hook.obj +0 -0
- package/build/Release/irsdk_node.exp +0 -0
- package/build/Release/irsdk_node.iobj +0 -0
- package/build/Release/irsdk_node.ipdb +0 -0
- package/build/Release/irsdk_node.lib +0 -0
- package/build/Release/irsdk_node.node +0 -0
- package/build/Release/irsdk_node.pdb +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.node.recipe +0 -11
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/CL.command.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/CL.read.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/CL.write.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/Cl.items.tlog +0 -4
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/irsdk_node.lastbuildstate +0 -2
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.command.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.read.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.secondary.1.tlog +0 -5
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.write.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/lib/irsdk_utils.obj +0 -0
- package/build/Release/obj/irsdk_node/lib/yaml_parser.obj +0 -0
- package/build/Release/obj/irsdk_node/src/irsdk_node.obj +0 -0
- package/build/Release/obj/irsdk_node/vcpkg.applocal.log +0 -1
- package/build/Release/obj/irsdk_node/win_delay_load_hook.obj +0 -0
- package/build/binding.sln +0 -19
- package/build/config.gypi +0 -426
- package/build/irsdk_node.vcxproj +0 -157
- package/build/irsdk_node.vcxproj.filters +0 -73
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -13
- package/src/index.js +0 -11
package/lib/irsdk_defines.h
CHANGED
|
@@ -1,528 +1,528 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2013, iRacing.com Motorsport Simulations, LLC.
|
|
3
|
-
All rights reserved.
|
|
4
|
-
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions are met:
|
|
7
|
-
* Redistributions of source code must retain the above copyright
|
|
8
|
-
notice, this list of conditions and the following disclaimer.
|
|
9
|
-
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
-
notice, this list of conditions and the following disclaimer in the
|
|
11
|
-
documentation and/or other materials provided with the distribution.
|
|
12
|
-
* Neither the name of iRacing.com Motorsport Simulations nor the
|
|
13
|
-
names of its contributors may be used to endorse or promote products
|
|
14
|
-
derived from this software without specific prior written permission.
|
|
15
|
-
|
|
16
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
17
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
18
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
20
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
21
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
22
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
23
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
24
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
#ifndef IRSDK_DEFINES_H
|
|
29
|
-
#define IRSDK_DEFINES_H
|
|
30
|
-
|
|
31
|
-
/*
|
|
32
|
-
The IRSDK is a simple api that lets clients access telemetry data from the
|
|
33
|
-
iRacing simulator. It is broken down into several parts:
|
|
34
|
-
|
|
35
|
-
- Live data
|
|
36
|
-
Live data is output from the sim into a shared memory mapped file. Any
|
|
37
|
-
application can open this memory mapped file and read the telemetry data
|
|
38
|
-
out. The format of this data was laid out in such a way that it should be
|
|
39
|
-
possible to access from any language that can open a windows memory mapped
|
|
40
|
-
file, without needing an external api.
|
|
41
|
-
|
|
42
|
-
There are two different types of data that the telemetry outputs,
|
|
43
|
-
sessionInfo and variables:
|
|
44
|
-
|
|
45
|
-
Session info is for data that only needs to be updated every once in a
|
|
46
|
-
while. This data is output as a YAML formatted string.
|
|
47
|
-
|
|
48
|
-
Variables, on the other hand, are output at a rate of 60 times a second.
|
|
49
|
-
The varHeader struct defines each variable that the sim will output, while
|
|
50
|
-
the varData struct gives details about the current line buffer that the vars
|
|
51
|
-
are being written into. Each variable is packed into a binary array with
|
|
52
|
-
an offset and length stored in the varHeader. The number of variables
|
|
53
|
-
available can change depending on the car or session loaded. But once the
|
|
54
|
-
sim is running the variable list is locked down and will not change during a
|
|
55
|
-
session.
|
|
56
|
-
|
|
57
|
-
The sim writes a new line of variables every 16 ms, and then signals any
|
|
58
|
-
listeners in order to wake them up to read the data. Because the sim has no
|
|
59
|
-
way of knowing when a listener is done reading the data, we triple buffer
|
|
60
|
-
it in order to give all the clients enough time to read the data out. This
|
|
61
|
-
gives you a minimum of 16 ms to read the data out and process it. So it is
|
|
62
|
-
best to copy the data out before processing it. You can use the function
|
|
63
|
-
irsdk_waitForDataReady() to both wait for new data and copy the data to a
|
|
64
|
-
local buffer.
|
|
65
|
-
|
|
66
|
-
- Logged data
|
|
67
|
-
Detailed information about the local drivers car can be logged to disk in
|
|
68
|
-
the form of an ibt binary file. This logging is enabled in the sim by
|
|
69
|
-
typing alt-L at any time. The ibt file format directly mirrors the format
|
|
70
|
-
of the live data.
|
|
71
|
-
|
|
72
|
-
It is stored as an irsdk_header followed immediately by an irsdk_diskSubHeader.
|
|
73
|
-
After that the offsets in the irsdk_header point to the sessionInfo string,
|
|
74
|
-
the varHeader, and the varBuffer.
|
|
75
|
-
|
|
76
|
-
- Remote Conrol
|
|
77
|
-
You can control the camera selections and playback of a replay tape, from
|
|
78
|
-
any external application by sending a windows message with the
|
|
79
|
-
irsdk_broadcastMsg() function.
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
// Constant Definitions
|
|
83
|
-
|
|
84
|
-
#include <tchar.h>
|
|
85
|
-
|
|
86
|
-
static const _TCHAR IRSDK_DATAVALIDEVENTNAME[] = _T("Local\\IRSDKDataValidEvent");
|
|
87
|
-
static const _TCHAR IRSDK_MEMMAPFILENAME[] = _T("Local\\IRSDKMemMapFileName");
|
|
88
|
-
static const _TCHAR IRSDK_BROADCASTMSGNAME[] = _T("IRSDK_BROADCASTMSG");
|
|
89
|
-
|
|
90
|
-
static const int IRSDK_MAX_BUFS = 4;
|
|
91
|
-
static const int IRSDK_MAX_STRING = 32;
|
|
92
|
-
// descriptions can be longer than max_string!
|
|
93
|
-
static const int IRSDK_MAX_DESC = 64;
|
|
94
|
-
|
|
95
|
-
// define markers for unlimited session lap and time
|
|
96
|
-
static const int IRSDK_UNLIMITED_LAPS = 32767;
|
|
97
|
-
static const float IRSDK_UNLIMITED_TIME = 604800.0f;
|
|
98
|
-
|
|
99
|
-
// latest version of our telemetry headers
|
|
100
|
-
static const int IRSDK_VER = 2;
|
|
101
|
-
|
|
102
|
-
enum irsdk_StatusField
|
|
103
|
-
{
|
|
104
|
-
irsdk_stConnected = 1
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
enum irsdk_VarType
|
|
108
|
-
{
|
|
109
|
-
// 1 byte
|
|
110
|
-
irsdk_char = 0,
|
|
111
|
-
irsdk_bool,
|
|
112
|
-
|
|
113
|
-
// 4 bytes
|
|
114
|
-
irsdk_int,
|
|
115
|
-
irsdk_bitField,
|
|
116
|
-
irsdk_float,
|
|
117
|
-
|
|
118
|
-
// 8 bytes
|
|
119
|
-
irsdk_double,
|
|
120
|
-
|
|
121
|
-
//index, don't use
|
|
122
|
-
irsdk_ETCount
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
static const int irsdk_VarTypeBytes[irsdk_ETCount] =
|
|
126
|
-
{
|
|
127
|
-
1, // irsdk_char
|
|
128
|
-
1, // irsdk_bool
|
|
129
|
-
|
|
130
|
-
4, // irsdk_int
|
|
131
|
-
4, // irsdk_bitField
|
|
132
|
-
4, // irsdk_float
|
|
133
|
-
|
|
134
|
-
8 // irsdk_double
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// bit fields
|
|
138
|
-
enum irsdk_EngineWarnings
|
|
139
|
-
{
|
|
140
|
-
irsdk_waterTempWarning = 0x01,
|
|
141
|
-
irsdk_fuelPressureWarning = 0x02,
|
|
142
|
-
irsdk_oilPressureWarning = 0x04,
|
|
143
|
-
irsdk_engineStalled = 0x08,
|
|
144
|
-
irsdk_pitSpeedLimiter = 0x10,
|
|
145
|
-
irsdk_revLimiterActive = 0x20,
|
|
146
|
-
irsdk_oilTempWarning = 0x40,
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// global flags
|
|
150
|
-
enum irsdk_Flags
|
|
151
|
-
{
|
|
152
|
-
// global flags
|
|
153
|
-
irsdk_checkered = 0x00000001,
|
|
154
|
-
irsdk_white = 0x00000002,
|
|
155
|
-
irsdk_green = 0x00000004,
|
|
156
|
-
irsdk_yellow = 0x00000008,
|
|
157
|
-
irsdk_red = 0x00000010,
|
|
158
|
-
irsdk_blue = 0x00000020,
|
|
159
|
-
irsdk_debris = 0x00000040,
|
|
160
|
-
irsdk_crossed = 0x00000080,
|
|
161
|
-
irsdk_yellowWaving = 0x00000100,
|
|
162
|
-
irsdk_oneLapToGreen = 0x00000200,
|
|
163
|
-
irsdk_greenHeld = 0x00000400,
|
|
164
|
-
irsdk_tenToGo = 0x00000800,
|
|
165
|
-
irsdk_fiveToGo = 0x00001000,
|
|
166
|
-
irsdk_randomWaving = 0x00002000,
|
|
167
|
-
irsdk_caution = 0x00004000,
|
|
168
|
-
irsdk_cautionWaving = 0x00008000,
|
|
169
|
-
|
|
170
|
-
// drivers black flags
|
|
171
|
-
irsdk_black = 0x00010000,
|
|
172
|
-
irsdk_disqualify = 0x00020000,
|
|
173
|
-
irsdk_servicible = 0x00040000, // car is allowed service (not a flag)
|
|
174
|
-
irsdk_furled = 0x00080000,
|
|
175
|
-
irsdk_repair = 0x00100000,
|
|
176
|
-
|
|
177
|
-
// start lights
|
|
178
|
-
irsdk_startHidden = 0x10000000,
|
|
179
|
-
irsdk_startReady = 0x20000000,
|
|
180
|
-
irsdk_startSet = 0x40000000,
|
|
181
|
-
irsdk_startGo = 0x80000000,
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// status
|
|
186
|
-
enum irsdk_TrkLoc
|
|
187
|
-
{
|
|
188
|
-
irsdk_NotInWorld = -1,
|
|
189
|
-
irsdk_OffTrack,
|
|
190
|
-
irsdk_InPitStall,
|
|
191
|
-
irsdk_AproachingPits,
|
|
192
|
-
irsdk_OnTrack
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
enum irsdk_TrkSurf
|
|
196
|
-
{
|
|
197
|
-
irsdk_SurfaceNotInWorld = -1,
|
|
198
|
-
irsdk_UndefinedMaterial = 0,
|
|
199
|
-
|
|
200
|
-
irsdk_Asphalt1Material,
|
|
201
|
-
irsdk_Asphalt2Material,
|
|
202
|
-
irsdk_Asphalt3Material,
|
|
203
|
-
irsdk_Asphalt4Material,
|
|
204
|
-
irsdk_Concrete1Material,
|
|
205
|
-
irsdk_Concrete2Material,
|
|
206
|
-
irsdk_RacingDirt1Material,
|
|
207
|
-
irsdk_RacingDirt2Material,
|
|
208
|
-
irsdk_Paint1Material,
|
|
209
|
-
irsdk_Paint2Material,
|
|
210
|
-
irsdk_Rumble1Material,
|
|
211
|
-
irsdk_Rumble2Material,
|
|
212
|
-
irsdk_Rumble3Material,
|
|
213
|
-
irsdk_Rumble4Material,
|
|
214
|
-
|
|
215
|
-
irsdk_Grass1Material,
|
|
216
|
-
irsdk_Grass2Material,
|
|
217
|
-
irsdk_Grass3Material,
|
|
218
|
-
irsdk_Grass4Material,
|
|
219
|
-
irsdk_Dirt1Material,
|
|
220
|
-
irsdk_Dirt2Material,
|
|
221
|
-
irsdk_Dirt3Material,
|
|
222
|
-
irsdk_Dirt4Material,
|
|
223
|
-
irsdk_SandMaterial,
|
|
224
|
-
irsdk_Gravel1Material,
|
|
225
|
-
irsdk_Gravel2Material,
|
|
226
|
-
irsdk_GrasscreteMaterial,
|
|
227
|
-
irsdk_AstroturfMaterial,
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
enum irsdk_SessionState
|
|
231
|
-
{
|
|
232
|
-
irsdk_StateInvalid,
|
|
233
|
-
irsdk_StateGetInCar,
|
|
234
|
-
irsdk_StateWarmup,
|
|
235
|
-
irsdk_StateParadeLaps,
|
|
236
|
-
irsdk_StateRacing,
|
|
237
|
-
irsdk_StateCheckered,
|
|
238
|
-
irsdk_StateCoolDown
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
enum irsdk_CarLeftRight
|
|
242
|
-
{
|
|
243
|
-
irsdk_LROff,
|
|
244
|
-
irsdk_LRClear, // no cars around us.
|
|
245
|
-
irsdk_LRCarLeft, // there is a car to our left.
|
|
246
|
-
irsdk_LRCarRight, // there is a car to our right.
|
|
247
|
-
irsdk_LRCarLeftRight, // there are cars on each side.
|
|
248
|
-
irsdk_LR2CarsLeft, // there are two cars to our left.
|
|
249
|
-
irsdk_LR2CarsRight // there are two cars to our right.
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
enum irsdk_CameraState
|
|
253
|
-
{
|
|
254
|
-
irsdk_IsSessionScreen = 0x0001, // the camera tool can only be activated if viewing the session screen (out of car)
|
|
255
|
-
irsdk_IsScenicActive = 0x0002, // the scenic camera is active (no focus car)
|
|
256
|
-
|
|
257
|
-
//these can be changed with a broadcast message
|
|
258
|
-
irsdk_CamToolActive = 0x0004,
|
|
259
|
-
irsdk_UIHidden = 0x0008,
|
|
260
|
-
irsdk_UseAutoShotSelection = 0x0010,
|
|
261
|
-
irsdk_UseTemporaryEdits = 0x0020,
|
|
262
|
-
irsdk_UseKeyAcceleration = 0x0040,
|
|
263
|
-
irsdk_UseKey10xAcceleration = 0x0080,
|
|
264
|
-
irsdk_UseMouseAimMode = 0x0100
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
enum irsdk_PitSvFlags
|
|
268
|
-
{
|
|
269
|
-
irsdk_LFTireChange = 0x0001,
|
|
270
|
-
irsdk_RFTireChange = 0x0002,
|
|
271
|
-
irsdk_LRTireChange = 0x0004,
|
|
272
|
-
irsdk_RRTireChange = 0x0008,
|
|
273
|
-
|
|
274
|
-
irsdk_FuelFill = 0x0010,
|
|
275
|
-
irsdk_WindshieldTearoff = 0x0020,
|
|
276
|
-
irsdk_FastRepair = 0x0040
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
enum irsdk_PitSvStatus
|
|
280
|
-
{
|
|
281
|
-
// status
|
|
282
|
-
irsdk_PitSvNone = 0,
|
|
283
|
-
irsdk_PitSvInProgress,
|
|
284
|
-
irsdk_PitSvComplete,
|
|
285
|
-
|
|
286
|
-
// errors
|
|
287
|
-
irsdk_PitSvTooFarLeft = 100,
|
|
288
|
-
irsdk_PitSvTooFarRight,
|
|
289
|
-
irsdk_PitSvTooFarForward,
|
|
290
|
-
irsdk_PitSvTooFarBack,
|
|
291
|
-
irsdk_PitSvBadAngle,
|
|
292
|
-
irsdk_PitSvCantFixThat,
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
enum irsdk_PaceMode
|
|
296
|
-
{
|
|
297
|
-
irsdk_PaceModeSingleFileStart = 0,
|
|
298
|
-
irsdk_PaceModeDoubleFileStart,
|
|
299
|
-
irsdk_PaceModeSingleFileRestart,
|
|
300
|
-
irsdk_PaceModeDoubleFileRestart,
|
|
301
|
-
irsdk_PaceModeNotPacing,
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
enum irsdk_PaceFlags
|
|
305
|
-
{
|
|
306
|
-
irsdk_PaceFlagsEndOfLine = 0x01,
|
|
307
|
-
irsdk_PaceFlagsFreePass = 0x02,
|
|
308
|
-
irsdk_PaceFlagsWavedAround = 0x04,
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
//----
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
struct irsdk_varHeader
|
|
315
|
-
{
|
|
316
|
-
int type; // irsdk_VarType
|
|
317
|
-
int offset; // offset fron start of buffer row
|
|
318
|
-
int count; // number of entrys (array)
|
|
319
|
-
// so length in bytes would be irsdk_VarTypeBytes[type] * count
|
|
320
|
-
bool countAsTime;
|
|
321
|
-
char pad[3]; // (16 byte align)
|
|
322
|
-
|
|
323
|
-
char name[IRSDK_MAX_STRING];
|
|
324
|
-
char desc[IRSDK_MAX_DESC];
|
|
325
|
-
char unit[IRSDK_MAX_STRING]; // something like "kg/m^2"
|
|
326
|
-
|
|
327
|
-
void clear()
|
|
328
|
-
{
|
|
329
|
-
type = 0;
|
|
330
|
-
offset = 0;
|
|
331
|
-
count = 0;
|
|
332
|
-
countAsTime = false;
|
|
333
|
-
memset(name, 0, sizeof(name));
|
|
334
|
-
memset(desc, 0, sizeof(name));
|
|
335
|
-
memset(unit, 0, sizeof(name));
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
struct irsdk_varBuf
|
|
340
|
-
{
|
|
341
|
-
int tickCount; // used to detect changes in data
|
|
342
|
-
int bufOffset; // offset from header
|
|
343
|
-
int pad[2]; // (16 byte align)
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
struct irsdk_header
|
|
347
|
-
{
|
|
348
|
-
int ver; // this api header version, see IRSDK_VER
|
|
349
|
-
int status; // bitfield using irsdk_StatusField
|
|
350
|
-
int tickRate; // ticks per second (60 or 360 etc)
|
|
351
|
-
|
|
352
|
-
// session information, updated periodicaly
|
|
353
|
-
int sessionInfoUpdate; // Incremented when session info changes
|
|
354
|
-
int sessionInfoLen; // Length in bytes of session info string
|
|
355
|
-
int sessionInfoOffset; // Session info, encoded in YAML format
|
|
356
|
-
|
|
357
|
-
// State data, output at tickRate
|
|
358
|
-
|
|
359
|
-
int numVars; // length of arra pointed to by varHeaderOffset
|
|
360
|
-
int varHeaderOffset; // offset to irsdk_varHeader[numVars] array, Describes the variables received in varBuf
|
|
361
|
-
|
|
362
|
-
int numBuf; // <= IRSDK_MAX_BUFS (3 for now)
|
|
363
|
-
int bufLen; // length in bytes for one line
|
|
364
|
-
int pad1[2]; // (16 byte align)
|
|
365
|
-
irsdk_varBuf varBuf[IRSDK_MAX_BUFS]; // buffers of data being written to
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
// sub header used when writing telemetry to disk
|
|
369
|
-
struct irsdk_diskSubHeader
|
|
370
|
-
{
|
|
371
|
-
time_t sessionStartDate;
|
|
372
|
-
double sessionStartTime;
|
|
373
|
-
double sessionEndTime;
|
|
374
|
-
int sessionLapCount;
|
|
375
|
-
int sessionRecordCount;
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
//----
|
|
379
|
-
// Client function definitions
|
|
380
|
-
|
|
381
|
-
bool irsdk_startup();
|
|
382
|
-
void irsdk_shutdown();
|
|
383
|
-
|
|
384
|
-
bool irsdk_getNewData(char *data);
|
|
385
|
-
bool irsdk_waitForDataReady(int timeOut, char *data);
|
|
386
|
-
bool irsdk_isConnected();
|
|
387
|
-
|
|
388
|
-
const irsdk_header *irsdk_getHeader();
|
|
389
|
-
const char *irsdk_getData(int index);
|
|
390
|
-
const char *irsdk_getSessionInfoStr();
|
|
391
|
-
int irsdk_getSessionInfoStrUpdate(); // incrementing index that indicates new session info string
|
|
392
|
-
|
|
393
|
-
const irsdk_varHeader *irsdk_getVarHeaderPtr();
|
|
394
|
-
const irsdk_varHeader *irsdk_getVarHeaderEntry(int index);
|
|
395
|
-
|
|
396
|
-
int irsdk_varNameToIndex(const char *name);
|
|
397
|
-
int irsdk_varNameToOffset(const char *name);
|
|
398
|
-
|
|
399
|
-
//----
|
|
400
|
-
// Remote controll the sim by sending these windows messages
|
|
401
|
-
// camera and replay commands only work when you are out of your car,
|
|
402
|
-
// pit commands only work when in your car
|
|
403
|
-
enum irsdk_BroadcastMsg
|
|
404
|
-
{
|
|
405
|
-
irsdk_BroadcastCamSwitchPos = 0, // car position, group, camera
|
|
406
|
-
irsdk_BroadcastCamSwitchNum, // driver #, group, camera
|
|
407
|
-
irsdk_BroadcastCamSetState, // irsdk_CameraState, unused, unused
|
|
408
|
-
irsdk_BroadcastReplaySetPlaySpeed, // speed, slowMotion, unused
|
|
409
|
-
irskd_BroadcastReplaySetPlayPosition, // irsdk_RpyPosMode, Frame Number (high, low)
|
|
410
|
-
irsdk_BroadcastReplaySearch, // irsdk_RpySrchMode, unused, unused
|
|
411
|
-
irsdk_BroadcastReplaySetState, // irsdk_RpyStateMode, unused, unused
|
|
412
|
-
irsdk_BroadcastReloadTextures, // irsdk_ReloadTexturesMode, carIdx, unused
|
|
413
|
-
irsdk_BroadcastChatComand, // irsdk_ChatCommandMode, subCommand, unused
|
|
414
|
-
irsdk_BroadcastPitCommand, // irsdk_PitCommandMode, parameter
|
|
415
|
-
irsdk_BroadcastTelemCommand, // irsdk_TelemCommandMode, unused, unused
|
|
416
|
-
irsdk_BroadcastFFBCommand, // irsdk_FFBCommandMode, value (float, high, low)
|
|
417
|
-
irsdk_BroadcastReplaySearchSessionTime, // sessionNum, sessionTimeMS (high, low)
|
|
418
|
-
irsdk_BroadcastVideoCapture, // irsdk_VideoCaptureMode, unused, unused
|
|
419
|
-
irsdk_BroadcastLast // unused placeholder
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
enum irsdk_ChatCommandMode
|
|
423
|
-
{
|
|
424
|
-
irsdk_ChatCommand_Macro = 0, // pass in a number from 1-15 representing the chat macro to launch
|
|
425
|
-
irsdk_ChatCommand_BeginChat, // Open up a new chat window
|
|
426
|
-
irsdk_ChatCommand_Reply, // Reply to last private chat
|
|
427
|
-
irsdk_ChatCommand_Cancel // Close chat window
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
enum irsdk_PitCommandMode // this only works when the driver is in the car
|
|
431
|
-
{
|
|
432
|
-
irsdk_PitCommand_Clear = 0, // Clear all pit checkboxes
|
|
433
|
-
irsdk_PitCommand_WS, // Clean the winshield, using one tear off
|
|
434
|
-
irsdk_PitCommand_Fuel, // Add fuel, optionally specify the amount to add in liters or pass '0' to use existing amount
|
|
435
|
-
irsdk_PitCommand_LF, // Change the left front tire, optionally specifying the pressure in KPa or pass '0' to use existing pressure
|
|
436
|
-
irsdk_PitCommand_RF, // right front
|
|
437
|
-
irsdk_PitCommand_LR, // left rear
|
|
438
|
-
irsdk_PitCommand_RR, // right rear
|
|
439
|
-
irsdk_PitCommand_ClearTires, // Clear tire pit checkboxes
|
|
440
|
-
irsdk_PitCommand_FR, // Request a fast repair
|
|
441
|
-
irsdk_PitCommand_ClearWS, // Uncheck Clean the winshield checkbox
|
|
442
|
-
irsdk_PitCommand_ClearFR, // Uncheck request a fast repair
|
|
443
|
-
irsdk_PitCommand_ClearFuel, // Uncheck add fuel
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
enum irsdk_TelemCommandMode // You can call this any time, but telemtry only records when driver is in there car
|
|
447
|
-
{
|
|
448
|
-
irsdk_TelemCommand_Stop = 0, // Turn telemetry recording off
|
|
449
|
-
irsdk_TelemCommand_Start, // Turn telemetry recording on
|
|
450
|
-
irsdk_TelemCommand_Restart, // Write current file to disk and start a new one
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
enum irsdk_RpyStateMode
|
|
454
|
-
{
|
|
455
|
-
irsdk_RpyState_EraseTape = 0, // clear any data in the replay tape
|
|
456
|
-
irsdk_RpyState_Last // unused place holder
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
enum irsdk_ReloadTexturesMode
|
|
460
|
-
{
|
|
461
|
-
irsdk_ReloadTextures_All = 0, // reload all textuers
|
|
462
|
-
irsdk_ReloadTextures_CarIdx // reload only textures for the specific carIdx
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
// Search replay tape for events
|
|
466
|
-
enum irsdk_RpySrchMode
|
|
467
|
-
{
|
|
468
|
-
irsdk_RpySrch_ToStart = 0,
|
|
469
|
-
irsdk_RpySrch_ToEnd,
|
|
470
|
-
irsdk_RpySrch_PrevSession,
|
|
471
|
-
irsdk_RpySrch_NextSession,
|
|
472
|
-
irsdk_RpySrch_PrevLap,
|
|
473
|
-
irsdk_RpySrch_NextLap,
|
|
474
|
-
irsdk_RpySrch_PrevFrame,
|
|
475
|
-
irsdk_RpySrch_NextFrame,
|
|
476
|
-
irsdk_RpySrch_PrevIncident,
|
|
477
|
-
irsdk_RpySrch_NextIncident,
|
|
478
|
-
irsdk_RpySrch_Last // unused placeholder
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
enum irsdk_RpyPosMode
|
|
482
|
-
{
|
|
483
|
-
irsdk_RpyPos_Begin = 0,
|
|
484
|
-
irsdk_RpyPos_Current,
|
|
485
|
-
irsdk_RpyPos_End,
|
|
486
|
-
irsdk_RpyPos_Last // unused placeholder
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
enum irsdk_FFBCommandMode // You can call this any time
|
|
490
|
-
{
|
|
491
|
-
irsdk_FFBCommand_MaxForce = 0, // Set the maximum force when mapping steering torque force to direct input units (float in Nm)
|
|
492
|
-
irsdk_FFBCommand_Last // unused placeholder
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
// irsdk_BroadcastCamSwitchPos or irsdk_BroadcastCamSwitchNum camera focus defines
|
|
496
|
-
// pass these in for the first parameter to select the 'focus at' types in the camera system.
|
|
497
|
-
enum irsdk_csMode
|
|
498
|
-
{
|
|
499
|
-
irsdk_csFocusAtIncident = -3,
|
|
500
|
-
irsdk_csFocusAtLeader = -2,
|
|
501
|
-
irsdk_csFocusAtExiting = -1,
|
|
502
|
-
// ctFocusAtDriver + car number...
|
|
503
|
-
irsdk_csFocusAtDriver = 0
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
enum irsdk_VideoCaptureMode
|
|
507
|
-
{
|
|
508
|
-
irsdk_VideoCapture_TriggerScreenShot = 0, // save a screenshot to disk
|
|
509
|
-
irsdk_VideoCaptuer_StartVideoCapture, // start capturing video
|
|
510
|
-
irsdk_VideoCaptuer_EndVideoCapture, // stop capturing video
|
|
511
|
-
irsdk_VideoCaptuer_ToggleVideoCapture, // toggle video capture on/off
|
|
512
|
-
irsdk_VideoCaptuer_ShowVideoTimer, // show video timer in upper left corner of display
|
|
513
|
-
irsdk_VideoCaptuer_HideVideoTimer, // hide video timer
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
//send a remote controll message to the sim
|
|
517
|
-
// var1, var2, and var3 are all 16 bits signed
|
|
518
|
-
void irsdk_broadcastMsg(irsdk_BroadcastMsg msg, int var1, int var2, int var3);
|
|
519
|
-
// var2 can be a full 32 bits
|
|
520
|
-
void irsdk_broadcastMsg(irsdk_BroadcastMsg msg, int var1, int var2);
|
|
521
|
-
// var2 can be a full 32 bit float
|
|
522
|
-
void irsdk_broadcastMsg(irsdk_BroadcastMsg msg, int var1, float var2);
|
|
523
|
-
|
|
524
|
-
// add a leading zero (or zeros) to a car number
|
|
525
|
-
// to encode car #001 call padCarNum(1,2)
|
|
526
|
-
int irsdk_padCarNum(int num, int zero);
|
|
527
|
-
|
|
528
|
-
#endif //IRSDK_DEFINES_H
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2013, iRacing.com Motorsport Simulations, LLC.
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
|
11
|
+
documentation and/or other materials provided with the distribution.
|
|
12
|
+
* Neither the name of iRacing.com Motorsport Simulations nor the
|
|
13
|
+
names of its contributors may be used to endorse or promote products
|
|
14
|
+
derived from this software without specific prior written permission.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
17
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
18
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
20
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
22
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
23
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#ifndef IRSDK_DEFINES_H
|
|
29
|
+
#define IRSDK_DEFINES_H
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
The IRSDK is a simple api that lets clients access telemetry data from the
|
|
33
|
+
iRacing simulator. It is broken down into several parts:
|
|
34
|
+
|
|
35
|
+
- Live data
|
|
36
|
+
Live data is output from the sim into a shared memory mapped file. Any
|
|
37
|
+
application can open this memory mapped file and read the telemetry data
|
|
38
|
+
out. The format of this data was laid out in such a way that it should be
|
|
39
|
+
possible to access from any language that can open a windows memory mapped
|
|
40
|
+
file, without needing an external api.
|
|
41
|
+
|
|
42
|
+
There are two different types of data that the telemetry outputs,
|
|
43
|
+
sessionInfo and variables:
|
|
44
|
+
|
|
45
|
+
Session info is for data that only needs to be updated every once in a
|
|
46
|
+
while. This data is output as a YAML formatted string.
|
|
47
|
+
|
|
48
|
+
Variables, on the other hand, are output at a rate of 60 times a second.
|
|
49
|
+
The varHeader struct defines each variable that the sim will output, while
|
|
50
|
+
the varData struct gives details about the current line buffer that the vars
|
|
51
|
+
are being written into. Each variable is packed into a binary array with
|
|
52
|
+
an offset and length stored in the varHeader. The number of variables
|
|
53
|
+
available can change depending on the car or session loaded. But once the
|
|
54
|
+
sim is running the variable list is locked down and will not change during a
|
|
55
|
+
session.
|
|
56
|
+
|
|
57
|
+
The sim writes a new line of variables every 16 ms, and then signals any
|
|
58
|
+
listeners in order to wake them up to read the data. Because the sim has no
|
|
59
|
+
way of knowing when a listener is done reading the data, we triple buffer
|
|
60
|
+
it in order to give all the clients enough time to read the data out. This
|
|
61
|
+
gives you a minimum of 16 ms to read the data out and process it. So it is
|
|
62
|
+
best to copy the data out before processing it. You can use the function
|
|
63
|
+
irsdk_waitForDataReady() to both wait for new data and copy the data to a
|
|
64
|
+
local buffer.
|
|
65
|
+
|
|
66
|
+
- Logged data
|
|
67
|
+
Detailed information about the local drivers car can be logged to disk in
|
|
68
|
+
the form of an ibt binary file. This logging is enabled in the sim by
|
|
69
|
+
typing alt-L at any time. The ibt file format directly mirrors the format
|
|
70
|
+
of the live data.
|
|
71
|
+
|
|
72
|
+
It is stored as an irsdk_header followed immediately by an irsdk_diskSubHeader.
|
|
73
|
+
After that the offsets in the irsdk_header point to the sessionInfo string,
|
|
74
|
+
the varHeader, and the varBuffer.
|
|
75
|
+
|
|
76
|
+
- Remote Conrol
|
|
77
|
+
You can control the camera selections and playback of a replay tape, from
|
|
78
|
+
any external application by sending a windows message with the
|
|
79
|
+
irsdk_broadcastMsg() function.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
// Constant Definitions
|
|
83
|
+
|
|
84
|
+
#include <tchar.h>
|
|
85
|
+
|
|
86
|
+
static const _TCHAR IRSDK_DATAVALIDEVENTNAME[] = _T("Local\\IRSDKDataValidEvent");
|
|
87
|
+
static const _TCHAR IRSDK_MEMMAPFILENAME[] = _T("Local\\IRSDKMemMapFileName");
|
|
88
|
+
static const _TCHAR IRSDK_BROADCASTMSGNAME[] = _T("IRSDK_BROADCASTMSG");
|
|
89
|
+
|
|
90
|
+
static const int IRSDK_MAX_BUFS = 4;
|
|
91
|
+
static const int IRSDK_MAX_STRING = 32;
|
|
92
|
+
// descriptions can be longer than max_string!
|
|
93
|
+
static const int IRSDK_MAX_DESC = 64;
|
|
94
|
+
|
|
95
|
+
// define markers for unlimited session lap and time
|
|
96
|
+
static const int IRSDK_UNLIMITED_LAPS = 32767;
|
|
97
|
+
static const float IRSDK_UNLIMITED_TIME = 604800.0f;
|
|
98
|
+
|
|
99
|
+
// latest version of our telemetry headers
|
|
100
|
+
static const int IRSDK_VER = 2;
|
|
101
|
+
|
|
102
|
+
enum irsdk_StatusField
|
|
103
|
+
{
|
|
104
|
+
irsdk_stConnected = 1
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
enum irsdk_VarType
|
|
108
|
+
{
|
|
109
|
+
// 1 byte
|
|
110
|
+
irsdk_char = 0,
|
|
111
|
+
irsdk_bool,
|
|
112
|
+
|
|
113
|
+
// 4 bytes
|
|
114
|
+
irsdk_int,
|
|
115
|
+
irsdk_bitField,
|
|
116
|
+
irsdk_float,
|
|
117
|
+
|
|
118
|
+
// 8 bytes
|
|
119
|
+
irsdk_double,
|
|
120
|
+
|
|
121
|
+
//index, don't use
|
|
122
|
+
irsdk_ETCount
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
static const int irsdk_VarTypeBytes[irsdk_ETCount] =
|
|
126
|
+
{
|
|
127
|
+
1, // irsdk_char
|
|
128
|
+
1, // irsdk_bool
|
|
129
|
+
|
|
130
|
+
4, // irsdk_int
|
|
131
|
+
4, // irsdk_bitField
|
|
132
|
+
4, // irsdk_float
|
|
133
|
+
|
|
134
|
+
8 // irsdk_double
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// bit fields
|
|
138
|
+
enum irsdk_EngineWarnings
|
|
139
|
+
{
|
|
140
|
+
irsdk_waterTempWarning = 0x01,
|
|
141
|
+
irsdk_fuelPressureWarning = 0x02,
|
|
142
|
+
irsdk_oilPressureWarning = 0x04,
|
|
143
|
+
irsdk_engineStalled = 0x08,
|
|
144
|
+
irsdk_pitSpeedLimiter = 0x10,
|
|
145
|
+
irsdk_revLimiterActive = 0x20,
|
|
146
|
+
irsdk_oilTempWarning = 0x40,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// global flags
|
|
150
|
+
enum irsdk_Flags
|
|
151
|
+
{
|
|
152
|
+
// global flags
|
|
153
|
+
irsdk_checkered = 0x00000001,
|
|
154
|
+
irsdk_white = 0x00000002,
|
|
155
|
+
irsdk_green = 0x00000004,
|
|
156
|
+
irsdk_yellow = 0x00000008,
|
|
157
|
+
irsdk_red = 0x00000010,
|
|
158
|
+
irsdk_blue = 0x00000020,
|
|
159
|
+
irsdk_debris = 0x00000040,
|
|
160
|
+
irsdk_crossed = 0x00000080,
|
|
161
|
+
irsdk_yellowWaving = 0x00000100,
|
|
162
|
+
irsdk_oneLapToGreen = 0x00000200,
|
|
163
|
+
irsdk_greenHeld = 0x00000400,
|
|
164
|
+
irsdk_tenToGo = 0x00000800,
|
|
165
|
+
irsdk_fiveToGo = 0x00001000,
|
|
166
|
+
irsdk_randomWaving = 0x00002000,
|
|
167
|
+
irsdk_caution = 0x00004000,
|
|
168
|
+
irsdk_cautionWaving = 0x00008000,
|
|
169
|
+
|
|
170
|
+
// drivers black flags
|
|
171
|
+
irsdk_black = 0x00010000,
|
|
172
|
+
irsdk_disqualify = 0x00020000,
|
|
173
|
+
irsdk_servicible = 0x00040000, // car is allowed service (not a flag)
|
|
174
|
+
irsdk_furled = 0x00080000,
|
|
175
|
+
irsdk_repair = 0x00100000,
|
|
176
|
+
|
|
177
|
+
// start lights
|
|
178
|
+
irsdk_startHidden = 0x10000000,
|
|
179
|
+
irsdk_startReady = 0x20000000,
|
|
180
|
+
irsdk_startSet = 0x40000000,
|
|
181
|
+
irsdk_startGo = 0x80000000,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
// status
|
|
186
|
+
enum irsdk_TrkLoc
|
|
187
|
+
{
|
|
188
|
+
irsdk_NotInWorld = -1,
|
|
189
|
+
irsdk_OffTrack,
|
|
190
|
+
irsdk_InPitStall,
|
|
191
|
+
irsdk_AproachingPits,
|
|
192
|
+
irsdk_OnTrack
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
enum irsdk_TrkSurf
|
|
196
|
+
{
|
|
197
|
+
irsdk_SurfaceNotInWorld = -1,
|
|
198
|
+
irsdk_UndefinedMaterial = 0,
|
|
199
|
+
|
|
200
|
+
irsdk_Asphalt1Material,
|
|
201
|
+
irsdk_Asphalt2Material,
|
|
202
|
+
irsdk_Asphalt3Material,
|
|
203
|
+
irsdk_Asphalt4Material,
|
|
204
|
+
irsdk_Concrete1Material,
|
|
205
|
+
irsdk_Concrete2Material,
|
|
206
|
+
irsdk_RacingDirt1Material,
|
|
207
|
+
irsdk_RacingDirt2Material,
|
|
208
|
+
irsdk_Paint1Material,
|
|
209
|
+
irsdk_Paint2Material,
|
|
210
|
+
irsdk_Rumble1Material,
|
|
211
|
+
irsdk_Rumble2Material,
|
|
212
|
+
irsdk_Rumble3Material,
|
|
213
|
+
irsdk_Rumble4Material,
|
|
214
|
+
|
|
215
|
+
irsdk_Grass1Material,
|
|
216
|
+
irsdk_Grass2Material,
|
|
217
|
+
irsdk_Grass3Material,
|
|
218
|
+
irsdk_Grass4Material,
|
|
219
|
+
irsdk_Dirt1Material,
|
|
220
|
+
irsdk_Dirt2Material,
|
|
221
|
+
irsdk_Dirt3Material,
|
|
222
|
+
irsdk_Dirt4Material,
|
|
223
|
+
irsdk_SandMaterial,
|
|
224
|
+
irsdk_Gravel1Material,
|
|
225
|
+
irsdk_Gravel2Material,
|
|
226
|
+
irsdk_GrasscreteMaterial,
|
|
227
|
+
irsdk_AstroturfMaterial,
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
enum irsdk_SessionState
|
|
231
|
+
{
|
|
232
|
+
irsdk_StateInvalid,
|
|
233
|
+
irsdk_StateGetInCar,
|
|
234
|
+
irsdk_StateWarmup,
|
|
235
|
+
irsdk_StateParadeLaps,
|
|
236
|
+
irsdk_StateRacing,
|
|
237
|
+
irsdk_StateCheckered,
|
|
238
|
+
irsdk_StateCoolDown
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
enum irsdk_CarLeftRight
|
|
242
|
+
{
|
|
243
|
+
irsdk_LROff,
|
|
244
|
+
irsdk_LRClear, // no cars around us.
|
|
245
|
+
irsdk_LRCarLeft, // there is a car to our left.
|
|
246
|
+
irsdk_LRCarRight, // there is a car to our right.
|
|
247
|
+
irsdk_LRCarLeftRight, // there are cars on each side.
|
|
248
|
+
irsdk_LR2CarsLeft, // there are two cars to our left.
|
|
249
|
+
irsdk_LR2CarsRight // there are two cars to our right.
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
enum irsdk_CameraState
|
|
253
|
+
{
|
|
254
|
+
irsdk_IsSessionScreen = 0x0001, // the camera tool can only be activated if viewing the session screen (out of car)
|
|
255
|
+
irsdk_IsScenicActive = 0x0002, // the scenic camera is active (no focus car)
|
|
256
|
+
|
|
257
|
+
//these can be changed with a broadcast message
|
|
258
|
+
irsdk_CamToolActive = 0x0004,
|
|
259
|
+
irsdk_UIHidden = 0x0008,
|
|
260
|
+
irsdk_UseAutoShotSelection = 0x0010,
|
|
261
|
+
irsdk_UseTemporaryEdits = 0x0020,
|
|
262
|
+
irsdk_UseKeyAcceleration = 0x0040,
|
|
263
|
+
irsdk_UseKey10xAcceleration = 0x0080,
|
|
264
|
+
irsdk_UseMouseAimMode = 0x0100
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
enum irsdk_PitSvFlags
|
|
268
|
+
{
|
|
269
|
+
irsdk_LFTireChange = 0x0001,
|
|
270
|
+
irsdk_RFTireChange = 0x0002,
|
|
271
|
+
irsdk_LRTireChange = 0x0004,
|
|
272
|
+
irsdk_RRTireChange = 0x0008,
|
|
273
|
+
|
|
274
|
+
irsdk_FuelFill = 0x0010,
|
|
275
|
+
irsdk_WindshieldTearoff = 0x0020,
|
|
276
|
+
irsdk_FastRepair = 0x0040
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
enum irsdk_PitSvStatus
|
|
280
|
+
{
|
|
281
|
+
// status
|
|
282
|
+
irsdk_PitSvNone = 0,
|
|
283
|
+
irsdk_PitSvInProgress,
|
|
284
|
+
irsdk_PitSvComplete,
|
|
285
|
+
|
|
286
|
+
// errors
|
|
287
|
+
irsdk_PitSvTooFarLeft = 100,
|
|
288
|
+
irsdk_PitSvTooFarRight,
|
|
289
|
+
irsdk_PitSvTooFarForward,
|
|
290
|
+
irsdk_PitSvTooFarBack,
|
|
291
|
+
irsdk_PitSvBadAngle,
|
|
292
|
+
irsdk_PitSvCantFixThat,
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
enum irsdk_PaceMode
|
|
296
|
+
{
|
|
297
|
+
irsdk_PaceModeSingleFileStart = 0,
|
|
298
|
+
irsdk_PaceModeDoubleFileStart,
|
|
299
|
+
irsdk_PaceModeSingleFileRestart,
|
|
300
|
+
irsdk_PaceModeDoubleFileRestart,
|
|
301
|
+
irsdk_PaceModeNotPacing,
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
enum irsdk_PaceFlags
|
|
305
|
+
{
|
|
306
|
+
irsdk_PaceFlagsEndOfLine = 0x01,
|
|
307
|
+
irsdk_PaceFlagsFreePass = 0x02,
|
|
308
|
+
irsdk_PaceFlagsWavedAround = 0x04,
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
//----
|
|
312
|
+
//
|
|
313
|
+
|
|
314
|
+
struct irsdk_varHeader
|
|
315
|
+
{
|
|
316
|
+
int type; // irsdk_VarType
|
|
317
|
+
int offset; // offset fron start of buffer row
|
|
318
|
+
int count; // number of entrys (array)
|
|
319
|
+
// so length in bytes would be irsdk_VarTypeBytes[type] * count
|
|
320
|
+
bool countAsTime;
|
|
321
|
+
char pad[3]; // (16 byte align)
|
|
322
|
+
|
|
323
|
+
char name[IRSDK_MAX_STRING];
|
|
324
|
+
char desc[IRSDK_MAX_DESC];
|
|
325
|
+
char unit[IRSDK_MAX_STRING]; // something like "kg/m^2"
|
|
326
|
+
|
|
327
|
+
void clear()
|
|
328
|
+
{
|
|
329
|
+
type = 0;
|
|
330
|
+
offset = 0;
|
|
331
|
+
count = 0;
|
|
332
|
+
countAsTime = false;
|
|
333
|
+
memset(name, 0, sizeof(name));
|
|
334
|
+
memset(desc, 0, sizeof(name));
|
|
335
|
+
memset(unit, 0, sizeof(name));
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
struct irsdk_varBuf
|
|
340
|
+
{
|
|
341
|
+
int tickCount; // used to detect changes in data
|
|
342
|
+
int bufOffset; // offset from header
|
|
343
|
+
int pad[2]; // (16 byte align)
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
struct irsdk_header
|
|
347
|
+
{
|
|
348
|
+
int ver; // this api header version, see IRSDK_VER
|
|
349
|
+
int status; // bitfield using irsdk_StatusField
|
|
350
|
+
int tickRate; // ticks per second (60 or 360 etc)
|
|
351
|
+
|
|
352
|
+
// session information, updated periodicaly
|
|
353
|
+
int sessionInfoUpdate; // Incremented when session info changes
|
|
354
|
+
int sessionInfoLen; // Length in bytes of session info string
|
|
355
|
+
int sessionInfoOffset; // Session info, encoded in YAML format
|
|
356
|
+
|
|
357
|
+
// State data, output at tickRate
|
|
358
|
+
|
|
359
|
+
int numVars; // length of arra pointed to by varHeaderOffset
|
|
360
|
+
int varHeaderOffset; // offset to irsdk_varHeader[numVars] array, Describes the variables received in varBuf
|
|
361
|
+
|
|
362
|
+
int numBuf; // <= IRSDK_MAX_BUFS (3 for now)
|
|
363
|
+
int bufLen; // length in bytes for one line
|
|
364
|
+
int pad1[2]; // (16 byte align)
|
|
365
|
+
irsdk_varBuf varBuf[IRSDK_MAX_BUFS]; // buffers of data being written to
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// sub header used when writing telemetry to disk
|
|
369
|
+
struct irsdk_diskSubHeader
|
|
370
|
+
{
|
|
371
|
+
time_t sessionStartDate;
|
|
372
|
+
double sessionStartTime;
|
|
373
|
+
double sessionEndTime;
|
|
374
|
+
int sessionLapCount;
|
|
375
|
+
int sessionRecordCount;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
//----
|
|
379
|
+
// Client function definitions
|
|
380
|
+
|
|
381
|
+
bool irsdk_startup();
|
|
382
|
+
void irsdk_shutdown();
|
|
383
|
+
|
|
384
|
+
bool irsdk_getNewData(char *data);
|
|
385
|
+
bool irsdk_waitForDataReady(int timeOut, char *data);
|
|
386
|
+
bool irsdk_isConnected();
|
|
387
|
+
|
|
388
|
+
const irsdk_header *irsdk_getHeader();
|
|
389
|
+
const char *irsdk_getData(int index);
|
|
390
|
+
const char *irsdk_getSessionInfoStr();
|
|
391
|
+
int irsdk_getSessionInfoStrUpdate(); // incrementing index that indicates new session info string
|
|
392
|
+
|
|
393
|
+
const irsdk_varHeader *irsdk_getVarHeaderPtr();
|
|
394
|
+
const irsdk_varHeader *irsdk_getVarHeaderEntry(int index);
|
|
395
|
+
|
|
396
|
+
int irsdk_varNameToIndex(const char *name);
|
|
397
|
+
int irsdk_varNameToOffset(const char *name);
|
|
398
|
+
|
|
399
|
+
//----
|
|
400
|
+
// Remote controll the sim by sending these windows messages
|
|
401
|
+
// camera and replay commands only work when you are out of your car,
|
|
402
|
+
// pit commands only work when in your car
|
|
403
|
+
enum irsdk_BroadcastMsg
|
|
404
|
+
{
|
|
405
|
+
irsdk_BroadcastCamSwitchPos = 0, // car position, group, camera
|
|
406
|
+
irsdk_BroadcastCamSwitchNum, // driver #, group, camera
|
|
407
|
+
irsdk_BroadcastCamSetState, // irsdk_CameraState, unused, unused
|
|
408
|
+
irsdk_BroadcastReplaySetPlaySpeed, // speed, slowMotion, unused
|
|
409
|
+
irskd_BroadcastReplaySetPlayPosition, // irsdk_RpyPosMode, Frame Number (high, low)
|
|
410
|
+
irsdk_BroadcastReplaySearch, // irsdk_RpySrchMode, unused, unused
|
|
411
|
+
irsdk_BroadcastReplaySetState, // irsdk_RpyStateMode, unused, unused
|
|
412
|
+
irsdk_BroadcastReloadTextures, // irsdk_ReloadTexturesMode, carIdx, unused
|
|
413
|
+
irsdk_BroadcastChatComand, // irsdk_ChatCommandMode, subCommand, unused
|
|
414
|
+
irsdk_BroadcastPitCommand, // irsdk_PitCommandMode, parameter
|
|
415
|
+
irsdk_BroadcastTelemCommand, // irsdk_TelemCommandMode, unused, unused
|
|
416
|
+
irsdk_BroadcastFFBCommand, // irsdk_FFBCommandMode, value (float, high, low)
|
|
417
|
+
irsdk_BroadcastReplaySearchSessionTime, // sessionNum, sessionTimeMS (high, low)
|
|
418
|
+
irsdk_BroadcastVideoCapture, // irsdk_VideoCaptureMode, unused, unused
|
|
419
|
+
irsdk_BroadcastLast // unused placeholder
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
enum irsdk_ChatCommandMode
|
|
423
|
+
{
|
|
424
|
+
irsdk_ChatCommand_Macro = 0, // pass in a number from 1-15 representing the chat macro to launch
|
|
425
|
+
irsdk_ChatCommand_BeginChat, // Open up a new chat window
|
|
426
|
+
irsdk_ChatCommand_Reply, // Reply to last private chat
|
|
427
|
+
irsdk_ChatCommand_Cancel // Close chat window
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
enum irsdk_PitCommandMode // this only works when the driver is in the car
|
|
431
|
+
{
|
|
432
|
+
irsdk_PitCommand_Clear = 0, // Clear all pit checkboxes
|
|
433
|
+
irsdk_PitCommand_WS, // Clean the winshield, using one tear off
|
|
434
|
+
irsdk_PitCommand_Fuel, // Add fuel, optionally specify the amount to add in liters or pass '0' to use existing amount
|
|
435
|
+
irsdk_PitCommand_LF, // Change the left front tire, optionally specifying the pressure in KPa or pass '0' to use existing pressure
|
|
436
|
+
irsdk_PitCommand_RF, // right front
|
|
437
|
+
irsdk_PitCommand_LR, // left rear
|
|
438
|
+
irsdk_PitCommand_RR, // right rear
|
|
439
|
+
irsdk_PitCommand_ClearTires, // Clear tire pit checkboxes
|
|
440
|
+
irsdk_PitCommand_FR, // Request a fast repair
|
|
441
|
+
irsdk_PitCommand_ClearWS, // Uncheck Clean the winshield checkbox
|
|
442
|
+
irsdk_PitCommand_ClearFR, // Uncheck request a fast repair
|
|
443
|
+
irsdk_PitCommand_ClearFuel, // Uncheck add fuel
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
enum irsdk_TelemCommandMode // You can call this any time, but telemtry only records when driver is in there car
|
|
447
|
+
{
|
|
448
|
+
irsdk_TelemCommand_Stop = 0, // Turn telemetry recording off
|
|
449
|
+
irsdk_TelemCommand_Start, // Turn telemetry recording on
|
|
450
|
+
irsdk_TelemCommand_Restart, // Write current file to disk and start a new one
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
enum irsdk_RpyStateMode
|
|
454
|
+
{
|
|
455
|
+
irsdk_RpyState_EraseTape = 0, // clear any data in the replay tape
|
|
456
|
+
irsdk_RpyState_Last // unused place holder
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
enum irsdk_ReloadTexturesMode
|
|
460
|
+
{
|
|
461
|
+
irsdk_ReloadTextures_All = 0, // reload all textuers
|
|
462
|
+
irsdk_ReloadTextures_CarIdx // reload only textures for the specific carIdx
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
// Search replay tape for events
|
|
466
|
+
enum irsdk_RpySrchMode
|
|
467
|
+
{
|
|
468
|
+
irsdk_RpySrch_ToStart = 0,
|
|
469
|
+
irsdk_RpySrch_ToEnd,
|
|
470
|
+
irsdk_RpySrch_PrevSession,
|
|
471
|
+
irsdk_RpySrch_NextSession,
|
|
472
|
+
irsdk_RpySrch_PrevLap,
|
|
473
|
+
irsdk_RpySrch_NextLap,
|
|
474
|
+
irsdk_RpySrch_PrevFrame,
|
|
475
|
+
irsdk_RpySrch_NextFrame,
|
|
476
|
+
irsdk_RpySrch_PrevIncident,
|
|
477
|
+
irsdk_RpySrch_NextIncident,
|
|
478
|
+
irsdk_RpySrch_Last // unused placeholder
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
enum irsdk_RpyPosMode
|
|
482
|
+
{
|
|
483
|
+
irsdk_RpyPos_Begin = 0,
|
|
484
|
+
irsdk_RpyPos_Current,
|
|
485
|
+
irsdk_RpyPos_End,
|
|
486
|
+
irsdk_RpyPos_Last // unused placeholder
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
enum irsdk_FFBCommandMode // You can call this any time
|
|
490
|
+
{
|
|
491
|
+
irsdk_FFBCommand_MaxForce = 0, // Set the maximum force when mapping steering torque force to direct input units (float in Nm)
|
|
492
|
+
irsdk_FFBCommand_Last // unused placeholder
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// irsdk_BroadcastCamSwitchPos or irsdk_BroadcastCamSwitchNum camera focus defines
|
|
496
|
+
// pass these in for the first parameter to select the 'focus at' types in the camera system.
|
|
497
|
+
enum irsdk_csMode
|
|
498
|
+
{
|
|
499
|
+
irsdk_csFocusAtIncident = -3,
|
|
500
|
+
irsdk_csFocusAtLeader = -2,
|
|
501
|
+
irsdk_csFocusAtExiting = -1,
|
|
502
|
+
// ctFocusAtDriver + car number...
|
|
503
|
+
irsdk_csFocusAtDriver = 0
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
enum irsdk_VideoCaptureMode
|
|
507
|
+
{
|
|
508
|
+
irsdk_VideoCapture_TriggerScreenShot = 0, // save a screenshot to disk
|
|
509
|
+
irsdk_VideoCaptuer_StartVideoCapture, // start capturing video
|
|
510
|
+
irsdk_VideoCaptuer_EndVideoCapture, // stop capturing video
|
|
511
|
+
irsdk_VideoCaptuer_ToggleVideoCapture, // toggle video capture on/off
|
|
512
|
+
irsdk_VideoCaptuer_ShowVideoTimer, // show video timer in upper left corner of display
|
|
513
|
+
irsdk_VideoCaptuer_HideVideoTimer, // hide video timer
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
//send a remote controll message to the sim
|
|
517
|
+
// var1, var2, and var3 are all 16 bits signed
|
|
518
|
+
void irsdk_broadcastMsg(irsdk_BroadcastMsg msg, int var1, int var2, int var3);
|
|
519
|
+
// var2 can be a full 32 bits
|
|
520
|
+
void irsdk_broadcastMsg(irsdk_BroadcastMsg msg, int var1, int var2);
|
|
521
|
+
// var2 can be a full 32 bit float
|
|
522
|
+
void irsdk_broadcastMsg(irsdk_BroadcastMsg msg, int var1, float var2);
|
|
523
|
+
|
|
524
|
+
// add a leading zero (or zeros) to a car number
|
|
525
|
+
// to encode car #001 call padCarNum(1,2)
|
|
526
|
+
int irsdk_padCarNum(int num, int zero);
|
|
527
|
+
|
|
528
|
+
#endif //IRSDK_DEFINES_H
|