@irsdk-node/native 3.0.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.
Files changed (56) hide show
  1. package/README.md +46 -0
  2. package/binding.gyp +19 -0
  3. package/build/Debug/irsdk_node.exp +0 -0
  4. package/build/Debug/irsdk_node.lib +0 -0
  5. package/build/Debug/irsdk_node.node +0 -0
  6. package/build/Debug/irsdk_node.pdb +0 -0
  7. package/build/Debug/obj/irsdk_node/irsdk_node.node.recipe +11 -0
  8. package/build/Debug/obj/irsdk_node/irsdk_node.tlog/CL.command.1.tlog +0 -0
  9. package/build/Debug/obj/irsdk_node/irsdk_node.tlog/CL.read.1.tlog +0 -0
  10. package/build/Debug/obj/irsdk_node/irsdk_node.tlog/CL.write.1.tlog +0 -0
  11. package/build/Debug/obj/irsdk_node/irsdk_node.tlog/irsdk_node.lastbuildstate +2 -0
  12. package/build/Debug/obj/irsdk_node/irsdk_node.tlog/irsdk_node.write.1u.tlog +0 -0
  13. package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.command.1.tlog +0 -0
  14. package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.read.1.tlog +0 -0
  15. package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.write.1.tlog +0 -0
  16. package/build/Debug/obj/irsdk_node/lib/irsdk_utils.obj +0 -0
  17. package/build/Debug/obj/irsdk_node/lib/yaml_parser.obj +0 -0
  18. package/build/Debug/obj/irsdk_node/src/irsdk_node.obj +0 -0
  19. package/build/Debug/obj/irsdk_node/win_delay_load_hook.obj +0 -0
  20. package/build/Release/irsdk_node.exp +0 -0
  21. package/build/Release/irsdk_node.iobj +0 -0
  22. package/build/Release/irsdk_node.ipdb +0 -0
  23. package/build/Release/irsdk_node.lib +0 -0
  24. package/build/Release/irsdk_node.node +0 -0
  25. package/build/Release/irsdk_node.pdb +0 -0
  26. package/build/Release/obj/irsdk_node/irsdk_node.node.recipe +11 -0
  27. package/build/Release/obj/irsdk_node/irsdk_node.tlog/CL.command.1.tlog +0 -0
  28. package/build/Release/obj/irsdk_node/irsdk_node.tlog/CL.read.1.tlog +0 -0
  29. package/build/Release/obj/irsdk_node/irsdk_node.tlog/CL.write.1.tlog +0 -0
  30. package/build/Release/obj/irsdk_node/irsdk_node.tlog/irsdk_node.lastbuildstate +2 -0
  31. package/build/Release/obj/irsdk_node/irsdk_node.tlog/irsdk_node.write.1u.tlog +0 -0
  32. package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.command.1.tlog +0 -0
  33. package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.read.1.tlog +0 -0
  34. package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.write.1.tlog +0 -0
  35. package/build/Release/obj/irsdk_node/lib/irsdk_utils.obj +0 -0
  36. package/build/Release/obj/irsdk_node/lib/yaml_parser.obj +0 -0
  37. package/build/Release/obj/irsdk_node/src/irsdk_node.obj +0 -0
  38. package/build/Release/obj/irsdk_node/win_delay_load_hook.obj +0 -0
  39. package/build/binding.sln +19 -0
  40. package/build/config.gypi +88 -0
  41. package/build/irsdk_node.vcxproj +155 -0
  42. package/build/irsdk_node.vcxproj.filters +73 -0
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.js +8 -0
  45. package/lib/irsdk_client.cpp +495 -0
  46. package/lib/irsdk_client.h +139 -0
  47. package/lib/irsdk_defines.h +528 -0
  48. package/lib/irsdk_utils.cpp +377 -0
  49. package/lib/yaml_parser.cpp +176 -0
  50. package/lib/yaml_parser.h +34 -0
  51. package/package.json +52 -0
  52. package/scripts/generate-var-types.js +71 -0
  53. package/src/index.d.ts +117 -0
  54. package/src/index.js +5 -0
  55. package/src/irsdk_node.cc +375 -0
  56. package/src/irsdk_node.h +50 -0
@@ -0,0 +1,495 @@
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
+ #include <stdio.h>
29
+ #include <string.h>
30
+
31
+ #include <assert.h>
32
+ #include "irsdk_defines.h"
33
+ #include "yaml_parser.h"
34
+ #include "irsdk_client.h"
35
+
36
+ #pragma warning(disable:4996)
37
+
38
+ irsdkClient& irsdkClient::instance()
39
+ {
40
+ static irsdkClient INSTANCE;
41
+ return INSTANCE;
42
+ }
43
+
44
+ bool irsdkClient::waitForData(int timeoutMS)
45
+ {
46
+ // wait for start of session or new data
47
+ if(irsdk_waitForDataReady(timeoutMS, m_data) && irsdk_getHeader())
48
+ {
49
+ // if new connection, or data changed lenght then init
50
+ if(!m_data || m_nData != irsdk_getHeader()->bufLen)
51
+ {
52
+ // allocate memory to hold incoming data from sim
53
+ if(m_data) delete [] m_data;
54
+ m_nData = irsdk_getHeader()->bufLen;
55
+ m_data = new char[m_nData];
56
+
57
+ // indicate a new connection
58
+ m_statusID++;
59
+
60
+ // reset session info str status
61
+ m_lastSessionCt = -1;
62
+
63
+ // and try to fill in the data
64
+ if(irsdk_getNewData(m_data))
65
+ return true;
66
+ }
67
+ else if(m_data)
68
+ {
69
+ // else we are allready initialized, and data is ready for processing
70
+ return true;
71
+ }
72
+ }
73
+ else if(!isConnected())
74
+ {
75
+ // else session ended
76
+ if(m_data)
77
+ delete[] m_data;
78
+ m_data = NULL;
79
+
80
+ // reset session info str status
81
+ m_lastSessionCt = -1;
82
+ }
83
+
84
+ return false;
85
+ }
86
+
87
+ void irsdkClient::shutdown()
88
+ {
89
+ irsdk_shutdown();
90
+ if(m_data)
91
+ delete[] m_data;
92
+ m_data = NULL;
93
+
94
+ // reset session info str status
95
+ m_lastSessionCt = -1;
96
+ }
97
+
98
+ bool irsdkClient::isConnected()
99
+ {
100
+ return m_data != NULL && irsdk_isConnected();
101
+ }
102
+
103
+ int irsdkClient::getVarIdx(const char*name)
104
+ {
105
+ if(isConnected())
106
+ {
107
+ return irsdk_varNameToIndex(name);
108
+ }
109
+
110
+ return -1;
111
+ }
112
+
113
+ int /*irsdk_VarType*/ irsdkClient::getVarType(int idx)
114
+ {
115
+ if(isConnected())
116
+ {
117
+ const irsdk_varHeader *vh = irsdk_getVarHeaderEntry(idx);
118
+ if(vh)
119
+ {
120
+ return vh->type;
121
+ }
122
+ else
123
+ {
124
+ //invalid variable index
125
+ assert(false);
126
+ }
127
+ }
128
+
129
+ return irsdk_char;
130
+ }
131
+
132
+ int irsdkClient::getVarCount(int idx)
133
+ {
134
+ if(isConnected())
135
+ {
136
+ const irsdk_varHeader *vh = irsdk_getVarHeaderEntry(idx);
137
+ if(vh)
138
+ {
139
+ return vh->count;
140
+ }
141
+ else
142
+ {
143
+ //invalid variable index
144
+ assert(false);
145
+ }
146
+ }
147
+
148
+ return 0;
149
+ }
150
+
151
+ bool irsdkClient::getVarBool(int idx, int entry)
152
+ {
153
+ if(isConnected())
154
+ {
155
+ const irsdk_varHeader *vh = irsdk_getVarHeaderEntry(idx);
156
+ if(vh)
157
+ {
158
+ if(entry >= 0 && entry < vh->count)
159
+ {
160
+ const char * data = m_data + vh->offset;
161
+ switch(vh->type)
162
+ {
163
+ // 1 byte
164
+ case irsdk_char:
165
+ case irsdk_bool:
166
+ return (((const char*)data)[entry]) != 0;
167
+ break;
168
+
169
+ // 4 bytes
170
+ case irsdk_int:
171
+ case irsdk_bitField:
172
+ return (((const int*)data)[entry]) != 0;
173
+ break;
174
+
175
+ // test float/double for greater than 1.0 so that
176
+ // we have a chance of this being usefull
177
+ // technically there is no right conversion...
178
+ case irsdk_float:
179
+ return (((const float*)data)[entry]) >= 1.0f;
180
+ break;
181
+
182
+ // 8 bytes
183
+ case irsdk_double:
184
+ return (((const double*)data)[entry]) >= 1.0;
185
+ break;
186
+ }
187
+ }
188
+ else
189
+ {
190
+ // invalid offset
191
+ assert(false);
192
+ }
193
+ }
194
+ else
195
+ {
196
+ //invalid variable index
197
+ assert(false);
198
+ }
199
+ }
200
+
201
+ return false;
202
+ }
203
+
204
+ int irsdkClient::getVarInt(int idx, int entry)
205
+ {
206
+ if(isConnected())
207
+ {
208
+ const irsdk_varHeader *vh = irsdk_getVarHeaderEntry(idx);
209
+ if(vh)
210
+ {
211
+ if(entry >= 0 && entry < vh->count)
212
+ {
213
+ const char * data = m_data + vh->offset;
214
+ switch(vh->type)
215
+ {
216
+ // 1 byte
217
+ case irsdk_char:
218
+ case irsdk_bool:
219
+ return (int)(((const char*)data)[entry]);
220
+ break;
221
+
222
+ // 4 bytes
223
+ case irsdk_int:
224
+ case irsdk_bitField:
225
+ return (int)(((const int*)data)[entry]);
226
+ break;
227
+
228
+ case irsdk_float:
229
+ return (int)(((const float*)data)[entry]);
230
+ break;
231
+
232
+ // 8 bytes
233
+ case irsdk_double:
234
+ return (int)(((const double*)data)[entry]);
235
+ break;
236
+ }
237
+ }
238
+ else
239
+ {
240
+ // invalid offset
241
+ assert(false);
242
+ }
243
+ }
244
+ else
245
+ {
246
+ //invalid variable index
247
+ assert(false);
248
+ }
249
+ }
250
+
251
+ return 0;
252
+ }
253
+
254
+ float irsdkClient::getVarFloat(int idx, int entry)
255
+ {
256
+ if(isConnected())
257
+ {
258
+ const irsdk_varHeader *vh = irsdk_getVarHeaderEntry(idx);
259
+ if(vh)
260
+ {
261
+ if(entry >= 0 && entry < vh->count)
262
+ {
263
+ const char * data = m_data + vh->offset;
264
+ switch(vh->type)
265
+ {
266
+ // 1 byte
267
+ case irsdk_char:
268
+ case irsdk_bool:
269
+ return (float)(((const char*)data)[entry]);
270
+ break;
271
+
272
+ // 4 bytes
273
+ case irsdk_int:
274
+ case irsdk_bitField:
275
+ return (float)(((const int*)data)[entry]);
276
+ break;
277
+
278
+ case irsdk_float:
279
+ return (float)(((const float*)data)[entry]);
280
+ break;
281
+
282
+ // 8 bytes
283
+ case irsdk_double:
284
+ return (float)(((const double*)data)[entry]);
285
+ break;
286
+ }
287
+ }
288
+ else
289
+ {
290
+ // invalid offset
291
+ assert(false);
292
+ }
293
+ }
294
+ else
295
+ {
296
+ //invalid variable index
297
+ assert(false);
298
+ }
299
+ }
300
+
301
+ return 0.0f;
302
+ }
303
+
304
+ double irsdkClient::getVarDouble(int idx, int entry)
305
+ {
306
+ if(isConnected())
307
+ {
308
+ const irsdk_varHeader *vh = irsdk_getVarHeaderEntry(idx);
309
+ if(vh)
310
+ {
311
+ if(entry >= 0 && entry < vh->count)
312
+ {
313
+ const char * data = m_data + vh->offset;
314
+ switch(vh->type)
315
+ {
316
+ // 1 byte
317
+ case irsdk_char:
318
+ case irsdk_bool:
319
+ return (double)(((const char*)data)[entry]);
320
+ break;
321
+
322
+ // 4 bytes
323
+ case irsdk_int:
324
+ case irsdk_bitField:
325
+ return (double)(((const int*)data)[entry]);
326
+ break;
327
+
328
+ case irsdk_float:
329
+ return (double)(((const float*)data)[entry]);
330
+ break;
331
+
332
+ // 8 bytes
333
+ case irsdk_double:
334
+ return (double)(((const double*)data)[entry]);
335
+ break;
336
+ }
337
+ }
338
+ else
339
+ {
340
+ // invalid offset
341
+ assert(false);
342
+ }
343
+ }
344
+ else
345
+ {
346
+ //invalid variable index
347
+ assert(false);
348
+ }
349
+ }
350
+
351
+ return 0.0;
352
+ }
353
+
354
+ //path is in the form of "DriverInfo:Drivers:CarIdx:{%d}UserName:"
355
+ int irsdkClient::getSessionStrVal(const char *path, char *val, int valLen)
356
+ {
357
+ if(isConnected() && path && val && valLen > 0)
358
+ {
359
+ // track changes in string
360
+ m_lastSessionCt = getSessionCt();
361
+
362
+ const char *tVal = NULL;
363
+ int tValLen = 0;
364
+ if(parseYaml(irsdk_getSessionInfoStr(), path, &tVal, &tValLen))
365
+ {
366
+ // dont overflow out buffer
367
+ int len = tValLen;
368
+ if(len > valLen)
369
+ len = valLen;
370
+
371
+ // copy what we can, even if buffer too small
372
+ memcpy(val, tVal, len);
373
+ val[len] = '\0'; // origional string has no null termination...
374
+
375
+ // if buffer was big enough, return success
376
+ if(valLen >= tValLen)
377
+ return 1;
378
+ else // return size of buffer needed
379
+ return -tValLen;
380
+ }
381
+ }
382
+
383
+ return 0;
384
+ }
385
+
386
+ // get the whole string
387
+ const char* irsdkClient::getSessionStr()
388
+ {
389
+ if(isConnected())
390
+ {
391
+ m_lastSessionCt = getSessionCt();
392
+ return irsdk_getSessionInfoStr();
393
+ }
394
+
395
+ return NULL;
396
+ }
397
+
398
+
399
+ //----------------------------------
400
+
401
+ irsdkCVar::irsdkCVar()
402
+ : m_idx(-1)
403
+ , m_statusID(-1)
404
+ {
405
+ m_name[0] = '\0';
406
+ }
407
+
408
+ irsdkCVar::irsdkCVar(const char *name)
409
+ {
410
+ m_name[0] = '\0';
411
+ setVarName(name);
412
+ }
413
+
414
+ void irsdkCVar::setVarName(const char *name)
415
+ {
416
+ if(!name || 0 != strncmp(name, m_name, sizeof(m_name)))
417
+ {
418
+ m_idx = -1;
419
+ m_statusID = -1;
420
+
421
+ if(name)
422
+ {
423
+ strncpy(m_name, name, max_string);
424
+ m_name[max_string-1] = '\0';
425
+ }
426
+ else
427
+ m_name[0] = '\0';
428
+ }
429
+ }
430
+
431
+ bool irsdkCVar::checkIdx()
432
+ {
433
+ if(irsdkClient::instance().isConnected())
434
+ {
435
+ if(m_statusID != irsdkClient::instance().getStatusID())
436
+ {
437
+ m_statusID = irsdkClient::instance().getStatusID();
438
+ m_idx = irsdkClient::instance().getVarIdx(m_name);
439
+ }
440
+
441
+ return true;
442
+ }
443
+
444
+ return false;
445
+ }
446
+
447
+ int /*irsdk_VarType*/ irsdkCVar::getType()
448
+ {
449
+ if(checkIdx())
450
+ return irsdkClient::instance().getVarType(m_idx);
451
+ return 0;
452
+ }
453
+
454
+ int irsdkCVar::getCount()
455
+ {
456
+ if(checkIdx())
457
+ return irsdkClient::instance().getVarCount(m_idx);
458
+ return 0;
459
+ }
460
+
461
+ bool irsdkCVar::isValid()
462
+ {
463
+ checkIdx();
464
+ return (m_idx > -1);
465
+ }
466
+
467
+
468
+ bool irsdkCVar::getBool(int entry)
469
+ {
470
+ if(checkIdx())
471
+ return irsdkClient::instance().getVarBool(m_idx, entry);
472
+ return false;
473
+ }
474
+
475
+ int irsdkCVar::getInt(int entry)
476
+ {
477
+ if(checkIdx())
478
+ return irsdkClient::instance().getVarInt(m_idx, entry);
479
+ return 0;
480
+ }
481
+
482
+ float irsdkCVar::getFloat(int entry)
483
+ {
484
+ if(checkIdx())
485
+ return irsdkClient::instance().getVarFloat(m_idx, entry);
486
+ return 0.0f;
487
+ }
488
+
489
+ double irsdkCVar::getDouble(int entry)
490
+ {
491
+ if(checkIdx())
492
+ return irsdkClient::instance().getVarDouble(m_idx, entry);
493
+ return 0.0;
494
+ }
495
+
@@ -0,0 +1,139 @@
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 IRSDKCLIENT_H
29
+ #define IRSDKCLIENT_H
30
+
31
+ // A C++ wrapper around the irsdk calls that takes care of the details of maintaining a connection.
32
+ // reads out the data into a cache so you don't have to worry about timming
33
+ class irsdkClient
34
+ {
35
+ public:
36
+ // singleton
37
+ static irsdkClient& instance();
38
+
39
+ // wait for live data, or if a .ibt file is open
40
+ // then read the next line from the file.
41
+ bool waitForData(int timeoutMS = 16);
42
+
43
+ bool isConnected();
44
+ int getStatusID() { return m_statusID; }
45
+
46
+ int getVarIdx(const char*name);
47
+
48
+ // what is the base type of the data
49
+ // returns irsdk_VarType as int so we don't depend on irsdk_defines.h
50
+ int getVarType(int idx);
51
+ int getVarType(const char *name) { return getVarType(getVarIdx(name)); }
52
+
53
+ // how many elements in array, or 1 if not an array
54
+ int getVarCount(int idx);
55
+ int getVarCount(const char *name) { return getVarCount(getVarIdx(name)); }
56
+
57
+ // idx is the variables index, entry is the array offset, or 0 if not an array element
58
+ // will convert data to requested type
59
+ bool getVarBool(int idx, int entry = 0);
60
+ bool getVarBool(const char *name, int entry = 0) { return getVarBool(getVarIdx(name), entry); }
61
+
62
+ int getVarInt(int idx, int entry = 0);
63
+ int getVarInt(const char *name, int entry = 0) { return getVarInt(getVarIdx(name), entry); }
64
+
65
+ float getVarFloat(int idx, int entry = 0);
66
+ float getVarFloat(const char *name, int entry = 0) { return getVarFloat(getVarIdx(name), entry); }
67
+
68
+ double getVarDouble(int idx, int entry = 0);
69
+ double getVarDouble(const char *name, int entry = 0) { return getVarDouble(getVarIdx(name), entry); }
70
+
71
+ //---
72
+
73
+ // value that increments with each update to string
74
+ int getSessionCt() { return irsdk_getSessionInfoStrUpdate(); }
75
+
76
+ // has string changed since we last read any values from it
77
+ bool wasSessionStrUpdated() { return m_lastSessionCt != getSessionCt(); }
78
+
79
+ // pars string for individual value, 1 success, 0 failure, -n minimum buffer size
80
+ //****Note, this is a linear parser, so it is slow!
81
+ int getSessionStrVal(const char *path, char *val, int valLen);
82
+
83
+ // get the whole string
84
+ const char *getSessionStr();
85
+
86
+ protected:
87
+
88
+ irsdkClient()
89
+ : m_data(NULL)
90
+ , m_nData(0)
91
+ , m_statusID(0)
92
+ , m_lastSessionCt(-1)
93
+ { }
94
+
95
+ ~irsdkClient() { shutdown(); }
96
+
97
+ void shutdown();
98
+
99
+ char *m_data;
100
+ int m_nData;
101
+ int m_statusID;
102
+
103
+ int m_lastSessionCt;
104
+
105
+ static irsdkClient *m_instance;
106
+ };
107
+
108
+
109
+ // helper class to keep track of our variables index
110
+ // Create a global instance of this and it will take care of the details for you.
111
+ class irsdkCVar
112
+ {
113
+ public:
114
+ irsdkCVar();
115
+ irsdkCVar(const char *name);
116
+
117
+ void setVarName(const char *name);
118
+
119
+ // returns irsdk_VarType as int so we don't depend on irsdk_defines.h
120
+ int getType();
121
+ int getCount();
122
+ bool isValid();
123
+
124
+ // entry is the array offset, or 0 if not an array element
125
+ bool getBool(int entry = 0);
126
+ int getInt(int entry = 0);
127
+ float getFloat(int entry = 0);
128
+ double getDouble(int entry = 0);
129
+
130
+ protected:
131
+ bool checkIdx();
132
+
133
+ static const int max_string = 32; //IRSDK_MAX_STRING
134
+ char m_name[max_string];
135
+ int m_idx;
136
+ int m_statusID;
137
+ };
138
+
139
+ #endif // IRSDKCLIENT_H